2017-09-07 5 views
0

に私のカレンダーイベントのいくつかは、拡張プロパティがあります。他のコードでフィルタリングマイクロソフトグラフを持つ2つの拡張プロパティ

// 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

2つの拡張プロパティを持つイベントをフィルタリングしたい。 –

+0

これらのうちの1つは動作していますが、別のものは動作しません。エラーメッセージが表示されますか? –

答えて

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を使用する2つの別々のフィルタを一緒にステッチすることでした。

関連する問題