示例#1
0
 // Token: 0x060007E5 RID: 2021 RVA: 0x00039374 File Offset: 0x00037574
 private void ProcessFolder(MailboxSession mailboxSession, StoreObjectId folderId, CalendarSyncLogEntry logEntry)
 {
     CalendarSyncAssistantHelper.Tracer.TraceDebug <object, StoreObjectId, string>((long)this.GetHashCode(), "{0}: CalendarSyncAssistantType.ProcessFolder will try to process folder {1} from mailbox {2}.", TraceContext.Get(), folderId, this.GetDisplayName(mailboxSession));
     using (Folder folder = Folder.Bind(mailboxSession, folderId))
     {
         SynchronizableFolderType            synchronizableFolderType            = SynchronizableFolderType.FromFolder(folder);
         CalendarSyncFolderOperationLogEntry calendarSyncFolderOperationLogEntry = new CalendarSyncFolderOperationLogEntry
         {
             MailboxGuid   = mailboxSession.MailboxGuid,
             FolderId      = folderId.ToString(),
             DisplayName   = folder.DisplayName,
             IsOnDemandJob = true,
             TenantGuid    = mailboxSession.MailboxOwner.MailboxInfo.OrganizationId.GetTenantGuid()
         };
         if (synchronizableFolderType != null)
         {
             FolderRow folderRow = FolderRow.FromFolder(folder);
             this.ThrowIfShuttingDown((mailboxSession != null) ? mailboxSession.MailboxOwner : null);
             if (!synchronizableFolderType.Synchronize(mailboxSession, folderRow, this.GetDeadline(SynchronizableFolderType.MaxSyncTimePerFolder), this.PerformanceCounters, calendarSyncFolderOperationLogEntry))
             {
                 CalendarSyncAssistantHelper.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.ProcessFolder: deadline expired while processing folder {1} from mailbox {2}. MaxSyncTime {3}.", new object[]
                 {
                     TraceContext.Get(),
                     folderId,
                     this.GetDisplayName(mailboxSession),
                     SynchronizableFolderType.MaxSyncTimePerFolder
                 });
                 calendarSyncFolderOperationLogEntry.IsDeadlineExpired = true;
             }
             else
             {
                 calendarSyncFolderOperationLogEntry.IsSyncSuccess = true;
             }
             calendarSyncFolderOperationLogEntry.FolderType = synchronizableFolderType.FolderTypeName;
         }
         else
         {
             CalendarSyncAssistantHelper.Tracer.TraceDebug <object, string, StoreObjectId>((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.ProcessFolder for mailbox {1}: id {2}. Couldn't find a corresponding SynchronizableFolderType object.", TraceContext.Get(), this.GetDisplayName(mailboxSession), folderId);
             calendarSyncFolderOperationLogEntry.FolderType = "UnknownFolderType";
         }
         logEntry.AddFolderDetailLogline(calendarSyncFolderOperationLogEntry);
     }
 }
示例#2
0
        // Token: 0x060007D2 RID: 2002 RVA: 0x0003891C File Offset: 0x00036B1C
        public void ProcessMailbox(MailboxSession mailboxSession, TimeSpan maxSyncTimePerMailbox, Guid activityId, CalendarSyncLogEntry logEntry)
        {
            Dictionary <SynchronizableFolderType, List <FolderRow> >   synchronizableFolderRows = this.GetSynchronizableFolderRows(mailboxSession, SynchronizableFolderType.All);
            List <KeyValuePair <SynchronizableFolderType, FolderRow> > list = this.ToList(synchronizableFolderRows);

            list.Sort(new Comparison <KeyValuePair <SynchronizableFolderType, FolderRow> >(CalendarSyncAssistantHelper.CompareFolderPairsByLastAttemptedSyncTime));
            if (this.PerformanceCounters != null)
            {
                this.PerformanceCounters.AverageSubscriptionsPerMailbox.IncrementBy((long)list.Count);
                this.PerformanceCounters.AverageSubscriptionsPerMailboxBase.Increment();
            }
            Deadline deadline = this.GetDeadline(maxSyncTimePerMailbox);
            bool     flag     = false;
            int      num      = 0;

            logEntry.MaxTimeoutValue    = (long)maxSyncTimePerMailbox.TotalMilliseconds;
            logEntry.NumOfFoldersToSync = list.Count;
            foreach (KeyValuePair <SynchronizableFolderType, FolderRow> keyValuePair in list)
            {
                this.ThrowIfShuttingDown((mailboxSession != null) ? mailboxSession.MailboxOwner : null);
                CalendarSyncFolderOperationLogEntry calendarSyncFolderOperationLogEntry = new CalendarSyncFolderOperationLogEntry
                {
                    MailboxGuid = mailboxSession.MailboxGuid,
                    FolderId    = keyValuePair.Value.FolderId.ToString(),
                    FolderType  = keyValuePair.Key.FolderTypeName,
                    DisplayName = keyValuePair.Value.DisplayName,
                    TenantGuid  = mailboxSession.MailboxOwner.MailboxInfo.OrganizationId.GetTenantGuid(),
                    ActivityId  = activityId
                };
                ExDateTime utcNow = ExDateTime.UtcNow;
                if (!keyValuePair.Key.Synchronize(mailboxSession, keyValuePair.Value, deadline, this.PerformanceCounters, calendarSyncFolderOperationLogEntry))
                {
                    CalendarSyncAssistantHelper.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.ProcessMailbox: didn't finish sync'ing folder {1} with id {2} for mailbox {3}.", new object[]
                    {
                        TraceContext.Get(),
                        keyValuePair.Value.DisplayName,
                        keyValuePair.Value.FolderId,
                        this.GetDisplayName(mailboxSession)
                    });
                }
                else
                {
                    num++;
                    this.UpdateTimeBasedPerfCounters(utcNow, keyValuePair.Value);
                    calendarSyncFolderOperationLogEntry.IsSyncSuccess = true;
                }
                calendarSyncFolderOperationLogEntry.LastAttemptedSyncTime = keyValuePair.Value.LastAttemptedSyncTime;
                calendarSyncFolderOperationLogEntry.LastSyncSuccessTime   = keyValuePair.Value.LastSuccessfulSyncTime;
                logEntry.AddFolderDetailLogline(calendarSyncFolderOperationLogEntry);
                flag = (num == list.Count);
                if (deadline.IsOver && !flag)
                {
                    CalendarSyncAssistantHelper.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.ProcessMailbox: deadline expired before sync'ing all folders for mailbox {1}. Processed {2}/{3} folders. MaxSyncTime: {4}", new object[]
                    {
                        TraceContext.Get(),
                        this.GetDisplayName(mailboxSession),
                        num,
                        list.Count,
                        maxSyncTimePerMailbox
                    });
                    if (mailboxSession != null)
                    {
                        logEntry.IsDeadlineExpired = true;
                        break;
                    }
                    break;
                }
            }
            logEntry.NumOfFoldersActuallySynced = num;
            this.ProcessExtendedProperties(mailboxSession, synchronizableFolderRows);
            if (list.Count > 0 && !flag)
            {
                throw new SyncAssistantPastDeadlineException(string.Format("Deadline expired before processing all the folders for mailbox {0}. Processed {1}/{2} folders. MaxSyncTime: {3}", new object[]
                {
                    this.GetDisplayName(mailboxSession),
                    num,
                    list.Count,
                    maxSyncTimePerMailbox
                }));
            }
        }