Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 从Exchange高效地获取房间预约_.net_Wcf_Calendar_Exchange Server_Ews Managed Api - Fatal编程技术网

.net 从Exchange高效地获取房间预约

.net 从Exchange高效地获取房间预约,.net,wcf,calendar,exchange-server,ews-managed-api,.net,Wcf,Calendar,Exchange Server,Ews Managed Api,问题 我需要能够使用Exchange托管API从会议室获取约会数据。我使用ExchangeService.GetUserAvailability() private IEnumerable GetEvents(ExchangeService ExchangeService、字符串室、日期时间、日期时间结束) { 列表与会者=新列表(); end=newdatetime(time.Ticks+Math.Max(end.Ticks-time.Ticks,time.AddDays(1.Ticks-ti

问题

我需要能够使用Exchange托管API从会议室获取约会数据。我使用
ExchangeService.GetUserAvailability()

private IEnumerable GetEvents(ExchangeService ExchangeService、字符串室、日期时间、日期时间结束)
{
列表与会者=新列表();
end=newdatetime(time.Ticks+Math.Max(end.Ticks-time.Ticks,time.AddDays(1.Ticks-time.Ticks));
AttendeInfo roomAttendee=新的AttendeInfo();
roomAttendee.AttendeType=MeetingAttendeType.Room;
roomAttendee.SmtpAddress=GetEmailAddress(房间);
与会者。添加(roomAttendee);
收集事件=ExchangeService.GetUserAvailability(
与会者:,
新时间窗口(时间,结束),
AvailabilityData.FreeBusy
).AttendeesAvailability[0]。日历事件;
返回(在事件中从e返回)
其中e.EndTime>time
选择e);
}
然而,我最近不得不扩展这项服务来执行其他一些需要更长时间(从一天到几个月)的任务。随着时间的增加,这种方法变得非常低效,并且在结果太多时偶尔会抛出错误

问题

这是最有效的方法吗?我还没有找到更好的方法,但如果您能确认,我将不胜感激。

您可以尝试使用以下方法:

  • 使用分页获取巨大的结果集
  • 选择要从服务器获取的字段
  • 指定可以筛选此查询服务器端的SearchFilter:

    从事件中的e 其中e.EndTime>time 选择e


    • 我使用委托,希望有用。代码示例

            ExchangeService service = new ExchangeService();
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
            service.Credentials = new NetworkCredential(username, password);
            service.Url = new Uri("...");
      
      
            List<DelegateUser> newDelegates = new System.Collections.Generic.List<DelegateUser>();
            DelegateUser calendarDelegate = new DelegateUser(roomemail);
            calendarDelegate.Permissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevel.Reviewer;
            newDelegates.Add(calendarDelegate);   
      
      ExchangeService服务=新的ExchangeService();
      ServicePointManager.ServerCertificateValidationCallback=CertificateValidationCallBack;
      service.Credentials=新的网络凭据(用户名、密码);
      Url=newURI(“…”);
      List newDelegates=newsystem.Collections.Generic.List();
      DelegateUser calendarDelegate=新的DelegateUser(roomemail);
      calendarDelegate.Permissions.CalendarFolderPermissionLevel=DelegateFolderPermissionLevel.Reviewer;
      添加(calendarDelegate);
      
      请注意,GetEmailAddress()是一个本地函数,它从配置文件中获取电子邮件后缀并将其固定在末尾。我也面临同样的问题。你解决了这个问题吗?通过提供房间名称和会议时间,是否有一种更简单、更有效的方法来检查房间在某个时间是否空闲?事实证明,在CalendarFolders上调用此选项的方式与在邮件项目上的方式略有不同,因此我无法远程应用此筛选器,但这不是问题。将在其上运行的服务器负载不重,因此从Exchange上卸下一些负载绝非坏事;)谢谢