Example #1
0
 /// <summary>
 /// Re name produced image(s) based on Bates Number
 /// </summary>
 private void RenameImagesBasedOnBatesNumber(ProductionDocumentDetail productionDocumentDetail)
 {
     try
     {
         if (!productionDocumentDetail.Profile.IsOneImagePerPage ||
             String.IsNullOrEmpty(productionDocumentDetail.StartingBatesNumber))
         {
             return;
         }
         if (string.IsNullOrEmpty(productionDocumentDetail.Profile.ProductionPrefix) ||
             string.IsNullOrEmpty(productionDocumentDetail.Profile.ProductionStartingNumber))
         {
             return;
         }
         var productionConversionHelper = new ProductionConversionHelper();
         var producedImages             =
             productionConversionHelper.RenameProducedImages(productionDocumentDetail);
         if (!producedImages.Any())
         {
             return;
         }
         productionConversionHelper.UpdateProducedImageFilePath(
             productionDocumentDetail.DocumentId, productionDocumentDetail.ProductionCollectionId,
             _matterId, producedImages, productionDocumentDetail.CreatedBy);
     }
     catch (Exception exception)
     {
         //Log the error message for failed documents
         var message = ConErrorOnRenameImage + productionDocumentDetail.DCNNumber;
         LogMessage(productionDocumentDetail, false, message, false);
         //continue the production process with out rename images
         exception.Trace().Swallow();
     }
 }
Example #2
0
        private void LogMessage(ProductionDocumentDetail documentDetail, bool success, string message, bool isMessage)
        {
            const string roleId    = "prod0fc6-113e-4217-9863-ec58c3f7yz89";
            var          log       = new List <JobWorkerLog <ProductionParserLogInfo> >();
            var          parserLog = new JobWorkerLog <ProductionParserLogInfo>
            {
                JobRunId =
                    (!String.IsNullOrEmpty(PipelineId)) ? Convert.ToUInt32(PipelineId) : 0,
                CorrelationId    = documentDetail.CorrelationId,
                WorkerRoleType   = roleId,
                WorkerInstanceId = WorkerId,
                IsMessage        = isMessage,
                Success          = success,
                CreatedBy        = documentDetail.CreatedBy,
                LogInfo          =
                    new ProductionParserLogInfo
                {
                    Information = message,
                    BatesNumber = documentDetail.AllBates,
                    DatasetName = documentDetail.OriginalDatasetName,
                    DCN         = documentDetail.DCNNumber,
                    ProductionDocumentNumber = documentDetail.DocumentProductionNumber,
                    ProductionName           = documentDetail.Profile.ProfileName
                }
            };

            log.Add(parserLog);
            SendLog(log);
        }
