2016-06-01 3 views
0

캘린더에서 모든 약속을 가져 오는 기존 코드가 있습니다.Exchange 웹 서비스에서 약속 시간 가져 오기

private List<string> GetCalendarItemsByDay(string folderId) 
    { 
     var items = new List<string>(); 
     using (var handler = new HttpClientHandler { Credentials = new NetworkCredential(_calenderSettings.Username, _calenderSettings.Password) }) 
     using (var client = new HttpClient(handler) { Timeout = TimeSpan.FromMinutes(10) }) 
     { 
      var soapRequest = 
       string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?> 
        <soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" 
            xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types""> 
         <soap:Header> 
         <t:RequestServerVersion Version=""Exchange2010"" /> 
         </soap:Header> 
         <soap:Body> 
         <FindItem xmlns=""http://schemas.microsoft.com/exchange/services/2006/messages"" xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types"" Traversal=""Shallow""> 
          <ItemShape> 
          <t:BaseShape>IdOnly</t:BaseShape> 
           </ItemShape> 
           <ParentFolderIds> 
           <t:FolderId Id=""{0}"" /> 
           </ParentFolderIds> 
           </FindItem> 
          </soap:Body> 
          </soap:Envelope>", folderId); 

      try 
      { 
       var content = new StringContent(soapRequest, Encoding.UTF8, "text/xml"); 
       var request = new HttpRequestMessage(HttpMethod.Post, _calenderSettings.EwsUri) 
       { 
        Content = content 
       }; 
       var response = client.SendAsync(request).Result; 

       using (var responseStream = response.Content.ReadAsStreamAsync().Result) 
       { 
        var nav = new XPathDocument(responseStream).CreateNavigator(); 
        var nsManager = new XmlNamespaceManager(nav.NameTable); 
        nsManager.AddNamespace("t", "http://schemas.microsoft.com/exchange/services/2006/types"); 
        var folderNodes = nav.Select("//t:ItemId", nsManager); 
        foreach (XPathNavigator folderNode in folderNodes) 
        { 
         items.Add(folderNode.TryGetNodeValue<string>("@Id", nsManager)); 
        } 
       } 
      } 
      catch (AggregateException a) 
      { 
       Log.For(this).Debug(a.Message); 
      } 
     } 
     return items; 
    } 

잘 작동하지만 다음 10 일간 만 약속이 필요합니다. 비누 요청에 날짜 필터를 추가 할 수 있습니까?

이후 필터링을 시도했지만 응답에 날짜가 없습니다.

답변

1

StartDate 및 EndDate를 지정하는 코드에서 CalendarView를 사용해야합니다. 예를 들어

<?xml version="1.0" encoding="utf-8"?> 
 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 
     xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
 
     xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
 
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
 
    <soap:Header> 
 
    <t:RequestServerVersion Version="Exchange2013_SP1" /> 
 
    </soap:Header> 
 
    <soap:Body> 
 
    <m:FindItem Traversal="Shallow"> 
 
     <m:ItemShape> 
 
     <t:BaseShape>IdOnly</t:BaseShape> 
 
     <t:AdditionalProperties> 
 
      <t:FieldURI FieldURI="item:Subject" /> 
 
      <t:FieldURI FieldURI="calendar:Start" /> 
 
      <t:FieldURI FieldURI="calendar:End" /> 
 
     </t:AdditionalProperties> 
 
     </m:ItemShape> 
 
     <m:CalendarView MaxEntriesReturned="5" StartDate="2013-08-21T17:30:24.127Z" EndDate="2013-09-20T17:30:24.127Z" /> 
 
     <m:ParentFolderIds> 
 
     <t:FolderId Id="AAMk" ChangeKey="AgAA" /> 
 
     </m:ParentFolderIds> 
 
    </m:FindItem> 
 
    </soap:Body> 
 
</soap:Envelope>

관련 문제