如何使用FindItems()获取在一个日期范围内开始出现一次或多次出现的所有重复序列的重复母版?

麦康

背景:

我正在使用Microsoft Exchange Web服务托管API 2.0。我试图搜索“日历”文件夹并返回符合以下条件的所有约会项目:

  • 具有正常的灵敏度
  • 拥有“测试”类别
  • 在特定日期范围内开始

我得出的结论是,由于我需要过滤的不仅仅是日期,我需要使用FindItems()而不是FindAppoinments()。(如果那是错误的,请更正我。)FindItems()的缺点),因为它只会返回一个重复序列的主人,我需要自己爆炸这些事件。我正在爆炸主数据库,没有问题,但是在我的测试中,FindItems()搜索重复发生了问题。如果整个系列在我的搜索范围内的某个时间开始,它似乎只能返回该系列的母版。因此,如果某人每天设置下一年的重复系列,而我在下个月搜索日历,则FindItems()不会给出任何指示该范围内正在发生的重复系列。

TLDR:

给定具有重复周期的日历,该日历的每日频率为2014年1月1日至2014年1月30日。如何使用过滤日期范围为1/10/2014-1/20/2014的FindItems()返回该系列的重复母版?

我的密码

// A search collection that contains all of the search conditions.
List<SearchFilter> masterSearchFilterCollection = new List<SearchFilter>();
masterSearchFilterCollection.Add(new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Appointment"));

masterSearchFilterCollection.Add(new SearchFilter.IsEqualTo(AppointmentSchema.Sensitivity, Sensitivity.Normal)); //No Private items
//masterSearchFilterCollection.Add(new SearchFilter.ContainsSubstring(AppointmentSchema.Categories, "Test"));

List<SearchFilter> dateRangeSearchFilterCollection = new List<SearchFilter>();
dateRangeSearchFilterCollection.Add(new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, searchStartDateTime));
dateRangeSearchFilterCollection.Add(new SearchFilter.IsLessThanOrEqualTo(AppointmentSchema.Start, searchEndDateTime));
masterSearchFilterCollection.Add(new SearchFilter.SearchFilterCollection(LogicalOperator.And, dateRangeSearchFilterCollection));

SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, masterSearchFilterCollection);

ItemView view = new ItemView(pageSize, initialOffset);
view.PropertySet = GetPrimaryProperties();
FindItemsResults<Item> results = Service.FindItems(Folder, searchFilter, view);

foreach(Appointment item in results)
{
   if (item.AppointmentType == AppointmentType.RecurringMaster)
   {
      // Calendar item is a recurring master item for a recurring series.
      // Loop through all occurrences of the master here
   }
   else
   {
      // Calendar item is not part of a recurring series.
   }
}
鲍勃·布恩

约翰,

为了找到您的定期主约会,您将需要使用该FindAppointments()方法。在此方法中指定开始日期和结束日期将使您看到跨越该日期范围的任何定期约会。然后,您可以通过检查这些约会的“敏感性”和“类别”属性来筛选约会。

找到符合条件的约会后,请检查AppointmentType酒店以确定下一步要做什么。如果是发生或异常,则可以使用该Appointment.BindToRecurringMaster()方法到达您的重复主记录。这是一个例子:

switch (calendarItem.AppointmentType)
{
    case AppointmentType.RecurringMaster:
       // Nothing to do here since you are already on the recurring master
       break;

    case AppointmentType.Single:
       // This is not a recurring series
       break;

    case AppointmentType.Occurrence:
       // We need to get to the recurring master
       Appointment recurringMaster = Appointment.BindToRecurringMaster(service, calendarItem.Id);
       break;

    case AppointmentType.Exception:
       // We need to get to the recurring master
       Appointment recurringMaster = Appointment.BindToRecurringMaster(service, calendarItem.Id);
       break;

}

现在,您可以引用递归母版了,您可以像以前一样遍历所有事件。

我希望这有帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档