Example #3
0
        /// <summary>
        /// Constructs the audit log.
        /// </summary>
        /// <param name="productionDocumentDetail">The production document detail.</param>
        /// <returns>DocumentIdentifierEntityBEO</returns>
        private DocumentIdentifierEntityBEO ConstructAuditLog(ProductionDocumentDetail productionDocumentDetail)
        {
            if (collectionId == 0)
            {
                datasetCollectionGuid.ShouldNotBeEmpty();
                collectionId = m_DatasetVaultManager.GetCollectionId(_matterId, new Guid(datasetCollectionGuid));
            }

            var documentIdentifierEntityBeo = new DocumentIdentifierEntityBEO();

            if (!string.IsNullOrEmpty(productionDocumentDetail.OriginalCollectionId))
            {
                documentIdentifierEntityBeo.CollectionId = productionDocumentDetail.OriginalCollectionId;
            }
            if (!string.IsNullOrEmpty(productionDocumentDetail.DCNNumber))
            {
                documentIdentifierEntityBeo.Dcn = productionDocumentDetail.DCNNumber;
            }
            if (!string.IsNullOrEmpty(productionDocumentDetail.OriginalDatasetName))
            {
                documentIdentifierEntityBeo.CollectionName = productionDocumentDetail.OriginalDatasetName;
            }

            documentIdentifierEntityBeo.ParentId            = collectionId;
            documentIdentifierEntityBeo.DocumentReferenceId =
                productionDocumentDetail.OriginalDocumentReferenceId;
            return(documentIdentifierEntityBeo);
        }
        public static ProductionDocumentDetail ConstructProductionModelDocument(ProductionDetailsBEO m_BootParameters)
        {
            var m_ProductionDocumentDetail = new ProductionDocumentDetail();

            m_ProductionDocumentDetail.MatterId  = m_BootParameters.MatterId.ToString(CultureInfo.InvariantCulture);
            m_ProductionDocumentDetail.CreatedBy = m_BootParameters.CreatedBy;
            m_ProductionDocumentDetail.DocumentSelectionContext = m_BootParameters.DocumentSelectionContext;
            m_ProductionDocumentDetail.DocumentExclusionContext = m_BootParameters.DocumentExclusionContext;
            m_ProductionDocumentDetail.ProductionCollectionId   = m_BootParameters.CollectionId;
            m_ProductionDocumentDetail.Profile           = ConvertToProfileDataObjects(m_BootParameters);
            m_ProductionDocumentDetail.Profile.DatasetId = Convert.ToInt64(null); //TODO: check why we have this
            GetMatterDatasetDetails(m_ProductionDocumentDetail, m_BootParameters);
            m_ProductionDocumentDetail.GetText = m_BootParameters.Profile.GetScrubbedText;
            var productionExtractionPath = Path.Combine(m_BootParameters.Profile.ProductionSetLocation,
                                                        m_BootParameters.Profile.ProductionSetName);

            if (!Directory.Exists(productionExtractionPath))
            {
                Directory.CreateDirectory(productionExtractionPath);
            }

            m_ProductionDocumentDetail.ExtractionLocation           = productionExtractionPath;
            m_ProductionDocumentDetail.ArchivePath                  = m_BootParameters.Profile.ProductionSetLocation;
            m_ProductionDocumentDetail.NearNativeConversionPriority = m_BootParameters.NearNativeConversionPriority;

            return(m_ProductionDocumentDetail);
        }
        private static void GetMatterDatasetDetails(ProductionDocumentDetail m_ProductionDocumentDetail, ProductionDetailsBEO m_BootParameters)
        {
            DatasetBEO dataset =
                DataSetBO.GetDataSetDetailForCollectionId(m_BootParameters.OriginalCollectionId);

            m_ProductionDocumentDetail.OriginalCollectionId = dataset.RedactableDocumentSetId;
            //Assign redactable set id as default collection id
            m_ProductionDocumentDetail.DatasetCollectionId = m_BootParameters.OriginalCollectionId;
            //Native set collection id
            m_ProductionDocumentDetail.OriginalDatasetName = dataset.FolderName;
            m_ProductionDocumentDetail.OriginalDatasetId   = (int)dataset.FolderID;

            m_ProductionDocumentDetail.lstProductionFields =
                DataSetBO.GetDataSetFields(Convert.ToInt64(m_ProductionDocumentDetail.OriginalDatasetId),
                                           m_ProductionDocumentDetail.ProductionCollectionId);
            m_ProductionDocumentDetail.dataSetBeo =
                DataSetBO.GetDataSetDetailForDataSetId(Convert.ToInt64(m_ProductionDocumentDetail.OriginalDatasetId));
            m_ProductionDocumentDetail.lstDsFieldsBeo =
                DataSetBO.GetDataSetFields(Convert.ToInt64(m_ProductionDocumentDetail.OriginalDatasetId),
                                           m_ProductionDocumentDetail.DatasetCollectionId);
            m_ProductionDocumentDetail.matterBeo =
                MatterBO.GetMatterDetails(m_ProductionDocumentDetail.dataSetBeo.ParentID.ToString(CultureInfo.InvariantCulture));
            m_ProductionDocumentDetail.SearchServerDetails =
                ServerBO.GetSearchServer(m_ProductionDocumentDetail.matterBeo.SearchServer.Id);
        }
