public override void Begin(object state) { if (this.ShouldSyncMailbox()) { PublicFolderSynchronizer.Begin(this.OrganizationId, this.ContentMailboxGuid, this.ExecuteReconcileFolders, delegate(Exception exception) { base.LastError = exception; this.End(); }); return; } this.End(); }
private void Execute() { PublicFolderSynchronizer.Tracer.TraceDebug((long)this.GetHashCode(), "Execute() starting"); Exception exception = null; bool complete = false; try { GrayException.MapAndReportGrayExceptions(delegate() { CommonUtils.CatchKnownExceptions(delegate { complete = this.ExecuteWithinBudget(); }, delegate(Exception e) { PublicFolderSynchronizer.Tracer.TraceError <Exception>((long)this.GetHashCode(), "ExecuteWithinBudget call failed with known exception: {0}", e); exception = e; }); }); } catch (GrayException ex) { if (ex.InnerException != null) { exception = ex.InnerException; } else { exception = ex; } PublicFolderSynchronizer.Tracer.TraceError <GrayException>((long)this.GetHashCode(), "ExecuteWithinBudget call failed with unknown exception: {0}", ex); } if (exception != null || complete) { if (exception != null) { exception = PublicFolderSynchronizer.MapToReportableException(exception); } this.ReportSynchronizerResult(exception, complete); this.ExecuteCallback(exception); this.Dispose(); } }
public static void Begin(OrganizationId organizationId, Guid contentMailboxGuid, bool executeReconcileFolders, Action <Exception> onEndCallback) { ArgumentValidator.ThrowIfNull("organizationId", organizationId); ArgumentValidator.ThrowIfEmpty("contentMailboxGuid", contentMailboxGuid); ArgumentValidator.ThrowIfNull("onEndCallback", onEndCallback); PublicFolderSynchronizer.Tracer.TraceDebug <OrganizationId, Guid, bool>(0L, "PublicFolderSynchronizer.Begin() for organization {0}, mailbox {1}, executeReconcileFolders {2}", organizationId, contentMailboxGuid, executeReconcileFolders); ConfigBase <MRSConfigSchema> .InitializeConfigProvider(new Func <IConfigSchema, IConfigProvider>(ConfigProvider.CreateProvider)); IActivityScope activityScope = ActivityContext.Start(null, ActivityType.System); activityScope.Component = "PublicFolderSynchronizer"; try { PublicFolderSynchronizerContext publicFolderSynchronizerContext = new PublicFolderSynchronizerContext(organizationId, contentMailboxGuid, false, executeReconcileFolders, activityScope.ActivityId); PublicFolderSynchronizer publicFolderSynchronizer = new PublicFolderSynchronizer(publicFolderSynchronizerContext, activityScope, onEndCallback); PublicFolderSynchronizer.Tracer.TraceDebug <int>(0L, "Created PublicFolderSynchronizer={0}", publicFolderSynchronizer.GetHashCode()); publicFolderSynchronizer.Execute(); } finally { ActivityContext.ClearThreadScope(); } }