2017-09-07 3 views
0

내 캘린더 이벤트의 일부가 확장 속성 : 다른 코드에서필터링이에 확장 속성

// Extended Properties 
var extendedProperties = new EventSingleValueExtendedPropertiesCollectionPage(); 
extendedProperties.Add(new SingleValueLegacyExtendedProperty 
{ 
    Id = _Property_TruckleSoft1, 
    Value = oSettings.CalendarEntryType 
}); 

if(!string.IsNullOrEmpty(oSettings.ScheduleType)) 
{ 
    extendedProperties.Add(new SingleValueLegacyExtendedProperty 
    { 
     Id = _Property_TruckleSoft2, 
     Value = oSettings.ScheduleType 
    }); 
} 

나는 이러한 이벤트를 필터링 할 :

string strFilterProperty = $"singleValueExtendedProperties/Any(ep: ep/id eq '{eventTypeTag}' and ep/value eq '{oData.Settings.CalendarEntryType}')"; 

string strFilterProperty = $"singleValueExtendedProperties/Any(ep: ep/id eq '{scheduleTypeTag}' and ep/value eq '{oData.Settings.ScheduleType}')"; 

어떻게 위의 확장 된 속성 중 모두 인 이벤트에 대해 필자는 필터링합니까?

+0

자세한 설명을 사용할 수 있습니다. 귀하의 질문이 무엇인지는 명확하지 않습니다. –

+0

확장 속성이 두 개인 이벤트를 필터링하려고합니다. –

+0

계속 진행할 것이 많지 않습니다. 이들 중 하나가 작동하지만 다른 하나는 작동하지 않습니까? 오류 메시지 또는 어떤 종류의 오류 메시지가 나타 납니까? –

답변

0

이 답변에 대한 답변은 question입니다. 나는 물건을 복잡하게 끝났다!

그래서 :

public async Task<bool> DeleteExistingEvents(string idCalendar, DateTime dateStart, DateTime dateEnd, string typeEvent, string typeSchedule = "") 
{ 
    try 
    { 
     // We only want events within the desired date range 
     string strFilterDateRange = String.Format("start/dateTime ge '{0}T00:00' and end/dateTime le '{1}T23:59'", 
      dateStart.ToString("yyyy-MM-dd"), 
      dateEnd.ToString("yyyy-MM-dd")); 

     // We only want events of the right type 
     string strFilterProperty = $"singleValueExtendedProperties/Any(ep: ep/id eq '{_Property_TruckleSoft1}' and ep/value eq '{typeEvent}')"; 

     string strFilter = strFilterDateRange + " and " + strFilterProperty; 

     if(typeSchedule != "") 
     { 
      strFilterProperty = $"singleValueExtendedProperties/Any(ep: ep/id eq '{_Property_TruckleSoft2}' and ep/value eq '{typeSchedule}')"; 
      strFilter += " and " + strFilterProperty; 
     } 

     // Select the events (if any) and delete them 
     var oEvents = await _graphClient 
           .Me 
           .Calendars[idCalendar] 
           .Events 
           .Request() 
           .Filter(strFilter) 
           .GetAsync(); 
     if (oEvents?.Count > 0) 
     { 
      foreach (Event oEvent in oEvents) 
      { 
       // Delete the event (Do I need to use the specific calendar events list?) 
       await _graphClient.Me.Events[oEvent.Id].Request().DeleteAsync(); 
      } 
     } 
    } 
    catch (Exception ex) 
    { 
     SimpleLog.Log(ex); 
     return false; 
    } 

    return true; 
} 

의 핵심은 단순히 and를 사용하여 함께 두 개의 필터를 스티치하는 것이 었습니다.