// Token: 0x06000818 RID: 2072 RVA: 0x00039B68 File Offset: 0x00037D68 public override bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry) { ConsumerCalendarSynchronizer consumerCalendarSynchronizer = new ConsumerCalendarSynchronizer(mailboxSession, XSOFactory.Default, SynchronizableFolderType.Tracer); consumerCalendarSynchronizer.LogError += delegate(object s, string e) { folderOpLogEntry.AddErrorToLog(e, string.Empty); }; bool result; try { switch (consumerCalendarSynchronizer.Synchronize(folderRow.FolderId, deadline)) { case SyncResult.DeadlineReached: return(false); } result = true; } catch (LocalizedException ex) { folderOpLogEntry.AddExceptionToLog(ex); result = true; } return(result); }
// Token: 0x06000800 RID: 2048 RVA: 0x0003991C File Offset: 0x00037B1C public static SynchronizableFolderType FromFolderRow(FolderRow folderRow) { foreach (SynchronizableFolderType synchronizableFolderType in SynchronizableFolderType.All) { if (synchronizableFolderType.MatchesFolderRow(folderRow)) { return(synchronizableFolderType); } } return(null); }
// Token: 0x06000847 RID: 2119 RVA: 0x0003A104 File Offset: 0x00038304 public override bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize will try to sync folder {1} with id {2} for mailbox {3}.", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName }); bool flag = true; PublishingSubscriptionData subscriptionData = this.GetSubscriptionData(mailboxSession, folderRow); if (subscriptionData == null) { folderOpLogEntry.AddErrorToLog("NoSubscriptionData", null); return(true); } folderOpLogEntry.SubscriptionData = subscriptionData; folderOpLogEntry.FolderUrl = subscriptionData.PublishingUrl.ToString(); SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize will try to open URL {1} to sync folder {2} with id {3} for mailbox {4}.", new object[] { TraceContext.Get(), subscriptionData.PublishingUrl, folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName }); try { flag = this.SyncFolder(mailboxSession, folderRow, subscriptionData, deadline, counters, folderOpLogEntry); } catch (ObjectNotFoundException ex) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize for subscription {1} folder {2} with id {3} for mailbox {4} hit exception {5}.", new object[] { TraceContext.Get(), subscriptionData, folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, ex }); folderOpLogEntry.AddExceptionToLog(ex); } SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize for folder {1} with id {2} for mailbox {3} will return {4}.", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, flag }); return(flag); }
// Token: 0x0600081B RID: 2075 RVA: 0x00039C5C File Offset: 0x00037E5C public static FolderRow FromFolder(Folder folder) { if (folder == null) { throw new ArgumentNullException("folder"); } object[] rawData = new object[] { folder.Id, folder.ClassName, folder.TryGetProperty(FolderSchema.ExtendedFolderFlags), folder.LastSuccessfulSyncTime, folder.DisplayName, folder.ParentId, folder.LastAttemptedSyncTime }; return(FolderRow.FromRawData(rawData)); }
// 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); } }
// Token: 0x06000833 RID: 2099 RVA: 0x00039EC8 File Offset: 0x000380C8 public override bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry) { bool result = true; SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: ExternalSharingCalendarType.Synchronize will try to sync folder {1} with id {2} for mailbox {3}.", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName }); folderOpLogEntry.FolderUrl = folderRow.DisplayName; try { result = SharingEngine.SyncFolder(mailboxSession, folderRow.FolderId, deadline); } catch (SharingSynchronizationException ex) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: ExternalSharingCalendarType.Synchronize SharingEngine threw an exception for for folder {1} with id {2} for mailbox {3}: {4}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, ex }); folderOpLogEntry.AddExceptionToLog(ex); } catch (OrganizationNotFederatedException ex2) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: ExternalSharingCalendarType.Synchronize SharingEngine couldn't sync folder {1} with id {2} for mailbox {3} because the org isn't federated.", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName }); folderOpLogEntry.AddExceptionToLog(ex2); } return(result); }
// Token: 0x060007DB RID: 2011 RVA: 0x00038E54 File Offset: 0x00037054 protected Dictionary <SynchronizableFolderType, List <FolderRow> > GetSynchronizableFolderRows(MailboxSession mailboxSession, object[][] rows) { Dictionary <SynchronizableFolderType, List <FolderRow> > dictionary = CalendarSyncAssistantHelper.CreateSynchronizableFolderRowsDictionary(); for (int i = 0; i < rows.Length; i++) { FolderRow folderRow = FolderRow.FromRawData(rows[i]); SynchronizableFolderType synchronizableFolderType = SynchronizableFolderType.FromFolderRow(folderRow); if (synchronizableFolderType != null && !this.IsDeletedItemsFolder(mailboxSession, folderRow.ParentItemId)) { StoreObjectId folderId = folderRow.FolderId; CalendarSyncAssistantHelper.Tracer.TraceDebug <object, string, PropertyDefinition>((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.GetSynchronizableFolderRows identified folder id {1} as a synchronizable folder of type {2}.", TraceContext.Get(), folderId.ToString(), synchronizableFolderType.CounterProperty); if (synchronizableFolderType.HasSubscription(mailboxSession, folderId)) { CalendarSyncAssistantHelper.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: CalendarSyncAssistantHelper.GetSynchronizableFolderRows found a subscription for folder id {1}.", TraceContext.Get(), folderId.ToString()); dictionary[synchronizableFolderType].Add(folderRow); } } } return(dictionary); }
// Token: 0x06000809 RID: 2057 RVA: 0x00039A74 File Offset: 0x00037C74 protected bool MatchesFolderRow(FolderRow folderRow) { object extendedFolderFlags = folderRow.ExtendedFolderFlags; return(!(extendedFolderFlags is PropertyError) && this.MatchesContainerClass(folderRow.ContainerClass) && this.MatchesExtendedFolderFlags((int)extendedFolderFlags)); }
// Token: 0x06000805 RID: 2053 public abstract bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry);
// Token: 0x0600084D RID: 2125 RVA: 0x0003A9CC File Offset: 0x00038BCC private PublishingSubscriptionData GetSubscriptionData(MailboxSession mailboxSession, FolderRow folderRow) { PublishingSubscriptionData byLocalFolderId; using (PublishingSubscriptionManager publishingSubscriptionManager = new PublishingSubscriptionManager(mailboxSession)) { byLocalFolderId = publishingSubscriptionManager.GetByLocalFolderId(folderRow.FolderId); } return(byLocalFolderId); }
// Token: 0x06000849 RID: 2121 RVA: 0x0003A754 File Offset: 0x00038954 private void SaveLocalFolder(MailboxSession mailboxSession, Folder folder, PublishingSubscriptionData subscriptionData, FolderRow folderRow) { if (folder.Save().OperationResult != OperationResult.Succeeded) { InternetCalendarLog.LogEntry(mailboxSession, string.Format("InternetCalendarType.SyncFolder couldn't update LastAttemptedSyncTime of URL {0} on folder {1} with id {2}.", subscriptionData.PublishingUrl, folderRow.DisplayName, folderRow.FolderId)); SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.SyncFolder couldn't update LastAttemptedSyncTime of URL {1} on folder {2} with id {3} for mailbox {4}.", new object[] { TraceContext.Get(), subscriptionData.PublishingUrl, folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName }); } }
// Token: 0x06000848 RID: 2120 RVA: 0x0003A2AC File Offset: 0x000384AC private bool SyncFolder(MailboxSession mailboxSession, FolderRow folderRow, PublishingSubscriptionData subscriptionData, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry) { List <LocalizedString> list = new List <LocalizedString>(); bool result = true; bool flag = false; ExDateTime utcNow = ExDateTime.UtcNow; using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, folderRow.FolderId)) { ImportCalendarResults importCalendarResults = null; try { TimeSpan timeLeft = deadline.TimeLeft; if (timeLeft > TimeSpan.Zero) { calendarFolder.LastAttemptedSyncTime = utcNow; TimeSpan timeout = (timeLeft > SynchronizableFolderType.MaxSyncTimePerFolder) ? SynchronizableFolderType.MaxSyncTimePerFolder : timeLeft; HttpWebRequest httpWebRequest = this.CreateWebRequest(subscriptionData, timeout, mailboxSession, folderOpLogEntry); if (httpWebRequest == null) { SynchronizableFolderType.Tracer.TraceWarning <Uri>((long)this.GetHashCode(), "Unable to get web request for subscription. {0}", subscriptionData.PublishingUrl); return(true); } using (ImportCalendarStream importCalendarStream = new ImportCalendarStream()) { int num = -1; using (WebResponse response = httpWebRequest.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { num = importCalendarStream.CopyFrom(responseStream); SynchronizableFolderType.Tracer.TraceDebug <object, int, PublishingSubscriptionData>((long)this.GetHashCode(), "{0}: Read data ({1} bytes ) into memory stream from subscription source {2}.", TraceContext.Get(), num, subscriptionData); responseStream.Close(); } response.Close(); } if (num < 0) { folderOpLogEntry.AddErrorToLog("SubscriptionOverSizeLimit", null); } else { ExDateRange importWindow = InternetCalendarType.GetImportWindow(subscriptionData.PublishingUrl); importCalendarResults = ICalSharingHelper.ImportCalendar(importCalendarStream, "utf-8", new InboundConversionOptions(mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), mailboxSession.ServerFullyQualifiedDomainName), mailboxSession, calendarFolder, deadline, importWindow.Start, importWindow.End); if (importCalendarResults.Result != ImportCalendarResultType.Success) { list.AddRange(importCalendarResults.Errors); foreach (LocalizedString value in importCalendarResults.Errors) { folderOpLogEntry.AddErrorToLog("ImportCalendarException", value); } } flag = (importCalendarResults.Result != ImportCalendarResultType.Failed); } } SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: iCal to folder {1} with id {2} for mailbox {3} with subscription {4}. Results: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, subscriptionData, (importCalendarResults != null) ? importCalendarResults.ToString() : "iCal over the size limit" }); if (importCalendarResults == null) { folderOpLogEntry.AddErrorToLog("iCalOverSizeLimit", null); } } result = (importCalendarResults != null && !importCalendarResults.TimedOut); } catch (WebException ex) { list.Add(new LocalizedString(ex.ToString())); result = (ex.Status != WebExceptionStatus.Timeout); folderOpLogEntry.AddExceptionToLog(ex); } catch (SystemException ex2) { list.Add(new LocalizedString(ex2.ToString())); folderOpLogEntry.AddExceptionToLog(ex2); } catch (Exception ex3) { SynchronizableFolderType.Tracer.TraceError((long)this.GetHashCode(), "{0}: InternetCalendarType.SyncFolder for folder {1} with id {2} for mailbox {3} had the following exception: {4}. Subscription data: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, ex3, subscriptionData }); this.SaveLocalFolder(mailboxSession, calendarFolder, subscriptionData, folderRow); list.Add(new LocalizedString(ex3.ToString())); folderOpLogEntry.AddExceptionToLog(ex3); throw; } if (flag) { calendarFolder.LastSuccessfulSyncTime = utcNow; } this.SaveLocalFolder(mailboxSession, calendarFolder, subscriptionData, folderRow); } if (list != null) { foreach (LocalizedString localizedString in list) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.SyncFolder for folder {1} with id {2} for mailbox {3} had the following error: {4}. Subscription data: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, localizedString, subscriptionData }); } } return(result); }
// Token: 0x060007E1 RID: 2017 RVA: 0x000391B4 File Offset: 0x000373B4 private void UpdateTimeBasedPerfCounters(ExDateTime beginProcessingTimeStamp, FolderRow folderRow) { if (this.PerformanceCounters != null) { ExDateTime utcNow = ExDateTime.UtcNow; if (folderRow.LastSuccessfulSyncTime != ExDateTime.MinValue) { this.PerformanceCounters.AverageTimeBetweenSyncs.IncrementBy((utcNow - folderRow.LastSuccessfulSyncTime).Ticks); this.PerformanceCounters.AverageTimeBetweenSyncsBase.Increment(); } this.PerformanceCounters.AverageSubscriptionProcessingTime.IncrementBy((utcNow - beginProcessingTimeStamp).Ticks); this.PerformanceCounters.AverageSubscriptionProcessingTimeBase.Increment(); } }