/// <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> /// This is the overriden Shutdown() method. /// </summary> /// <param name="jobParameters">Input settings / parameters of the job.</param> protected override void Shutdown(GlobalReplaceJobBEO jobParameters) { try { LogMessage(Constants.ShutdownLogMessage, false, LogCategory.Job, null); GetGlobalReplaceBEO(jobParameters.BootParameters); JobLogInfo.CustomMessage = Constants.JobSummary; JobLogInfo.AddParameters(Constants.JobName, Constants.JOB_NAME); JobLogInfo.AddParameters(Constants.EV_AUDIT_ACTUAL_STRING, jobParameters.ActualString); JobLogInfo.AddParameters(Constants.EV_AUDIT_REPLACE_STRING, jobParameters.ReplaceString); } catch (EVException ex) { EvLog.WriteEntry(Constants.JOB_NAME + Constants.ShutdownErrorMessage, ex.ToUserString(), EventLogEntryType.Error); LogException(jobParameters.JobId, ex, Constants.ShutdownErrorMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobExecution); } catch (Exception ex) { EvLog.WriteEntry(Constants.JOB_NAME + Constants.ShutdownErrorMessage, ex.Message, EventLogEntryType.Error); LogException(jobParameters.JobId, ex, Constants.ShutdownErrorMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobExecution); } finally { _mMatter = null; _mOrginatorField = null; } }
/// <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> /// Add Existing Fields to document /// </summary> /// <param name="docDetail"></param> /// <param name="documentResult"></param> /// <param name="misMatchedFields"></param> /// <param name="misMatchedFieldsMessage"></param> private void DocumentAddExistingFields(DocumentDetail docDetail, List <DocumentResult> documentResult, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { if (documentResult.First().Fields == null) { return; } var resultFields = documentResult.First().Fields; var docFields = docDetail.document.FieldList; foreach (var resultField in resultFields.Where(resultField => !docFields.Exists(f => f.FieldName.ToLower() == resultField.Name.ToLower()) && resultField.Name.ToLower() != "snippet")) { if (_datasetBEO.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower() && !f.IsSystemField)) { //Field id not availble in search result object, so get from datasetBEO var id = _datasetBEO.DatasetFieldList.First(f => f.Name.ToLower() == resultField.Name.ToLower()).ID; var field = new RVWDocumentFieldBEO { FieldId = id, FieldName = resultField.Name, FieldValue = resultField.Value }; //Add Fields into document object docDetail.document.FieldList.Add(field); //Need to add log for Mismatch Field only for Fields mapped during Overlay. if (_jobParams.MappingFields.Any() && _jobParams.MappingFields.Exists(f => f.Name.ToLower().Equals(resultField.Name.ToLower()))) { FieldValueValidation(field, misMatchedFields, misMatchedFieldsMessage); } } else if (!_datasetBEO.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower())) //Add Existing fields list - Need to reinsert during overlay { var field = new RVWDocumentFieldBEO { FieldName = resultField.Name, FieldValue = resultField.Value }; //Add Fields into document object if (docDetail.OverlayReImportField == null) { docDetail.OverlayReImportField = new List <RVWDocumentFieldBEO>(); } docDetail.OverlayReImportField.Add(field); } //Filling DCN field for overlay if (resultField.DataTypeId == Constants.DCNFieldType && !string.IsNullOrEmpty(resultField.Value)) { docDetail.document.DocumentControlNumber = resultField.Value; } if (string.Equals(resultField.Name, EVSystemFields.PagesNatives, StringComparison.CurrentCultureIgnoreCase)) { docDetail.document.PagesNatives = resultField.Value; } if (string.Equals(resultField.Name, EVSystemFields.PagesImages, StringComparison.CurrentCultureIgnoreCase)) { docDetail.document.PagesImages = resultField.Value; } } }
private void InitializeDefaultFields() { _evDocumentSysImportTypeField = new RVWDocumentFieldBEO { FieldId = Convert.ToInt32(DcbOpticonJobBEO.SysImportType), FieldName = EVSystemFields.ImportType, FieldValue = Constants.DCB_IMPORT_TYPE, IsSystemField = true, IsRequired = true }; if (_dataset != null) { FieldBEO contentField = _dataset.DatasetFieldList.Find(o => o.FieldType.DataTypeId == Constants.ContentFieldType); if (contentField != null) { _contentFieldId = contentField.ID; _contentFieldName = contentField.Name; } } }
private void FieldValueValidation(RVWDocumentFieldBEO documentField, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { FieldBEO field = m_Dataset.DatasetFieldList.FirstOrDefault(f => f.ID.Equals(documentField.FieldId)); if (field != null) { var dataTypeId = (field.FieldType != null) ? field.FieldType.DataTypeId : 0; if (dataTypeId == Constants.DateFieldTypeId) { DateTime dateFieldValue; DateTime.TryParse(documentField.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)); } } } }
private void FieldValueValidation(RVWDocumentFieldBEO documentField, ICollection <string> misMatchedFields, ICollection <string> misMatchedFieldsMessage) { var field = _datasetBEO.DatasetFieldList.FirstOrDefault(f => f.ID.Equals(documentField.FieldId)); if (field == null) { return; } var dataTypeId = (field.FieldType != null) ? field.FieldType.DataTypeId : 0; if (dataTypeId != Constants.DateFieldTypeId) { return; } DateTime dateFieldValue; DateTime.TryParse(documentField.FieldValue, out dateFieldValue); if (dateFieldValue != DateTime.MinValue && dateFieldValue != DateTime.MaxValue) { return; } misMatchedFields.Add(string.Format(Constants.MisMatchedToWrongData, field.Name)); misMatchedFieldsMessage.Add(string.Format(Constants.MsgMismatchedFile, field.Name)); }
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(); } } }
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> /// 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> /// Method to add removable fields /// </summary> /// <param name="documentCollection">DocumentCollection</param> /// <param name="imagesetId">string</param> /// <param name="doc">DocumentDetail</param> private void ResetRedactableFields(DocumentCollection documentCollection, string imagesetId, DocumentDetail doc) { #region Remove Tag //Removing the Tag field for overlay updated documents here. if (documentCollection.IsDeleteTagsForOverlay) { var tagField = new RVWDocumentFieldBEO { FieldName = EVSystemFields.Tag.ToLower(), FieldValue = doc.SystemTags != null && doc.SystemTags.Any() ? string.Format(EVSearchSyntax.TagValueFormat + "{0}", doc.SystemTags.First().Id) : string.Empty }; doc.document.FieldList.Add(tagField); } #endregion #region Remove Redactions In nativeSet var redactionText = EVSystemFields.RedactionText.ToLower(); var markup = EVSystemFields.MarkUp.ToLower(); if (documentCollection.IsIncludeNativeFile) { if (!doc.document.FieldList.Exists(field => field.FieldName.ToLower().Equals(redactionText))) { doc.document.FieldList.Add(new RVWDocumentFieldBEO { IsRequired = true, FieldName = redactionText, FieldValue = string.Empty }); } else { doc.document.FieldList.Where(field => field.FieldName.ToLower().Equals(redactionText)).ToList(). ForEach(x => x.FieldValue = string.Empty); } if (!doc.document.FieldList.Exists(field => field.FieldName.ToLower().Equals(markup))) { doc.document.FieldList.Add(new RVWDocumentFieldBEO { IsRequired = true, FieldName = markup, FieldValue = string.Empty }); } else { doc.document.FieldList.Where(field => field.FieldName.ToLower().Equals(markup)).ToList(). ForEach(x => x.FieldValue = string.Empty); } } #endregion #region Remove Redactions In ImageSet if (!string.IsNullOrWhiteSpace(imagesetId)) { redactionText = string.Format("{0}_{1}", imagesetId.Replace('-', '_'), redactionText); markup = string.Format("{0}_{1}", imagesetId.Replace('-', '_'), markup); if (!doc.document.FieldList.Exists(field => field.FieldName.ToLower().Equals(redactionText))) { doc.document.FieldList.Add(new RVWDocumentFieldBEO { IsRequired = true, FieldName = redactionText, FieldValue = string.Empty }); } else { doc.document.FieldList.Where(field => field.FieldName.ToLower().Equals(redactionText)) .ToList() .ForEach(x => x.FieldValue = string.Empty); } if (!doc.document.FieldList.Exists(field => field.FieldName.ToLower().Equals(markup))) { doc.document.FieldList.Add(new RVWDocumentFieldBEO { IsRequired = true, FieldName = markup, FieldValue = string.Empty }); } else { doc.document.FieldList.Where(field => field.FieldName.ToLower().Equals(markup)).ToList(). ForEach(x => x.FieldValue = string.Empty); } } #endregion }
/// <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); }
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> /// Add Existing Fields to document /// </summary> /// <param name="docDetail"></param> /// <param name="documentResult"></param> private void DocumentAddExistingFields(DocumentDetail docDetail, List <DocumentResult> documentResult, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { if (documentResult.First().Fields != null) { List <FieldResult> resultFields = documentResult.First().Fields; List <RVWDocumentFieldBEO> docFields = docDetail.document.FieldList; foreach (FieldResult resultField in resultFields) { if (!docFields.Exists(f => f.FieldName.ToLower() == resultField.Name.ToLower()) && resultField.Name.ToLower() != "snippet") { if (m_Dataset.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower() && !f.IsSystemField) || resultField.Name.ToLower().Equals(EVSystemFields.LawDocumentId.ToLower())) { //Field id not availble in search result object, so get from dataset int id = m_Dataset.DatasetFieldList.First(f => f.Name.ToLower() == resultField.Name.ToLower()).ID; RVWDocumentFieldBEO field = new RVWDocumentFieldBEO(); field.FieldId = id; field.FieldName = resultField.Name; field.FieldValue = resultField.Value; //Add Fields into document object docDetail.document.FieldList.Add(field); //Need to add log for Mismatch Field //Need to add log for Mismatch Field only for Fields mapped during Overlay. if (m_JobParameter.FieldMapping.Any() && m_JobParameter.FieldMapping.Exists(f => f.DatasetFieldName.ToLower().Equals(resultField.Name.ToLower()))) { FieldValueValidation(field, misMatchedFields, misMatchedFieldsMessage); } } else if (!m_Dataset.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower())) //Add Existing fields list - Need to reinsert during overlay { RVWDocumentFieldBEO field = new RVWDocumentFieldBEO(); field.FieldName = resultField.Name; field.FieldValue = resultField.Value; //Add Fields into document object if (docDetail.OverlayReImportField == null) { docDetail.OverlayReImportField = new List <RVWDocumentFieldBEO>(); } docDetail.OverlayReImportField.Add(field); } } if (string.IsNullOrEmpty(resultField.Name) || string.IsNullOrEmpty(resultField.Value)) { continue; } if (resultField.Name.ToLower().Equals(EVSystemFields.ReviewSetId.ToLower())) { if (docDetail.Reviewsets == null) { docDetail.Reviewsets = new List <string>(); } docDetail.Reviewsets.Add(resultField.Value); } if (resultField.Name.ToLower().Equals(EVSystemFields.DcnField.ToLower())) { docDetail.document.DocumentControlNumber = resultField.Value; } if (string.Equals(resultField.Name, EVSystemFields.PagesNatives, StringComparison.CurrentCultureIgnoreCase)) { docDetail.document.PagesNatives = resultField.Value; } if (string.Equals(resultField.Name, EVSystemFields.PagesImages, StringComparison.CurrentCultureIgnoreCase)) { docDetail.document.PagesImages = resultField.Value; } if (string.Equals(resultField.Name, EVSystemFields.LawDocumentId, StringComparison.CurrentCultureIgnoreCase)) { docDetail.document.LawDocumentId = !string.IsNullOrEmpty(resultField.Value)?Convert.ToInt32(resultField.Value):0; } } } }
/// <summary> /// Get Field Vaule For DpnAndBates /// </summary> /// <param name="productionDocumentDetail">production document detail</param> /// <param name="fieldSelected">field Selected </param> /// <returns></returns> private void GetFieldVauleForDpnAndBates(ProductionDocumentDetail productionDocumentDetail, RVWDocumentFieldBEO fieldSelected) { switch (fieldSelected.FieldType.DataTypeId) { case (Int32)Constants.FieldTypeIds.DPN: fieldSelected.FieldValue = productionDocumentDetail.DocumentProductionNumber; break; case (Int32)Constants.FieldTypeIds.BatesBegin: fieldSelected.FieldValue = productionDocumentDetail.StartingBatesNumber; break; case (Int32)Constants.FieldTypeIds.BatesEnd: fieldSelected.FieldValue = productionDocumentDetail.EndingBatesNumber; break; case (Int32)Constants.FieldTypeIds.BatesRange: var batesRange = new StringBuilder(productionDocumentDetail.StartingBatesNumber); batesRange.Append(Constants.UnderScore); batesRange.Append(productionDocumentDetail.EndingBatesNumber); fieldSelected.FieldValue = batesRange.ToString(); break; default: fieldSelected.FieldValue = fieldSelected.FieldValue; break; } }
private void FieldValueValidation(RVWDocumentFieldBEO documentField, List<string> misMatchedFields, List<string> misMatchedFieldsMessage) { FieldBEO field = m_Dataset.DatasetFieldList.FirstOrDefault(f => f.ID.Equals(documentField.FieldId)); if (field != null) { var dataTypeId = (field.FieldType != null) ? field.FieldType.DataTypeId : 0; if (dataTypeId == Constants.DateFieldTypeId) { DateTime dateFieldValue; DateTime.TryParse(documentField.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)); } } } }
/// <summary> /// Add Existing Fields to document /// </summary> /// <param name="docDetail"></param> /// <param name="documentResult"></param> private void DocumentAddExistingFields(DocumentDetail docDetail, List<DocumentResult> documentResult, List<string> misMatchedFields, List<string> misMatchedFieldsMessage) { if (documentResult.First().Fields != null) { List<FieldResult> resultFields = documentResult.First().Fields; List<RVWDocumentFieldBEO> docFields = docDetail.document.FieldList; foreach (FieldResult resultField in resultFields) { if (!docFields.Exists(f => f.FieldName.ToLower() == resultField.Name.ToLower()) && resultField.Name.ToLower() != "snippet") { if (m_Dataset.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower() && !f.IsSystemField) || resultField.Name.ToLower().Equals(EVSystemFields.LawDocumentId.ToLower())) { //Field id not availble in search result object, so get from dataset int id = m_Dataset.DatasetFieldList.First(f => f.Name.ToLower() == resultField.Name.ToLower()).ID; RVWDocumentFieldBEO field = new RVWDocumentFieldBEO(); field.FieldId = id; field.FieldName = resultField.Name; field.FieldValue = resultField.Value; //Add Fields into document object docDetail.document.FieldList.Add(field); //Need to add log for Mismatch Field //Need to add log for Mismatch Field only for Fields mapped during Overlay. if (m_JobParameter.FieldMapping.Any() && m_JobParameter.FieldMapping.Exists(f => f.DatasetFieldName.ToLower().Equals(resultField.Name.ToLower()))) { FieldValueValidation(field, misMatchedFields, misMatchedFieldsMessage); } } else if (!m_Dataset.DatasetFieldList.Exists(f => f.Name.ToLower() == resultField.Name.ToLower())) //Add Existing fields list - Need to reinsert during overlay { RVWDocumentFieldBEO field = new RVWDocumentFieldBEO(); field.FieldName = resultField.Name; field.FieldValue = resultField.Value; //Add Fields into document object if (docDetail.OverlayReImportField == null) docDetail.OverlayReImportField = new List<RVWDocumentFieldBEO>(); docDetail.OverlayReImportField.Add(field); } } if (string.IsNullOrEmpty(resultField.Name) || string.IsNullOrEmpty(resultField.Value)) continue; if (resultField.Name.ToLower().Equals(EVSystemFields.ReviewSetId.ToLower())) { if (docDetail.Reviewsets == null) { docDetail.Reviewsets = new List<string>(); } docDetail.Reviewsets.Add(resultField.Value); } if (resultField.Name.ToLower().Equals(EVSystemFields.DcnField.ToLower())) docDetail.document.DocumentControlNumber = resultField.Value; if (string.Equals(resultField.Name, EVSystemFields.PagesNatives, StringComparison.CurrentCultureIgnoreCase)) docDetail.document.PagesNatives = resultField.Value; if (string.Equals(resultField.Name, EVSystemFields.PagesImages, StringComparison.CurrentCultureIgnoreCase)) docDetail.document.PagesImages = resultField.Value; if (string.Equals(resultField.Name, EVSystemFields.LawDocumentId, StringComparison.CurrentCultureIgnoreCase)) docDetail.document.LawDocumentId = !string.IsNullOrEmpty(resultField.Value)?Convert.ToInt32(resultField.Value):0; } } }
/// <summary> /// This is the overridden Initialize() method. /// </summary> /// <param name="jobId">Job Identifier.</param> /// <param name="jobRunId">Job Run Identifier.</param> /// <param name="bootParameters">Boot Parameters.</param> /// <param name="createdBy">string</param> /// <returns>GlobalReplaceJobBEO</returns> protected override GlobalReplaceJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { GlobalReplaceJobBEO jobBeo = null; try { LogMessage(Constants.InitializationStartMessage, false, LogCategory.Job, null); LogMessage(Constants.InitializationStartMessage, GetType(), "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.Initialize", EventLogEntryType.Information, jobId, jobRunId); // Initialize the JobBEO jobBeo = new GlobalReplaceJobBEO { JobId = jobId, JobRunId = jobRunId, JobScheduleCreatedBy = createdBy, JobTypeName = Constants.Job_TYPE_NAME, BootParameters = bootParameters, JobName = Constants.JOB_NAME, StatusBrokerType = BrokerType.Database, CommitIntervalBrokerType = BrokerType.ConfigFile, CommitIntervalSettingType = SettingType.CommonSetting }; //filling properties of the job parameter // Default settings //constructing GlobalReplaceBEO from boot parameter by de serializing GlobalReplaceBEO globalReplaceContextBeo = GetGlobalReplaceBEO(bootParameters); globalReplaceContextBeo.CreatedBy = createdBy; // Set output batch size _mTaskBatchSize = Convert.ToInt16(ApplicationConfigurationManager.GetValue(Constants.ResultsPageSize)); EvLog.WriteEntry(jobId + Constants.AUDIT_BOOT_PARAMETER_KEY, Constants.AUDIT_BOOT_PARAMETER_VALUE, EventLogEntryType.Information); jobBeo.SearchContext = globalReplaceContextBeo.SearchContext; jobBeo.ActualString = globalReplaceContextBeo.ActualString; jobBeo.ReplaceString = globalReplaceContextBeo.ReplaceString; _mOrginatorField = new RVWDocumentFieldBEO { FieldName = Constants.OrginatorFieldName, FieldValue = Guid.NewGuid().ToString(), FieldId = -1 }; _mMatter = MatterDAO.GetMatterDetails(globalReplaceContextBeo.SearchContext.MatterId.ToString()); } catch (EVException ex) { EvLog.WriteEntry(jobId + " - " + Constants.InitializationFailMessage, ex.ToUserString(), EventLogEntryType.Error); LogException(jobId, ex, Constants.InitializationFailMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } catch (Exception exp) { EvLog.WriteEntry(jobId + " - " + jobId.ToString(CultureInfo.InvariantCulture), Constants.InitializationFailMessage + ":" + exp.Message, EventLogEntryType.Information); LogException(jobId, exp, Constants.InitializationFailMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } return(jobBeo); }