// Token: 0x0600086E RID: 2158 RVA: 0x0003AC9C File Offset: 0x00038E9C
 public void AddFolderDetailLogline(CalendarSyncFolderOperationLogEntry folderDetail)
 {
     if (this.FolderDetailLoglines == null)
     {
         this.FolderDetailLoglines = new List <CalendarSyncFolderOperationLogEntry>();
     }
     this.FolderDetailLoglines.Add(folderDetail);
 }
Exemplo n.º 2
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);
     }
 }
 // Token: 0x0600086F RID: 2159 RVA: 0x0003ACC0 File Offset: 0x00038EC0
 private void PostFolderDetailsToQuickLogs(MailboxSession mailboxSession, CalendarSyncFolderOperationLogEntry folderOpLogEntry, string folderDetailsToLog)
 {
     if (folderOpLogEntry.FolderType == "UnknownFolderType")
     {
         InternetCalendarLog.LogEntry(mailboxSession, string.Format("CalendarSyncAssistantHelper.ProcessFolder Couldn't find a corresponding SynchronizableFolderType object for folder id {0}.", folderOpLogEntry.FolderId));
         return;
     }
     if (folderOpLogEntry.FolderType == "InternetCalendar")
     {
         if (folderOpLogEntry.SubscriptionData == null)
         {
             string entry = string.Format("InternetCalendarType.Synchronize couldn't find subscription data for folder {0} with id {1} for mailbox {2}.", folderOpLogEntry.DisplayName, folderOpLogEntry.FolderId, mailboxSession.DisplayName);
             InternetCalendarLog.LogEntry(mailboxSession, entry);
         }
         InternetCalendarLog.LogEntry(mailboxSession, string.Format("Sync Details for InternetCalendar subscription {0}, folder {1} with id {2} are {3}.", new object[]
         {
             folderOpLogEntry.SubscriptionData,
             folderOpLogEntry.DisplayName,
             folderOpLogEntry.FolderId,
             folderDetailsToLog
         }));
     }
     if (folderOpLogEntry.IsDeadlineExpired)
     {
         SharingSyncAssistantLog.LogEntry(mailboxSession, "Deadline expired before processing folder {0}. MaxSyncTime: {1}", new object[]
         {
             folderOpLogEntry.DisplayName,
             SynchronizableFolderType.MaxSyncTimePerFolder
         });
     }
     SharingSyncAssistantLog.LogEntry(mailboxSession, "Sync Details for folder {0} are {1}", new object[]
     {
         folderOpLogEntry.DisplayName,
         folderDetailsToLog
     });
 }
 // 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);
        }
Exemplo n.º 6
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.º 7
0
        // Token: 0x0600084C RID: 2124 RVA: 0x0003A920 File Offset: 0x00038B20
        private Uri ExpandSubscriptionUrl(Uri subscriptionUri, VariantConfigurationSnapshot config, CultureInfo culture, CalendarSyncFolderOperationLogEntry folderOpLogEntry)
        {
            Uri         result      = null;
            UrlResolver urlResolver = null;

            try
            {
                urlResolver = ConfigurationCache.Instance.GetUrlResolver(config);
                result      = urlResolver.ResolveUrl(subscriptionUri, culture);
            }
            catch (HolidayCalendarException ex)
            {
                SynchronizableFolderType.Tracer.TraceError((long)this.GetHashCode(), "Exception encountered while expanding holiday calendar URL:'{0}' Endpoint: '{1}' Resolver: '{2}' Exception: {3}", new object[]
                {
                    subscriptionUri,
                    (config.HolidayCalendars.HostConfiguration != null) ? config.HolidayCalendars.HostConfiguration.Endpoint : "<null>",
                    (urlResolver != null) ? "Retrieved" : "<null>",
                    ex
                });
                folderOpLogEntry.AddExceptionToLog(ex);
            }
            return(result);
        }
Exemplo n.º 8
0
        // Token: 0x0600084A RID: 2122 RVA: 0x0003A7E0 File Offset: 0x000389E0
        private HttpWebRequest CreateWebRequest(PublishingSubscriptionData subscriptionData, TimeSpan timeout, MailboxSession session, CalendarSyncFolderOperationLogEntry folderOpLogEntry)
        {
            Uri uri = subscriptionData.PublishingUrl;

            if (subscriptionData.UrlNeedsExpansion)
            {
                VariantConfigurationSnapshot snapshot = VariantConfiguration.GetSnapshot(session.MailboxOwner.GetContext(null), null, null);
                if (snapshot.OwaClientServer.XOWAHolidayCalendars.Enabled)
                {
                    uri = this.ExpandSubscriptionUrl(uri, snapshot, session.PreferedCulture, folderOpLogEntry);
                }
            }
            if (uri == null)
            {
                return(null);
            }
            HttpWebRequest httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;

            if (httpWebRequest == null)
            {
                throw new UriFormatException(string.Format("The following URI isn't supported: {0}", uri));
            }
            httpWebRequest.Timeout           = (int)timeout.TotalMilliseconds;
            httpWebRequest.Method            = "GET";
            httpWebRequest.Accept            = "*/*";
            httpWebRequest.Credentials       = null;
            httpWebRequest.AllowAutoRedirect = true;
            httpWebRequest.UserAgent         = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";
            Server localServer = LocalServerCache.LocalServer;

            if (localServer != null && localServer.InternetWebProxy != null)
            {
                httpWebRequest.Proxy = new WebProxy(localServer.InternetWebProxy, true);
            }
            return(httpWebRequest);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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
                }));
            }
        }