protected override void BeginWork() { //Tracer.Debug("BeginWork started"); base.BeginWork(); _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(BootParameters) as ExportLoadJobDetailBEO; Debug.Assert(_exportLoadJobDetailBeo != null, "exportLoadJobDetailBEO != null"); _dataset = DataSetBO.GetDatasetDetailsWithMatterInfo(Convert.ToInt64(_exportLoadJobDetailBeo.DatasetId), _exportLoadJobDetailBeo.MatterId); matterId = _dataset.Matter.FolderID; if (_exportLoadJobDetailBeo.RecreateFamilyGroup) { PipelineProperty pipelineProperty = GetPipelineSharedProperty(BeginsEndsPropertyName); lock (pipelineProperty) { if (pipelineProperty.Value == null) { //Tracer.Debug("CalculateBeginsAndEnds"); var endNumber = !string.IsNullOrEmpty(_exportLoadJobDetailBeo.FamilyEndNumberField) ? _exportLoadJobDetailBeo.FamilyEndNumberField : _exportLoadJobDetailBeo.FamilyBegNumberField; pipelineProperty.Value = CalculateBeginsAndEnds(_exportLoadJobDetailBeo.FamilyBegNumberField, endNumber); } _beginsEnds = pipelineProperty.Value as Dictionary<string, Tuple<string, string>>; } } //Tracer.Debug("BeginWork completed"); }
protected override void BeginWork() { //Tracer.Debug("BeginWork started"); base.BeginWork(); _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(BootParameters) as ExportLoadJobDetailBEO; Debug.Assert(_exportLoadJobDetailBeo != null, "exportLoadJobDetailBEO != null"); _dataset = DataSetBO.GetDatasetDetailsWithMatterInfo(Convert.ToInt64(_exportLoadJobDetailBeo.DatasetId), _exportLoadJobDetailBeo.MatterId); matterId = _dataset.Matter.FolderID; if (_exportLoadJobDetailBeo.RecreateFamilyGroup) { PipelineProperty pipelineProperty = GetPipelineSharedProperty(BeginsEndsPropertyName); lock (pipelineProperty) { if (pipelineProperty.Value == null) { //Tracer.Debug("CalculateBeginsAndEnds"); var endNumber = !string.IsNullOrEmpty(_exportLoadJobDetailBeo.FamilyEndNumberField) ? _exportLoadJobDetailBeo.FamilyEndNumberField : _exportLoadJobDetailBeo.FamilyBegNumberField; pipelineProperty.Value = CalculateBeginsAndEnds(_exportLoadJobDetailBeo.FamilyBegNumberField, endNumber); } _beginsEnds = pipelineProperty.Value as Dictionary <string, Tuple <string, string> >; } } //Tracer.Debug("BeginWork completed"); }
protected override void BeginWork() { base.BeginWork(); _maxParallelThread = Convert.ToInt32(ApplicationConfigurationManager.GetValue("NumberOfMaxParallelism", "Export")); _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(BootParameters) as ExportLoadJobDetailBEO; _dataset = DataSetBO.GetDatasetDetailsWithMatterInfo(Convert.ToInt64(_exportLoadJobDetailBeo.DatasetId), _exportLoadJobDetailBeo.MatterId); }
protected override void BeginWork() { base.BeginWork(); _bootParameter = BootParameters; _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(_bootParameter) as ExportLoadJobDetailBEO; _dataset = DataSetBO.GetDatasetDetailsWithMatterInfo(Convert.ToInt64(_exportLoadJobDetailBeo.DatasetId), _exportLoadJobDetailBeo.MatterId); }
public ExportLoadFileHelper(string bootParameter) { _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(bootParameter) as ExportLoadJobDetailBEO; }
private void InitializeForProcessing(string exportBootParameter) { parametersExportLoadFile = GetExportBEO <ExportLoadJobDetailBEO>(exportBootParameter); if (parametersExportLoadFile.ExportLoadFileInfo != null) { columnDelimiter = Convert.ToChar(Convert.ToInt32(parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Column)); quoteCharacter = Convert.ToChar(Convert.ToInt32(parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Quote)); contentNewLine = Convert.ToChar(Convert.ToInt32(parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.NewLine)); newLine = Constants.ConcordanceRecordSplitter; if (parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat != null) { dateFormatForData = (!string.IsNullOrEmpty(parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.DateFormat)) ? parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.DateFormat : string.Empty; } encoding = (parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.EncodingType == EncodingTypeSelection.Ansi) ? Encoding.GetEncoding(Constants.Ansi) : Encoding.Unicode; if (parametersExportLoadFile.ExportLoadFileInfo.ExportLoadNativeFileLocation != null) { isRelativePath = parametersExportLoadFile.ExportLoadFileInfo.ExportLoadNativeFileLocation.RelativePathLocation; } if (!string.IsNullOrEmpty(parametersExportLoadFile.CreatedBy)) { createdBy = parametersExportLoadFile.CreatedBy; } } if (exportDocumentCollection.ExportOption != null) { loadFileName = exportDocumentCollection.ExportOption.LoadFilePath; imageHelperFileName = (!string.IsNullOrEmpty(exportDocumentCollection.ExportOption.LoadFileImageHelperFilePath)) ? exportDocumentCollection.ExportOption.LoadFileImageHelperFilePath : string.Empty; textHelperFileName = (!string.IsNullOrEmpty(exportDocumentCollection.ExportOption.LoadFileTextHelperFilePath)) ? exportDocumentCollection.ExportOption.LoadFileTextHelperFilePath : string.Empty; exportFolderPath = exportDocumentCollection.ExportOption.ExportDestinationFolderPath; } if (parametersExportLoadFile.ExportLoadFields != null) { exportFieldsSelection = parametersExportLoadFile.ExportLoadFields; } if (parametersExportLoadFile.ExportLoadTagInfo != null && !string.IsNullOrEmpty(parametersExportLoadFile.ExportLoadTagInfo.Delimeter)) { tagSeparator = Convert.ToChar(Convert.ToInt32(parametersExportLoadFile.ExportLoadTagInfo.Delimeter)); } if (!string.IsNullOrEmpty(PipelineId) && WorkAssignment != null) { jobID = WorkAssignment.JobId; } #region Initialize File writer //Initialize File writer for First time loadFileIoWriter = new StreamWriter(loadFileName, true, encoding); if (exportDocumentCollection.ExportOption.IsText && parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.Nameselection == TextFileNameSelection.UseOPT) { textFileIoWriter = new StreamWriter(textHelperFileName, true); } if (exportDocumentCollection.ExportOption.IsImage || exportDocumentCollection.ExportOption.IsProduction) { imageFileIoWriter = new StreamWriter(imageHelperFileName, true); } #endregion #region Initialize Sort Order collection loadFileSortOrderCollection = new SortedDictionary <string, string>(); if (exportDocumentCollection.ExportOption.IsText) { textFileSortOrderCollection = new SortedDictionary <string, string>(); } if (exportDocumentCollection.ExportOption.IsImage || exportDocumentCollection.ExportOption.IsProduction) { imageFileSortOrderCollection = new SortedDictionary <string, string>(); } #endregion foreach (var exportField in exportFieldsSelection) { if (String.Equals(exportField.DataSetFieldName, "CONTENT", StringComparison.CurrentCultureIgnoreCase)) { continue; } var textFieldId = DocumentBO.GetFieldIdByNameForExportJob(_dataset, exportField.DataSetFieldName, false); _selectedFieldIds.Add(textFieldId); } }
public ExportLoadFileHelper(string bootParameter) { _exportLoadJobDetailBeo = Utils.SmartXmlDeserializer(bootParameter) as ExportLoadJobDetailBEO; }
private void Initialize(string bootParameter) { _parametersExportLoadFile = GetExportBEO <ExportLoadJobDetailBEO>(bootParameter); #region Assertion _parametersExportLoadFile.ShouldNotBe(null); _parametersExportLoadFile.ExportLoadFileInfo.FilePath.ShouldNotBeEmpty(); #endregion Directory.CreateDirectory(_parametersExportLoadFile.ExportLoadFileInfo.FilePath); if (!Utils.CanWriteToFolder(_parametersExportLoadFile.ExportLoadFileInfo.FilePath)) { Tracer.Error("ExportOption Startup Worker: Invalid export path for job run id:{0}", PipelineId); LogMessage(false, Constants.ExportPathInvalid); throw new EVException().AddUsrMsg(Constants.ExportPathInvalid); } if (_parametersExportLoadFile != null && _parametersExportLoadFile.ExportLoadFileInfo != null) { #region Get Dataset Details if (!string.IsNullOrEmpty(_parametersExportLoadFile.DatasetId) && !string.IsNullOrEmpty(_parametersExportLoadFile.MatterId)) { _dataset = DataSetBO.GetDatasetDetailsWithMatterInfo(Convert.ToInt64(_parametersExportLoadFile.DatasetId), _parametersExportLoadFile.MatterId); #region Assertion _dataset.ShouldNotBe(null); #endregion if (_dataset == null) { Tracer.Error("ExportOption Startup Worker: Cannot get dataset details for job run id: {0}", PipelineId); // TODO: Throw appropriate exception after analysis. } } #endregion #region Setup ExportOption Options _exportOption = new ExportOption { IsNative = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption != null && _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.IncludeNativeFile, IncludeNativeTagName = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption != null ? _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.TagToIncludeNative : string.Empty, IsText = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption != null && _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.IncludeTextFile, IsField = _parametersExportLoadFile.ExportLoadFields != null && _parametersExportLoadFile.ExportLoadFields.Count > 0, IsTag = _parametersExportLoadFile.ExportLoadTagInfo != null && _parametersExportLoadFile.ExportLoadTagInfo.IncludeTag, ExportDestinationFolderPath = _parametersExportLoadFile.ExportLoadFileInfo.FilePath != null ? _parametersExportLoadFile.ExportLoadFileInfo.FilePath.Replace(@"/", @"\") .TrimEnd(new[] { '\\' }) : string.Empty, TextOption1 = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.TextOption1, TextOption2 = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.TextOption2, FieldForNativeFileName = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.FieldForNativeFileName, FieldForTextFileName = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.Nameselection == TextFileNameSelection.UseOPT && !string.IsNullOrEmpty( _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.ImageFileName) ? _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.ImageFileName : _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.FieldForTextFileName, IsTextFieldToExportSelected = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.IsTextFieldToExportSelected, TextFieldToExport = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.TextFieldToExport }; switch (_parametersExportLoadFile.ExportLoadFileInfo.PriImgSelection) { case SetSelection.ProductionSet: _exportOption.IsProduction = true; _exportOption.ProductionSetCollectionId = _parametersExportLoadFile.ExportLoadFileInfo.ProdImgCollectionId; break; case SetSelection.ImageSet: _exportOption.IsImage = true; _exportOption.ImageSetCollectionId = _parametersExportLoadFile.ExportLoadFileInfo.ProdImgCollectionId; break; } if (_parametersExportLoadFile.ExportLoadTagInfo != null && _parametersExportLoadFile.ExportLoadTagInfo.IncludeTag) { _exportOption.TagList = _parametersExportLoadFile.ExportLoadTagInfo.TagList; } #endregion #region Get delimiters var columnDelimiter = Convert.ToChar( Convert.ToInt32(_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Column)); var quoteCharacter = Convert.ToChar( Convert.ToInt32(_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Quote)); if (string.IsNullOrEmpty(_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Column) || string.IsNullOrEmpty(_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.Quote) || string.IsNullOrEmpty(_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.NewLine) || (_exportOption.IsTag && string.IsNullOrEmpty(_parametersExportLoadFile.ExportLoadTagInfo.Delimeter))) { Tracer.Info( "ExportOption Startup Worker: One or more delimiters are null or empty for job run id:{0}", PipelineId); } #endregion #region Create files _loadFileFullyQualifiedName = _parametersExportLoadFile.ExportLoadFileInfo.FilePath + @"\" + _parametersExportLoadFile.ExportLoadFileInfo.FileName + "." + _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat. FileExtension; var encoding = _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileFormat.EncodingType == EncodingTypeSelection.Ansi ? Encoding.GetEncoding(Constants.Ansi) : Encoding.Unicode; try { Tracer.Info("Export Load File path = {0}", _loadFileFullyQualifiedName); CreateLoadFileWithHeader(_loadFileFullyQualifiedName, columnDelimiter, quoteCharacter, encoding); } catch (Exception) { LogMessage(false, Constants.FailureInCreateLoadFile); throw; } _exportOption.LoadFilePath = _loadFileFullyQualifiedName; if (_parametersExportLoadFile.ExportLoadFileInfo.PriImgSelection == SetSelection.ProductionSet || _parametersExportLoadFile.ExportLoadFileInfo.PriImgSelection == SetSelection.ImageSet) { _imageHelperFileName = _parametersExportLoadFile.ExportLoadFileInfo.FilePath + Constants.BackSlash + _parametersExportLoadFile.ExportLoadFileInfo.FileName + Constants.OptFileExtension; _exportOption.LoadFileImageHelperFilePath = _imageHelperFileName; } if (_parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.IncludeTextFile && _parametersExportLoadFile.ExportLoadFileInfo.ExportLoadFileOption.Nameselection == TextFileNameSelection.UseOPT) { _contentHelperFileName = _parametersExportLoadFile.ExportLoadFileInfo.FilePath + Constants.TextHelperFileName; _exportOption.LoadFileTextHelperFilePath = _contentHelperFileName; } #endregion #region Assertion _parametersExportLoadFile.CreatedBy.ShouldNotBeEmpty(); #endregion #region Set User if (!string.IsNullOrEmpty(_parametersExportLoadFile.CreatedBy)) { _createdBy = _parametersExportLoadFile.CreatedBy; } else { Tracer.Error( "ExportOption Startup Worker: Job created by user id not specified in boot parameters for job run id:{0}", PipelineId); //TODO: throw appropriate exception after analysis. } MockSession(); #endregion BuildSearchQueryForExportLoadFile(); } }