2014-09-12 65 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; 
相关问题