2012-05-18 113 views
1

我想在下面的代码中获得与约会相关的重复模式。当我调试代码并展开本地窗口中的microsoftAppointment.Recurrence属性时,我可以看到一个名为[Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern]的嵌套类,它具有我需要的信息,但我无法弄清楚如何在我的代码中访问这些信息。这显然是在内存中我只是不明白为什么我不能在运行时在代码中读取它。我尝试过FindAppointments,但只返回为空。EWS:访问约会重复模式

FindItemsResults<Item> findResults = exchangeService.FindItems(WellKnownFolderName.Calendar, new ItemView(folderCount)); 

exchangeService.LoadPropertiesForItems(findResults.Items, new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Body, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Body, AppointmentSchema.IsRecurring, AppointmentSchema.Recurrence)); 

foreach (var v in findResults.Items) 
{ 
    Microsoft.Exchange.WebServices.Data.Appointment microsoftAppointment = v as Microsoft.Exchange.WebServices.Data.Appointment; 

    if (microsoftAppointment.IsRecurring) 
    { 
    ... 
    } 
} 

回答

2

以下演员结束了为我工作。您可以跳过间隔模式步骤,但之后我会进行切换以查找类型(每周,每天等),以便我可以正确投射间隔模式。

Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern pattern = (Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern)microsoftAppointment.Recurrence; 
weeklyPattern = (Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern) pattern;