/// <summary> /// To create dataset fields that are selected for law imprort /// </summary> private void CreateSelectedLawFields() { if (_jobParams == null) { _jobParams = GetJobParams(BootParameters); } _selectedFields = _jobParams.MappingFields; var dataSetNewFields = new List <FieldBEO>(); var dataTypes = DataSetTemplateBO.GetDataTypeAndDataFormatList(); var dataSetExistingFields = DataSetBO.GetDataSetFields(_jobParams.DatasetId, _jobParams.CollectionId); dataSetExistingFields = dataSetExistingFields ?? new List <FieldBEO>(); foreach (var mappedField in _jobParams.MappingFields.FindAll(x => string.IsNullOrEmpty(x.MappingFieldId))) { if (string.IsNullOrEmpty(mappedField.MappingFieldName)) { continue; } var dataSetField = dataSetExistingFields.FirstOrDefault( dsField => !string.IsNullOrEmpty(dsField.Name) && dsField.Name.ToLower().Equals(mappedField.MappingFieldName.ToLower())); if (dataSetField != null) { //If mapped field already exists in dataset then don't create continue; } var field = new FieldBEO { Name = mappedField.MappingFieldName, IsReadable = true, IsSingleEntry = true, IsHiddenField = false, IsValidateDateValues = true, CharacterLength = 10, ModifiedBy = _jobParams.CreatedBy }; SetFieldDataType(field, mappedField, dataTypes); dataSetNewFields.Add(field); } if (!dataSetNewFields.Any()) { return; } DataSetBO.AddBulkFields(_jobParams.FolderId, dataSetNewFields, _jobParams.CreatedBy); SetFieldIdForCreatedFields(_jobParams.MappingFields); }
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 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; } } }
/// <summary> /// To set field data type /// </summary> /// <param name="field"></param> /// <param name="lawField"></param> /// <param name="dataTypes"></param> private static void SetFieldDataType(FieldBEO field, LawFieldBEO lawField, IEnumerable <DataTypeBEO> dataTypes) { switch (lawField.FieldType) { case LawFieldTypeBEO.Numeric: field.DataType = "NUMERIC"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == NumericDataType); break; case LawFieldTypeBEO.DateTime: field.DataType = "DATE"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == DateDataType); break; default: field.DataType = "TEXT"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == TextDataType); break; } }
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> /// constructs document fields and audit log /// </summary> /// <param name="productionDocumentDetail"></param> /// <returns></returns> private List <DocumentFieldsBEO> ConstructDocumentFields(ProductionDocumentDetail productionDocumentDetail) { List <DocumentFieldsBEO> lstDocumentFields = null; var lstProductionFields = productionDocumentDetail.lstProductionFields; var lstDsFeildsBeo = productionDocumentDetail.lstDsFieldsBeo; if (lstProductionFields != null && lstDsFeildsBeo != null) { lstDocumentFields = new List <DocumentFieldsBEO>(); //Bates Number Fieldtype Id-3004 FieldBEO productionFieldBeo = null; productionFieldBeo = lstProductionFields.FirstOrDefault( prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesNumber)); if (productionFieldBeo != null) { lstDocumentFields.Add(new DocumentFieldsBEO { FieldId = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID, FieldType = new FieldDataTypeBusinessEntity { DataTypeId = (Int32)Constants.FieldTypeIds.BatesNumber, DataTypeDisplayValue = Constants.BatesNumber }, FieldValue = !string.IsNullOrWhiteSpace(productionDocumentDetail.AllBates) ? productionDocumentDetail.AllBates : string.Empty, FieldName = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name, DocumentReferenceId = productionDocumentDetail.DocumentId }); //Bates Begin Fieldtype Id-3005 productionFieldBeo = lstProductionFields.FirstOrDefault( prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesBegin)); if (productionFieldBeo != null) { lstDocumentFields.Add(new DocumentFieldsBEO { FieldId = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID, FieldType = new FieldDataTypeBusinessEntity { DataTypeId = (Int32)Constants.FieldTypeIds.BatesBegin, DataTypeDisplayValue = Constants.BatesBegin }, FieldValue = !string.IsNullOrWhiteSpace(productionDocumentDetail.StartingBatesNumber) ? productionDocumentDetail.StartingBatesNumber : string.Empty, FieldName = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name, DocumentReferenceId = productionDocumentDetail.DocumentId }); } //Bates End Fieldtype Id-3006 productionFieldBeo = lstProductionFields.FirstOrDefault( prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesEnd)); if (productionFieldBeo != null) { lstDocumentFields.Add(new DocumentFieldsBEO { FieldId = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID, FieldType = new FieldDataTypeBusinessEntity { DataTypeId = (Int32)Constants.FieldTypeIds.BatesEnd, DataTypeDisplayValue = Constants.BatesEnd }, FieldValue = !string.IsNullOrWhiteSpace(productionDocumentDetail.EndingBatesNumber) ? productionDocumentDetail.EndingBatesNumber : string.Empty, FieldName = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name, DocumentReferenceId = productionDocumentDetail.DocumentId }); } //Bates Range Field Type Id-3007 productionFieldBeo = lstProductionFields.FirstOrDefault( prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.BatesRange)); if (productionFieldBeo != null) { lstDocumentFields.Add(new DocumentFieldsBEO { FieldId = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID, FieldType = new FieldDataTypeBusinessEntity { DataTypeId = (Int32)Constants.FieldTypeIds.BatesRange, DataTypeDisplayValue = Constants.BatesRange }, FieldValue = productionDocumentDetail.StartingBatesNumber + "-" + productionDocumentDetail.EndingBatesNumber, FieldName = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name, DocumentReferenceId = productionDocumentDetail.DocumentId }); } } //DPN Fieldtype Id-3008 productionFieldBeo = lstProductionFields.FirstOrDefault( prodField => prodField.FieldType.DataTypeId == Convert.ToInt32(Constants.FieldTypeIds.DPN)); if (productionFieldBeo != null) { lstDocumentFields.Add(new DocumentFieldsBEO { FieldId = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).ID, FieldType = new FieldDataTypeBusinessEntity { DataTypeId = (Int32)Constants.FieldTypeIds.DPN, DataTypeDisplayValue = Constants.DPN }, FieldValue = !string.IsNullOrWhiteSpace(productionDocumentDetail.DocumentProductionNumber) ? productionDocumentDetail.DocumentProductionNumber : string.Empty, FieldName = lstDsFeildsBeo.FirstOrDefault( DsField => DsField.Name.ToLower().Equals(productionFieldBeo.Name.ToLower())).Name, DocumentReferenceId = productionDocumentDetail.DocumentId }); } } return(lstDocumentFields); }
/// <summary> /// To set field data type /// </summary> /// <param name="field"></param> /// <param name="lawField"></param> /// <param name="dataTypes"></param> private static void SetFieldDataType(FieldBEO field, LawFieldBEO lawField, IEnumerable<DataTypeBEO> dataTypes) { switch (lawField.FieldType) { case LawFieldTypeBEO.Numeric: field.DataType = "NUMERIC"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == NumericDataType); break; case LawFieldTypeBEO.DateTime: field.DataType = "DATE"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == DateDataType); break; default: field.DataType = "TEXT"; field.FieldType = dataTypes.FirstOrDefault(x => x.DataTypeId == TextDataType); break; } }
/// <summary> /// To create dataset fields that are selected for law imprort /// </summary> private void CreateSelectedLawFields() { if (_jobParams == null) _jobParams = GetJobParams(BootParameters); _selectedFields = _jobParams.MappingFields; var dataSetNewFields = new List<FieldBEO>(); var dataTypes = DataSetTemplateBO.GetDataTypeAndDataFormatList(); var dataSetExistingFields = DataSetBO.GetDataSetFields(_jobParams.DatasetId, _jobParams.CollectionId); dataSetExistingFields = dataSetExistingFields ?? new List<FieldBEO>(); foreach (var mappedField in _jobParams.MappingFields.FindAll(x => string.IsNullOrEmpty(x.MappingFieldId))) { if (string.IsNullOrEmpty(mappedField.MappingFieldName)) continue; var dataSetField = dataSetExistingFields.FirstOrDefault( dsField => !string.IsNullOrEmpty(dsField.Name) && dsField.Name.ToLower().Equals(mappedField.MappingFieldName.ToLower())); if (dataSetField != null) { //If mapped field already exists in dataset then don't create continue; } var field = new FieldBEO { Name = mappedField.MappingFieldName, IsReadable = true, IsSingleEntry = true, IsHiddenField = false, IsValidateDateValues = true, CharacterLength = 10, ModifiedBy = _jobParams.CreatedBy }; SetFieldDataType(field, mappedField, dataTypes); dataSetNewFields.Add(field); } if (!dataSetNewFields.Any()) return; DataSetBO.AddBulkFields(_jobParams.FolderId, dataSetNewFields, _jobParams.CreatedBy); SetFieldIdForCreatedFields(_jobParams.MappingFields); }