public static void LogEntry(MailboxSession session, PublishingSubscriptionData subscriptionData, HttpWebRequest request, List <LocalizedString> errors) { StringBuilder stringBuilder = new StringBuilder(InternetCalendarLog.MaxErrorBufferSize); if (errors != null && errors.Count > 0) { string arg; if (request != null && request.Proxy is WebProxy) { arg = ((WebProxy)request.Proxy).Address.ToString(); } else { arg = "<unknown>"; } stringBuilder.AppendFormat("Errors while synchronizing calendar. Subscription data: {0}, proxy is: {1}. ", subscriptionData.ToString(), arg); foreach (LocalizedString value in errors) { if (stringBuilder.Length > InternetCalendarLog.MaxErrorBufferSize) { InternetCalendarLog.instance.WriteLogEntry(session, stringBuilder.ToString()); stringBuilder.Length = 0; } stringBuilder.Append(value); stringBuilder.Append(';'); } if (stringBuilder.Length > 0) { InternetCalendarLog.LogEntry(session, stringBuilder.ToString()); } } }
// 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: 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: 0x06002FE9 RID: 12265 RVA: 0x00117994 File Offset: 0x00115B94 public static string GetWebCalendarUrl(MailboxSession session, StoreObjectId folderId) { if (session == null) { throw new ArgumentNullException("session"); } if (folderId == null) { throw new ArgumentNullException("folderId"); } using (PublishingSubscriptionManager publishingSubscriptionManager = new PublishingSubscriptionManager(session)) { PublishingSubscriptionData byLocalFolderId = publishingSubscriptionManager.GetByLocalFolderId(folderId); if (byLocalFolderId != null) { return(byLocalFolderId.PublishingUrl.ToString()); } } return(null); }
// 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); }
// 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); }