Example #6
0
 /// <summary>
 /// Converts the production document details.
 /// </summary>
 /// <param name="productionDocumentDetail">The production document detail.</param>
 /// <returns></returns>
 private DocumentConversionLogBeo ConvertProductionDocumentDetails(ProductionDocumentDetail productionDocumentDetail)
 {
     return(new DocumentConversionLogBeo()
     {
         CollectionId = productionDocumentDetail.OriginalCollectionId,
         DocumentId = productionDocumentDetail.DocumentId,
         JobRunId = BootObject.OrginialJobId,
         ProcessJobId = WorkAssignment.JobId,
         Status = EVRedactItErrorCodes.Submitted,
         ReasonId = EVRedactItErrorCodes.Na,
         LastModifiedDate = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)
     });
 }
Example #7
0
        /// <summary>
        /// Converts the specified production document detail.
        /// </summary>
        /// <param name="productionDocumentDetail">The production document detail.</param>
        /// <param name="processStatus">The process status.</param>
        /// <param name="errorReason">The error reason.</param>
        /// <param name="errorDetails">The error details.</param>
        /// <returns></returns>
        private DocumentConversionLogBeo ConvertToDocumentConversionLogBeo(ProductionDocumentDetail productionDocumentDetail, byte processStatus, string errorReason = null, string errorDetails = null)
        {
            var documentConversionLogBeo = new DocumentConversionLogBeo
            {
                JobRunId     = WorkAssignment.JobId,
                ProcessJobId = WorkAssignment.JobId,
                Status       = processStatus,
                ErrorReason  = errorReason,
                CollectionId = productionDocumentDetail.OriginalCollectionId,
                DocumentId   = productionDocumentDetail.DocumentId,
                ModifiedDate = DateTime.UtcNow,
                ErrorDetails = errorDetails
            };

            return(documentConversionLogBeo);
        }
Example #8
0
        /// <summary>
        /// Sends the specified document batch to next worker in the pipeline.
        /// </summary>
        /// <param name="docCollection">The document batch.</param>
        public static List <ProductionDocumentDetail> ConvertToProductionDocumentList(
            ConversionDocCollection docCollection)
        {
            List <ProductionDocumentDetail> docList = null;
            var baseConfig = docCollection.BaseJobConfig as ProductionDetailsBEO;

            if (docCollection != null && docCollection.Documents != null && docCollection.Documents.Any())
            {
                var modelDoc = ProductionStartupHelper.ConstructProductionModelDocument(baseConfig);

                docList = new List <ProductionDocumentDetail>();

                int docNumber = 0;

                foreach (var doc in docCollection.Documents)
                {
                    ProductionDocumentDetail newDoc =
                        ConvertToProductionDocumentDetail((ReconversionProductionDocumentBEO)doc, modelDoc);
                    //To set Bates running number for selected reprocess document
                    int batesRunningNumber = 0;
                    if (!string.IsNullOrEmpty(newDoc.StartingBatesNumber))
                    {
                        batesRunningNumber = Convert.ToInt32(newDoc.StartingBatesNumber.Replace(newDoc.Profile.ProductionPrefix, ""));
                    }
                    newDoc.StartBatesRunningNumber = (batesRunningNumber > 0)
                                                         ? (batesRunningNumber -
                                                            Convert.ToInt32(newDoc.Profile.ProductionStartingNumber))
                                                         : batesRunningNumber;

                    //use doc number in the sequence for correctationId, will be used as part of key in inserting to EV_JOB_ProductionTaskFlags table
                    newDoc.CorrelationId = ++docNumber;

                    //create the folder if it doesnot exists
                    if (!string.IsNullOrEmpty(newDoc.ExtractionLocation) && !Directory.Exists(newDoc.ExtractionLocation))
                    {
                        Directory.CreateDirectory(newDoc.ExtractionLocation);
                    }

                    //add the new doc to list
                    docList.Add(newDoc);
                }
            }

            return(docList);
        }
