2014-01-15 80 views
2

我正在努力統計接受EWS會議邀請的與會者。統計與EWS接受會議的與會者人數

我能夠通過模仿看到組織者會議,並計算所需的與會者人數。

 //Determine User to impersonat 
     string impersonated_email = "[email protected]"; 
     service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, impersonated_email); 

     //Bind User Calendar 
     FolderId UserCalendarId = new FolderId(WellKnownFolderName.Calendar, impersonated_email); 
     CalendarFolder UserCalendar = CalendarFolder.Bind(service, UserCalendarId); 

     // Initialize values for the start and end times, and the number of appointments to retrieve. 
     DateTime startDate = DateTime.Now.AddDays(0); 
     DateTime endDate = startDate.AddDays(1); 

     // Execute the search in the calendar folder and return the view 
     CalendarView userCalendar = new CalendarView(startDate, endDate); 
     userCalendar.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties); 
     FindItemsResults<Appointment> apt = service.FindAppointments(WellKnownFolderName.Calendar, userCalendar); 

     foreach (Item item in apt.Items) 
     { 
      //Console.WriteLine(item.Subject); 
      ServiceResponseCollection<GetItemResponse> myColl = service.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, userCalendar.PropertySet); 
      foreach (GetItemResponse temp in myColl) 
      { 
       Appointment app = (Appointment)temp.Item; 
       Int32 Tn = app.RequiredAttendees.Count-1; 
       Console.WriteLine(app.Subject + " " +Tn); 
      } 

我還想看看有多少人需要參加者接受會議邀請。

親切的問候 Xristos

回答

2

可以應該能夠得到響應類型是這樣的:

Appointment app; 

int count = app.RequiredAttendees.Count(x => (x.ResponseType.HasValue && x.ResponseType.Value == MeetingResponseType.Accept)); 
+0

謝謝topher91。 它工作完美! – user3197311