/// <summary> /// Identifiy all Ids of removed items of a system (Outlook or Office 365) /// </summary> /// <param name="SrcItems">Items of the systems</param> /// <param name="SyncCache_Items">Sync cache (history) stored on disk</param> /// <param name="System">System to analyse (Outlook or Office 365)</param> /// <returns>Returns a list of Ids of removed items since the last sync run.</returns> /// private static List <string> GetIDsOfDeletedItems(IEnumerable <SyncElement> SrcItems, List <SyncHelpers.SyncInfo> SyncCache_Items, OriginSystemEnum System) { List <string> result = new List <string>(); switch (System) { case OriginSystemEnum.Office365: result.AddRange(SyncCache_Items.Select(x => x.O365ID).Except(SrcItems.Select(x => x.OriginId))); break; case OriginSystemEnum.Outlook: result.AddRange(SyncCache_Items.Select(x => x.OutlookID).Except(SrcItems.Select(x => x.OriginId))); break; } return(result); }
public SyncElementType GetEventByOriginId(string Id, OriginSystemEnum origin) { return(this.Find(x => ((x as SyncElement).OriginId.Equals(Id) && (x as SyncElement).OriginSystem.Equals(origin)))); }
/// <summary> /// Identifiy all Ids of modified items of a system (Outlook or Office 365) /// </summary> /// <param name="SrcItems">Items of the systems</param> /// <param name="SyncCache_Items">Sync cache (history) stored on disk</param> /// <param name="System">System to analyse (Outlook or Office 365)</param> /// <returns>Returns a list of Ids of modified items since the last sync run.</returns> /// private static List <string> GetIDsOfModifiedItems(IEnumerable <SyncElement> SrcItems, List <SyncHelpers.SyncInfo> SyncCache_Items, OriginSystemEnum System) { List <string> tmpModifiedIds = new List <string>(); //all ids which were modified AFTER the last sync { SyncCache_Items.ForEach( (item) => { try { //if the current item could still be found (is not removed) switch (System) { case OriginSystemEnum.Office365: if (SrcItems.ToList().Find(x => x.OriginId == item.O365ID).LastModTime > item.LastSyncTime.AddSeconds(10)) { tmpModifiedIds.Add(item.O365ID); } break; case OriginSystemEnum.Outlook: if (SrcItems.ToList().Find(x => x.OriginId == item.OutlookID).LastModTime > item.LastSyncTime.AddSeconds(10)) { tmpModifiedIds.Add(item.OutlookID); } break; } } catch (NullReferenceException) { //not found -> nothing to do Program.LogLn("Item not found: " + item.OutlookID + " > " + item.O365ID); } }); } return(tmpModifiedIds); }