Example #9
0
        /// <summary>
        /// Helper method to construct the fields to update in search index
        /// </summary>
        /// <param name="document"></param>
        /// <param name="productionFields"></param>
        /// <param name="indexFields"></param>
        private void ConstructIndexFields(ProductionDocumentDetail document, List <DocumentFieldsBEO> productionFields,
                                          ref Dictionary <string, List <KeyValuePair <string, string> > > indexFields)
        {
            //determine the indexName for bate fields
            var indexBateFieldNames =
                document.lstDsFieldsBeo.Where(f => f.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesNumber) ||
                                              f.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesBegin) ||
                                              f.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesEnd) ||
                                              f.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesRange) ||
                                              f.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.DPN)).Select(
                    f => f.Name).ToList();

            var docFields = new List <KeyValuePair <string, string> >();

            //loop through all the bates & dpn fields in dataset
            foreach (var bateField in indexBateFieldNames)
            {
                var lstFields = document.Fields.FirstOrDefault(f => f.Key == bateField);
                var field     = productionFields.FirstOrDefault(f => f.FieldName == bateField);
                if (lstFields.Key != null)
                {
                    //determine if there is change in value
                    if (field != null && lstFields.Value != field.FieldValue)
                    {
                        docFields.Add(new KeyValuePair <string, string>(bateField,
                                                                        string.Format("{0},{1}", lstFields.Value,
                                                                                      field.FieldValue)));
                    }
                    else
                    {
                        docFields.Add(new KeyValuePair <string, string>(bateField, lstFields.Value));
                    }
                }
                else
                {
                    if (field != null)
                    {
                        docFields.Add(new KeyValuePair <string, string>(bateField, field.FieldValue));
                    }
                }
            }
            indexFields.Add(document.DocumentId, docFields);
        }
        /// <summary>
        /// Converts to document conversion log beo.
        /// </summary>
        /// <param name="productionDocumentDetail">The production document detail.</param>
        /// <param name="status">The status.</param>
        /// <param name="reasonId">The reason id.</param>
        /// <returns></returns>
        private DocumentConversionLogBeo ConvertToDocumentConversionLogBeo(ProductionDocumentDetail productionDocumentDetail, byte status, short reasonId)
        {
            if (productionDocumentDetail == null || WorkAssignment == null)
            {
                return(null);
            }
            var documentConversionLogBeo = new DocumentConversionLogBeo
            {
                DocumentId   = productionDocumentDetail.DocumentId,
                CollectionId = productionDocumentDetail.OriginalCollectionId,
                DCN          = productionDocumentDetail.DCNNumber,
                ProcessJobId = WorkAssignment.JobId,
                JobRunId     = WorkAssignment.JobId,
                Status       = status,
                ReasonId     = reasonId,
                ModifiedDate = DateTime.UtcNow
            };

            return(documentConversionLogBeo);
        }
