代码之家  ›  专栏  ›  技术社区  ›  tvanfosson

如何使用Exchange Web服务仅检索定期事件主控形状?

  •  16
  • tvanfosson  · 技术社区  · 15 年前

    我正在使用CalendarItemType视图检索日历项。我只关心那些我已经创建的项目,我知道它们都是每周重复出现的项目。我可以得到每一个单独的事件,并且从其中任何一个事件中获得重复的主项目,但是我想将搜索范围缩小到与我的模式匹配的项目。

    我尝试使用finditemtype上的restriction属性为calendarRecurrenceId指定一个具有空常量的noteEqualTo限制。这导致我的请求超时。到目前为止,我还无法用finditemtype加载recurrences,当我发现循环序列中出现的事件时,需要使用后续的getitemtype调用。

    这是我开始使用的代码。代码需要与Exchange2007和Exchange2010一起使用。

        var findItemRequest = new FindItemType();
    
        findItemRequest.ParentFolderIds = new DistinguishedFolderIdType[]
        {
            new DistinguishedFolderIdType()
        };
    
        ((DistinguishedFolderIdType)findItemequest.ParentFolderIds[0]).Id = DistinguishedFolderIdNameType.calendar;
        findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
    
        var itemShapeDefinition = new ItemResponseShapeType(
        {
            BaseShape = DefaultShapeNamesType.AllProperties;
        }
    
        findItemRequest.Item = calenderView;
        findItemRequest.ItemShape = itemShapeDefinition;
    
        var findItemResponse = this.esb.FindItem( findItemRequest );
    

    另外,如果你知道任何好的例子来源(除了在msdn中的例子),我欢迎他们。我在紧急情况下拿起别人的代码,并尝试在飞行中学习交换Web服务。

    4 回复  |  直到 7 年前
        1
  •  4
  •   MJB    14 年前

    也许我误解了你,在这种情况下我道歉。

    您不使用日历视图-如果您只需要主循环日历项,则使用普通的indexedpageitemview。

    您可以使用CalendarView将重复周期展开为单个项目。但是,除了开始和结束日期之外,与CalendarView的折衷是不允许的。一个也没有。

        2
  •  1
  •   Chris D    8 年前

    通过使用具有扩展属性定义的定期pidlid,可以搜索RecurrenceMaster。这是因为,根据他们的文档,“此属性不能存在于单实例日历项上。”

    https://msdn.microsoft.com/en-us/library/cc842017.aspx

    // https://msdn.microsoft.com/en-us/library/cc842017.aspx
    ExtendedPropertyDefinition apptType = new ExtendedPropertyDefinition(
        DefaultExtendedPropertySet.Appointment,
        0x00008216, //PidLidAppointmentRecur
        MapiPropertyType.Binary);
    
    var restriction = new SearchFilter.Exists(apptType);
    var iView = new ItemView(10);
    var found = folder.FindItems(restriction, iView);
    

    我刚刚确认了这一点,今天,当我重新访问一些在云中使用Office365 EWS的旧代码时。

        3
  •  0
  •   Y.Mickey    12 年前

    只找到您需要的属性是RecurrenceStart属性。因为EWS有限制,所以不可能在限制中使用所有属性。这个按预期工作。

    参考文献: Find master recurring appointments

        4
  •  -1
  •   eL-Prova    13 年前

    可以创建自定义搜索筛选器。如果从特定的StartDate或IsRecurring属性进行搜索,则最简单的方法是…(searchitems返回循环主控形状)

    List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
    
            SearchFilter.IsGreaterThanOrEqualTo startDatumFilter = new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, new DateTime(2012, 9, 16));
            SearchFilter.IsEqualTo masterRecurringFilter = new SearchFilter.IsEqualTo(AppointmentSchema.IsRecurring, true);
    
            searchFilterCollection.Add(startDatumFilter);
            searchFilterCollection.Add(masterRecurringFilter);
    
            SearchFilter finalFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection);
    
            ItemView itemView = new ItemView(100000);
            itemView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.AppointmentType);
    
            FindItemsResults<Item> items = _service.FindItems(WellKnownFolderName.Calendar, finalFilter, itemView);