public void Rollback(bool removeStatusLog) { lock (this) { this.EnsureStatusLogValid(); Tracer.TraceInformation("StatusManager.Rollback: removeStatusLog: {0}; CurrentStatus: {1}", new object[] { removeStatusLog, this.CurrentStatus }); if (this.CurrentStatus != OperationStatus.Rollbacking) { throw new ArgumentException("IStatusManager.Rollback(bool) should be only called when the status is Rollbacking"); } this.target.Rollback(this.AllSourceInformation); if (removeStatusLog) { if (this.statusLog != null) { this.statusLog.Delete(); this.statusLog.Dispose(); this.statusLog = null; } this.CurrentStatus = OperationStatus.None; this.AllSourceInformation = null; } else { this.ResetStatusToDefault(); } } }
public void CreateSourceServiceClients(SourceInformationCollection allSourceInformation) { Dictionary <Uri, IServiceClient <ISourceDataProvider> > dictionary = new Dictionary <Uri, IServiceClient <ISourceDataProvider> >(allSourceInformation.Count); foreach (SourceInformation sourceInformation in allSourceInformation.Values) { if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when creating service clients.", new object[0]); return; } if (this.IsServiceClientNeededForSource(sourceInformation)) { IServiceClient <ISourceDataProvider> serviceClient; if (!dictionary.TryGetValue(sourceInformation.Configuration.ServiceEndpoint, out serviceClient)) { serviceClient = this.serviceClientFactory.CreateSourceDataProvider(sourceInformation.Configuration.ServiceEndpoint, this.abortTokenForTasks); if (!serviceClient.Connect()) { throw new ExportException(ExportErrorType.Unauthorized, sourceInformation.Configuration.ServiceEndpoint.ToString()); } dictionary.Add(sourceInformation.Configuration.ServiceEndpoint, serviceClient); } sourceInformation.ServiceClient = serviceClient.FunctionalInterface; } } Tracer.TraceInformation("SourceDataProviderManager.CreateSourceServiceClients: number of service clients created: {0}", new object[] { dictionary.Count }); }
public ItemListGenerator(SourceInformationCollection allSourceInformation, ITarget target, IProgressController progressController) { this.AllSourceInformation = allSourceInformation; this.target = target; this.includeDuplicates = target.ExportContext.ExportMetadata.IncludeDuplicates; this.progressController = progressController; }
public void Rollback(SourceInformationCollection allSourceInformation) { Tracer.TraceInformation("PstTarget.Rollback - Start", new object[0]); Tracer.TraceInformation("PstTarget.Rollback IncludeDuplicates {0}, IncludeSearchableItems {1}, IncludeUnsearchableItems {2}", new object[] { this.ExportContext.ExportMetadata.IncludeDuplicates ? "true" : "false", this.ExportContext.ExportMetadata.IncludeSearchableItems ? "true" : "false", this.ExportContext.ExportMetadata.IncludeUnsearchableItems ? "true" : "false" }); foreach (SourceInformation sourceInformation in allSourceInformation.Values) { Tracer.TraceInformation("PstTarget.Rollback source Id {0}, source Name {1}", new object[] { sourceInformation.Configuration.Id, sourceInformation.Configuration.Name }); bool isPublicFolder = sourceInformation.Configuration.Id.StartsWith("\\"); if (this.ExportContext.ExportMetadata.IncludeDuplicates) { if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { this.RemoveFileForSource(sourceInformation.Configuration.Name, false, isPublicFolder); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { this.RemoveFileForSource(sourceInformation.Configuration.Name, true, isPublicFolder); } } if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { string itemIdListFilePath = this.GetItemIdListFilePath(sourceInformation.Configuration.Id, false); LocalFileHelper.RemoveFile(itemIdListFilePath, ExportErrorType.FailedToRollbackResultsInTargetLocation); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { string itemIdListFilePath2 = this.GetItemIdListFilePath(sourceInformation.Configuration.Id, true); LocalFileHelper.RemoveFile(itemIdListFilePath2, ExportErrorType.FailedToRollbackResultsInTargetLocation); } } if (!this.ExportContext.ExportMetadata.IncludeDuplicates) { if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { this.RemoveFileForSource(null, false, false); this.RemoveFileForSource(null, false, true); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { this.RemoveFileForSource(null, true, false); this.RemoveFileForSource(null, true, true); } } Tracer.TraceInformation("PstTarget.Rollback - End", new object[0]); }
private void ResetStatusToDefault() { Tracer.TraceInformation("StatusManager.ResetStatusToDefault", new object[0]); this.AllSourceInformation = new SourceInformationCollection(this.target.ExportContext.Sources.Count); foreach (ISource source in this.target.ExportContext.Sources) { SourceInformation value = new SourceInformation(source.Name, source.Id, source.SourceFilter, source.ServiceEndpoint, source.LegacyExchangeDN); this.AllSourceInformation[source.Id] = value; } this.CurrentStatus = OperationStatus.Pending; }
public void AutoDiscoverSourceServiceEndpoints(SourceInformationCollection allSourceInformation, Uri configurationServiceEndpoint, ICredentialHandler credentialHandler) { this.serviceClientFactory.CredentialHandler = credentialHandler; if (configurationServiceEndpoint != null && configurationServiceEndpoint.IsAbsoluteUri && configurationServiceEndpoint.Scheme == Uri.UriSchemeHttps) { if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with configuration service server", new object[0]); return; } Uri autoDiscoverUrl = new Uri(configurationServiceEndpoint.GetLeftPart(UriPartial.Authority) + "/autodiscover/autodiscover.svc"); this.AutoDiscoverServiceEndpoints((from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) select sourceInformation).ToList <SourceInformation>(), autoDiscoverUrl, 0); if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with configuration service endpoint", new object[0]); return; } using (IServiceClient <ISourceDataProvider> serviceClient = this.serviceClientFactory.CreateSourceDataProvider(configurationServiceEndpoint, this.abortTokenForTasks)) { if (serviceClient.Connect()) { SourceDataProviderManager.VerifyAndSetServiceEndpoint((from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) select sourceInformation).ToList <SourceInformation>(), serviceClient); } } } IEnumerable <IGrouping <string, SourceInformation> > enumerable = from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) group sourceInformation by SourceDataProviderManager.GetDomainFromSmtpEmailAddress(sourceInformation.Configuration.Id.StartsWith("\\")?sourceInformation.Configuration.Name : sourceInformation.Configuration.Id); foreach (IGrouping <string, SourceInformation> grouping in enumerable) { if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with email domains of source mailboxes.", new object[0]); return; } this.AutoDiscoverServiceEndpointsWithEmailDomain(grouping.ToList <SourceInformation>(), grouping.Key.ToLowerInvariant()); } SourceInformation sourceInformation2 = allSourceInformation.Values.FirstOrDefault((SourceInformation sourceInformation) => this.IsServiceEndpointNeededForSource(sourceInformation)); if (sourceInformation2 != null && !this.IsStopRequested) { throw new ExportException(ExportErrorType.FailedToAutoDiscoverExchangeWebServiceUrl, sourceInformation2.Configuration.Id); } }
public void CheckInitialStatus(SourceInformationCollection allSourceInformation, OperationStatus status) { foreach (SourceInformation sourceInformation in allSourceInformation.Values) { bool isPublicFolder = sourceInformation.Configuration.Id.StartsWith("\\"); if (this.ExportContext.ExportMetadata.IncludeDuplicates) { if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { this.ValidateDataFile(sourceInformation.Configuration.Name, false, isPublicFolder); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { this.ValidateDataFile(sourceInformation.Configuration.Name, true, isPublicFolder); } } if (!this.ExportContext.IsResume || !sourceInformation.Status.IsSearchCompleted(this.ExportContext.ExportMetadata.IncludeSearchableItems, this.ExportContext.ExportMetadata.IncludeUnsearchableItems)) { if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { string itemIdListFilePath = this.GetItemIdListFilePath(sourceInformation.Configuration.Id, false); LocalFileHelper.RemoveFile(itemIdListFilePath, ExportErrorType.FailedToCleanupCorruptedStatusLog); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { string itemIdListFilePath2 = this.GetItemIdListFilePath(sourceInformation.Configuration.Id, true); LocalFileHelper.RemoveFile(itemIdListFilePath2, ExportErrorType.FailedToCleanupCorruptedStatusLog); } } } if (!this.ExportContext.ExportMetadata.IncludeDuplicates) { if (this.ExportContext.ExportMetadata.IncludeSearchableItems) { this.ValidateDataFile(null, false, false); } if (this.ExportContext.ExportMetadata.IncludeUnsearchableItems) { this.ValidateDataFile(null, true, false); } } }
public void CheckInitialStatus(SourceInformationCollection allSourceInformation, OperationStatus status) { this.TargetInternal.CheckInitialStatus(allSourceInformation, status); }
public void Rollback(SourceInformationCollection allSourceInformation) { this.TargetInternal.Rollback(allSourceInformation); }
private void EnsureStatusLogValid() { if (this.statusLog == null) { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: initializing status log in memory", new object[0]); try { this.statusLog = this.target.GetStatusLog(); SourceInformationCollection sourceInformationCollection = null; OperationStatus currentStatus = OperationStatus.None; ExportSettings exportSettings = this.statusLog.LoadStatus(out sourceInformationCollection, out currentStatus); if (sourceInformationCollection == null) { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: creating status log since no existing log found", new object[0]); if (this.target.ExportContext.IsResume) { throw new ExportException(ExportErrorType.StatusNotFoundToResume, "This is a resume request of previous job. But there is no corresponding previous job found."); } this.ResetStatusToDefault(); this.target.ExportSettings = new ExportSettings { ExportTime = this.target.ExportContext.ExportMetadata.ExportStartTime, IncludeDuplicates = this.target.ExportContext.ExportMetadata.IncludeDuplicates, IncludeSearchableItems = this.target.ExportContext.ExportMetadata.IncludeSearchableItems, IncludeUnsearchableItems = this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems, RemoveRms = this.target.ExportContext.ExportMetadata.RemoveRms }; this.statusLog.ResetStatusLog(this.AllSourceInformation, this.CurrentStatus, this.target.ExportSettings); } else { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Using existing status log", new object[0]); if (!this.target.ExportContext.IsResume) { throw new ExportException(ExportErrorType.ExistingStatusMustBeAResumeOperation, "This operation has previous job status so it must be a resume operation this time."); } if (exportSettings == null) { throw new ExportException(ExportErrorType.CorruptedStatus, "The export settings in the status log is missing or corrupted."); } this.target.ExportSettings = exportSettings; bool flag = false; if (this.target.ExportContext.ExportMetadata.IncludeDuplicates == this.target.ExportSettings.IncludeDuplicates && this.target.ExportContext.ExportMetadata.IncludeSearchableItems == this.target.ExportSettings.IncludeSearchableItems && this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems == this.target.ExportSettings.IncludeUnsearchableItems && this.target.ExportContext.ExportMetadata.RemoveRms == this.target.ExportSettings.RemoveRms && this.target.ExportContext.Sources.Count == sourceInformationCollection.Count) { using (IEnumerator <ISource> enumerator = this.target.ExportContext.Sources.GetEnumerator()) { while (enumerator.MoveNext()) { ISource source = enumerator.Current; try { SourceInformation sourceInformation = sourceInformationCollection[source.Id]; if (sourceInformation.Configuration.Name != source.Name || sourceInformation.Configuration.SourceFilter != source.SourceFilter || sourceInformation.Configuration.LegacyExchangeDN != source.LegacyExchangeDN) { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed for source '{0}'", new object[] { source.Id }); flag = true; break; } } catch (KeyNotFoundException) { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed(new source detected) for source '{0}'", new object[] { source.Id }); flag = true; break; } } goto IL_37E; } } Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed(source count doesn't match). Original source count: {0}; New source count: {1}", new object[] { sourceInformationCollection.Count, this.target.ExportContext.Sources.Count }); flag = true; IL_37E: if (flag) { throw new ExportException(ExportErrorType.CannotResumeWithConfigurationChange); } this.AllSourceInformation = sourceInformationCollection; this.CurrentStatus = currentStatus; if (StatusManager.IsTransientStatus(this.CurrentStatus)) { Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Recovering on status: {0}", new object[] { this.CurrentStatus }); this.Recover(); } } this.target.CheckInitialStatus(this.AllSourceInformation, this.CurrentStatus); } catch (Exception ex) { Tracer.TraceError("StatusManager.EnsureStatusLogValid: Exception happend, closing status log. Exception: {0}", new object[] { ex }); this.CloseStatusLog(); throw; } } }
internal SearchResults(SourceInformationCollection sources, ITarget target) { this.sourceMailboxes = sources; this.target = target; }