private void CalculateVolume(IEnumerable <ExportDocumentDetail> documents) { var exportDocumentDetails = new List <ExportDocumentDetail>(); var loadFileHelper = new ExportLoadFileHelper(_bootParameter); Parallel.ForEach(documents.ToList(), new ParallelOptions { MaxDegreeOfParallelism = _maxParallelThread }, (docDetail) => loadFileHelper.SetImageSourceFiles(docDetail, _exportDocumentCollection.ExportOption)); foreach (var documentDetail in documents) { exportDocumentDetails.Add(SetDestinationFolderByFileType(documentDetail)); if (exportDocumentDetails.Count <= 100) { continue; } loadFileHelper.RemoveImageFile(exportDocumentDetails, _exportBaseFolderPath); Send(exportDocumentDetails); exportDocumentDetails.Clear(); } if (!exportDocumentDetails.Any()) { return; } loadFileHelper.RemoveImageFile(exportDocumentDetails, _exportBaseFolderPath); Send(exportDocumentDetails); exportDocumentDetails.Clear(); }
private void PerformCopy(out List <JobWorkerLog <ExportFileCopyLogInfo> > fileCopyLogList) { fileCopyLogList = new List <JobWorkerLog <ExportFileCopyLogInfo> >(); #region New var documentDetails = new List <ExportDocumentDetail>(); var tempFileCopyLogList = new List <JobWorkerLog <ExportFileCopyLogInfo> >(); var loadFileHelper = new ExportLoadFileHelper(_bootParameter); foreach (var doc in _exportDocumentCollection.Documents) { JobWorkerLog <ExportFileCopyLogInfo> fileCopyLog; loadFileHelper.SetImageSourceFiles(doc, _exportDocumentCollection.ExportOption); var exportDocument = CopyFiles(doc, out fileCopyLog); lock (DocObject) { if (exportDocument != null) { documentDetails.Add(exportDocument); } if (fileCopyLog != null) { tempFileCopyLogList.Add(fileCopyLog); } } } _exportDocumentCollection.Documents.Clear(); loadFileHelper.RemoveImageFile(documentDetails, _exportDocumentCollection.ExportOption.ExportDestinationFolderPath); _exportDocumentCollection.Documents.AddRange(documentDetails); if (tempFileCopyLogList.Any()) { fileCopyLogList.AddRange(tempFileCopyLogList); } #endregion #region Old Debug Purpose /* foreach (ExportDocumentDetail docDetail in _exportDocumentCollection.Documents) * { * JobWorkerLog<ExportFileCopyLogInfo> fileCopyLog = null; * var exportDocument = CopyFiles(docDetail, out fileCopyLog); * if (exportDocument != null) * documentDetails.Add(exportDocument); * if (fileCopyLog != null) * fileCopyLogList.Add(fileCopyLog); * * } * _exportDocumentCollection.Documents.Clear(); * _exportDocumentCollection.Documents.AddRange(documentDetails); */ #endregion }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { if (envelope.Label == "PleaseFinalize") { FinalizeFiles(); return; } exportDocumentCollection = (ExportDocumentCollection)envelope.Body; #region Assertion //Pre Condition PipelineId.ShouldNotBeEmpty(); BootParameters.ShouldNotBe(null); BootParameters.ShouldBeTypeOf <string>(); exportDocumentCollection.ShouldNotBe(null); exportDocumentCollection.Documents.ShouldNotBe(null); exportDocumentCollection.Documents.LongCount().ShouldBeGreaterThan(0); #endregion exportDocumentCollection.Dataset = _dataset; try { if (parametersExportLoadFile == null) { InitializeForProcessing(BootParameters); } GetDocumentFields(exportDocumentCollection.Documents); #region Get Content-Field value from Text file GetDocumentsContentField(); #endregion if (exportDocumentCollection.ExportOption.IsImage || exportDocumentCollection.ExportOption.IsProduction) { //Set Images File Path.. var loadFileHelper = new ExportLoadFileHelper(BootParameters); Parallel.ForEach(exportDocumentCollection.Documents, new ParallelOptions { MaxDegreeOfParallelism = _maxParallelThread }, (docDetail) => loadFileHelper.SetImageSourceFiles(docDetail, exportDocumentCollection.ExportOption)); } var fileWriterLogList = WriteLoadFiles(); #region Send Log if (fileWriterLogList != null && fileWriterLogList.Any()) { //Send to Log pipe SendLog(fileWriterLogList); } #endregion documentContentFieldsValueCollection.Clear(); } catch (Exception ex) { ex.Trace().Swallow(); ReportToDirector(ex); } }