private void ExportSourceMailbox(IContextualBatchDataWriter <List <ItemInformation> > dataWriter, SourceInformation source, bool isUnsearchable) { Tracer.TraceInformation("ProgressController.ExportSourceMailbox: Source Id: {0}; isUnsearchable: {1}", new object[] { source.Configuration.Id, isUnsearchable }); this.ItemListGenerator.DoUnSearchable = isUnsearchable; bool flag = (!isUnsearchable && source.Status.ItemCount <= 0) || (isUnsearchable && source.Status.UnsearchableItemCount <= 0); if ((!isUnsearchable && source.Status.ItemCount > source.Status.ProcessedItemCount) || (isUnsearchable && source.Status.UnsearchableItemCount > source.Status.ProcessedUnsearchableItemCount) || !this.target.ExportContext.IsResume || flag) { IItemIdList itemIdList = this.target.CreateItemIdList(source.Configuration.Id, isUnsearchable); DataContext dataContext = new DataContext(source, itemIdList); DataRetriever dataRetriever = new DataRetriever(dataContext, this); dataRetriever.DataWriter = dataWriter; this.ItemListGenerator.DataRetriever = dataRetriever; this.ItemListGenerator.DataBatchRead += this.ItemListGenerator.WriteDataBatchItemListGen; dataRetriever.DataBatchRead += this.ItemListGenerator.WriteDataBatchDataRetriever; ExportException ex = null; try { this.ItemListGenerator.DoExportForSourceMailbox(dataRetriever.DataContext.SourceInformation); } finally { ex = AsynchronousTaskHandler.WaitForAsynchronousTask(this.ItemListGenerator.WritingTask); this.ItemListGenerator.WritingTask = null; this.ItemListGenerator.DataRetriever = null; } if (ex != null) { throw ex; } } }
private void InternalExport() { using (IContextualBatchDataWriter <List <ItemInformation> > contextualBatchDataWriter = this.target.CreateDataWriter(this)) { bool errorHappened = false; try { if (this.StatusManager.AllSourceInformation != null) { ScenarioData.Current["M"] = this.StatusManager.AllSourceInformation.Count.ToString(); } this.sourceDataProviderManager.CreateSourceServiceClients(this.StatusManager.AllSourceInformation); this.ItemListGenerator.AllSourceInformation = this.StatusManager.AllSourceInformation; int num = 0; this.ReportStatistics(new ExportStatusEventArgs { ActualBytes = 0L, ActualCount = 0, ActualMailboxesProcessed = 0, ActualMailboxesTotal = this.StatusManager.AllSourceInformation.Count, TotalDuration = TimeSpan.Zero }); foreach (SourceInformation sourceInformation in this.StatusManager.AllSourceInformation.Values) { if (sourceInformation.Configuration != null && sourceInformation.Configuration.SourceFilter != null) { ScenarioData.Current["QL"] = sourceInformation.Configuration.SourceFilter.Length.ToString(); } Tracer.TraceInformation("ProgressController.InternalExport: Exporting source '{0}'. ItemCount: {1}; ProcessedItemCount: {2}; UnsearchableItemCount: {3}; ProcessedUnsearchableItemCount: {4}; DuplicateItemCount: {5}; UnsearchableDuplicateItemCount: {6}; ErrorItemCount: {7}", new object[] { sourceInformation.Configuration.Id, sourceInformation.Status.ItemCount, sourceInformation.Status.ProcessedItemCount, sourceInformation.Status.UnsearchableItemCount, sourceInformation.Status.ProcessedUnsearchableItemCount, sourceInformation.Status.DuplicateItemCount, sourceInformation.Status.UnsearchableDuplicateItemCount, sourceInformation.Status.ErrorItemCount }); if (this.IsStopRequested) { Tracer.TraceInformation("ProgressController.InternalExport: Stop requested.", new object[0]); this.StatusManager.BeginProcedure(ProcedureType.Stop); break; } try { num++; this.ExportSourceMailbox(contextualBatchDataWriter, sourceInformation, false); this.ExportSourceMailbox(contextualBatchDataWriter, sourceInformation, true); if (sourceInformation.Configuration.Id.StartsWith("\\")) { errorHappened = true; } Tracer.TraceInformation("ProgressController.InternalExport: Exporting source '{0}'. ItemCount: {1}; ProcessedItemCount: {2}; UnsearchableItemCount: {3}; ProcessedUnsearchableItemCount: {4}; DuplicateItemCount: {5}; UnsearchableDuplicateItemCount: {6}; ErrorItemCount: {7}", new object[] { sourceInformation.Configuration.Id, sourceInformation.Status.ItemCount, sourceInformation.Status.ProcessedItemCount, sourceInformation.Status.UnsearchableItemCount, sourceInformation.Status.ProcessedUnsearchableItemCount, sourceInformation.Status.DuplicateItemCount, sourceInformation.Status.UnsearchableDuplicateItemCount, sourceInformation.Status.ErrorItemCount }); } catch (ExportException ex) { if (ex.ErrorType == ExportErrorType.TargetOutOfSpace) { Tracer.TraceInformation("ProgressController.InternalExport: Target level error occurs during export.: {0}", new object[] { ex }); throw; } Tracer.TraceInformation("ProgressController.InternalExport: Source level error occurs during export: {0}", new object[] { ex }); ProgressRecord progressRecord = new ProgressRecord(); progressRecord.ReportSourceError(new ErrorRecord { Item = null, ErrorType = ex.ErrorType, DiagnosticMessage = ex.Message, SourceId = sourceInformation.Configuration.Id, Time = DateTime.UtcNow }); this.ReportProgress(progressRecord); } finally { this.ReportStatistics(new ExportStatusEventArgs { ActualBytes = 0L, ActualCount = 0, ActualMailboxesProcessed = num, ActualMailboxesTotal = this.StatusManager.AllSourceInformation.Count, TotalDuration = TimeSpan.Zero }); } } errorHappened = true; } finally { contextualBatchDataWriter.ExitPFDataContext(errorHappened); } } }