Example #11
0
        protected override void ProcessMessage(PipeMessageEnvelope envelope)
        {
            try
            {
                var documentIdentifierEntityBeos =
                    new List <DocumentIdentifierEntityBEO>();
                var productionDocuments = envelope.Body as List <ProductionDocumentDetail>;
                if (productionDocuments == null || productionDocuments.Count == 0)
                {
                    return;
                }
                ProductionDocumentDetail productionDocument = productionDocuments.First();
                if (productionDocument == null)
                {
                    return;
                }
                productionDocument.MatterId.ShouldNotBeEmpty();
                long.TryParse(productionDocument.MatterId, out _matterId);
                _matterId.ShouldBeGreaterThan(0);

                productionDocument.dataSetBeo.ShouldNotBe(null);
                productionDocument.dataSetBeo.CollectionId.ShouldNotBeEmpty();
                datasetCollectionGuid = productionDocument.dataSetBeo.CollectionId;


                var ready    = new List <ProductionDocumentDetail>();
                var notReady = new List <ProductionDocumentDetail>();
                var documentConversionLogBeos = new List <DocumentConversionLogBeo>();

                foreach (var productionDocumentDetail in productionDocuments)
                {
                    var documentStatus =
                        RedactItHeartbeatWatcher.CheckDocumentState(productionDocumentDetail.HeartBeatFile, 2);

                    switch (documentStatus.DocumentState)
                    {
                    case RedactItHeartbeatWatcher.DocumentStateEnum.NotFound:

                        if (!productionDocumentDetail.ConversionEnqueueTime.HasValue)
                        {
                            productionDocumentDetail.ConversionEnqueueTime = DateTime.UtcNow;
                        }
                        //the document conversion global timeout is the maximum waiting  time for  a document to be  converted
                        //Below are the possible reasons for this kind of timeout
                        //1)heart beat file is not generated for this documents
                        //2)document is waiting in queue then the expected global or waiting timeout configured in the CCMS
                        if (DateTime.UtcNow - productionDocumentDetail.ConversionEnqueueTime >
                            documentConverisonGlobalTimeout)
                        {
                            documentStatus.DocumentState = RedactItHeartbeatWatcher.DocumentStateEnum.Failure;
                            documentStatus.ErrorReason   = "RedactIt heartbeat file creation timeout warning";

                            Tracer.Trace(
                                "Global Conversion Timeout For Document with document id - {0} ,dcn {1},collection id - {2} , matter id - {3} , HeartBeatFile {4} and Timeout Value {5}",
                                productionDocumentDetail.DocumentId, productionDocumentDetail.DCNNumber,
                                productionDocumentDetail.OriginalCollectionId, _matterId,
                                productionDocumentDetail.HeartBeatFile, documentConverisonGlobalTimeout);
                            goto case RedactItHeartbeatWatcher.DocumentStateEnum.Failure;
                        }
                        notReady.Add(productionDocumentDetail);
                        break;

                    case RedactItHeartbeatWatcher.DocumentStateEnum.NotReady:
                        if (!productionDocumentDetail.ConversionStartTime.HasValue)
                        {
                            productionDocumentDetail.ConversionStartTime = DateTime.UtcNow;
                        }
                        if (DateTime.UtcNow - productionDocumentDetail.ConversionStartTime >
                            documentConversionTimeout)
                        {
                            documentStatus.DocumentState = RedactItHeartbeatWatcher.DocumentStateEnum.Failure;
                            documentStatus.ErrorMessage  = documentStatus.ErrorReason = "Document conversion validation timeout warning";
                            Tracer.Trace(
                                " Conversion Timeout For Document with document id - {0} ,dcn {1},collection id - {2} , matter id - {3} , HeartBeatFile {4} and Timeout Value {5}",
                                productionDocumentDetail.DocumentId, productionDocumentDetail.DCNNumber,
                                productionDocumentDetail.OriginalCollectionId, _matterId,
                                productionDocumentDetail.HeartBeatFile, documentConversionTimeout);
                            goto case RedactItHeartbeatWatcher.DocumentStateEnum.Failure;
                        }
                        notReady.Add(productionDocumentDetail);
                        break;

                    case RedactItHeartbeatWatcher.DocumentStateEnum.Success:
                        ready.Add(productionDocumentDetail);
                        SafeDeleteFolder(productionDocumentDetail.SourceDestinationPath);
                        SafeDeleteFile(productionDocumentDetail.HeartBeatFile);
                        documentConversionLogBeos.Add(ConvertToDocumentConversionLogBeo(productionDocumentDetail,
                                                                                        EVRedactItErrorCodes.
                                                                                        Completed));
                        var documentIdentifierEntity = ConstructAuditLog(productionDocumentDetail);
                        documentIdentifierEntityBeos.Add(documentIdentifierEntity);
                        RenameImagesBasedOnBatesNumber(productionDocumentDetail);
                        //Delete all the source file for the document
                        // Heart beat file and source file are deleted by callback in Production Notify service
                        break;

                    case RedactItHeartbeatWatcher.DocumentStateEnum.Failure:
                        SafeDeleteFolder(productionDocumentDetail.SourceDestinationPath);
                        //Delete all the source file for the document
                        string message = "Redact-It reported error converting document DCN: " +
                                         productionDocumentDetail.DCNNumber + ". Heartbeat error: " +
                                         documentStatus.ErrorMessage + ". Refer heartbeat file " +
                                         productionDocumentDetail.HeartBeatFile + " for more info.";
                        if (string.IsNullOrEmpty(documentStatus.ErrorReason))
                        {
                            documentStatus.ErrorReason = EVRedactItErrorCodes.UnKnownConversionFailure;
                        }
                        documentConversionLogBeos.Add(ConvertToDocumentConversionLogBeo(productionDocumentDetail,
                                                                                        EVRedactItErrorCodes.Failed,
                                                                                        documentStatus.ErrorReason,
                                                                                        documentStatus.ErrorMessage));

                        if (message.ToLower().Contains(TimeoutError))
                        {
                            LogMessage(productionDocumentDetail, true, message, true);
                        }
                        else
                        {
                            LogMessage(productionDocumentDetail, false, message, false);
                        }
                        RenameImagesBasedOnBatesNumber(productionDocumentDetail);
                        //Handle partially converted documents
                        IncreaseProcessedDocumentsCount(1);     // Failed document counted as processed
                        break;
                    }
                }

                if (notReady.Any())
                {
                    InputDataPipe.Send(new PipeMessageEnvelope()
                    {
                        Body = notReady, IsPostback = true
                    });
                }

                BulkUpdateProcessSetStatus(documentConversionLogBeos);
                if (m_BootParameters != null &&
                    m_BootParameters.Profile != null &&
                    !string.IsNullOrEmpty(m_BootParameters.Profile.ProductionSetName) &&
                    documentIdentifierEntityBeos.Count > 0)
                {
                    DoAuditLog(documentIdentifierEntityBeos, m_BootParameters.Profile.ProductionSetName);
                }
                IncreaseProcessedDocumentsCount(ready.Count);
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
                ReportToDirector(ex);
            }
        }
