Example #1
0
 public FirstTimeFolderSync(ISyncProvider syncProvider, IFolderSyncState syncState, ConflictResolutionPolicy policy, bool deferStateModifications) : base(syncProvider, syncState, policy, deferStateModifications)
 {
 }
        // Token: 0x060010EA RID: 4330 RVA: 0x00045E10 File Offset: 0x00044010
        public SyncCalendarResponse Execute(out IFolderSyncState newSyncState, out IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions)
        {
            ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.Execute: Start");
            Stopwatch stopwatch = Stopwatch.StartNew();

            caughtExceptions = new List <KeyValuePair <StoreId, LocalizedException> >();
            MailboxSyncProviderFactory  mailboxSyncProviderFactory        = new MailboxSyncProviderFactory(this.session, this.folderId);
            HashSet <StoreId>           syncItemsHashSet                  = new HashSet <StoreId>();
            List <SyncCalendarItemType> updatedItemsList                  = new List <SyncCalendarItemType>();
            List <SyncCalendarItemType> recurrenceMastersWithInstances    = new List <SyncCalendarItemType>();
            List <SyncCalendarItemType> recurrenceMastersWithoutInstances = new List <SyncCalendarItemType>();
            Dictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances = new Dictionary <StoreId, SyncCalendarItemType>();
            List <StoreId> deletedItemsList = new List <StoreId>();
            bool           flag             = true;
            CalendarViewQueryResumptionPoint calendarViewQueryResumptionPoint = null;

            using (ISyncProvider syncProvider = mailboxSyncProviderFactory.CreateSyncProvider(null))
            {
                newSyncState = this.syncState.CreateFolderSyncState(this.folderId, syncProvider);
                ExDateTime value;
                if (CalendarSyncState.IsEmpty(this.syncState) || this.syncState.OldWindowEnd == null || this.windowStart >= this.syncState.OldWindowEnd.Value)
                {
                    ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.InternalExecute: Requesting catch-up sync state from ICS");
                    newSyncState.Watermark = syncProvider.GetMaxItemWatermark(newSyncState.Watermark);
                    value = this.windowStart;
                }
                else
                {
                    value = this.syncState.OldWindowEnd.Value;
                }
                if (newSyncState.Watermark != null)
                {
                    int num  = this.maxChangesReturned;
                    int num2 = 0;
                    int num3 = 0;
                    if (this.windowEnd > value)
                    {
                        calendarViewQueryResumptionPoint = this.DoQuerySync(syncItemsHashSet, updatedItemsList, recurrenceMastersWithInstances, unchangedRecurrenceMastersWithInstances, value, this.windowEnd, num, caughtExceptions, out num2);
                        flag = !calendarViewQueryResumptionPoint.IsEmpty;
                        num  = this.CalculateRemainingItemsCount(num, num2);
                        ExTraceGlobals.SyncCalendarTracer.TraceDebug <int, int, bool>((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync added {0} items to the sync response. Remaining Items: {1}; More Available: {2}", num2, num, flag);
                    }
                    if (num != 0)
                    {
                        flag = this.DoIcsSync(syncItemsHashSet, updatedItemsList, recurrenceMastersWithInstances, recurrenceMastersWithoutInstances, unchangedRecurrenceMastersWithInstances, deletedItemsList, newSyncState.Watermark, syncProvider, num, caughtExceptions, out num3);
                        ExTraceGlobals.SyncCalendarTracer.TraceDebug <int, bool>((long)this.GetHashCode(), "XsoSyncCalendar.DoIcsSync added {0} items to the sync response. More Available: {1}", num3, flag);
                    }
                    else
                    {
                        ExTraceGlobals.SyncCalendarTracer.TraceDebug <int, int>((long)this.GetHashCode(), "XsoSyncCalendar; Skipping ICS sync, since we've reached the max items requested (Requested: {0}; Actual: {1}).", this.maxChangesReturned, num2);
                    }
                    ExTraceGlobals.SyncCalendarTracer.TraceDebug <int, int>((long)this.GetHashCode(), "XsoSyncCalendar; Finished fetching items. Total items synced: {0}; Max requested: {1}", num2 + num3, this.maxChangesReturned);
                }
                else
                {
                    flag = false;
                    ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar; Nothing to sync. The specified folder is empty.");
                }
            }
            SyncCalendarResponse result = this.AssembleResponse(flag ? calendarViewQueryResumptionPoint : null, flag ? this.syncState.OldWindowEnd : new ExDateTime?(this.windowEnd), updatedItemsList, recurrenceMastersWithInstances, recurrenceMastersWithoutInstances, unchangedRecurrenceMastersWithInstances, deletedItemsList, !flag);

            stopwatch.Stop();
            ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.InternalExecute: End " + stopwatch.ElapsedMilliseconds);
            return(result);
        }