コード例 #1
0
         /// <summary>
         /// Set Image source files
         /// </summary>
        public void SetImageSourceFiles(ExportDocumentDetail documentDetail, ExportOption exportOption)
        {
            if (!exportOption.IsImage && !exportOption.IsProduction) return;

            var imageCollectionId = exportOption.IsImage
                ? exportOption.ImageSetCollectionId
                : exportOption.ProductionSetCollectionId;

            var documentFiles = DocumentBO.GetImagesForExportLoadFile(documentDetail.DocumentId,
                exportOption.IsImage,
                exportOption.IsProduction,
                imageCollectionId, Convert.ToInt32(_exportLoadJobDetailBeo.MatterId));

            if ((documentDetail.ImageFiles!=null && documentDetail.ImageFiles.Any()) && documentFiles.Any())
            {
                var sourceFiles = documentFiles.OrderBy(p => p.Path).ToList();
                var pathIndex = 0;
                foreach (var image in documentDetail.ImageFiles)
                {
                    if (pathIndex > sourceFiles.Count) break;
                    image.SourceFilePath =  sourceFiles[pathIndex].Path;
                    image.DestinationFolder = string.Format("{0}{1}", documentDetail.ExportBasePath, image.DestinationFolder);
                    pathIndex++;
                }
            }
            else
            {
                var lstImgFiles = new List<ExportFileInformation>();
                if (documentFiles != null)
                {
                    lstImgFiles.AddRange(ConvertToExportFileInformation(documentFiles));
                }
                documentDetail.ImageFiles = lstImgFiles;
            }
        }
コード例 #2
0
        /// <summary>
        /// Set Image source files
        /// </summary>
        public void SetImageSourceFiles(ExportDocumentDetail documentDetail, ExportOption exportOption)
        {
            if (!exportOption.IsImage && !exportOption.IsProduction)
            {
                return;
            }

            var imageCollectionId = exportOption.IsImage
                ? exportOption.ImageSetCollectionId
                : exportOption.ProductionSetCollectionId;

            var documentFiles = DocumentBO.GetImagesForExportLoadFile(documentDetail.DocumentId,
                                                                      exportOption.IsImage,
                                                                      exportOption.IsProduction,
                                                                      imageCollectionId, Convert.ToInt32(_exportLoadJobDetailBeo.MatterId));

            if ((documentDetail.ImageFiles != null && documentDetail.ImageFiles.Any()) && documentFiles.Any())
            {
                var sourceFiles = documentFiles.OrderBy(p => p.Path).ToList();
                var pathIndex   = 0;
                foreach (var image in documentDetail.ImageFiles)
                {
                    if (pathIndex > sourceFiles.Count)
                    {
                        break;
                    }
                    image.SourceFilePath    = sourceFiles[pathIndex].Path;
                    image.DestinationFolder = string.Format("{0}{1}", documentDetail.ExportBasePath, image.DestinationFolder);
                    pathIndex++;
                }
            }
            else
            {
                var lstImgFiles = new List <ExportFileInformation>();
                if (documentFiles != null)
                {
                    lstImgFiles.AddRange(ConvertToExportFileInformation(documentFiles));
                }
                documentDetail.ImageFiles = lstImgFiles;
            }
        }
コード例 #3
0
        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();
            }
        }