Example #12
0
        /// <summary>
        /// Convert the document to the ProductionDocumentDetail that can be used by ProductionNearNativeConversionHelper class
        /// </summary>
        /// <param name="document">The document</param>
        /// <param name="modelDoc">The model document</param>
        private static ProductionDocumentDetail ConvertToProductionDocumentDetail(
            ReconversionProductionDocumentBEO document, ProductionDocumentDetail modelDoc)
        {
            var pDoc = new ProductionDocumentDetail
            {
                MatterId  = modelDoc.MatterId,
                CreatedBy = modelDoc.CreatedBy,
                DocumentSelectionContext = modelDoc.DocumentSelectionContext,
                DatasetCollectionId      = modelDoc.DatasetCollectionId,
                OriginalCollectionId     = modelDoc.OriginalCollectionId,
                DocumentExclusionContext = modelDoc.DocumentExclusionContext,
                ProductionCollectionId   = modelDoc.ProductionCollectionId,
                Profile             = modelDoc.Profile,
                ArchivePath         = modelDoc.ArchivePath,
                OriginalDatasetId   = modelDoc.OriginalDatasetId,
                OriginalDatasetName = modelDoc.OriginalDatasetName,
                GetText             = modelDoc.GetText,
                lstProductionFields = modelDoc.lstProductionFields,
                dataSetBeo          = modelDoc.dataSetBeo,
                lstDsFieldsBeo      = modelDoc.lstDsFieldsBeo,
                matterBeo           = modelDoc.matterBeo,
                SearchServerDetails = modelDoc.SearchServerDetails
            };

            //same info for all docs
            //pDoc.ManageShareRootPath = modelDoc.ManageShareRootPath;
            pDoc.GetText = modelDoc.GetText;

            //pupulate from document



            pDoc.DocumentId = document.DocumentId;
            pDoc.OriginalDocumentReferenceId = document.DocumentId;
            pDoc.DCNNumber = document.DCNNumber;

            //populdate bates
            pDoc.StartingBatesNumber = document.StartingBatesNumber;
            pDoc.EndingBatesNumber   = document.EndingBatesNumber;

            //comma seperated list of bates numbers
            pDoc.AllBates = document.AllBates;

            //get the number of pages by counting all bates
            if (document.AllBates != null)
            {
                pDoc.NumberOfPages = (document.AllBates.Split(new char[] { ',' })).Length;
            }

            //popudate DPN
            pDoc.DocumentProductionNumber = document.DocumentProductionNumber;

            //set NearNativeConversionPriority
            pDoc.NearNativeConversionPriority = document.NearNativeConversionPriority;
            //get the directory for the production location; ProductionPath contain the full path, including the file name
            if (String.IsNullOrEmpty(document.ProductionPath))
            {
                return(pDoc);
            }
            pDoc.ExtractionLocation = Path.GetDirectoryName(document.ProductionPath);
            return(pDoc);
        }
        /// <summary>
        /// Rename Produced documents based on Bates Field Value
        /// </summary>
        /// <param name="productionDocumentDetail"></param>
        public List <string> RenameProducedImages(ProductionDocumentDetail productionDocumentDetail)
        {
            var producedImages = new List <string>();

            if (String.IsNullOrEmpty(productionDocumentDetail.ExtractionLocation))
            {
                return(null);
            }
            var files =
                new DirectoryInfo(productionDocumentDetail.ExtractionLocation).
                GetFiles(productionDocumentDetail.StartingBatesNumber + ConPagingNameFormat + "*");

            foreach (var file in files)
            {
                if (file.DirectoryName == null)
                {
                    continue;
                }
                if (String.IsNullOrEmpty(file.Name))
                {
                    continue;
                }
                var fileExtenstion           = Path.GetExtension(file.Name);
                var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.Name);
                if (fileNameWithoutExtension == null)
                {
                    continue;
                }
                var strPageNumber = fileNameWithoutExtension.Replace(
                    productionDocumentDetail.
                    StartingBatesNumber, "").Replace(
                    ConPagingNameFormat, "");
                long pageNumebr;

                if (!long.TryParse(strPageNumber, out pageNumebr))
                {
                    continue;
                }

                long batesBeginNumber;

                var strBatesBeginNumber = productionDocumentDetail.
                                          StartingBatesNumber.Replace(
                    productionDocumentDetail.Profile.ProductionPrefix, "");
                if (!long.TryParse(strBatesBeginNumber,
                                   out batesBeginNumber))
                {
                    continue;
                }
                var batesRunningNumber = batesBeginNumber + pageNumebr;
                var fileName           = productionDocumentDetail.Profile.ProductionPrefix +
                                         batesRunningNumber.ToString("D" +
                                                                     productionDocumentDetail.Profile.ProductionStartingNumber.
                                                                     Length) +
                                         fileExtenstion;
                var imageFilePath = Path.Combine(file.DirectoryName,
                                                 fileName);
                if (File.Exists(imageFilePath)) // If same document was reprocessed again using ‘Reprocess Job’, then need to delete old one & keep the latest
                {
                    File.Delete(imageFilePath);
                }
                File.Move(file.FullName, imageFilePath);
                producedImages.Add(imageFilePath);
            }
            return(producedImages);
        }
