Joh*_*Con 3 exchangewebservices
背景:
我正在使用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.
}
}
Run Code Online (Sandbox Code Playgroud)
约翰,
要查找定期主预约,您需要使用该FindAppointments()方法.在此方法中指定开始日期和结束日期将允许您查看跨越日期范围的任何定期约会.然后,您可以通过选中这些约会的"灵敏度"和"类别"属性来过滤约会
找到符合条件的约会后,请检查该AppointmentType属性以确定下一步操作.如果它是一个Occurrence或Exception,那么您可以使用该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;
}
Run Code Online (Sandbox Code Playgroud)
现在您已经引用了定期主数据,您可以像以前一样遍历事件.
我希望这有帮助.
| 归档时间: |
|
| 查看次数: |
2566 次 |
| 最近记录: |