/// <summary> /// Clear except image file information in DocumentBEO /// </summary> /// <param name="document">document</param> /// <param name="collectionId">CollectionId</param> /// <returns>RVWDocumentBEO</returns> private static RVWDocumentBEO GetImageDocuments(RVWDocumentBEO document, string collectionId) { document.ShouldNotBe(null); collectionId.ShouldNotBe(null); var imageSetDocument = CopyDocumentObject(document, false); var imageSize = 0; if (imageSetDocument.DocumentBinary.FileList != null && imageSetDocument.DocumentBinary.FileList.Count > 0) { var imagefileList = imageSetDocument.DocumentBinary.FileList.Where( x => x.Type.ToLower().Equals(Constants.IMAGE_FILE_TYPE.ToLower()) && !String.IsNullOrEmpty(x.Path) ).ToList(); imageSetDocument.DocumentBinary.FileList.Clear(); imagefileList.ForEach(x => imageSetDocument.DocumentBinary.FileList.Add(x)); imageSize += (from docFile in imageSetDocument.DocumentBinary.FileList where File.Exists(docFile.Path) select new FileInfo(docFile.Path) into fileInfo where fileInfo != null select(int) Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant)).Sum(); } //Set Imageset Collection Id. imageSetDocument.CollectionId = collectionId; //Clear Field Mapping imageSetDocument.FieldList.Clear(); //Clear Native File Info imageSetDocument.MimeType = string.Empty; imageSetDocument.FileName = string.Empty; imageSetDocument.NativeFilePath = string.Empty; imageSetDocument.FileExtension = string.Empty; imageSetDocument.FileSize = imageSize; return(imageSetDocument); }
/// <summary> /// Clear image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <returns></returns> private static RVWDocumentBEO GetNativeDocument(RVWDocumentBEO document) { var nativeSetDocument = CopyDocumentObject(document, true); var fileList = nativeSetDocument.DocumentBinary.FileList.Where( x => x.Type.ToLower() != Constants.IMAGE_FILE_TYPE.ToLower()).ToList(); nativeSetDocument.DocumentBinary.FileList.Clear(); if (fileList.Any()) { fileList.ForEach(x => nativeSetDocument.DocumentBinary.FileList.Add(x)); nativeSetDocument.DocumentBinary.FileList.ForEach( x => x.Path = (x.Type == Constants.TEXT_FILE_TYPE) ? string.Format("{0}?id={1}", x.Path, Guid.NewGuid().ToString() /*.Replace("-", "").ToUpper()*/) : x.Path); } if (document.DocumentBinary != null) { if (!string.IsNullOrEmpty(document.DocumentBinary.Content)) //Assign Content Value { nativeSetDocument.DocumentBinary.Content = document.DocumentBinary.Content; } } return(nativeSetDocument); }
/// <summary> /// To get the overlay documents /// </summary> /// <param name="document"></param> /// <param name="documentDetailList"></param> /// <param name="correlationId"></param> private void GetOverlayDocuments(RVWDocumentBEO document, List <DocumentDetail> documentDetailList, string correlationId) { var doc = new DocumentDetail { document = document, ConversationIndex = document.ConversationIndex }; //Create a unique file name for content file doc.document.DocumentBinary.FileList.ForEach( x => x.Path = (x.Type.ToLower() == Constants.TEXT_FILE_TYPE.ToLower()) ? string.Format("{0}?id={1}", x.Path, Guid.NewGuid().ToString() /*.Replace("-", "").ToUpper()*/) : x.Path); doc.CorrelationId = correlationId; var lawDocId = _datasetDetails.DatasetFieldList.FirstOrDefault(x => x.Name.Equals(LawDocumentId)); if (lawDocId != null) { // Create a Field Business Entity for each mapped field var matchingField = new RVWDocumentFieldBEO { // set required properties / field data FieldId = lawDocId.ID, FieldName = lawDocId.Name, FieldValue = document.LawDocumentId.ToString(CultureInfo.InvariantCulture) }; doc.OverlayMatchingField = new List <RVWDocumentFieldBEO> { matchingField }; } doc.ParentDocId = document.FamilyId; documentDetailList.Add(doc); }
/// <summary> /// Add Existing Native File Info during overlay , if Native file was not included /// </summary> private void AddNativeFileInfo(RVWDocumentBEO document) { if (document == null) { return; } var nativeFilePath = GetNativeFilePath(document.DocumentId); if (string.IsNullOrEmpty(nativeFilePath)) { return; } var extension = Path.GetExtension(nativeFilePath); if (extension != null) { document.MimeType = GetMimeType(extension.Replace(".", "")); } document.FileName = Path.GetFileNameWithoutExtension(nativeFilePath); document.NativeFilePath = nativeFilePath; document.FileExtension = Path.GetExtension(nativeFilePath); if (!File.Exists(nativeFilePath)) { return; } //Calculating size of file in KB var fileInfo = new FileInfo(nativeFilePath); document.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); document.MD5HashValue = DocumentHashHelper.GetMD5HashValue(nativeFilePath); document.SHAHashValue = DocumentHashHelper.GetSHAHashValue(nativeFilePath); }
/// <summary> /// Gets the file paths for redact it conversion. /// </summary> /// <param name="document">The document.</param> /// <returns></returns> private IEnumerable <string> GetFilePathsForRedactItConversion(RVWDocumentBEO document) { List <string> finalFileList = new List <string>(); try { if (document != null && document.DocumentBinary != null && document.DocumentBinary.FileList != null && document.DocumentBinary.FileList.Count > 0) { IEnumerable <RVWExternalFileBEO> imageAndNativeFiles = document.DocumentBinary.FileList .Where(p => p.Type.Equals(Constants.IMAGEFILETYPE) || p.Type.Equals(Constants.NATIVEFILETYPE)); // images to be converted. if (imageAndNativeFiles != null && imageAndNativeFiles.Any()) { finalFileList = imageAndNativeFiles.Select(p => p.Path).ToList(); } } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); //LogMessage(false, ex.ToUserString()); } return(finalFileList); }
private bool DumpTextToFile(RVWDocumentBEO rVwDocumentBEO, string contentText, JobWorkerLog <DcbParserLogInfo> dcbParserLogEntry) { TextFileFolder.ShouldNotBe(null); if (string.IsNullOrEmpty(contentText)) { return(true); } string filePath = Path.Combine(TextFileFolder, rVwDocumentBEO.DocumentId + Constants.FileExtension); File.AppendAllText(filePath, contentText); if (rVwDocumentBEO.DocumentBinary == null) { rVwDocumentBEO.DocumentBinary = new RVWDocumentBinaryBEO(); } RVWExternalFileBEO textFile = new RVWExternalFileBEO { Type = TEXT_FILE_TYPE, Path = filePath }; rVwDocumentBEO.DocumentBinary.FileList.Add(textFile); return(true); }
private void AddComments(DocumentDetail documentDetail, RVWDocumentBEO rVwDocumentBEO, Document currentDcbDocument) { if (!DcbOpticonJobBEO.IncludeNotes || null == currentDcbDocument.Notes || currentDcbDocument.Notes.Count == 0) { return; } DcbDocumentTags dcbDocumentTags = new DcbDocumentTags { compositeTagNames = new List <string>(), DatasetId = DcbOpticonJobBEO.TargetDatasetId, MatterId = DcbOpticonJobBEO.MatterId, DocumentId = rVwDocumentBEO.DocumentId }; List <DocumentCommentBEO> comments = FetchComments(rVwDocumentBEO, currentDcbDocument, dcbDocumentTags); if (null == documentDetail.DcbComments) { documentDetail.DcbComments = new List <DocumentCommentBEO>(); } documentDetail.DcbComments = comments; if (dcbDocumentTags.compositeTagNames.Count == 0) { return; // Notes don't contain any tags } if (null == documentDetail.DcbTags) { documentDetail.DcbTags = new List <DcbTags>(); } documentDetail.DcbTags.Add(dcbDocumentTags); }
/// <summary> /// To get the text file path. /// </summary> /// <param name="document"></param> /// <returns></returns> public static string GetTextFilePath(RVWDocumentBEO document) { var textFilePath = string.Empty; if (document == null || document.DocumentBinary == null || document.DocumentBinary.FileList == null || !document.DocumentBinary.FileList.Any()) { return(textFilePath); } // Get text file from external file list var txtFile = document.DocumentBinary.FileList.FirstOrDefault (x => x.Type.Equals(Constants.TEXT_FILE_TYPE, StringComparison.InvariantCultureIgnoreCase) || x.Type.Equals("1")); if (txtFile == null || string.IsNullOrEmpty(txtFile.Path)) { return(textFilePath); } textFilePath = txtFile.Path; if (textFilePath.Contains('?')) { textFilePath = textFilePath.Substring(0, (textFilePath.IndexOf('?'))); } return(textFilePath); }
/// <summary> /// Clear image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <param name="misMatchedFields"></param> /// <param name="misMatchedFieldsMessage"></param> /// <returns></returns> private RVWDocumentBEO GetDocumentForNativeSet(RVWDocumentBEO document, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { RVWDocumentBEO nativeSetDocument = CopyDocumentObject(document, true); List <RVWExternalFileBEO> fileList = nativeSetDocument.DocumentBinary.FileList.Where(x => x.Type.ToLower() != Constants.IMAGE_FILE_TYPE.ToLower()).ToList(); nativeSetDocument.DocumentBinary.FileList.Clear(); if (fileList.Any()) { fileList.ForEach(x => nativeSetDocument.DocumentBinary.FileList.Add(x)); } if (document.DocumentBinary != null) { if (!string.IsNullOrEmpty(document.DocumentBinary.Content)) //Assign Content Value { nativeSetDocument.DocumentBinary.Content = document.DocumentBinary.Content; } } //Need to add log for Mismatch Field foreach (var field in document.FieldList) { if (m_JobParameter.FieldMapping.Any() && m_JobParameter.FieldMapping.Exists(f => f.DatasetFieldName.ToLower().Equals(field.FieldName.ToLower()))) { FieldValueValidation(field, misMatchedFields, misMatchedFieldsMessage); } } return(nativeSetDocument); }
/// <summary> /// Transforms EDRM fields to list of EV Document field Business entities /// </summary> /// <param name="rvwDocumentBEO"> call by reference - Document object for which fields to be updated. </param> /// <param name="edrmDocument"> EDRM document object </param> /// <param name="mappedFields"> fields mapped while scheduling import. </param> protected virtual void TransformEDRMFieldsToDocumentFields(ref RVWDocumentBEO rvwDocumentBEO, DocumentEntity edrmDocument, List <FieldMapBEO> mappedFields) { #region Add all mapped fields foreach (FieldMapBEO mappedField in mappedFields) { //Create a Tag Entity for each mapped field TagEntity tag = new TagEntity(); // Get tag/field from EDRM file for give mapped field IEnumerable <TagEntity> tagEnumerator = edrmDocument.Tags.Where(p => p.TagName.Equals(mappedField.SourceFieldName, StringComparison.CurrentCultureIgnoreCase)); if (tagEnumerator.Count <TagEntity>() > 0) { tag = tagEnumerator.First <TagEntity>(); } // Adding Field map information only if Tag Value is available. // Create a Field business Entity for each mapped field RVWDocumentFieldBEO fieldBEO = new RVWDocumentFieldBEO() { // set required properties / field data FieldId = mappedField.DatasetFieldID, FieldName = mappedField.DatasetFieldName, FieldValue = tag.TagValue ?? string.Empty, FieldType = new FieldDataTypeBusinessEntity() { DataTypeId = mappedField.DatasetFieldTypeID } }; // Add tag to the document rvwDocumentBEO.FieldList.Add(fieldBEO); } // End of loop through fields in a document. #endregion }
/// <summary> /// Clear except image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <param name="collectionId"></param> /// <returns></returns> private static RVWDocumentBEO GetDocumentForImageSet(RVWDocumentBEO document, string collectionId) { var imageSetDocument = CopyDocumentObject(document, false); if (imageSetDocument.DocumentBinary.FileList != null && imageSetDocument.DocumentBinary.FileList.Count > 0) { List <RVWExternalFileBEO> imagefileList = imageSetDocument.DocumentBinary.FileList.Where(x => x.Type.ToLower().Equals(Constants.IMAGE_FILE_TYPE.ToLower())).ToList(); imageSetDocument.DocumentBinary.FileList.Clear(); imagefileList.ForEach(x => imageSetDocument.DocumentBinary.FileList.Add(x)); } //Set Imageset Collection Id. imageSetDocument.CollectionId = collectionId; //Clear Field Mapping imageSetDocument.FieldList.Clear(); //Clear Native File Info imageSetDocument.MimeType = string.Empty; imageSetDocument.FileName = string.Empty; imageSetDocument.NativeFilePath = string.Empty; imageSetDocument.FileExtension = string.Empty; imageSetDocument.FileSize = 0; if (!string.IsNullOrEmpty(document.DocumentControlNumber)) { imageSetDocument.DocumentControlNumber = document.DocumentControlNumber; } return(imageSetDocument); }
private static List <RVWDocumentBEO> ToDocumentBeoList(List <DocumentDetail> documents) { var documentBeoList = new List <RVWDocumentBEO>(); RVWDocumentBEO document; documents.ForEach(d => { document = new RVWDocumentBEO { MatterId = d.document.MatterId }; document.FieldList.AddRange(d.document.FieldList); document.CollectionId = d.document.CollectionId; document.NativeFilePath = d.document.NativeFilePath; document.DocumentRelationShip = d.document.DocumentRelationShip; document.DocumentId = d.document.DocumentId; document.Id = d.document.Id; document.DocumentBinary = d.document.DocumentBinary; document.CustomFieldToPopulateText = d.document.CustomFieldToPopulateText; if (d.document.Tags != null && d.document.Tags.Any()) { d.document.Tags.ForEach(x => document.Tags.Add(x)); } documentBeoList.Add(document); }); return(documentBeoList); }
/// <summary> /// Copy Document Object /// </summary> /// <param name="document"></param> /// <param name="isNativeDoc"></param> /// <returns></returns> private static RVWDocumentBEO CopyDocumentObject(RVWDocumentBEO document, bool isNativeDoc) { var documentsetDocument = new RVWDocumentBEO(); documentsetDocument.CollectionId = document.CollectionId; documentsetDocument.MatterId = document.MatterId; documentsetDocument.CreatedBy = document.CreatedBy; documentsetDocument.Id = document.Id; documentsetDocument.DocumentId = document.DocumentId; documentsetDocument.MimeType = document.MimeType; documentsetDocument.FileName = document.FileName; documentsetDocument.NativeFilePath = document.NativeFilePath; documentsetDocument.FileExtension = document.FileExtension; documentsetDocument.FileSize = document.FileSize; documentsetDocument.PagesNatives = document.PagesNatives; documentsetDocument.PagesImages = document.PagesImages; documentsetDocument.CustomFieldToPopulateText = document.CustomFieldToPopulateText; documentsetDocument.LawDocumentId = document.LawDocumentId; documentsetDocument.IsImageFilesNotAssociated = document.IsImageFilesNotAssociated; if (isNativeDoc) { documentsetDocument.EVLoadFileDocumentId = document.EVLoadFileDocumentId; documentsetDocument.EVLoadFileParentId = document.EVLoadFileParentId; documentsetDocument.EVInsertSystemRelationShipFields = document.EVInsertSystemRelationShipFields; } if (!string.IsNullOrEmpty(document.MD5HashValue)) { documentsetDocument.MD5HashValue = document.MD5HashValue; } if (!string.IsNullOrEmpty(document.SHAHashValue)) { documentsetDocument.SHAHashValue = document.SHAHashValue; } if (!string.IsNullOrEmpty(document.ImportMessage)) { documentsetDocument.ImportMessage = document.ImportMessage; } if (document.FieldList != null && document.FieldList.Count > 0) { document.FieldList.ForEach(x => documentsetDocument.FieldList.Add(x)); } documentsetDocument.DocumentBinary = new RVWDocumentBinaryBEO(); if (document.DocumentBinary != null) { if (document.DocumentBinary.FileList.Count > 0) //Add File List { document.DocumentBinary.FileList.ForEach(x => documentsetDocument.DocumentBinary.FileList.Add(x)); } } if (!string.IsNullOrEmpty(document.CrossReferenceFieldValue)) { documentsetDocument.CrossReferenceFieldValue = document.CrossReferenceFieldValue; } return(documentsetDocument); }
/// <summary> /// To set family id and document relationship. /// </summary> /// <param name="document"></param> private void SetFamilyRelationshipIds(RVWDocumentBEO document) { if (!_jobParams.CreateFamilyGroups) { return; } document.EVInsertSystemRelationShipFields = true; document.EVLoadFileDocumentId = document.LawDocumentId.ToString(CultureInfo.InvariantCulture); document.EVLoadFileParentId = document.FamilyId; }
/// <summary> /// To get the missing content files. /// </summary> /// <param name="document"></param> /// <param name="isMissingContent"></param> /// <returns></returns> private IEnumerable <string> GetMissingContentFiles(RVWDocumentBEO document, out bool isMissingContent) { isMissingContent = false; var missingContentFiles = new List <string>(); if (document.DocumentBinary == null) { return(missingContentFiles); } if (_jobParams.IsImportTextOCR) { var textFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.TEXT_FILE_TYPE); var textPriority = _jobParams.TextImportOrder.Select(item => item.Replace(" ", string.Empty).ToLower()).ToList(); if (textFiles.Any()) { var matchText = string.Empty; //Loop through each priority text and find the available content text file foreach (var pText in textPriority) { var textFile = textFiles.Find(t => t.Text.ToLower().Equals(pText)); if (textFile == null) { continue; } if (string.IsNullOrWhiteSpace(textFile.Path) || !File.Exists(textFile.Path)) { continue; } matchText = textFile.Text; break; } //Removing the other text files from FileList when the priority is met document.DocumentBinary.FileList.RemoveAll( x => x.Type == Constants.TEXT_FILE_TYPE && !string.IsNullOrEmpty(x.Text) && x.Text.ToLower() != matchText.ToLower()); //Set as missing content file when the priority text file is not found. var contentFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.TEXT_FILE_TYPE); if (!contentFiles.Any()) { isMissingContent = true; missingContentFiles.AddRange(from textFile in textFiles where !string.IsNullOrEmpty(textFile.Path) select textFile.Path); } } } else { document.DocumentBinary.FileList.RemoveAll(x => x.Type == Constants.TEXT_FILE_TYPE); } return(missingContentFiles); }
/// <summary> /// Methos to identify the field's to which values are to be updated /// </summary> /// <param name="document">DocumentResult</param> /// <param name="actualString">string</param> /// <param name="replaceString">string</param> /// <param name="userGuid">string</param> /// <returns>List<RVWDocumentFieldBEO /></returns> private List <RVWDocumentFieldBEO> GetFieldValuesToUpdate(DocumentResult document, string actualString, string replaceString, string userGuid) { var documentFields = new List <RVWDocumentFieldBEO>(); RVWDocumentBEO documentData = DocumentService.GetDocumentData(document.MatterID.ToString(CultureInfo.InvariantCulture), document.CollectionID, document.DocumentID, userGuid, "false"); if (documentData != null && !documentData.IsLocked && documentData.FieldList.Count > 0) { //Filters the system and read only fields IEnumerable <RVWDocumentFieldBEO> editableFields = documentData.FieldList.Where(x => !x.IsReadable); if (editableFields.Any()) { List <RVWDocumentFieldBEO> fields = editableFields.ToList(); documentData.FieldList.Clear(); fields.SafeForEach(y => documentData.FieldList.Add(y)); } //Loop through the fields and update the field value accordingly foreach (RVWDocumentFieldBEO documentFieldValue in documentData.FieldList) { if (documentFieldValue.FieldType.DataTypeId == Constants.ContentFieldType) { documentFieldValue.FieldValue = DecodeContentField(documentFieldValue.FieldValue); } if (!string.IsNullOrEmpty(documentFieldValue.FieldValue)) { if (documentFieldValue.FieldValue.ToLowerInvariant().Contains(actualString.ToLowerInvariant())) { var reg = new Regex(actualString.ToLowerInvariant(), RegexOptions.Multiline); MatchCollection theMatches = reg.Matches(documentFieldValue.FieldValue.ToLowerInvariant()); _mOccurrences += theMatches.Count; documentFields.Add(new RVWDocumentFieldBEO { FieldId = documentFieldValue.FieldId, FieldName = documentFieldValue.FieldName, FieldValue = documentFieldValue.FieldValue.ToLowerInvariant(). Replace(actualString.ToLowerInvariant(), replaceString), FieldTypeId = documentFieldValue.FieldType.DataTypeId }); } } } } return(documentFields); }
/// <summary> /// Gets the law documents based on filter tags it includes mapped fields and tags /// </summary> /// <param name="correlationId"></param> /// <param name="documentCtrlNbr"></param> /// <param name="rawDocument"></param> /// <param name="logs"></param> /// <returns></returns> public List <DocumentDetail> GetDocuments(string correlationId, string documentCtrlNbr, RVWDocumentBEO rawDocument, out JobWorkerLog <LawImportLogInfo> logs) { var documentDetailList = new List <DocumentDetail>(); var document = ConsturctDocument(correlationId, rawDocument, out logs); if (_jobParams.ImportOptions == ImportOptionsBEO.AppendNew) { // Assign DCN document.DocumentControlNumber = documentCtrlNbr; //1) Construct Native Set var nativeSetDocument = GetNativeDocument(document); var doc = new DocumentDetail { CorrelationId = correlationId, docType = DocumentsetType.NativeSet, document = nativeSetDocument, ConversationIndex = document.ConversationIndex, IsNewDocument = true }; //Add Native Document documentDetailList.Add(doc); //2) Construct Image Set if (_jobParams.IsImportImages && !string.IsNullOrEmpty(_jobParams.ImageSetId)) { var imageSetDocument = GetImageDocuments(document, _jobParams.ImageSetId); var docImg = new DocumentDetail { CorrelationId = correlationId, docType = DocumentsetType.ImageSet, document = imageSetDocument, IsNewDocument = true }; //Add Image Document documentDetailList.Add(docImg); } } else { GetOverlayDocuments(document, documentDetailList, correlationId); } return(documentDetailList); }
//To get the missing native files private string GetMissingNativeFiles(RVWDocumentBEO document) { string missingNativeFile = null; if (document.DocumentBinary == null) { return(null); } if (_jobParams.IsImportNative) { var nativeFile = document.DocumentBinary.FileList.Find(x => x.Type == Constants.NATIVE_FILE_TYPE); if (nativeFile != null) { var nativeFilePath = nativeFile.Path; var extension = Path.GetExtension(nativeFilePath); if (extension != null) { document.MimeType = GetMimeType(extension.Replace(".", "")); // Remove MimeType } document.FileName = Path.GetFileNameWithoutExtension(nativeFilePath); document.NativeFilePath = nativeFilePath; nativeFile.Type = Constants.NATIVE_FILE_TYPE; nativeFile.Path = document.NativeFilePath; document.FileExtension = Path.GetExtension(nativeFilePath); if (File.Exists(nativeFilePath)) { //Calculating size of file in KB var fileInfo = new FileInfo(nativeFilePath); document.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); document.MD5HashValue = DocumentHashHelper.GetMD5HashValue(nativeFilePath); document.SHAHashValue = DocumentHashHelper.GetSHAHashValue(nativeFilePath); } else //Missing Native File { missingNativeFile = nativeFilePath; } } } else { document.DocumentBinary.FileList.RemoveAll(x => x.Type == Constants.NATIVE_FILE_TYPE); } return(missingNativeFile); }
/// <summary> /// Gets the law documents based on filter tags it includes mapped fields and tags /// </summary> /// <param name="correlationId"></param> /// <param name="documentCtrlNbr"></param> /// <param name="rawDocument"></param> /// <param name="logs"></param> /// <returns></returns> public List<DocumentDetail> GetDocuments(string correlationId, string documentCtrlNbr, RVWDocumentBEO rawDocument, out JobWorkerLog<LawImportLogInfo> logs) { var documentDetailList = new List<DocumentDetail>(); var document = ConsturctDocument(correlationId, rawDocument, out logs); if (_jobParams.ImportOptions == ImportOptionsBEO.AppendNew) { // Assign DCN document.DocumentControlNumber = documentCtrlNbr; //1) Construct Native Set var nativeSetDocument = GetNativeDocument(document); var doc = new DocumentDetail { CorrelationId = correlationId, docType = DocumentsetType.NativeSet, document = nativeSetDocument, ConversationIndex = document.ConversationIndex, IsNewDocument = true }; //Add Native Document documentDetailList.Add(doc); //2) Construct Image Set if (_jobParams.IsImportImages && !string.IsNullOrEmpty(_jobParams.ImageSetId)) { var imageSetDocument = GetImageDocuments(document, _jobParams.ImageSetId); var docImg = new DocumentDetail { CorrelationId = correlationId, docType = DocumentsetType.ImageSet, document = imageSetDocument, IsNewDocument = true }; //Add Image Document documentDetailList.Add(docImg); } } else { GetOverlayDocuments(document, documentDetailList, correlationId); } return documentDetailList; }
public RVWDocumentBEO ConsturctDocument(string correlationId, RVWDocumentBEO document, out JobWorkerLog <LawImportLogInfo> logs) { int importedImagesCount; document.CollectionId = _jobParams.CollectionId; document.MatterId = _jobParams.MatterId; document.CreatedBy = _jobParams.CreatedBy; document.ImportDescription = _jobParams.ImportDetail; bool isMissingContent; SetFamilyRelationshipIds(document); #region Native File var missingNativeFile = GetMissingNativeFiles(document); #endregion #region Image File var missingImageFiles = GetMissingImageFiles(document, out importedImagesCount); #endregion #region Text File (Content File) if (_jobParams != null) { if (!_datasetDetails.DatasetFieldList.Any(f => f.FieldType.DataTypeId == 2000 && f.Name == _jobParams.FieldNameToPopulateText)) { document.CustomFieldToPopulateText = _jobParams.FieldNameToPopulateText; } } var missingContentFiles = GetMissingContentFiles(document, out isMissingContent); #endregion logs = ConstructLog(correlationId, document.DocumentId, missingNativeFile, missingImageFiles, isMissingContent, missingContentFiles, importedImagesCount, document.DocumentControlNumber, document.CrossReferenceFieldValue); return(document); }
/// <summary> /// To get the missing image files /// </summary> /// <param name="document"></param> /// <param name="importedImagesCount"></param> /// <returns></returns> private List <string> GetMissingImageFiles(RVWDocumentBEO document, out int importedImagesCount) { importedImagesCount = 0; var missingImageFiles = new List <string>(); if (_jobParams.IsImportImages && document.DocumentBinary != null) { var imageFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.IMAGE_FILE_TYPE); if (imageFiles.Any()) { missingImageFiles.AddRange(from image in imageFiles where !string.IsNullOrWhiteSpace(image.Path) && !File.Exists(image.Path) select image.Path); importedImagesCount = imageFiles.Count() - missingImageFiles.Count(); } } return(missingImageFiles); }
/// <summary> /// Transform "EDRM document entity" to EV's Document BEO /// This function doesn't set field data /// Field data is set separately as there are two variances of this operation. </summary> /// 1) set all fields available in the EDRM file /// 2) set mapped fields only. /// /// In relationship objects for the EDRM Manager document IDs are updated in a format compatible with Vault/EV system. /// </summary> /// <param name="rvwDocumentBEO"> Document Business Entity, by reference so that the transformed data is updated in this object. </param> /// <param name="edrmDocument"> EDRM document entity which is going tobe transformed to EV Document Business Entity. </param> protected virtual void TransformDocumentsAndRelationships(ref RVWDocumentBEO rvwDocumentBEO, DocumentEntity edrmDocument) { // Transform "EDRM document entity" to EV's Document BEO TransformEDRMDocumentEntityToDocumentBusinessEntity(ref rvwDocumentBEO, edrmDocument); // Update relationship's IDs foreach (RelationshipEntity relationship in relationships) { if (edrmDocument.DocumentID.Equals(relationship.ParentDocID)) { relationship.ParentDocID = rvwDocumentBEO.DocumentId; } if (edrmDocument.DocumentID.Equals(relationship.ChildDocID)) { relationship.ChildDocID = rvwDocumentBEO.DocumentId; } } }
/// <summary> /// Pushes the document for conversion. /// </summary> /// <param name="document">The document.</param> /// <param name="documentCollectionToReSend">The document collection to re send.</param> /// <param name="converter">The converter.</param> private void GetDocumentForConversion(RVWDocumentBEO document, DocumentCollection documentCollectionToReSend, INearNativeConverter converter, List <RVWDocumentBEO> nativeDocuments, Dictionary <string, IEnumerable <string> > filesToPush, string importType) { // get list of files to be converted from document object. IEnumerable <string> fileListForConversion = GetFilePathsForRedactItConversion(document); if (importType.Equals(Constants.EdocsImport)) { if (fileListForConversion != null)// if the file list is available - attempt to push for conversion { // Push all documents that exist and NOT zero byte files for conversion. IEnumerable <string> existingFileList = fileListForConversion.Where(f => File.Exists(f) && (new FileInfo(f).Length > 0)); if (existingFileList.Count() == fileListForConversion.Count()) { nativeDocuments.Add(document); filesToPush.Add(document.DocumentId + ":" + document.CollectionId, fileListForConversion); } else { #region If files doesn't exist yet, add them to a list so that they are put back to the Conversion Worker input data pipe. // Files that are not ready for conversion need to be put back to Conversion worker - next time around they might have been created. // if there is a null file we shouldn't resend it to Conversion worker - hence no else clause. if (fileListForConversion.Where(f => !File.Exists(f)).FirstOrDefault() != null) { documentCollectionToReSend.documents.Add(new DocumentDetail() { document = document, }); } #endregion If files doesn't exist yet, add them to a list so that they are put back to the Conversion Worker input data pipe. } } } else { nativeDocuments.Add(document); filesToPush.Add(document.DocumentId + ":" + document.CollectionId, fileListForConversion); } }
/// <summary> /// Converts to conversion log beo. /// </summary> /// <param name="rvwDocumentBeo">The RVW document beo.</param> /// <param name="processStatus">The process status.</param> /// <param name="reasonId">The reason id.</param> /// <returns></returns> private DocumentConversionLogBeo ConvertToConversionLogBeo(RVWDocumentBEO rvwDocumentBeo, byte processStatus = EVRedactItErrorCodes.Submitted, short reasonId = EVRedactItErrorCodes.Na) { return(new DocumentConversionLogBeo() { DocumentId = rvwDocumentBeo.DocumentId, CollectionId = rvwDocumentBeo.CollectionId, JobRunId = WorkAssignment.JobId, ProcessJobId = WorkAssignment.JobId, DCN = rvwDocumentBeo.DocumentControlNumber, CrossReferenceId = !string.IsNullOrEmpty(rvwDocumentBeo.CrossReferenceFieldValue) ? rvwDocumentBeo.CrossReferenceFieldValue : "N/A", Status = processStatus, ReasonId = reasonId, ModifiedDate = DateTime.UtcNow, CreatedDate = DateTime.UtcNow }); }
private RVWDocumentBEO GetDocumentData(string documentId, string collectionId, out bool isError) { RVWDocumentBEO document = null; isError = false; try { using (new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { document = DocumentBO.GetDocumentDataViewFromVaultWithOutContent(matterId.ToString(CultureInfo.InvariantCulture), collectionId, documentId, string.Empty, true, false); } } catch (Exception ex) { ex.Trace().Swallow(); isError = true; } return(document); }
/// <summary> /// Overlay- Check ContentFile (i.e same file as used during Append) /// </summary> /// <param name="collectionId"></param> /// <param name="documentId"></param> /// <param name="textFilePath"></param> /// <param name="newTextFile"></param> /// <returns></returns> private string GetExistingContentFile(string collectionId, string documentId) { string contentFilePath = null; DocumentVaultManager docVaultManager = new DocumentVaultManager(); var collectionGUILD = new Guid(collectionId); RVWDocumentBEO document = null; using (EVTransactionScope transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { document = docVaultManager.GetDocumentFileDetails(m_Dataset.Matter.FolderID, new Guid(collectionId), documentId, 1, string.Empty); } if (document != null && document.DocumentBinary != null && document.DocumentBinary.FileList != null && document.DocumentBinary.FileList.Count > 0) { var contentFile = document.DocumentBinary.FileList.Where(f => f.Type == Constants.ExtractedText_FILE_TYPE); if (contentFile != null && contentFile.FirstOrDefault() != null) { contentFilePath = (!string.IsNullOrEmpty(contentFile.FirstOrDefault().Path) ? contentFile.FirstOrDefault().Path : string.Empty); } } return(contentFilePath); }
/// <summary> /// Creates the and update external file entity for native set. /// </summary> /// <param name="document">The document.</param> private static void CreateAndUpdateExternalFileEntityForNativeSet(RVWDocumentBEO document) { try { //Insert document binary, if any -- to do: Should we need call this @ this place if (document != null && !StringUtility.IsNullOrWhiteSpace(document.NativeFilePath)) { RVWExternalFileBEO externalFile = new RVWExternalFileBEO(); externalFile.Type = "Native"; externalFile.Path = document.NativeFilePath; document.DocumentBinary.FileList.Add(externalFile); } else { throw new EVException().AddErrorCode(ErrorCodes.EDLoaderExtractionWorker_NativeFileNotAvailable); } } catch (Exception ex) { ex.Trace().Swallow(); } }
private void BulkUpsertDocumentContentSizeAndIndexStatusInfo(long matterId, string datasetCollectionId, IEnumerable <DocumentDetail> documentDetails) { try { var documentList = new List <RVWDocumentBEO>(); foreach (var documentDetail in documentDetails) { if (documentDetail.document == null) { continue; } var document = new RVWDocumentBEO { DocumentId = documentDetail.document.DocumentId, DocumentIndexingStatus = true }; var filePath = Extensions.GetTextFilePath(documentDetail.document); if (!string.IsNullOrEmpty(filePath)) { var textFile = new FileInfo(filePath); if (textFile.Exists) { document.FileSize = Convert.ToInt32(textFile.Length); } } documentList.Add(document); } var vaultManager = EVUnityContainer.Resolve <IDocumentVaultManager>("DocumentVaultManager"); vaultManager.BulkUpsertDocumentContentSizeAndIndexStatusInfo(matterId, datasetCollectionId, documentList); } catch (Exception ex) { Tracer.Error("Error occured in Update Index status and Text File size for Job Id {0}", WorkAssignment.JobId); ex.Trace().Swallow(); } }
/// <summary> /// Gets documents from EDRM file /// </summary> /// <returns> List of Document Business Entities </returns> public virtual List <RVWDocumentBEO> GetDocuments() { List <RVWDocumentBEO> documents = new List <RVWDocumentBEO>(); // Loop through documents and extract fields and file details. foreach (DocumentEntity edrmDocument in edrmEntity.BatchEntity.DocumentEntity) { RVWDocumentBEO rvwDocumentBEO = new RVWDocumentBEO(); // Transform "EDRM document entity" to EV's Document BEO // This function doesn't set field data // Field data is set separately as there are two variances of this operation. // 1) set all fields available in the EDRM file // 2) set mapped fields only. TransformEDRMDocumentEntityToDocumentBusinessEntity(ref rvwDocumentBEO, edrmDocument); // Set field data - set all fields available in the EDRM file. #region Add all fields from EDRM file foreach (RVWDocumentFieldBEO rvwDocumentFieldBEO in edrmDocument.Tags.Select(tagEntity => new RVWDocumentFieldBEO { FieldName = tagEntity.TagName, FieldValue = tagEntity.TagValue })) { rvwDocumentBEO.FieldList.Add(rvwDocumentFieldBEO); } #endregion documents.Add(rvwDocumentBEO); } return(documents); }
protected void FetchDocumentFromDCB(int documentNumber, List<DocumentDetail> documentDetailList, FamiliesInfo familiesInfo, JobWorkerLog<DcbParserLogInfo> dcbParserLogEntry) { #region Precondition asserts documentDetailList.ShouldNotBe(null); dcbParserLogEntry.ShouldNotBe(null); #endregion RVWDocumentBEO evDocument = new RVWDocumentBEO(); try { //Get the document from DcbFacade Document currentDcbDocument = DcbFacade.GetDocument(documentNumber); //Throw exception if GetDocument fails currentDcbDocument.ShouldNotBe(null); //Create the target EV document evDocument.DocumentId = Guid.NewGuid().ToString().Replace("-", "").ToUpper(); dcbParserLogEntry.LogInfo.DocumentId = evDocument.DocumentId; evDocument.CollectionId = DcbOpticonJobBEO.TargetDatasetId; evDocument.MatterId = DcbOpticonJobBEO.MatterId; //Add the fields required for casemap RVWDocumentFieldBEO evDocumentAccessionNumField = new RVWDocumentFieldBEO { FieldId = Convert.ToInt32(DcbOpticonJobBEO.SysDocId), FieldName = EVSystemFields.DcbId, IsSystemField = true, IsRequired = true, FieldValue = Convert.ToString(currentDcbDocument.UUID, CultureInfo.InvariantCulture) }; evDocument.FieldList.Add(evDocumentAccessionNumField); evDocument.FieldList.Add(_evDocumentSysImportTypeField); //Set the fields from field mapping except content field foreach (FieldMapBEO fieldMap in DcbOpticonJobBEO.FieldMappings) { Field dcbField = currentDcbDocument.FieldItems.Find(o => (o.Code == fieldMap.SourceFieldID)); //Profile fieldmapping has duplicates RVWDocumentFieldBEO evDocumentFieldBEO = evDocument.FieldList.Find(o => o.FieldId.Equals(fieldMap.DatasetFieldID)); if ((null != dcbField) && (evDocumentFieldBEO == null) && (fieldMap.DatasetFieldID != _contentFieldId)) { RVWDocumentFieldBEO evDocuemtnField = new RVWDocumentFieldBEO { FieldId = fieldMap.DatasetFieldID, FieldName = fieldMap.DatasetFieldName }; FieldBEO evfieldDef = _dataset.DatasetFieldList.Find(o => o.ID == evDocuemtnField.FieldId); evDocuemtnField.FieldValue = evfieldDef.FieldType.DataTypeId == Constants.DateDataType ? GetDateFiedlValue(dcbField, dcbParserLogEntry) : Regex.Replace(dcbField.Value, "\r\n", "\n"); evDocument.FieldList.Add(evDocuemtnField); } } //Separate logic for content StringBuilder sbContent = new StringBuilder(); if (DcbOpticonJobBEO.ContentFields != null) { foreach (string contentfield in DcbOpticonJobBEO.ContentFields.Field) { Field dcbContentField = currentDcbDocument.FieldItems.Find(o => (o.Name.Equals(contentfield))); if (null != dcbContentField) { sbContent.Append(dcbContentField.Value); } } } string text = sbContent.ToString().Replace("\r\n", "\n"); //evDocument.DocumentBinary.Content = Regex.Replace(sbContent.ToString(), "\r\n", "\n"); if (!DumpTextToFile(evDocument, text, dcbParserLogEntry)) { return; } //Set the native file path if selected evDocument.NativeFilePath = GetNativeFilePath(currentDcbDocument); if (!String.IsNullOrEmpty(evDocument.NativeFilePath) && File.Exists(evDocument.NativeFilePath)) { FileInfo fileInfo = new FileInfo(evDocument.NativeFilePath); //Tracer.Trace("DcbParcer located native document {0} for DocumentId = {1} and the file length is {2}", // evDocument.NativeFilePath, evDocument.DocumentId, fileInfo.Length); if (fileInfo.Length > 0) { evDocument.FileSize = (int)Math.Ceiling(fileInfo.Length / 1024.0); } else { evDocument.FileSize = 0; } evDocument.MD5HashValue = DocumentHashHelper.GetMD5HashValue(evDocument.NativeFilePath); evDocument.SHAHashValue = DocumentHashHelper.GetSHAHashValue(evDocument.NativeFilePath); } //Set the MIME type string extn = string.Empty; string newExtn = string.Empty; extn = Path.GetExtension(evDocument.NativeFilePath); if (!String.IsNullOrEmpty(extn)) newExtn = extn.Remove(0, 1); evDocument.MimeType = GetMimeType(newExtn); evDocument.FileExtension = extn; string createdByGuid = String.Empty; if (null != ProfileBEO && null != ProfileBEO.CreatedBy) { createdByGuid = ProfileBEO.CreatedBy; } evDocument.CreatedBy = createdByGuid; evDocument.ModifiedBy = createdByGuid; if (File.Exists(evDocument.NativeFilePath)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(evDocument.NativeFilePath); evDocument.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); if (evDocument.DocumentBinary == null) { evDocument.DocumentBinary = new RVWDocumentBinaryBEO(); } RVWExternalFileBEO nativeFile = new RVWExternalFileBEO { Type = NATIVE_FILE_TYPE, Path = evDocument.NativeFilePath }; evDocument.DocumentBinary.FileList.Add(nativeFile); } DocumentDetail documentDetail = new DocumentDetail { // CorrId is the same as TaskId and it is 1 based. CorrelationId = checked(documentNumber + 1).ToString(CultureInfo.InvariantCulture), IsNewDocument = true, docType = DocumentsetType.NativeSet, document = evDocument }; documentDetailList.Add(documentDetail); //Add Tags if (DcbOpticonJobBEO.IncludeTags && null != currentDcbDocument.TagItems && currentDcbDocument.TagItems.Count > 0) { if (null == documentDetail.DcbTags) { documentDetail.DcbTags = new List<DcbTags>(); } DcbDocumentTags dcbDocumentTags = new DcbDocumentTags { compositeTagNames = currentDcbDocument.TagItems, DatasetId = DcbOpticonJobBEO.TargetDatasetId, MatterId = DcbOpticonJobBEO.MatterId, DocumentId = evDocument.DocumentId }; documentDetail.DcbTags.Add(dcbDocumentTags); } // Add notes AddComments(documentDetail, evDocument, currentDcbDocument); //Add Images if (DcbOpticonJobBEO.ImportImages) { RVWDocumentBEO images = ImportDocumentImages(evDocument.DocumentId, currentDcbDocument); if (null != images) { DocumentDetail imageDocumentDetail = new DocumentDetail { // CorrId is the same as TaskId and it is 1 based. CorrelationId = checked(documentNumber + 1).ToString(CultureInfo.InvariantCulture), IsNewDocument = true, docType = DocumentsetType.ImageSet, document = images }; documentDetailList.Add(imageDocumentDetail); dcbParserLogEntry.LogInfo.AddedImages = images.DocumentBinary.FileList.Count; } //Add Redlines //ImportDocumentRedlines(); } //Add Document Relation if (DcbOpticonJobBEO.IsImportFamilies) { ImportDocumentRelationship(evDocument.DocumentId, currentDcbDocument, familiesInfo); } #region Postcondition asserts documentDetailList.ShouldNotBe(null); #endregion } catch (Exception ex) { //TaskLogInfo.AddParameters(Constants.ErrorDoAtomicWork + "<br/>" + ex.Message); //TaskLogInfo.StackTrace = ex.Source + "<br/>" + ex.Message + "<br/>" + ex.StackTrace; //TaskLogInfo.IsError = true; ex.Trace().Swallow(); dcbParserLogEntry.Success = false; if (ex.ToUserString().Contains(Constants.DiskFullErrorMessage)) { dcbParserLogEntry.LogInfo.Message = "There is not enough space on the disk"; throw; } else { dcbParserLogEntry.LogInfo.Message = ex.ToUserString(); } } }
/// <summary> /// Add Existing Native File Info during overlay , if Native file was not included /// </summary> private void AddNativeFileInfo(RVWDocumentBEO document) { if (document != null) { var nativeFilePath = GetNativeFilePath(document.DocumentId); if (!string.IsNullOrEmpty(nativeFilePath)) { document.MimeType = GetMimeType(Path.GetExtension(nativeFilePath).Replace(".", "")); document.FileName = Path.GetFileNameWithoutExtension(nativeFilePath); document.NativeFilePath = nativeFilePath; document.FileExtension = Path.GetExtension(nativeFilePath); if (File.Exists(nativeFilePath)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(nativeFilePath); document.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); document.MD5HashValue = DocumentHashHelper.GetMD5HashValue(nativeFilePath); document.SHAHashValue = DocumentHashHelper.GetSHAHashValue(nativeFilePath); } } } }
/// <summary> /// Method to import document images /// </summary> /// <param name="currentDocumentId">current DocumentId</param> /// <param name="currentDcbDocument">current Dcb Document</param> /// <returns>RVWDocumentBEO entity</returns> private RVWDocumentBEO ImportDocumentImages(string currentDocumentId, Document currentDcbDocument) { RVWDocumentBEO evImageDocument = new RVWDocumentBEO(); try { if ((currentDcbDocument.Images != null) && (currentDcbDocument.Images.Count > 0)) { int imageSize = 0; evImageDocument = new RVWDocumentBEO { DocumentId = currentDocumentId, CollectionId = ImageSetId, MatterId = DcbOpticonJobBEO.MatterId }; foreach (DcbImage imageObj in currentDcbDocument.Images) { RVWExternalFileBEO rvwExternalfilebeo = new RVWExternalFileBEO { Path = imageObj.ImageData.FullImagePath, Type = Constants.Image }; evImageDocument.DocumentBinary.FileList.Add(rvwExternalfilebeo); if (File.Exists(rvwExternalfilebeo.Path)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(rvwExternalfilebeo.Path); if (fileInfo != null) { imageSize += (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); } } } #region Assertion evImageDocument.DocumentBinary.FileList.ShouldNotBe(null); evImageDocument.DocumentBinary.FileList.Count.ShouldBeGreaterThan(0); #endregion string createdByGuid = String.Empty; if (null != ProfileBEO && null != ProfileBEO.CreatedBy) { createdByGuid = ProfileBEO.CreatedBy; } evImageDocument.CreatedBy = createdByGuid; evImageDocument.ModifiedBy = createdByGuid; evImageDocument.MimeType = string.Empty; evImageDocument.FileName = string.Empty; evImageDocument.NativeFilePath = string.Empty; evImageDocument.FileExtension = string.Empty; evImageDocument.FileSize = imageSize; return(evImageDocument); } } catch (Exception ex) { ex.Trace().Swallow(); } return(null); }
/// <summary> /// Gets Documents from EDRM file, extracts specified mapped fields only. /// </summary> /// <param name="mappedFields"> Mapped fields with Dataset </param> /// <param name="matterID"> Matter folder id into which documents are being imported (Dataset of exists in this matter - documents are imported into dataset) </param> /// <param name="collectionID"> Identifier for Collection into which documents are expected to be imported </param> /// <param name="relationshipBEOs"> By Reference - List of relationships </param> /// <returns> List of Document BEOs </returns> public virtual List<RVWDocumentBEO> GetDocuments(List<FieldMapBEO> mappedFields, long matterID, string collectionID, ref List<RelationshipBEO> relationshipBEOs) { List<RVWDocumentBEO> documents = new List<RVWDocumentBEO>(); #region Null Checks if (relationshipBEOs == null) relationshipBEOs = new List<RelationshipBEO>(); // Set collection ID - if it's empty throw error if (collectionID == string.Empty) throw new EVException().AddResMsg("CollectionIDIsEmpty"); // Set matter id. if the object is not available throw error if (matterID == 0) throw new EVException().AddResMsg("MatterObjectIsEmpty"); #endregion try { // Loop through documents and extract fields and file details. foreach (DocumentEntity edrmDocument in edrmEntity.BatchEntity.DocumentEntity) { // Create a document BEO for each document entity RVWDocumentBEO rvwDocumentBEO = new RVWDocumentBEO { CollectionId = collectionID, MatterId = matterID }; // Transform "EDRM document entity" to EV's Document BEO // UPDATE RELATIONSHIP INFORMATION WITH ACCURATE DOCUMENT ID (override EDRM document id with the id tobe stored in Vault) // This function doesn't set field data // Field data is set separately as there are two variances of this operation. // 1) set all fields available in the EDRM file // 2) set mapped fields only. TransformDocumentsAndRelationships(ref rvwDocumentBEO, edrmDocument); // Add all mapped fields from EDRM file TransformEDRMFieldsToDocumentFields(ref rvwDocumentBEO, edrmDocument, mappedFields); documents.Add(rvwDocumentBEO); }// End of loop throgh documents in EDRM file // Create relationships relationshipBEOs = TransformEDRMRelationshipsToDocumentRelationships(collectionID); } catch (Exception ex) { ex.AddUsrMsg("ErrorGettingDocumentsFromEDRM"); throw; } return documents; }
/// <summary> /// Clear image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <param name="misMatchedFields"></param> /// <param name="misMatchedFieldsMessage"></param> /// <returns></returns> private RVWDocumentBEO GetDocumentForNativeSet(RVWDocumentBEO document, List<string> misMatchedFields, List<string> misMatchedFieldsMessage) { RVWDocumentBEO nativeSetDocument = CopyDocumentObject(document, true); List<RVWExternalFileBEO> fileList = nativeSetDocument.DocumentBinary.FileList.Where(x => x.Type.ToLower() != Constants.IMAGE_FILE_TYPE.ToLower()).ToList(); nativeSetDocument.DocumentBinary.FileList.Clear(); if (fileList.Any()) { fileList.ForEach(x => nativeSetDocument.DocumentBinary.FileList.Add(x)); } if (document.DocumentBinary != null) { if (!string.IsNullOrEmpty(document.DocumentBinary.Content)) //Assign Content Value { nativeSetDocument.DocumentBinary.Content = document.DocumentBinary.Content; } } //Need to add log for Mismatch Field foreach (var field in document.FieldList) { if (m_JobParameter.FieldMapping.Any() && m_JobParameter.FieldMapping.Exists(f => f.DatasetFieldName.ToLower().Equals(field.FieldName.ToLower()))) { FieldValueValidation(field, misMatchedFields, misMatchedFieldsMessage); } } return nativeSetDocument; }
public static List<RVWDocumentBEO> ToDocumentBEOList(this List<DocumentDetail> documents) { var documentBeoList = new List<RVWDocumentBEO>(); RVWDocumentBEO document; documents.ForEach(d => { document = new RVWDocumentBEO { MatterId = d.document.MatterId }; document.FieldList.AddRange(d.document.FieldList); document.CollectionId = d.document.CollectionId; document.NativeFilePath = d.document.NativeFilePath; document.DocumentRelationShip = d.document.DocumentRelationShip; document.DocumentId = d.document.DocumentId; document.Id = d.document.Id; document.DocumentBinary = d.document.DocumentBinary; document.CustomFieldToPopulateText = d.document.CustomFieldToPopulateText; if (d.document.Tags != null && d.document.Tags.Any()) { d.document.Tags.ForEach(x => document.Tags.Add(x)); } documentBeoList.Add(document); }); return documentBeoList; }
public RVWDocumentBEO ConsturctDocument(string correlationId, string[] fields, List<string> textFileList, ref List<RVWDocumentFieldBEO> matchingKeyField, out string missingNativeFile, List<string> missingImageFiles, out bool isMissingContent, List<string> missingContentFiles, List<string> misMatchedFields, List<string> misMatchedFieldsMessage, out int importedImagesCount) { var document = new RVWDocumentBEO(); missingNativeFile = null; isMissingContent = false; document.CollectionId = m_JobParameter.CollectionId; document.MatterId = m_JobParameter.MatterId; document.CreatedBy = m_JobParameter.CreatedBy; document.ImportDescription = m_ImportDescription; importedImagesCount = 0; document.DocumentId = GetDocumentId(); SetLoadFileRelationShipInformation(fields, m_FieldRowDelimiter, document); if (m_JobParameter.FamilyRelations != null && m_JobParameter.IsMapEmailThread) { document.ConversationIndex = GetConversionIndex(fields, m_FieldRowDelimiter); } if (m_JobParameter.LoadFile != null && m_JobParameter.LoadFile.CrossReferenceField > -1) { document.CrossReferenceFieldValue = GetCrossReferecneField(fields, m_FieldRowDelimiter); } if (m_JobParameter.LoadFile != null && m_JobParameter.LoadFile.ContentFile != null) { if (!m_Dataset.DatasetFieldList.Any(f => f.FieldType.DataTypeId == 2000 && f.Name == m_JobParameter.LoadFile.ContentFile.FieldNameToPopulateText)) { document.CustomFieldToPopulateText = m_JobParameter.LoadFile.ContentFile.FieldNameToPopulateText; } } #region Native File string nativeFilePath = string.Empty; if ((m_JobParameter.IsImportNativeFiles) && (m_JobParameter.LoadFile.NativeFile.LoadfileNativeField != string.Empty)) { if (fields.Count() > Convert.ToInt32(m_JobParameter.LoadFile.NativeFile.LoadfileNativeField)) nativeFilePath = fields[Convert.ToInt32(m_JobParameter.LoadFile.NativeFile.LoadfileNativeField)]; if (CheckValidFilePathFormat(nativeFilePath)) { if (m_JobParameter.LoadFile.NativeFile.NativePathSubstitution != null) { FilePathSubstitutionBEO nativePathSubstitution = m_JobParameter.LoadFile.NativeFile.NativePathSubstitution; if (nativePathSubstitution.StringToMatch != string.Empty && nativePathSubstitution.StringToReplace != string.Empty) { nativeFilePath = PathSubstituion(nativeFilePath, nativePathSubstitution); } else { //Construct Absolute Path for Relative Path nativeFilePath = ConstructAbsolutePath(nativeFilePath, m_SourceFile.OriginalString); } } else { //Construct Absolute Path for Relative Path nativeFilePath = ConstructAbsolutePath(nativeFilePath, m_SourceFile.OriginalString); } document.MimeType = GetMimeType(Path.GetExtension(nativeFilePath).Replace(".", "")); // Remove MimeType document.FileName = Path.GetFileNameWithoutExtension(nativeFilePath); document.NativeFilePath = nativeFilePath; #region Update native file information in document binary object as well... if (document.DocumentBinary == null) { document.DocumentBinary = new RVWDocumentBinaryBEO(); } RVWExternalFileBEO externalFile = new RVWExternalFileBEO(); externalFile.Type = Constants.NATIVE_FILE_TYPE; externalFile.Path = document.NativeFilePath; document.DocumentBinary.FileList.Add(externalFile); #endregion Update native file information in document binary object as well... document.FileExtension = Path.GetExtension(nativeFilePath); if (File.Exists(nativeFilePath)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(nativeFilePath); document.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); document.MD5HashValue = DocumentHashHelper.GetMD5HashValue(nativeFilePath); document.SHAHashValue = DocumentHashHelper.GetSHAHashValue(nativeFilePath); } else //Missing Native File { missingNativeFile = nativeFilePath; } } else //Missing Native File { missingNativeFile = nativeFilePath; } } #endregion #region Image File if (m_JobParameter.IsImportImages) { if (m_JobParameter.LoadFile.ImageFile != null) { #region "Image File Type" string fileType = (!string.IsNullOrEmpty(m_JobParameter.LoadFile.ImageFile.ImageType.ToString())) ? m_JobParameter.LoadFile.ImageFile.ImageType.ToString() : string.Empty; #endregion var lsImageFilePath = GetImageFilePaths(fields, _JobId); if (document.DocumentBinary == null) { document.DocumentBinary = new RVWDocumentBinaryBEO(); } if (lsImageFilePath.Any()) { //Int64 ImportedImagesCount = 0; bool isAllFiles = false; isAllFiles = (fileType.ToLower().Equals(Constants.ALL_FILE_TYPE.ToLower())) ? true : false; foreach (string path in lsImageFilePath) { RVWExternalFileBEO textFile = null; if (CheckValidFilePathFormat(path)) { if ((isAllFiles) || (fileType.ToLower().Contains(Path.GetExtension(path).Replace(Constants.STR_DOT, string.Empty).ToLower()))) // Allows the user to select the type of images to import { textFile = new RVWExternalFileBEO { Type = Constants.IMAGE_FILE_TYPE, Path = path }; document.DocumentBinary.FileList.Add(textFile); #region Missing Images if (!File.Exists(path)) //Missing Image File { missingImageFiles.Add(path); } #endregion } } else //Missing Image File { missingImageFiles.Add(path); } } importedImagesCount = lsImageFilePath.Count - missingImageFiles.Count; } } } #endregion #region Text File (Content File) if (m_JobParameter.LoadFile.ContentFile != null) { string txtFilePath = string.Empty; string contentFilePath = string.Empty; if (m_JobParameter.LoadFile.ContentFile.TextExtractionOption != LoadFileTextExtractionOption.NoTextImport) { if (m_JobParameter.LoadFile.ContentFile.TextExtractionOption == LoadFileTextExtractionOption.LoadFileField) { if (fields.Count() > Convert.ToInt32(m_JobParameter.LoadFile.ContentFile.LoadFileContentField)) txtFilePath = (fields[Convert.ToInt32(m_JobParameter.LoadFile.ContentFile.LoadFileContentField)] != string.Empty) ? fields[Convert.ToInt32(m_JobParameter.LoadFile.ContentFile.LoadFileContentField)] : string.Empty; if (!string.IsNullOrEmpty(txtFilePath) && txtFilePath.IndexOfAny(Path.GetInvalidPathChars()) == -1) //Check Valid file path { if (CheckValidFilePathFormat(txtFilePath)) //Check its a file or not { if (!string.IsNullOrEmpty(m_JobParameter.LoadFile.ContentFile.FolderLocation)) { txtFilePath = m_JobParameter.LoadFile.ContentFile.FolderLocation + Constants.BackSlash + txtFilePath; } if (m_JobParameter.LoadFile.ContentFile.TextFilePathSubstitution != null) { FilePathSubstitutionBEO txtFilePathSubstitution = m_JobParameter.LoadFile.ContentFile.TextFilePathSubstitution; contentFilePath = PathSubstituion(txtFilePath, txtFilePathSubstitution); } else { //Construct Absolute Path for Relative Path contentFilePath = ConstructAbsolutePath(txtFilePath, m_SourceFile.OriginalString); } } else { if (missingContentFiles != null) { missingContentFiles.Add(txtFilePath); } isMissingContent = true; } } else { if (missingContentFiles != null) { missingContentFiles.Add(txtFilePath); } isMissingContent = true; } } else if (m_JobParameter.LoadFile.ContentFile.TextExtractionOption == LoadFileTextExtractionOption.HelperFile) { if (textFileList != null && textFileList.Count > 0) { if (textFileList.Count == 1) contentFilePath = textFileList.First(); else { //Create single text file after fetch content from multiple text file StringBuilder sbFilePath = new StringBuilder(); if (m_DatasetPath.EndsWith(Constants.BackSlash)) { sbFilePath.Append(m_DatasetPath); } else { sbFilePath.Append(m_DatasetPath); sbFilePath.Append(Constants.BackSlash); } sbFilePath.Append(Guid.NewGuid().ToString().Replace("-", "").ToUpper()); sbFilePath.Append(DateTime.UtcNow.ToString(Constants.DateFormat)); sbFilePath.Append(Constants.TextFileExtension); string filePath = sbFilePath.ToString(); CreateSingleContentFile(textFileList, filePath, missingContentFiles); contentFilePath = filePath; if (missingContentFiles != null && missingContentFiles.Count > 0) //Capture log for missing content file. { isMissingContent = true; } } } } else if (m_JobParameter.LoadFile.ContentFile.TextExtractionOption == LoadFileTextExtractionOption.BodyTextField) { if (null != textFileList && textFileList.Any()) { contentFilePath = textFileList[0]; } } else if (m_JobParameter.LoadFile.ContentFile.TextExtractionOption == LoadFileTextExtractionOption.TextFromFolderLocation) { string filename = string.Empty; string fieldValueToSearchFile = string.Empty; if (m_JobParameter.LoadFile != null && m_JobParameter.LoadFile.ContentFile.MatchingFieldIdForFileName > -1) { fieldValueToSearchFile = GetFieldValues(fields, m_FieldRowDelimiter, m_JobParameter.LoadFile.ContentFile.MatchingFieldIdForFileName); } if (!string.IsNullOrEmpty(m_JobParameter.LoadFile.ContentFile.FolderLocation) && !string.IsNullOrEmpty(fieldValueToSearchFile)) { filename = string.Format("{0}.txt", fieldValueToSearchFile); var files = Directory.GetFiles(m_JobParameter.LoadFile.ContentFile.FolderLocation, filename, SearchOption.AllDirectories); if (files.Any()) { contentFilePath = files.LastOrDefault(); } else { if (missingContentFiles != null && !string.IsNullOrEmpty(filename)) { missingContentFiles.Add(filename); } isMissingContent = true; } } else { isMissingContent = true; } } // Checks in below statement 1) null check on "file path" and 2) are there any external files if (document.DocumentBinary == null) { document.DocumentBinary = new RVWDocumentBinaryBEO(); } if (!string.IsNullOrEmpty(contentFilePath)) { if (CheckValidFilePathFormat(contentFilePath) && File.Exists(contentFilePath)) { RVWExternalFileBEO textFile = new RVWExternalFileBEO { Type = Constants.TEXT_FILE_TYPE, Path = contentFilePath }; document.DocumentBinary.FileList.Add(textFile); } else { missingContentFiles.Add(contentFilePath); isMissingContent = true; } } } } #endregion #region Field Mapping if (m_JobParameter.FieldMapping != null) { List<FieldMapBEO> mappedFields = m_JobParameter.FieldMapping; foreach (FieldMapBEO mappedField in mappedFields) { string fieldValue = string.Empty; FieldBEO field = m_Dataset.DatasetFieldList.FirstOrDefault(f => f.ID.Equals(mappedField.DatasetFieldID)); if (null == field) { continue; } var dataTypeId = (field.FieldType != null) ? field.FieldType.DataTypeId : 0; if (fields.Count() > mappedField.SourceFieldID && fields.Length > mappedField.SourceFieldID) fieldValue = (fields[mappedField.SourceFieldID] != string.Empty) ? fields[mappedField.SourceFieldID].Replace(m_FieldRowDelimiter.ToString(), m_ConcordanceFieldSplitter) : string.Empty; // To maintain Equiset value as unique within a collection. Will append unique identifier with Equiset Value // E.g : Equiset value in .DAT file :126 // Imported in EV : UniqueIdentifier_126 if (!string.IsNullOrEmpty(mappedField.DatasetFieldName) && mappedField.DatasetFieldName.ToLower() == EVSystemFields.ND_FamilyID.ToLower() && !string.IsNullOrEmpty(fieldValue)) { fieldValue = string.Format("{0}_{1}", m_ThreadingConstraint, fieldValue); } if (dataTypeId == Constants.DateFieldTypeId) { DateTime dateFieldValue; DateTime.TryParse(fieldValue, out dateFieldValue); if (dateFieldValue == DateTime.MinValue || dateFieldValue == DateTime.MaxValue) { misMatchedFields.Add(string.Format(Constants.MisMatchedToWrongData, field.Name)); misMatchedFieldsMessage.Add(string.Format(Constants.MsgMismatchedFile, field.Name)); } } // Create a Field Business Entity for each mapped field RVWDocumentFieldBEO fieldBeo = new RVWDocumentFieldBEO() { // set required properties / field data FieldId = mappedField.DatasetFieldID, FieldName = mappedField.DatasetFieldName, FieldValue = fieldValue, FieldType = new FieldDataTypeBusinessEntity() { DataTypeId = dataTypeId } }; // Add Field to the document document.FieldList.Add(fieldBeo); } // End of loop through fields in a document. } #endregion #region Overlay Matching Condition // Assign Field value. if (!m_JobParameter.IsAppend && m_JobParameter.OverlayKeys != null) { List<FieldMapBEO> overlayMatchingKeyFields = m_JobParameter.OverlayKeys; matchingKeyField = new List<RVWDocumentFieldBEO>(); foreach (FieldMapBEO mappedField in overlayMatchingKeyFields) { string fieldValue = string.Empty; if (fields.Count() > mappedField.SourceFieldID) fieldValue = (fields[mappedField.SourceFieldID] != string.Empty) ? fields[mappedField.SourceFieldID] : string.Empty; // Create a Field Business Entity for each mapped field RVWDocumentFieldBEO fieldBEO = new RVWDocumentFieldBEO() { // set required properties / field data FieldId = mappedField.DatasetFieldID, FieldName = mappedField.DatasetFieldName, FieldValue = fieldValue }; // Add Field to the document matchingKeyField.Add(fieldBEO); } } #endregion return document; }
/// <summary> /// Set Load file realtionship field values for each document /// </summary> /// <param name="fields"></param> /// <param name="fieldRowDelimiter"></param> /// <param name="document"></param> private void SetLoadFileRelationShipInformation(string[] fields, char fieldRowDelimiter, RVWDocumentBEO document) { if (m_JobParameter.FamilyRelations != null && m_JobParameter.IsImportFamilyRelations) { int childDocumentFieldId = m_JobParameter.FamilyRelations.DocId; int parentDocumentFieldId = m_JobParameter.FamilyRelations.ParentDocId; bool isParentIdRange = m_JobParameter.FamilyRelations.IsParentDocIDFormatRange; bool isDocumentIdRange = m_JobParameter.FamilyRelations.IsDocIDFormatRange; document.EVInsertSystemRelationShipFields = true; if (fields.Length > childDocumentFieldId && fields.Length > parentDocumentFieldId) { //Document Id string docid = string.Empty; if (fields.Count() > childDocumentFieldId) { docid = GetFieldValue(fields[childDocumentFieldId], fieldRowDelimiter, isDocumentIdRange); } document.EVLoadFileDocumentId = docid; //Parent Id string parentId = string.Empty; if (fields.Count() > parentDocumentFieldId) { parentId = GetFieldValue(fields[parentDocumentFieldId], fieldRowDelimiter, isParentIdRange); } document.EVLoadFileParentId = parentId; //Tracer.Warning("OLD: OriginalDocumentId = {0}, OriginalParentId = {1}", // document.EVLoadFileDocumentId, document.EVLoadFileParentId); } } }
private bool DumpTextToFile(RVWDocumentBEO rVwDocumentBEO, string contentText, JobWorkerLog<DcbParserLogInfo> dcbParserLogEntry) { TextFileFolder.ShouldNotBe(null); if (string.IsNullOrEmpty(contentText)) return true; string filePath = Path.Combine(TextFileFolder, rVwDocumentBEO.DocumentId + Constants.FileExtension); File.AppendAllText(filePath, contentText); if (rVwDocumentBEO.DocumentBinary == null) { rVwDocumentBEO.DocumentBinary = new RVWDocumentBinaryBEO(); } RVWExternalFileBEO textFile = new RVWExternalFileBEO { Type = TEXT_FILE_TYPE, Path = filePath }; rVwDocumentBEO.DocumentBinary.FileList.Add(textFile); return true; }
private List<DocumentCommentBEO> FetchComments(RVWDocumentBEO rVwDocumentBEO, Document currentDcbDocument, DcbDocumentTags dcbDocumentTags) { List<DocumentCommentBEO> documentCommentBEOList = new List<DocumentCommentBEO>(); try { foreach (NoteRecord2 dcbnotes in currentDcbDocument.Notes) { DocumentCommentBEO comment = new DocumentCommentBEO { DocumentId = rVwDocumentBEO.DocumentId, CollectionId = new Guid(DcbOpticonJobBEO.TargetDatasetId), MatterId = Convert.ToInt64(DcbOpticonJobBEO.MatterId), MetadataTypeVersionId = Constants.One }; FieldMapBEO fieldmap = DcbOpticonJobBEO.FieldMappings.Find(o => (o.SourceFieldID == dcbnotes.LinkFieldCode)); if (null != fieldmap) { comment.Comment.FieldId = fieldmap.DatasetFieldID; comment.MetadataType = MetadataType.TextLevelComments; Field fld = currentDcbDocument.FieldItems.Find(o => o.Code == fieldmap.SourceFieldID); int startindex = 0; if (DcbOpticonJobBEO.ContentFields.Field.Contains(fld.Name)) { foreach (string contentfld in DcbOpticonJobBEO.ContentFields.Field) { if (contentfld.Equals(fld.Name)) { break; } else { if (!String.IsNullOrEmpty(fld.Value)) startindex = startindex + Regex.Replace(fld.Value, "\r\n", "\n").Length; } } } JsonComment jscomment = new JsonComment { FieldId = Convert.ToString(fieldmap.DatasetFieldID), IndexInDocument = Convert.ToString(startindex + dcbnotes.LinkOffset), SelectedText = Regex.Replace(fld.Value, Constants.ReturnAndNewLineFeed, Constants.NewLineFeed).Substring( dcbnotes.LinkOffset, dcbnotes.LinkLength) }; jscomment.SelectedText = Regex.Replace(jscomment.SelectedText, Constants.NewLineFeed, Constants.HtmlBreakWithNewLine); JavaScriptSerializer serializer = new JavaScriptSerializer(); comment.Comment.SelectedText = serializer.Serialize(jscomment); comment.SequenceId = 0; comment.VersionId = 0; comment.Comment.Comment = dcbnotes.Text; comment.Comment.FontSize = int.Parse(ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontSize)); comment.Comment.FontName = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFont); comment.Comment.Color = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontColor); string createdByGuid = String.Empty; if (null != ProfileBEO && null != ProfileBEO.CreatedBy) { createdByGuid = ProfileBEO.CreatedBy; } comment.CreatedBy = createdByGuid; comment.ModifiedBy = createdByGuid; documentCommentBEOList.Add(comment); if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0)) { dcbDocumentTags.compositeTagNames.AddRange(dcbnotes.Tags); } } else { if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0)) { Field fld = currentDcbDocument.FieldItems.Find(o => o.Code == dcbnotes.LinkFieldCode); StringBuilder sbTags = new StringBuilder(); foreach (string tag in dcbnotes.Tags) { sbTags.AppendFormat(" {0}, ", tag); } } } } } catch (Exception ex) { ex.Trace().Swallow(); } return documentCommentBEOList; }
/// <summary> /// Method to import document images /// </summary> /// <param name="currentDocumentId">current DocumentId</param> /// <param name="currentDcbDocument">current Dcb Document</param> /// <returns>RVWDocumentBEO entity</returns> private RVWDocumentBEO ImportDocumentImages(string currentDocumentId, Document currentDcbDocument) { RVWDocumentBEO evImageDocument = new RVWDocumentBEO(); try { if ((currentDcbDocument.Images != null) && (currentDcbDocument.Images.Count > 0)) { int imageSize = 0; evImageDocument = new RVWDocumentBEO { DocumentId = currentDocumentId, CollectionId = ImageSetId, MatterId = DcbOpticonJobBEO.MatterId }; foreach (DcbImage imageObj in currentDcbDocument.Images) { RVWExternalFileBEO rvwExternalfilebeo = new RVWExternalFileBEO { Path = imageObj.ImageData.FullImagePath, Type = Constants.Image }; evImageDocument.DocumentBinary.FileList.Add(rvwExternalfilebeo); if (File.Exists(rvwExternalfilebeo.Path)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(rvwExternalfilebeo.Path); if (fileInfo != null) { imageSize += (int) Math.Ceiling(fileInfo.Length/Constants.KBConversionConstant); } } } #region Assertion evImageDocument.DocumentBinary.FileList.ShouldNotBe(null); evImageDocument.DocumentBinary.FileList.Count.ShouldBeGreaterThan(0); #endregion string createdByGuid = String.Empty; if (null != ProfileBEO && null != ProfileBEO.CreatedBy) { createdByGuid = ProfileBEO.CreatedBy; } evImageDocument.CreatedBy = createdByGuid; evImageDocument.ModifiedBy = createdByGuid; evImageDocument.MimeType = string.Empty; evImageDocument.FileName = string.Empty; evImageDocument.NativeFilePath = string.Empty; evImageDocument.FileExtension = string.Empty; evImageDocument.FileSize = imageSize; return evImageDocument; } } catch (Exception ex) { ex.Trace().Swallow(); } return null; }
/// <summary> /// To get the missing content files. /// </summary> /// <param name="document"></param> /// <param name="isMissingContent"></param> /// <returns></returns> private IEnumerable<string> GetMissingContentFiles(RVWDocumentBEO document, out bool isMissingContent) { isMissingContent = false; var missingContentFiles = new List<string>(); if (document.DocumentBinary == null) return missingContentFiles; if (_jobParams.IsImportTextOCR) { var textFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.TEXT_FILE_TYPE); var textPriority = _jobParams.TextImportOrder.Select(item => item.Replace(" ", string.Empty).ToLower()).ToList(); if (textFiles.Any()) { var matchText = string.Empty; //Loop through each priority text and find the available content text file foreach (var pText in textPriority) { var textFile = textFiles.Find(t => t.Text.ToLower().Equals(pText)); if (textFile == null) continue; if (string.IsNullOrWhiteSpace(textFile.Path) || !File.Exists(textFile.Path)) continue; matchText = textFile.Text; break; } //Removing the other text files from FileList when the priority is met document.DocumentBinary.FileList.RemoveAll( x => x.Type == Constants.TEXT_FILE_TYPE && !string.IsNullOrEmpty(x.Text) && x.Text.ToLower() != matchText.ToLower()); //Set as missing content file when the priority text file is not found. var contentFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.TEXT_FILE_TYPE); if (!contentFiles.Any()) { isMissingContent = true; missingContentFiles.AddRange(from textFile in textFiles where !string.IsNullOrEmpty(textFile.Path) select textFile.Path); } } } else { document.DocumentBinary.FileList.RemoveAll(x => x.Type == Constants.TEXT_FILE_TYPE); } return missingContentFiles; }
private void AddComments(DocumentDetail documentDetail, RVWDocumentBEO rVwDocumentBEO, Document currentDcbDocument) { if (!DcbOpticonJobBEO.IncludeNotes || null == currentDcbDocument.Notes || currentDcbDocument.Notes.Count == 0) { return; } DcbDocumentTags dcbDocumentTags = new DcbDocumentTags { compositeTagNames = new List<string>(), DatasetId = DcbOpticonJobBEO.TargetDatasetId, MatterId = DcbOpticonJobBEO.MatterId, DocumentId = rVwDocumentBEO.DocumentId }; List<DocumentCommentBEO> comments = FetchComments(rVwDocumentBEO, currentDcbDocument, dcbDocumentTags); if (null == documentDetail.DcbComments) { documentDetail.DcbComments = new List<DocumentCommentBEO>(); } documentDetail.DcbComments = comments; if (dcbDocumentTags.compositeTagNames.Count == 0) { return; // Notes don't contain any tags } if (null == documentDetail.DcbTags) { documentDetail.DcbTags = new List<DcbTags>(); } documentDetail.DcbTags.Add(dcbDocumentTags); }
/// <summary> /// To get the overlay documents /// </summary> /// <param name="document"></param> /// <param name="documentDetailList"></param> /// <param name="correlationId"></param> private void GetOverlayDocuments(RVWDocumentBEO document, List<DocumentDetail> documentDetailList, string correlationId) { var doc = new DocumentDetail { document = document, ConversationIndex = document.ConversationIndex }; //Create a unique file name for content file doc.document.DocumentBinary.FileList.ForEach( x => x.Path = (x.Type.ToLower() == Constants.TEXT_FILE_TYPE.ToLower()) ? string.Format("{0}?id={1}", x.Path, Guid.NewGuid().ToString()/*.Replace("-", "").ToUpper()*/) : x.Path); doc.CorrelationId = correlationId; var lawDocId = _datasetDetails.DatasetFieldList.FirstOrDefault(x => x.Name.Equals(LawDocumentId)); if (lawDocId != null) { // Create a Field Business Entity for each mapped field var matchingField = new RVWDocumentFieldBEO { // set required properties / field data FieldId = lawDocId.ID, FieldName = lawDocId.Name, FieldValue = document.LawDocumentId.ToString(CultureInfo.InvariantCulture) }; doc.OverlayMatchingField = new List<RVWDocumentFieldBEO> { matchingField }; } doc.ParentDocId = document.FamilyId; documentDetailList.Add(doc); }
/// <summary> /// Clear except image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <param name="collectionId"></param> /// <returns></returns> private static RVWDocumentBEO GetDocumentForImageSet(RVWDocumentBEO document, string collectionId) { var imageSetDocument = CopyDocumentObject(document, false); if (imageSetDocument.DocumentBinary.FileList != null && imageSetDocument.DocumentBinary.FileList.Count > 0) { List<RVWExternalFileBEO> imagefileList = imageSetDocument.DocumentBinary.FileList.Where(x => x.Type.ToLower().Equals(Constants.IMAGE_FILE_TYPE.ToLower())).ToList(); imageSetDocument.DocumentBinary.FileList.Clear(); imagefileList.ForEach(x => imageSetDocument.DocumentBinary.FileList.Add(x)); } //Set Imageset Collection Id. imageSetDocument.CollectionId = collectionId; //Clear Field Mapping imageSetDocument.FieldList.Clear(); //Clear Native File Info imageSetDocument.MimeType = string.Empty; imageSetDocument.FileName = string.Empty; imageSetDocument.NativeFilePath = string.Empty; imageSetDocument.FileExtension = string.Empty; imageSetDocument.FileSize = 0; if (!string.IsNullOrEmpty(document.DocumentControlNumber)) imageSetDocument.DocumentControlNumber = document.DocumentControlNumber; return imageSetDocument; }
/// <summary> /// Gets documents from EDRM file /// </summary> /// <returns> List of Document Business Entities </returns> public virtual List<RVWDocumentBEO> GetDocuments() { List<RVWDocumentBEO> documents = new List<RVWDocumentBEO>(); // Loop through documents and extract fields and file details. foreach (DocumentEntity edrmDocument in edrmEntity.BatchEntity.DocumentEntity) { RVWDocumentBEO rvwDocumentBEO = new RVWDocumentBEO(); // Transform "EDRM document entity" to EV's Document BEO // This function doesn't set field data // Field data is set separately as there are two variances of this operation. // 1) set all fields available in the EDRM file // 2) set mapped fields only. TransformEDRMDocumentEntityToDocumentBusinessEntity(ref rvwDocumentBEO, edrmDocument); // Set field data - set all fields available in the EDRM file. #region Add all fields from EDRM file foreach (RVWDocumentFieldBEO rvwDocumentFieldBEO in edrmDocument.Tags.Select(tagEntity => new RVWDocumentFieldBEO { FieldName = tagEntity.TagName, FieldValue = tagEntity.TagValue })) { rvwDocumentBEO.FieldList.Add(rvwDocumentFieldBEO); } #endregion documents.Add(rvwDocumentBEO); } return documents; }
public RVWDocumentBEO ConsturctDocument(string correlationId, RVWDocumentBEO document, out JobWorkerLog<LawImportLogInfo> logs) { int importedImagesCount; document.CollectionId = _jobParams.CollectionId; document.MatterId = _jobParams.MatterId; document.CreatedBy = _jobParams.CreatedBy; document.ImportDescription = _jobParams.ImportDetail; bool isMissingContent; SetFamilyRelationshipIds(document); #region Native File var missingNativeFile = GetMissingNativeFiles(document); #endregion #region Image File var missingImageFiles = GetMissingImageFiles(document, out importedImagesCount); #endregion #region Text File (Content File) if (_jobParams != null) { if (!_datasetDetails.DatasetFieldList.Any(f => f.FieldType.DataTypeId == 2000 && f.Name == _jobParams.FieldNameToPopulateText)) { document.CustomFieldToPopulateText = _jobParams.FieldNameToPopulateText; } } var missingContentFiles = GetMissingContentFiles(document, out isMissingContent); #endregion logs = ConstructLog(correlationId, document.DocumentId, missingNativeFile, missingImageFiles, isMissingContent, missingContentFiles, importedImagesCount, document.DocumentControlNumber, document.CrossReferenceFieldValue); return document; }
/// <summary> /// Transform "EDRM document entity" to EV's Document BEO /// This function doesn't set field data /// Field data is set separately as there are two variances of this operation. </summary> /// 1) set all fields available in the EDRM file<param name="rvwDocumentBEO"></param> /// 2) set mapped fields only. /// </summary> /// <param name="rvwDocumentBEO"> Document Business Entity, by reference so that the transformed data is updated in this object. </param> /// <param name="edrmDocument"> EDRM document entity which is going tobe transformed to EV Document Business Entity. </param> protected virtual void TransformEDRMDocumentEntityToDocumentBusinessEntity(ref RVWDocumentBEO rvwDocumentBEO, DocumentEntity edrmDocument) { // Initialize if the object is not created if (rvwDocumentBEO == null) rvwDocumentBEO = new RVWDocumentBEO(); // Document ID is MD5 hash of EDRM file + EDRM Document ID. // This makes document unique in the system and identifies if same EDRM file attempted to be imported twice. // Special character to rvwDocumentBEO.DocumentId = GetDocumentId(edrmDocument); // Set MIME type rvwDocumentBEO.MimeType = edrmDocument.MIMEType; #region Add associate file details/names from EDRM file // NOTES: // Binary and text is set later by the consuming module. This is to reduce weight of objects // Binary and text could increase memory by great extent. foreach (FileEntity fileEntity in edrmDocument.Files) { // Check if type is native if (fileEntity.FileType.ToLower().Equals(Constants.EDRMAttributeNativeFileType.ToLower())) { // Set file path for native file types. // Condition - check if native file entity has external file entities in it or not. if (fileEntity.ExternalFile != null) { // Checks in below statement 1) null check on "file path" and 2) are there any external files rvwDocumentBEO.FileName = (fileEntity.ExternalFile.Count > 0) ? fileEntity.ExternalFile[0].FileName : string.Empty; rvwDocumentBEO.NativeFilePath = (fileEntity.ExternalFile.Count > 0) ? CreateFileURI(fileEntity.ExternalFile[0].FilePath, fileEntity.ExternalFile[0].FileName) : string.Empty; rvwDocumentBEO.FileExtension = (fileEntity.ExternalFile.Count > 0) ? fileEntity.ExternalFile[0].FileName.Substring(fileEntity.ExternalFile[0].FileName.LastIndexOf(".")) : string.Empty; if (!string.IsNullOrEmpty(rvwDocumentBEO.NativeFilePath) && File.Exists(rvwDocumentBEO.NativeFilePath)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(rvwDocumentBEO.NativeFilePath); rvwDocumentBEO.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); } } } // Check if the type is Text. if (fileEntity.FileType.ToLower().Equals(Constants.EDRMAttributeTextFileType.ToLower())) { if (fileEntity.ExternalFile != null) { // For text set file details in TextContent property. Set the real text just before import. // This is to help reduce weight of the object. // Checks in below statement 1) null check on "file path" and 2) are there any external files if (rvwDocumentBEO.DocumentBinary == null) { rvwDocumentBEO.DocumentBinary = new RVWDocumentBinaryBEO(); } RVWExternalFileBEO textFile = new RVWExternalFileBEO { Type = Constants.EDRMAttributeTextFileType, Path = (fileEntity.ExternalFile.Count > 0) ? CreateFileURI(fileEntity.ExternalFile[0].FilePath, fileEntity.ExternalFile[0].FileName) : string.Empty }; rvwDocumentBEO.DocumentBinary.FileList.Add(textFile); } } } #endregion }
/// <summary> /// To set family id and document relationship. /// </summary> /// <param name="document"></param> private void SetFamilyRelationshipIds(RVWDocumentBEO document) { if (!_jobParams.CreateFamilyGroups) return; document.EVInsertSystemRelationShipFields = true; document.EVLoadFileDocumentId = document.LawDocumentId.ToString(CultureInfo.InvariantCulture); document.EVLoadFileParentId = document.FamilyId; }
/// <summary> /// Transforms EDRM fields to list of EV Document field Business entities /// </summary> /// <param name="rvwDocumentBEO"> call by reference - Document object for which fields to be updated. </param> /// <param name="edrmDocument"> EDRM document object </param> /// <param name="mappedFields"> fields mapped while scheduling import. </param> protected virtual void TransformEDRMFieldsToDocumentFields(ref RVWDocumentBEO rvwDocumentBEO, DocumentEntity edrmDocument, List<FieldMapBEO> mappedFields) { #region Add all mapped fields foreach (FieldMapBEO mappedField in mappedFields) { //Create a Tag Entity for each mapped field TagEntity tag = new TagEntity(); // Get tag/field from EDRM file for give mapped field IEnumerable<TagEntity> tagEnumerator = edrmDocument.Tags.Where(p => p.TagName.Equals(mappedField.SourceFieldName, StringComparison.CurrentCultureIgnoreCase)); if (tagEnumerator.Count<TagEntity>() > 0) { tag = tagEnumerator.First<TagEntity>(); } // Adding Field map information only if Tag Value is available. // Create a Field business Entity for each mapped field RVWDocumentFieldBEO fieldBEO = new RVWDocumentFieldBEO() { // set required properties / field data FieldId = mappedField.DatasetFieldID, FieldName = mappedField.DatasetFieldName, FieldValue = tag.TagValue ?? string.Empty, FieldType = new FieldDataTypeBusinessEntity() { DataTypeId = mappedField.DatasetFieldTypeID } }; // Add tag to the document rvwDocumentBEO.FieldList.Add(fieldBEO); } // End of loop through fields in a document. #endregion }
//To get the missing native files private string GetMissingNativeFiles(RVWDocumentBEO document) { string missingNativeFile = null; if (document.DocumentBinary == null) return null; if (_jobParams.IsImportNative) { var nativeFile = document.DocumentBinary.FileList.Find(x => x.Type == Constants.NATIVE_FILE_TYPE); if (nativeFile != null) { var nativeFilePath = nativeFile.Path; var extension = Path.GetExtension(nativeFilePath); if (extension != null) document.MimeType = GetMimeType(extension.Replace(".", "")); // Remove MimeType document.FileName = Path.GetFileNameWithoutExtension(nativeFilePath); document.NativeFilePath = nativeFilePath; nativeFile.Type = Constants.NATIVE_FILE_TYPE; nativeFile.Path = document.NativeFilePath; document.FileExtension = Path.GetExtension(nativeFilePath); if (File.Exists(nativeFilePath)) { //Calculating size of file in KB var fileInfo = new FileInfo(nativeFilePath); document.FileSize = (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); document.MD5HashValue = DocumentHashHelper.GetMD5HashValue(nativeFilePath); document.SHAHashValue = DocumentHashHelper.GetSHAHashValue(nativeFilePath); } else //Missing Native File { missingNativeFile = nativeFilePath; } } } else { document.DocumentBinary.FileList.RemoveAll(x => x.Type == Constants.NATIVE_FILE_TYPE); } return missingNativeFile; }
/// <summary> /// To get the text file path. /// </summary> /// <param name="document"></param> /// <returns></returns> public static string GetTextFilePath(RVWDocumentBEO document) { var textFilePath = string.Empty; if (document == null || document.DocumentBinary == null || document.DocumentBinary.FileList == null || !document.DocumentBinary.FileList.Any()) return textFilePath; // Get text file from external file list var txtFile = document.DocumentBinary.FileList.FirstOrDefault (x => x.Type.Equals(Constants.TEXT_FILE_TYPE, StringComparison.InvariantCultureIgnoreCase) || x.Type.Equals("1")); if (txtFile == null || string.IsNullOrEmpty(txtFile.Path)) return textFilePath; textFilePath = txtFile.Path; if (textFilePath.Contains('?')) { textFilePath = textFilePath.Substring(0, (textFilePath.IndexOf('?'))); } return textFilePath; }
/// <summary> /// To get the missing image files /// </summary> /// <param name="document"></param> /// <param name="importedImagesCount"></param> /// <returns></returns> private List<string> GetMissingImageFiles(RVWDocumentBEO document, out int importedImagesCount) { importedImagesCount = 0; var missingImageFiles = new List<string>(); if (_jobParams.IsImportImages && document.DocumentBinary != null) { var imageFiles = document.DocumentBinary.FileList.FindAll(x => x.Type == Constants.IMAGE_FILE_TYPE); if (imageFiles.Any()) { missingImageFiles.AddRange(from image in imageFiles where !string.IsNullOrWhiteSpace(image.Path) && !File.Exists(image.Path) select image.Path); importedImagesCount = imageFiles.Count() - missingImageFiles.Count(); } } return missingImageFiles; }
/// <summary> /// Clear image file information in DocumentBEO /// </summary> /// <param name="document"></param> /// <returns></returns> private static RVWDocumentBEO GetNativeDocument(RVWDocumentBEO document) { var nativeSetDocument = CopyDocumentObject(document, true); var fileList = nativeSetDocument.DocumentBinary.FileList.Where( x => x.Type.ToLower() != Constants.IMAGE_FILE_TYPE.ToLower()).ToList(); nativeSetDocument.DocumentBinary.FileList.Clear(); if (fileList.Any()) { fileList.ForEach(x => nativeSetDocument.DocumentBinary.FileList.Add(x)); nativeSetDocument.DocumentBinary.FileList.ForEach( x => x.Path = (x.Type == Constants.TEXT_FILE_TYPE) ? string.Format("{0}?id={1}", x.Path, Guid.NewGuid().ToString()/*.Replace("-", "").ToUpper()*/) : x.Path); } if (document.DocumentBinary != null) { if (!string.IsNullOrEmpty(document.DocumentBinary.Content)) //Assign Content Value { nativeSetDocument.DocumentBinary.Content = document.DocumentBinary.Content; } } return nativeSetDocument; }
/// <summary> /// Clear except image file information in DocumentBEO /// </summary> /// <param name="document">document</param> /// <param name="collectionId">CollectionId</param> /// <returns>RVWDocumentBEO</returns> private RVWDocumentBEO GetDocumentForImageSet(RVWDocumentBEO document, string collectionId) { document.ShouldNotBe(null); collectionId.ShouldNotBe(null); var imageSetDocument = CopyDocumentObject(document, false); int imageSize = 0; if (imageSetDocument.DocumentBinary.FileList != null && imageSetDocument.DocumentBinary.FileList.Count > 0) { List<RVWExternalFileBEO> imagefileList = imageSetDocument.DocumentBinary.FileList.Where(x => x.Type.ToLower().Equals(Constants.IMAGE_FILE_TYPE.ToLower())).ToList(); imageSetDocument.DocumentBinary.FileList.Clear(); imagefileList.ForEach(x => imageSetDocument.DocumentBinary.FileList.Add(x)); foreach (var docFile in imageSetDocument.DocumentBinary.FileList) { if (File.Exists(docFile.Path)) { //Calculating size of file in KB FileInfo fileInfo = new FileInfo(docFile.Path); if (fileInfo != null) { imageSize += (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); } } } } //Set Imageset Collection Id. imageSetDocument.CollectionId = collectionId; //Clear Field Mapping imageSetDocument.FieldList.Clear(); //Clear Native File Info imageSetDocument.MimeType = string.Empty; imageSetDocument.FileName = string.Empty; imageSetDocument.NativeFilePath = string.Empty; imageSetDocument.FileExtension = string.Empty; imageSetDocument.FileSize = imageSize; return imageSetDocument; }
/// <summary> /// Clear except image file information in DocumentBEO /// </summary> /// <param name="document">document</param> /// <param name="collectionId">CollectionId</param> /// <returns>RVWDocumentBEO</returns> private static RVWDocumentBEO GetImageDocuments(RVWDocumentBEO document, string collectionId) { document.ShouldNotBe(null); collectionId.ShouldNotBe(null); var imageSetDocument = CopyDocumentObject(document, false); var imageSize = 0; if (imageSetDocument.DocumentBinary.FileList != null && imageSetDocument.DocumentBinary.FileList.Count > 0) { var imagefileList = imageSetDocument.DocumentBinary.FileList.Where( x => x.Type.ToLower().Equals(Constants.IMAGE_FILE_TYPE.ToLower()) && !String.IsNullOrEmpty(x.Path) ).ToList(); imageSetDocument.DocumentBinary.FileList.Clear(); imagefileList.ForEach(x => imageSetDocument.DocumentBinary.FileList.Add(x)); imageSize += (from docFile in imageSetDocument.DocumentBinary.FileList where File.Exists(docFile.Path) select new FileInfo(docFile.Path) into fileInfo where fileInfo != null select (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant)).Sum(); } //Set Imageset Collection Id. imageSetDocument.CollectionId = collectionId; //Clear Field Mapping imageSetDocument.FieldList.Clear(); //Clear Native File Info imageSetDocument.MimeType = string.Empty; imageSetDocument.FileName = string.Empty; imageSetDocument.NativeFilePath = string.Empty; imageSetDocument.FileExtension = string.Empty; imageSetDocument.FileSize = imageSize; return imageSetDocument; }
/// <summary> /// Copy Document Object /// </summary> /// <param name="document"></param> /// <param name="isNativeDoc"></param> /// <returns></returns> private static RVWDocumentBEO CopyDocumentObject(RVWDocumentBEO document, bool isNativeDoc) { var documentsetDocument = new RVWDocumentBEO { CollectionId = document.CollectionId, MatterId = document.MatterId, CreatedBy = document.CreatedBy, Id = document.Id, DocumentId = document.DocumentId, MimeType = document.MimeType, FileName = document.FileName, NativeFilePath = document.NativeFilePath, FileExtension = document.FileExtension, FileSize = document.FileSize, DocumentControlNumber = document.DocumentControlNumber, ImportDescription = document.ImportDescription, CustomFieldToPopulateText = document.CustomFieldToPopulateText }; if (isNativeDoc) { documentsetDocument.LawDocumentId = document.LawDocumentId; documentsetDocument.EVLoadFileDocumentId = document.EVLoadFileDocumentId; documentsetDocument.EVLoadFileParentId = document.EVLoadFileParentId; documentsetDocument.EVInsertSystemRelationShipFields = document.EVInsertSystemRelationShipFields; } if (!string.IsNullOrEmpty(document.MD5HashValue)) documentsetDocument.MD5HashValue = document.MD5HashValue; if (!string.IsNullOrEmpty(document.SHAHashValue)) documentsetDocument.SHAHashValue = document.SHAHashValue; if (!string.IsNullOrEmpty(document.ImportMessage)) documentsetDocument.ImportMessage = document.ImportMessage; if (document.FieldList != null && document.FieldList.Count > 0) { document.FieldList.ForEach(x => documentsetDocument.FieldList.Add(x)); } documentsetDocument.DocumentBinary = new RVWDocumentBinaryBEO(); if (document.DocumentBinary != null) { if (document.DocumentBinary.FileList.Count > 0) //Add File List { document.DocumentBinary.FileList.ForEach(x => documentsetDocument.DocumentBinary.FileList.Add(x)); } } if (document.Tags != null && document.Tags.Any()) { document.Tags.ForEach(x => documentsetDocument.Tags.Add(x)); } if (!string.IsNullOrEmpty(document.CrossReferenceFieldValue)) { documentsetDocument.CrossReferenceFieldValue = document.CrossReferenceFieldValue; } return documentsetDocument; }
/// <summary> /// Populates the review set dcoument entity. /// </summary> /// <param name="reviewSetId">The review set id.</param> /// <param name="binderId">The binder ID.</param> /// <param name="document">The document.</param> /// <returns></returns> private static ReviewsetDocumentBEO PolulateReviewSetDcoumentEntity(string reviewSetId, string binderId, RVWDocumentBEO document, string createdBy) { ReviewsetDocumentBEO reviewsetDocument = new ReviewsetDocumentBEO { DocumentId = document.DocumentId, CollectionViewId = reviewSetId, BinderId = binderId, TotalRecordCount = document.TotalRecordCount, FamilyId = document.FamilyId, DCN = document.DocumentControlNumber, CreatedBy = createdBy }; return(reviewsetDocument); }
/// <summary> /// Copy Document Object /// </summary> /// <param name="document"></param> /// <param name="isNativeDoc"></param> /// <returns></returns> private static RVWDocumentBEO CopyDocumentObject(RVWDocumentBEO document, bool isNativeDoc) { var documentsetDocument = new RVWDocumentBEO(); documentsetDocument.CollectionId = document.CollectionId; documentsetDocument.MatterId = document.MatterId; documentsetDocument.CreatedBy = document.CreatedBy; documentsetDocument.Id = document.Id; documentsetDocument.DocumentId = document.DocumentId; documentsetDocument.MimeType = document.MimeType; documentsetDocument.FileName = document.FileName; documentsetDocument.NativeFilePath = document.NativeFilePath; documentsetDocument.FileExtension = document.FileExtension; documentsetDocument.FileSize = document.FileSize; documentsetDocument.PagesNatives = document.PagesNatives; documentsetDocument.PagesImages = document.PagesImages; documentsetDocument.CustomFieldToPopulateText = document.CustomFieldToPopulateText; documentsetDocument.LawDocumentId = document.LawDocumentId; documentsetDocument.IsImageFilesNotAssociated = document.IsImageFilesNotAssociated; if (isNativeDoc) { documentsetDocument.EVLoadFileDocumentId = document.EVLoadFileDocumentId; documentsetDocument.EVLoadFileParentId = document.EVLoadFileParentId; documentsetDocument.EVInsertSystemRelationShipFields = document.EVInsertSystemRelationShipFields; } if (!string.IsNullOrEmpty(document.MD5HashValue)) documentsetDocument.MD5HashValue = document.MD5HashValue; if (!string.IsNullOrEmpty(document.SHAHashValue)) documentsetDocument.SHAHashValue = document.SHAHashValue; if (!string.IsNullOrEmpty(document.ImportMessage)) documentsetDocument.ImportMessage = document.ImportMessage; if (document.FieldList != null && document.FieldList.Count > 0) { document.FieldList.ForEach(x => documentsetDocument.FieldList.Add(x)); } documentsetDocument.DocumentBinary = new RVWDocumentBinaryBEO(); if (document.DocumentBinary != null) { if (document.DocumentBinary.FileList.Count > 0) //Add File List { document.DocumentBinary.FileList.ForEach(x => documentsetDocument.DocumentBinary.FileList.Add(x)); } } if (!string.IsNullOrEmpty(document.CrossReferenceFieldValue)) { documentsetDocument.CrossReferenceFieldValue = document.CrossReferenceFieldValue; } return documentsetDocument; }