2014-09-12 49 views
2

GetUserAvailability()中的與會者需要IList的與會者,並根據該列表提供一組結果。現在從我所知道的情況來看,AttendeesAvailability屬性沒有字段/指示符來表明哪個與會者報告了其可用性。在Exchange Web Services API中獲取Exchange的GetUserAvailability()結果

我可以假設,attendee[0] == AttendeeAvailability[0],attendee[1] == AttendeeAvailability[1]等,但是這並沒有明確記錄在MSDN中,據我所見,所以我不想依賴它。如果它確實是一個簡單的1:1比賽,我想知道它在哪裏記錄:-)

我錯過了MSDN中的某些東西,或者是唯一的方法來保證映射(如果映射參加者ID和他們的可用性問題)是否在列表上迭代地調用GetUserAvailability()

爲了完整起見,我打電話GetUserAvailability如下:

var options = new AvailabilityOptions 
    { 
     MeetingDuration = 30, 
     RequestedFreeBusyView = FreeBusyViewType.DetailedMerged 
    }; 

var attendees = new List<AttendeeInfo>() 
attendees.Add(new AttendeeInfo { SmtpAddress = "[email protected]", AttendeeType = MeetingAttendeeType.Required); 
attendees.Add(new AttendeeInfo { SmtpAddress = "[email protected]", AttendeeType = MeetingAttendeeType.Required); 

var results = this.exchangeService.GetUserAvailability(
    attendees, 
    new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)), 
    AvailabilityData.FreeBusy, 
    options); 

foreach (AttendeeAvailability avail in results.AttendeesAvailability) 
{ 
    // How to marry each AttendeeAvailability object with the appropriate attendee? 
} 
+1

有一個快速瀏覽一下MSDN解決這個問題,我也有同樣的結論爲你的。這似乎沒有指定,奇怪! – 2014-09-12 12:43:22

+0

我至少感謝這不是我的閱讀理解失敗:-) – 2014-09-12 12:55:51

+0

這是我現在可以做的最好的;)這就是爲什麼我沒有回答但只評論,但你的問題很有趣! – 2014-09-12 12:56:56

回答

1

我遇到了同樣的問題。

正如我在MSDN給出的例子中看到的,他們依靠相同的假設attendees[0] == AttendeeAvailability[0]

https://msdn.microsoft.com/en-us/library/office/dn643673(v=exchg.150).aspx

int i = 0; 

// Display free/busy times. 
foreach (AttendeeAvailability availability in results.AttendeesAvailability) 
{ 
    Console.WriteLine("Availability information for {0}:\n", attendees[i].SmtpAddress); 

    foreach (CalendarEvent calEvent in availability.CalendarEvents) 
    { 
     Console.WriteLine("\tBusy from {0} to {1} \n", calEvent.StartTime.ToString(), calEvent.EndTime.ToString()); 
    } 

    i++; 
} 
+0

看起來是最接近「正式」的文件,因爲我會在這裏找到ta。 – 2017-10-18 14:18:21

2

我已經通過這一努力,以及和找不到文檔。因此,沒有真正的方法可以通過正確的事件「嫁給」適當的與會者。

我通過大量測試發現的解決方法是,它獲取第一個參加者的所有事件,然後轉到下一個參加者並查找所有這些事件等。所以這是一個1比1的比賽,如你所說。 爲了跟蹤哪個參與者與哪個事件做了這個事情。這似乎有點狡猾,但我做了很多測試,並且它對我有用。

var options = new AvailabilityOptions 
    { 
     MeetingDuration = 30, 
     RequestedFreeBusyView = FreeBusyViewType.DetailedMerged 
    }; 

var attendees = new List<AttendeeInfo>() 
attendees.Add(new AttendeeInfo { SmtpAddress = "[email protected]", AttendeeType = MeetingAttendeeType.Required); 
attendees.Add(new AttendeeInfo { SmtpAddress = "[email protected]", AttendeeType = MeetingAttendeeType.Required); 

var results = this.exchangeService.GetUserAvailability(
    attendees, 
    new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)), 
    AvailabilityData.FreeBusy, 
    options); 
//This will represent the first attendee in your list. 
int i = 0; 
//I was passing strings around for my program. Not sure what you want with it. 
StringBuilder sb = new StringBuilder(); 
foreach (AttendeeAvailability avail in results.AttendeesAvailability) 
{ 
    sb.Append("Availability for: ").Append(attendees[i].SmtpAddress).Append("\n"); 
    foreach (CalendarEvent calItem in avail.CalendarEvents) 
    { 
     //The info you are looking for like Free/Busy or event times. 
     //This is an example of their free busy status with start and end time of that event 
     sb.Append(calItem.FreeBusyStatus).Append(": ").Append(calItem.StartTime); 
     sb.Append(" - ").Append(calItem.EndTime).Append("\n"); 
    } 
    //This will show the name of the next attendee through the next foreach loop 
    i++; 
} 
return sb; 
相關問題