Exemple #1
0
 /// <summary>
 /// Deal, in CRM, with items deleted in Outlook.
 /// </summary>
 protected void RemoveDeletedItems()
 {
     if (IsCurrentView && PropagatesLocalDeletions)
     {
         // Make a copy of the list to avoid mutation error while iterating:
         var syncStatesCopy = new List <SyncState <OutlookItemType> >(ItemsSyncState);
         foreach (var oItem in syncStatesCopy)
         {
             var shouldDeleteFromCrm = oItem.IsDeletedInOutlook || !oItem.ShouldSyncWithCrm;
             if (shouldDeleteFromCrm)
             {
                 RemoveFromCrm(oItem);
             }
             if (oItem.IsDeletedInOutlook)
             {
                 ItemsSyncState.Remove(oItem);
             }
         }
     }
     else
     {
         var items = ItemsSyncState.Where(x => x.IsDeletedInOutlook).Count();
         if (items > 0)
         {
             Log.Error($"Possibly bug #95: was attempting to delete {items} items from CRM");
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Find any existing Outlook items which appear to be identical to this CRM item.
        /// </summary>
        /// <param name="crmItem">The CRM item to match.</param>
        /// <returns>A list of matching Outlook items.</returns>
        protected List <SyncState <OutlookItemType> > FindMatches(EntryValue crmItem)
        {
            List <SyncState <OutlookItemType> > result;

            try
            {
                result = ItemsSyncState.Where(a => this.IsMatch(a.OutlookItem, crmItem))
                         .ToList <SyncState <OutlookItemType> >();
            }
            catch (Exception any)
            {
                this.Log.Error("Exception while checking for matches", any);
                result = new List <SyncState <OutlookItemType> >();
            }

            return(result);
        }