Getting Room Appointments Efficiently from Exchange

北慕城南 提交于 2019-12-11 05:46:28

问题


The Problem

I need to be able to get appointment data from meeting rooms using the Exchange Managed API. I have had a service running for about a month that serves this purpose just fine by using ExchangeService.GetUserAvailability() as follows:

private IEnumerable<CalendarEvent> GetEvents(ExchangeService ExchangeService, string room, DateTime time, DateTime end)
{
    List<AttendeeInfo> attendees = new List<AttendeeInfo>();
    end = new DateTime(time.Ticks + Math.Max(end.Ticks - time.Ticks, time.AddDays(1).Ticks - time.Ticks));

    AttendeeInfo roomAttendee = new AttendeeInfo();
    roomAttendee.AttendeeType = MeetingAttendeeType.Room;
    roomAttendee.SmtpAddress = GetEmailAddress(room);
    attendees.Add(roomAttendee);

    Collection<CalendarEvent> events = ExchangeService.GetUserAvailability(
                attendees,
                new TimeWindow(time, end),
                AvailabilityData.FreeBusy
            ).AttendeesAvailability[0].CalendarEvents;

    return (from e in events
            where e.EndTime > time
            select e);
}

However, I have recently had to extend this service to perform some other tasks that have required larger spans of time (gone from one day to several months). This method becomes highly inefficient with an increase in time, and can occasionally throw errors when there are too many results.

The Question

Is this the most efficient way of going about this? I have found no better ways, but I would be grateful for confirmation.


回答1:


You can try using ExchangeService.FindItems which enables you to :

  • use pagination to fetch huge resultsets.
  • select the fields you want to get from the server
  • specify a SearchFilter that could filter this query server side :

    from e in events where e.EndTime > time select e




回答2:


I Use Delegate,Hope usefull. Code Sample...

      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);   


来源:https://stackoverflow.com/questions/14723679/getting-room-appointments-efficiently-from-exchange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!