gpt4 book ai didi

c# - 从 Exchange 的 GetUserAvailability() 结果中获取与会者

转载 作者:行者123 更新时间:2023-11-30 16:10:26 25 4
gpt4 key购买 nike

GetUserAvailability()在 Exchange Web 服务 API 中,获取与会者的 IList 并根据该列表给出一组结果。现在据我所知,AttendeesAvailability属性没有字段/指示符来说明它正在报告哪个与会者的可用性。

我可以假设 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 = "bob@our.domain.org", AttendeeType = MeetingAttendeeType.Required);
attendees.Add(new AttendeeInfo { SmtpAddress = "alice@our.domain.org", 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:1 的比赛。为了跟踪哪个与会者参加了哪个事件,我这样做了。这看起来有点狡猾,但我对此进行了大量测试,它对我很有效。

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

var attendees = new List<AttendeeInfo>()
attendees.Add(new AttendeeInfo { SmtpAddress = "bob@our.domain.org", AttendeeType = MeetingAttendeeType.Required);
attendees.Add(new AttendeeInfo { SmtpAddress = "alice@our.domain.org", 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;

关于c# - 从 Exchange 的 GetUserAvailability() 结果中获取与会者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25808450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com