// 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }