// Token: 0x060008B8 RID: 2232 RVA: 0x0003B804 File Offset: 0x00039A04
        internal CalendarSyncPerformanceCountersInstance(string instanceName, CalendarSyncPerformanceCountersInstance autoUpdateTotalInstance) : base(instanceName, "MSExchange Calendar Sync Assistant")
        {
            bool flag = false;
            List <ExPerformanceCounter> list = new List <ExPerformanceCounter>();

            try
            {
                this.OnDemandRequests = new ExPerformanceCounter(base.CategoryName, "On demand requests", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.OnDemandRequests, new ExPerformanceCounter[0]);
                list.Add(this.OnDemandRequests);
                this.AverageSubscriptionsPerMailbox = new ExPerformanceCounter(base.CategoryName, "Average Number of Subscriptions per Mailbox", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionsPerMailbox, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionsPerMailbox);
                this.AverageSubscriptionsPerMailboxBase = new ExPerformanceCounter(base.CategoryName, "Average Number of Subscriptions per Mailbox Base", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionsPerMailboxBase, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionsPerMailboxBase);
                this.AverageTimeBetweenSyncs = new ExPerformanceCounter(base.CategoryName, "Average Time Between Syncs", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageTimeBetweenSyncs, new ExPerformanceCounter[0]);
                list.Add(this.AverageTimeBetweenSyncs);
                this.AverageTimeBetweenSyncsBase = new ExPerformanceCounter(base.CategoryName, "Average Time Between Syncs Base", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageTimeBetweenSyncsBase, new ExPerformanceCounter[0]);
                list.Add(this.AverageTimeBetweenSyncsBase);
                this.AverageDownloadTime = new ExPerformanceCounter(base.CategoryName, "Average Download Time", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageDownloadTime, new ExPerformanceCounter[0]);
                list.Add(this.AverageDownloadTime);
                this.AverageDownloadTimeBase = new ExPerformanceCounter(base.CategoryName, "Average Download Time Base", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageDownloadTimeBase, new ExPerformanceCounter[0]);
                list.Add(this.AverageDownloadTimeBase);
                this.AverageSubscriptionProcessingTime = new ExPerformanceCounter(base.CategoryName, "Average Subscription Processing Time", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionProcessingTime, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionProcessingTime);
                this.AverageSubscriptionProcessingTimeBase = new ExPerformanceCounter(base.CategoryName, "Average Subscription Processing Time Base", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionProcessingTimeBase, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionProcessingTimeBase);
                this.AverageSubscriptionImportTime = new ExPerformanceCounter(base.CategoryName, "Average Subscription Import Time", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionImportTime, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionImportTime);
                this.AverageSubscriptionImportTimeBase = new ExPerformanceCounter(base.CategoryName, "Average Subscription Import Time Base", instanceName, true, (autoUpdateTotalInstance == null) ? null : autoUpdateTotalInstance.AverageSubscriptionImportTimeBase, new ExPerformanceCounter[0]);
                list.Add(this.AverageSubscriptionImportTimeBase);
                long num = this.OnDemandRequests.RawValue;
                num += 1L;
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    foreach (ExPerformanceCounter exPerformanceCounter in list)
                    {
                        exPerformanceCounter.Close();
                    }
                }
            }
            this.counters = list.ToArray();
        }
 // Token: 0x06000805 RID: 2053
 public abstract bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry);
        // 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);
        }
Example #4
0
        // 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);
        }
Example #5
0
        // 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);
        }
Example #6
0
        // 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);
        }
Example #7
0
 // Token: 0x060007D1 RID: 2001 RVA: 0x00038903 File Offset: 0x00036B03
 public CalendarSyncAssistantHelper(AssistantBase assistant, CalendarSyncPerformanceCountersInstance counters)
 {
     this.assistant    = assistant;
     this.perfCounters = counters;
 }