2012-05-18 150 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;