Example #14
0
        /// <summary>
        /// constructs document fields and audit log
        /// </summary>
        /// <param name="productionDocumentDetail"></param>
        /// <returns></returns>
        private List <DocumentFieldsBEO> ConstructDocumentFields(ProductionDocumentDetail productionDocumentDetail)
        {
            List <DocumentFieldsBEO> lstDocumentFields = null;
            var lstProductionFields = productionDocumentDetail.lstProductionFields;
            var lstDsFeildsBeo      = productionDocumentDetail.lstDsFieldsBeo;

            if (lstProductionFields != null && lstDsFeildsBeo != null)
            {
                lstDocumentFields = new List <DocumentFieldsBEO>();
                //Bates Number Fieldtype Id-3004
                FieldBEO productionFieldBeo = null;
                productionFieldBeo =
                    lstProductionFields.FirstOrDefault(
                        prodField =>
                        prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesNumber));
                if (productionFieldBeo != null)
                {
                    lstDocumentFields.Add(new DocumentFieldsBEO
                    {
                        FieldId =
                            lstDsFeildsBeo.FirstOrDefault(
                                DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID,
                        FieldType =
                            new FieldDataTypeBusinessEntity
                        {
                            DataTypeId           = (Int32)Constants.FieldTypeIds.BatesNumber,
                            DataTypeDisplayValue = Constants.BatesNumber
                        },
                        FieldValue =
                            !string.IsNullOrWhiteSpace(productionDocumentDetail.AllBates)
                                ? productionDocumentDetail.AllBates
                                : string.Empty,
                        FieldName =
                            lstDsFeildsBeo.FirstOrDefault(
                                DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name,
                        DocumentReferenceId = productionDocumentDetail.DocumentId
                    });
                    //Bates Begin Fieldtype Id-3005
                    productionFieldBeo =
                        lstProductionFields.FirstOrDefault(
                            prodField =>
                            prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesBegin));
                    if (productionFieldBeo != null)
                    {
                        lstDocumentFields.Add(new DocumentFieldsBEO
                        {
                            FieldId =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID,
                            FieldType =
                                new FieldDataTypeBusinessEntity
                            {
                                DataTypeId           = (Int32)Constants.FieldTypeIds.BatesBegin,
                                DataTypeDisplayValue = Constants.BatesBegin
                            },
                            FieldValue =
                                !string.IsNullOrWhiteSpace(productionDocumentDetail.StartingBatesNumber)
                                    ? productionDocumentDetail.StartingBatesNumber
                                    : string.Empty,
                            FieldName =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name,
                            DocumentReferenceId = productionDocumentDetail.DocumentId
                        });
                    }
                    //Bates End Fieldtype Id-3006
                    productionFieldBeo =
                        lstProductionFields.FirstOrDefault(
                            prodField =>
                            prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesEnd));
                    if (productionFieldBeo != null)
                    {
                        lstDocumentFields.Add(new DocumentFieldsBEO
                        {
                            FieldId =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID,
                            FieldType =
                                new FieldDataTypeBusinessEntity
                            {
                                DataTypeId           = (Int32)Constants.FieldTypeIds.BatesEnd,
                                DataTypeDisplayValue = Constants.BatesEnd
                            },
                            FieldValue =
                                !string.IsNullOrWhiteSpace(productionDocumentDetail.EndingBatesNumber)
                                    ? productionDocumentDetail.EndingBatesNumber
                                    : string.Empty,
                            FieldName =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name,
                            DocumentReferenceId = productionDocumentDetail.DocumentId
                        });
                    }
                    //Bates Range Field Type Id-3007
                    productionFieldBeo =
                        lstProductionFields.FirstOrDefault(
                            prodField =>
                            prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesRange));
                    if (productionFieldBeo != null)
                    {
                        lstDocumentFields.Add(new DocumentFieldsBEO
                        {
                            FieldId =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID,
                            FieldType =
                                new FieldDataTypeBusinessEntity
                            {
                                DataTypeId           = (Int32)Constants.FieldTypeIds.BatesRange,
                                DataTypeDisplayValue = Constants.BatesRange
                            },
                            FieldValue =
                                productionDocumentDetail.StartingBatesNumber + "-" +
                                productionDocumentDetail.EndingBatesNumber,
                            FieldName =
                                lstDsFeildsBeo.FirstOrDefault(
                                    DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name,
                            DocumentReferenceId = productionDocumentDetail.DocumentId
                        });
                    }
                }
                //DPN Fieldtype Id-3008
                productionFieldBeo =
                    lstProductionFields.FirstOrDefault(
                        prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.DPN));
                if (productionFieldBeo != null)
                {
                    lstDocumentFields.Add(new DocumentFieldsBEO
                    {
                        FieldId =
                            lstDsFeildsBeo.FirstOrDefault(
                                DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID,
                        FieldType =
                            new FieldDataTypeBusinessEntity
                        {
                            DataTypeId           = (Int32)Constants.FieldTypeIds.DPN,
                            DataTypeDisplayValue = Constants.DPN
                        },
                        FieldValue =
                            !string.IsNullOrWhiteSpace(productionDocumentDetail.DocumentProductionNumber)
                                ? productionDocumentDetail.DocumentProductionNumber
                                : string.Empty,
                        FieldName =
                            lstDsFeildsBeo.FirstOrDefault(
                                DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name,
                        DocumentReferenceId = productionDocumentDetail.DocumentId
                    });
                }
            }
            return(lstDocumentFields);
        }