protected override bool GenerateMessage()
        {
            var isErrorInCreateMetadata = false;

            try
            {
                //Create Fields & tags in LAW
                if (!CreateMetaDataFieldsInLawCase())
                {
                    isErrorInCreateMetadata = true;
                    throw new EVException().AddUsrMsg(Constants.LawSyncFailureinCreateMetadata);
                }
                //1) Get documents for LawSync
                var documentsSelection = new List <DocumentsSelectionBEO> {
                    _jobParameter.DocumentsSelection
                };
                var resultDocuments = LawSyncSearchHelper.GetDocuments(documentsSelection, _dcnFieldName, _jobParameter.CreatedBy);
                if (!resultDocuments.Any())
                {
                    throw new EVException().AddUsrMsg(Constants.LawSyncFailureinGetDcoumentsMessage);
                }
                resultDocuments.ForEach(d => d.IsExclude = true); //Default Exclude all documents for imaging

                //2) Get subset documents for LawSync Imaging
                if (_jobParameter.IsProduceImage)
                {
                    documentsSelection.Add(_jobParameter.ImageDocumentsSelection);
                    var resultImagingDocuments = LawSyncSearchHelper.GetDocuments(documentsSelection, _dcnFieldName, _jobParameter.CreatedBy);
                    if (resultImagingDocuments.Any())
                    {
                        //Document not part of imaging subset excluded for imaging.
                        resultDocuments.FindAll(x => resultImagingDocuments.Exists(y => y.DCN.Equals(x.DCN))).SafeForEach(f => f.IsExclude = false);
                    }
                }
                resultDocuments = resultDocuments.DistinctBy(f => f.Id).ToList();
                //Construct LawSync Document
                ConstructLawSyncDocument(resultDocuments.OrderBy(d => d.DCN).ToList());
                return(true);
            }
            catch (Exception ex)
            {
                ex.Trace();
                ReportToDirector(ex);
                ConstructLog(isErrorInCreateMetadata ? Constants.LawSyncFailureinCreateMetadata : Constants.LawSyncFailureinGetDcoumentsMessage);
                throw;
            }
        }
Пример #2
0
        private void ConstructLawSyncDocument(IEnumerable <ReconversionDocumentBEO> reprocessDocumentList)
        {
            #region Produce Image
            List <FilteredDocumentBusinessEntity> imagingDocuments = null;
            if (_lawSyncJobParameter.IsProduceImage)
            {
                var documentsSelection = new List <DocumentsSelectionBEO>
                {
                    _lawSyncJobParameter.DocumentsSelection,
                    _lawSyncJobParameter.ImageDocumentsSelection
                };
                imagingDocuments = LawSyncSearchHelper.GetDocuments(documentsSelection, _dcnFieldName, _lawSyncJobParameter.CreatedBy);
            }
            #endregion

            var runningDocCount          = 0;
            var lawDocumentsList         = new List <LawSyncDocumentDetail>();
            var documentProcessStateList = new List <DocumentConversionLogBeo>();
            _logInfoList = new List <JobWorkerLog <LawSyncLogInfo> >();
            foreach (var reprocessDocument in reprocessDocumentList)
            {
                _documentCorrelationId++;
                runningDocCount++;
                if (runningDocCount > Constants.BatchSize)
                {
                    runningDocCount = 0;
                    UpdateDcoumentProcessState(documentProcessStateList);
                    Send(lawDocumentsList);
                    lawDocumentsList         = new List <LawSyncDocumentDetail>();    //Clear document List
                    documentProcessStateList = new List <DocumentConversionLogBeo>(); //Clear document process state List
                }
                var lawDocument = new LawSyncDocumentDetail
                {
                    DocumentReferenceId   = reprocessDocument.DocumentId,
                    DocumentControlNumber = reprocessDocument.DCNNumber,
                    CorrelationId         = _documentCorrelationId
                };

                if (_lawSyncJobParameter.IsProduceImage && imagingDocuments != null && imagingDocuments.Any())
                {
                    lawDocument.IsImaging = imagingDocuments.Exists(y => y.DCN.Equals(lawDocument.DocumentControlNumber));
                }
                else
                {
                    //Document not part of imaging subset excluded for imaging.
                    lawDocument.IsImaging = false;
                }


                var field =
                    DocumentBO.GetDocumentFieldById(
                        _lawSyncJobParameter.MatterId.ToString(CultureInfo.InvariantCulture), _dataset.CollectionId,
                        lawDocument.DocumentReferenceId, _lawFieldId);
                if (field != null && !string.IsNullOrEmpty(field.FieldValue))
                {
                    lawDocument.LawDocumentId = Convert.ToInt32(field.FieldValue);
                }

                if (lawDocument.IsImaging)
                {
                    _volumeDocumentCount++;
                    var documentPagesCount = GetPageCountForImages(_lawSyncJobParameter.MatterId,
                                                                   _dataset.RedactableDocumentSetId, lawDocument.DocumentReferenceId);
                    if (_volumeDocumentCount > VolumeMaximumDocumentCount)
                    {
                        _volumeDocumentCount = 0;
                        _volumeCount++;
                        _volumeFolderName         = LawVolumeHelper.CreateVolumeFolder(_jobEVImagesDirectory, _volumeCount);
                        _volumeDocumentPagesCount = 0;
                    }
                    lawDocument.ImagesFolderPath    = _volumeFolderName;
                    lawDocument.ImageStartingNumber = _volumeDocumentPagesCount;
                    _volumeDocumentPagesCount       = _volumeDocumentPagesCount + documentPagesCount;
                }
                if (lawDocument.LawDocumentId > 0)
                {
                    lawDocumentsList.Add(lawDocument);
                }
                else
                {
                    ConstructLog(lawDocument.LawDocumentId, lawDocument.CorrelationId, lawDocument.DocumentControlNumber, Constants.LawSyncDocumentNotAvailable);
                }
                documentProcessStateList.Add(GetDocumentProcessStateInformation(lawDocument));
            }

            if (documentProcessStateList.Any())
            {
                UpdateDcoumentProcessState(documentProcessStateList);
            }

            if (lawDocumentsList.Any())
            {
                Send(lawDocumentsList);
            }
            if (_logInfoList.Any())
            {
                SendLogPipe(_logInfoList);
            }
        }