protected void Page_Load(object sender, EventArgs e) { if (DocumentID > 0) { DocumentDetail.BindData(DocumentServices.GetById(DocumentID).WrapInList()); } }
public ActionResult InsertAndAppr(Document model) { using (DLSMEntities context = new DLSMEntities()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { string avbError = CheckAvailable(model); string snError = CheckSerialOut(model); if (avbError == "Y" && snError == "Y") { try { Document w = context.Documents.Where(p => (p.DocNo == model.DocNo)).FirstOrDefault(); if (w != null) { return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ")); } context.Documents.Add(model); context.SaveChanges(); model.DocDetailList.RemoveAt(0); foreach (var i in model.DocDetailList) { DocumentDetail dd = new DocumentDetail(); dd.DocID = model.ID; dd.PdID = i.PdID; dd.Qty = i.Qty; dd.RemainQty = i.RemainQty; dd.SerialBegin = i.SerialBegin; dd.SerialEnd = i.SerialEnd; dd.IpProperty = i.IpProperty; dd.TrnType = "O"; context.DocumentDetails.Add(dd); } context.SaveChanges(); // Execute store procudure var docid = model.ID; var userid = int.Parse(Session["UserID"].ToString()); var result = context.sp_ProcessDocument(docid, userid).ToList(); if (result[0].ID == 0) { context.SaveChanges(); dbContextTransaction.Commit(); } } catch (Exception ex) { dbContextTransaction.Rollback(); return(Json(ex.InnerException.Message)); } } } } return(Json("success")); }
public DocumentController( IUserService IUserService, IRelationService IRelationService, IDocumentService IDocumentService, IEmployementService IEmployementService, IDocumentDetailsService IDocumentDetailsService, IDocumentCategoryService IDocumentCategoryService, IEducationDocumentCategoryMappingService IEducationDocumentCategoryMappingService, ICandidateProgressDetailService ICandidateProgressDetailService, IPersonalService IPersonalService, IEmployeeService IEmployeeService, IEmploymentCountService IEmploymentCountService) { _IUserService = IUserService; _IRelationService = IRelationService; _IEmployementService = IEmployementService; _IDocumentDetailsService = IDocumentDetailsService; _IDocumentCategoryService = IDocumentCategoryService; _IDocumentService = IDocumentService; _IEducationDocumentCategoryMappingService = IEducationDocumentCategoryMappingService; _ICandidateProgressDetailService = ICandidateProgressDetailService; _IPersonalService = IPersonalService; _IEmploymentCountService = IEmploymentCountService; _loginDetails = new LoginDetail(); _document = new Master_Document(); _docDetails = new DocumentDetail(); _employment = new EmploymentDetail(); _DocumetCat = new Master_DocumentCategory(); _DocumetCatNew = new Master_DocumentCategory(); _educationDocumentCategoryMapping = new EducationDocumentCategoryMapping(); _IEmployeeService = IEmployeeService; }
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); }
//Hàm sửa đổi thông tin chi tiết của tài liệu. public DocumentDetail UpdateDocumentDetail(DocumentDetail documentdetail) { string queryString = "UPDATE DocumentDetail SET CourseId = @courseId, TeacherId = @teacherId, DocumentDetailFileUpLoad = @documentDetailFileUpload " + " WHERE DocumentDetailId = @documentDetailId"; //Mở kết nối đến database using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { // Khởi tạo command với các tham số truyền vào là các trường trong đối tượng DocumentDetail SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@documentDetailId", documentdetail.DocumentDetailId); command.Parameters.AddWithValue("@courseId", documentdetail.CourseId); command.Parameters.AddWithValue("@teacherId", documentdetail.TeacherId); command.Parameters.AddWithValue("@documentDetailFileUpload", documentdetail.DocumentDetailFileUpload); //Mở kết nối và thực hiện query vào database connection.Open(); command.ExecuteNonQuery(); //Không có giá trị trả về: dùng ExecuteNonQuery //Đóng kết nối connection.Close(); } //Trả về chính tham số truyền vào nếu hàm không xảy ra bất cứ lỗi gì return(documentdetail); }
//Thêm mới 1 tài liệu chi tiết. public DocumentDetail InsertDocumentDetail(DocumentDetail documentdetail) { //Câu lệnh truy vấn ở dạng string string queryString = "INSERT INTO DocumentDetail(DocumentDetailId, CourseId, TeacherId, DocumentDetailFileUpload) VALUES" + "(@DocumentDetailId, @CourseId, @TeacherId, @DocumentDetailFileUpload);"; //Mở kết nối đến database using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { // Khởi tạo command với các tham số truyền vào là các trường trong đối tượng DocumentDetail SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@documentDetailId", documentdetail.DocumentDetailId); command.Parameters.AddWithValue("@courseId", documentdetail.CourseId); command.Parameters.AddWithValue("@teacherId", documentdetail.TeacherId); command.Parameters.AddWithValue("@documentDetailFileUpload", documentdetail.DocumentDetailFileUpload); //Mở kết nối và thực hiện query vào database connection.Open(); SqlDataReader reader = command.ExecuteReader(); //Đọc kết quả trả về while (reader.Read()) { //Lấy documentDetailID sau khi Create xong documentdetail.DocumentDetailId = Convert.ToInt64(reader.GetValue(0).ToString()); } reader.Close(); connection.Close(); } return(documentdetail); }
/// <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 bool SetActive(DocumentDetail documentDetail) { var status = false; try { using (var context = new IPDEntities()) { var data = context.DocumentDetails.FirstOrDefault(x => x.DocumentID == documentDetail.DocumentID && x.DocDetID == documentDetail.DocDetID && x.UserID == documentDetail.UserID); if (data != null) { data.IsActive = true; data.UpdatedBy = HttpContext.Current.User.Identity.Name; data.UpdatedDate = DateTime.UtcNow; status = Convert.ToBoolean(context.SaveChanges()); } } } catch (Exception e) { throw; } return(status); }
/// <summary> /// Match document fomr bulk search result /// </summary> private static List <DocumentResult> DocumentMatchFromBulkSearchResult(DocumentDetail document, List <DocumentResult> bulkSearchresult) { List <DocumentResult> resultDocuments = new List <DocumentResult>(); if (bulkSearchresult != null && bulkSearchresult.Count > 0) { foreach (DocumentResult result in bulkSearchresult) { List <RVWDocumentFieldBEO> docFields = document.OverlayMatchingField; bool isMatch = false; foreach (RVWDocumentFieldBEO field in docFields) { string value = field.FieldValue.Trim('"'); if (result.Fields.Exists(f => f.Name == field.FieldName && f.Value == value)) { isMatch = true; } else { break; } } if (isMatch) { resultDocuments.Add(result); } } } return(resultDocuments); }
public ActionResult Insert(Document model) { Document w = db.Documents.Where(p => (p.DocNo == model.DocNo)).FirstOrDefault(); if (w != null) { return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ")); } db.Documents.Add(model); db.SaveChanges(); int docid = model.ID; model.DocDetailList.RemoveAt(0); foreach (var i in model.DocDetailList) { DocumentDetail dd = new DocumentDetail(); dd.DocID = docid; dd.PdID = i.PdID; dd.Qty = i.Qty; dd.SerialBegin = i.SerialBegin; dd.SerialEnd = i.SerialEnd; dd.IpProperty = i.IpProperty; dd.TrnType = "O"; db.DocumentDetails.Add(dd); } db.SaveChanges(); return(Json("success")); }
public ActionResult EditRequisition(Document model) { Document w = db.Documents.Where(p => (p.DocNo == model.DocNo) && (p.ID != model.ID)).FirstOrDefault(); if (w != null) { return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ")); } model.DocDate = model.DocDate.Value.AddYears(-543); db.Entry(model).State = EntityState.Modified; db.SaveChanges(); //Delete old data db.DocumentDetails.RemoveRange(db.DocumentDetails.Where(x => x.DocID == model.ID)); db.SaveChanges(); model.DocDetailList.RemoveAt(0); foreach (var i in model.DocDetailList) { DocumentDetail dd = new DocumentDetail(); dd.DocID = model.ID; dd.PdID = i.PdID; dd.Qty = i.Qty; dd.SerialBegin = i.SerialBegin; dd.SerialEnd = i.SerialEnd; dd.IpProperty = i.IpProperty; dd.TrnType = "O"; db.DocumentDetails.Add(dd); } db.SaveChanges(); return(Json("success")); }
/// <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; } } }
public bool InsertDocDetails(out long ID, DocumentDetail obj, string[] param, string spName) { bool status = _IDocumentDetailsRepository.Insert(obj, param, spName); Save(); ID = obj.DocDetID; return(status); }
// GET: Document/Details/5 public ActionResult Details(int id) { DocumentService documentrepo = new DocumentService(); Document documents = documentrepo.Get(id); DocumentDetail documentDetail = new DocumentDetail(documents); return(View(documentDetail)); }
/// <summary> /// Update Document For ExactMatch /// </summary> private void UpdateDocumentForExactMatch(DocumentDetail docDetail, ref string existingThreadConstraint, ref bool isNewRecord, ref bool isNewImageSet, List <DocumentResult> documentResult, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { if (existingThreadConstraint == null) { throw new ArgumentNullException("existingThreadConstraint"); } //Update record #region "RelationShip" if (docDetail.docType == DocumentsetType.NativeSet) { // <Newly generated Id>,<Old Id> if (!_overlayNewAndOldDocumentIdPairs.Keys.Contains(docDetail.document.DocumentId)) { _overlayNewAndOldDocumentIdPairs.Add(docDetail.document.DocumentId, documentResult.First().DocumentID); } } #endregion docDetail.document.Id = Convert.ToInt32(documentResult.First().Id); docDetail.document.DocumentId = documentResult.First().DocumentID; DocumentAddExistingFields(docDetail, documentResult, misMatchedFields, misMatchedFieldsMessage); //Add Existing Native File Info during overlay , if Native file was not included during overlay if (!_jobParams.IsImportNative) { AddNativeFileInfo(docDetail.document); } existingThreadConstraint = documentResult.First().DocumentID.Substring(0, 32); isNewRecord = false; // Update existing document isNewImageSet = !_jobParams.IsExistingImageSet; if (isNewImageSet) { return; } var firstOrDefault = documentResult.FirstOrDefault(); if (firstOrDefault == null || (firstOrDefault.Fields == null)) { return; } var imageSetfields = firstOrDefault.Fields.FirstOrDefault(f => f.Name.ToLower() == EVSystemFields.ImageSets.ToLower()); if (imageSetfields != null && !string.IsNullOrEmpty(imageSetfields.Value)) { if (!string.IsNullOrEmpty(_jobParams.ImageSetId)) { isNewImageSet = !imageSetfields.Value.ToLower().Contains(_jobParams.ImageSetId.ToLower()); } } else //If Imageset field is not exist in Fields List then there is no imageset { isNewImageSet = true; } }
//Lấy danh sách chi tiết tất cả tài liệu. public List <DocumentDetail> GetAllDocumentDetailByCourse(long courseId) { //Giá trị trả về của hàm này: List<DocumentDetail> List <DocumentDetail> queryResult = new List <DocumentDetail>(); //Cấu lệnh truy vấn ở dạng string string queryString = "SELECT * FROM DocumentDetail WHERE CourseId = @courseId "; //Mở kết nối đến database using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { // Khởi tạo command có tham số nào truyền vào là từ khóa tìm kiếm SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@courseId", courseId); //Mở kết nối và thực hiện query vào database connection.Open(); SqlDataReader reader = command.ExecuteReader(); //Đọc dữ liệu trả về từ truy vấn ở trên while (reader.Read()) { //Tạo biến tạm để lấy đọc giá trị và sau dó thêm vào List queryResult DocumentDetail entity = new DocumentDetail(); //Lấy từng cột đọc được lưu vào entity if (reader["DocumentDetailId"] != DBNull.Value) { entity.DocumentDetailId = (long)reader["DocumentDetailId"]; } if (reader["CourseId"] != DBNull.Value) { entity.Course.CourseId = (long)reader["CourseId"]; } if (reader["TeacherId"] != DBNull.Value) { entity.Teacher.UserId = (long)reader["TeacherId"]; } if (reader["DocumentDetailFileUpload"] != DBNull.Value) { entity.DocumentDetailFileUpload = (string)reader["DocumentDetailFileUpload"]; } //Thêm entity vào list trả về queryResult.Add(entity); } //Đóng kết nối reader.Close(); connection.Close(); } //Trả về kết quả return(queryResult); }
public void TestUpdateDocumentSuccess() { var client = CreateMockTestClientNullRequiredFieldsRequest("Mocks/marketpay/account/upload-document-success.json"); var account = new Account(client); var documentDetail = new DocumentDetail(accountHolderCode: "123456", filename: "stament.pdf", bankAccountUUID: "aaaaaaaa-7863-f943-4e3s-ffffffff", documentType: DocumentDetail.DocumentTypeEnum.BANKSTATEMENT); var uploadDocumentRequest = new UploadDocumentRequest(documentDetail: documentDetail, documentContent: new byte[1000]); var uploadDocumentResponse = account.UploadDocument(uploadDocumentRequest); Assert.AreEqual(uploadDocumentResponse.PspReference, "8815815165741111"); Assert.AreEqual(uploadDocumentResponse.AccountHolderCode, "TestAccountHolder8031"); }
//Hàm lấy 1 thông tin bài tập theo Id public DocumentDetail GetOneDocumentDetailById(long documentDetailId) { //Giá trị trả về của hàm này DocumentDetail queryResult = new DocumentDetail(); //Câu lệnh truy vấn ở dạng string string queryString = "SELECT * FROM DocumentDetail WHERE DocumentDetailId = @documentDetailId"; //Mở kết nối đến database using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { // Khởi tạo command với tham số truyền vào là DocumentDetailId SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@documentDetailId", documentDetailId); //Mở kết nối và thực hiện query vào database connection.Open(); SqlDataReader reader = command.ExecuteReader(); //Đọc dữ liệu trả về từ truy vấn ở trên while (reader.Read()) { //Lấy từng cột đọc được lưu vào queryResult if (reader["DocumentDetailId"] != DBNull.Value) { queryResult.DocumentDetailId = (long)reader["DocumentDetailId"]; } if (reader["CourseId"] != DBNull.Value) { queryResult.CourseId = (long)reader["CourseId"]; } if (reader["TeacherId"] != DBNull.Value) { queryResult.TeacherId = (long)reader["TeacherId"]; } if (reader["DocumentDetailFileUpload"] != DBNull.Value) { queryResult.DocumentDetailFileUpload = (string)reader["DocumentDetailFileUpload"]; } //Đóng kết nối reader.Close(); connection.Close(); } //Trả về kết quả return(queryResult); } }
public ActionResult EditCheckStock(Document model) { Document w = db.Documents.Where(p => (p.DocNo == model.DocNo) && (p.ID != model.ID)).FirstOrDefault(); if (w != null) { return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ")); } model.DocDate = model.DocDate.Value.AddYears(-543); db.Entry(model).State = EntityState.Modified; db.SaveChanges(); //Delete old data db.DocumentDetails.RemoveRange(db.DocumentDetails.Where(x => x.DocID == model.ID)); db.SaveChanges(); model.DocDetailList.RemoveAt(0); foreach (var i in model.DocDetailList) { DocumentDetail dd = new DocumentDetail(); dd.DocID = model.ID; dd.PdID = i.PdID; dd.Qty = (i.Qty == null ? 0 : i.Qty); dd.RemainQty = i.RemainQty; dd.SerialBegin = i.SerialBegin; dd.SerialEnd = i.SerialEnd; dd.IpProperty = i.IpProperty; dd.TrnType = "A"; db.DocumentDetails.Add(dd); } db.SaveChanges(); foreach (var i in model.DocDetailList) { //Update to Unlock Row List <Stock> res = (from s in db.Stocks where s.WhID == model.WhID && s.PdID == i.PdID select s).ToList(); res.ForEach(o => o.CheckStatus = "Y"); db.SaveChanges(); } return(Json("success")); }
/// <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 ActionResult Insert(Document model) { Document w = db.Documents.Where(p => (p.DocNo == model.DocNo)).FirstOrDefault(); if (w != null) { return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ")); } db.Documents.Add(model); db.SaveChanges(); int docid = model.ID; model.DocDetailList.RemoveAt(0); foreach (var i in model.DocDetailList) { DocumentDetail dd = new DocumentDetail(); dd.DocID = docid; dd.PdID = i.PdID; dd.Qty = (i.Qty == null ? 0 : i.Qty); dd.RemainQty = i.RemainQty; dd.SerialBegin = i.SerialBegin; dd.SerialEnd = i.SerialEnd; dd.IpProperty = i.IpProperty; dd.TrnType = "A"; db.DocumentDetails.Add(dd); } db.SaveChanges(); foreach (var i in model.DocDetailList) { //Update to Unlock Row List <Stock> res = (from s in db.Stocks where s.WhID == model.WhID && s.PdID == i.PdID select s).ToList(); res.ForEach(o => o.CheckStatus = "Y"); db.SaveChanges(); } return(Json("success")); }
/// <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 FileContentResult getImg(int id) { byte[] byteArray; DocumentDetail Doc = _IDocumentDetailsService.GetById(id); byteArray = Doc.Data; string strContentType = string.Empty; if (Doc.ContentType == ".pdf") { strContentType = "application/pdf"; } else { strContentType = "image/jpg"; } return(byteArray != null ? new FileContentResult(byteArray, strContentType) : null); }
/// <summary> /// Update Document For ExactMatch /// </summary> private void UpdateDocumentForExactMatch(DocumentDetail docDetail, ref string existingThreadConstraint, ref bool isNewRecord, ref bool isNewImageSet, List <DocumentResult> documentResult, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { //Update record docDetail.document.DocumentId = documentResult.First().DocumentID; docDetail.document.Id = Convert.ToInt32(documentResult.First().Id); DocumentAddExistingFields(docDetail, documentResult, misMatchedFields, misMatchedFieldsMessage); //Add Existing Native File Info during overlay , if Native file was not included during overlay if (m_JobParameter != null && !m_JobParameter.IsImportNativeFiles) { AddNativeFileInfo(docDetail.document); } existingThreadConstraint = documentResult.First().DocumentID.Substring(0, 32); isNewRecord = false; // Update existing document isNewImageSet = m_JobParameter.IsNewImageSet; if (!m_JobParameter.IsNewImageSet) //If Image is updated then check for each document (i.e ImageSet collection is already exist or not) { if (documentResult.FirstOrDefault() != null && documentResult.FirstOrDefault().Fields != null) { var imageSetfields = documentResult.FirstOrDefault().Fields.FirstOrDefault(f => f.Name.ToLower() == EVSystemFields.ImageSets.ToLower()); if (imageSetfields != null && !string.IsNullOrEmpty(imageSetfields.Value)) { if (!string.IsNullOrEmpty(m_JobParameter.ImageSetId)) { if (imageSetfields.Value.ToLower().Contains(m_JobParameter.ImageSetId.ToLower())) //Exists then Update imageset document, Otherwise add image { isNewImageSet = false; } else { isNewImageSet = true; } } } else //If Imageset field is not exist in Fields List then there is no imageset { isNewImageSet = true; } } } }
public ActionResult DeleteConfirmed(int id) { var context = new DLSMEntities(); DocumentDetail st = context.DocumentDetails.Where(p => p.PdID == id).FirstOrDefault(); if (st != null) { // Cannot delete becasue Topic group is using another process TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลนี้มีการถูกใช้งานอยู่"; return(RedirectToAction("Edit", new { id = id, ViewBag.Msg })); } else { Product product = db.Products.Find(id); db.Products.Remove(product); db.SaveChanges(); TempData["Msg"] = "ลบข้อมูลเรียบร้อยแล้ว"; } return(RedirectToAction("Index")); }
public ActionResult UpdateIsIdProofProp(DocumentDetail model) { bool status = false; long id; if (model.IsIdProof != null && model.IsIdProof.Value) { var cloneObj = _IDocumentDetailsService.GetById(model.DocDetID); cloneObj.CreatedDate = DateTime.Now; cloneObj.DocumentID = IDProof.Passport; cloneObj.DocCatID = DocumentCategory.IdProof; cloneObj.IsIdProof = true; status = _IDocumentDetailsService.InsertDocDetails(out id, cloneObj, null, ""); } if ((model.IsIdProof != null && model.IsIdProof.Value == false) || status) { status = _IDocumentDetailsService.Update(model, p => p.IsIdProof); } return(Json(new { status = status })); }
/// <summary> /// Match document fomr bulk search result /// </summary> private static List <DocumentResult> DocumentMatchFromBulkSearchReult(DocumentDetail document, ICollection <DocumentResult> bulkSearchresult) { var resultDocuments = new List <DocumentResult>(); if (bulkSearchresult != null && bulkSearchresult.Count > 0) { var matchingField = document.OverlayMatchingField.First(); if (null == matchingField) { return(resultDocuments); } var value = matchingField.FieldValue.Trim('"'); foreach (var result in bulkSearchresult) { var isMatch = false; if (result.Fields.Exists(f => f.Name == matchingField.FieldName && f.Value == value)) { isMatch = true; //set document file size var fileSizeField = result.Fields.Find(f => f.Name.Equals("_EVFileSize")); if (fileSizeField != null) { int fileSize; int.TryParse(fileSizeField.Value, out fileSize); if (fileSize > 0) //Don't override the file size if native file not imported while append. { document.document.FileSize = fileSize; } } } if (isMatch) { resultDocuments.Add(result); } } } return(resultDocuments); }
public ActionResult getDocument(int id) { byte[] byteArray; DocumentDetail Doc = _IDocumentDetailsService.GetById(id); byteArray = Doc.Data; string strContentType = string.Empty; if (Doc.ContentType == ".docx" || Doc.ContentType == ".doc") { if (Doc.ContentType == ".doc") { strContentType = "application/msword"; } else { strContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } } else { if (Doc.ContentType == ".pdf") { strContentType = "application/pdf"; } else { strContentType = "image/jpg"; } } if (byteArray != null) { return(this.File(byteArray, strContentType, Doc.DocumentName)); } else { return(new EmptyResult()); } }
public async Task <DocumentDetailResponse> DocumentDetail(DocumentDetailRequest request) { try { using (IDbConnection connection = new SqlConnection(_configuration.GetValue <string>("ConnectionStrings:DefaultConnection"))) { DocumentDetail document = new DocumentDetail(); DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", request.Id); await Task.Run(() => document = connection.Query <DocumentDetail>("App_Docs_Get", parameters, null, true, null, CommandType.StoredProcedure).FirstOrDefault() ); if (document != null) { parameters = new DynamicParameters(); parameters.Add("@DocId", document.Id); await Task.Run(() => document.DocsFiles = connection.Query <DocsFile>("DocsFiles_GetByDocId", parameters, null, true, null, CommandType.StoredProcedure).AsList <DocsFile>() ); } return(new DocumentDetailResponse { Status = ResponseStatus.Success, Message = ResponseStatus.Success.ToString(), Document = document, }); } } catch (Exception ex) { return(new DocumentDetailResponse { Status = ResponseStatus.Faile, Message = ex.Message, }); } }
public ReturnResult <DocumentDetail> GetDocumentById(int documentId) { DbProvider dbProvider = new DbProvider(); string outCode = String.Empty; string outMessage = String.Empty; var document = new DocumentDetail(); dbProvider.SetQuery("DOCUMENT_GET_BY_ID", CommandType.StoredProcedure) .SetParameter("DocumentId", SqlDbType.Int, documentId, ParameterDirection.Input) .SetParameter("ErrorCode", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output) .SetParameter("ErrorMessage", SqlDbType.NVarChar, DBNull.Value, 4000, ParameterDirection.Output) .GetSingle <DocumentDetail>(out document) .Complete(); dbProvider.GetOutValue("ErrorCode", out outCode) .GetOutValue("ErrorMessage", out outMessage); return(new ReturnResult <DocumentDetail>() { Item = document, ErrorCode = outCode, ErrorMessage = outMessage, }); }
/// <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> /// Method to get the documents from loadfile /// </summary> /// <param name="correlationId">Correlation id</param> /// <param name="recordText">record text</param> /// <param name="documentCtrlNbr">document control number</param> /// <param name="imageFileList">imagefile list</param> /// <param name="textFileList">text file list</param> /// <param name="recordParserLog">recordParser Log</param> /// <returns>list of DocumentDetail</returns> public List<DocumentDetail> GetDocuments(string correlationId, string recordText, string documentCtrlNbr, List<string> textFileList, out JobWorkerLog<LoadFileDocumentParserLogInfo> recordParserLog) { recordText.ShouldNotBe(null); List<DocumentDetail> documentDetailList = new List<DocumentDetail>(); recordParserLog = null; RVWDocumentBEO document = null; string missingNativeFile = null; List<string> missingImageFiles = new List<string>(); bool isMissingContent = false; List<string> missingContentFiles = new List<string>(); List<string> misMatchedFields = new List<string>(); List<string> misMatchedFieldsMessage = new List<string>(); Int32 importedImagesCount = 0; #region Parse Record Text var recordTokenizer = new RecordTokenizer(m_ColumnDelimiter, m_QuoteCharacter); var fields = recordTokenizer.ParseRecord(recordText); #endregion List<RVWDocumentFieldBEO> matchingKeyField = null; //For Overlay //Get document document = ConsturctDocument(correlationId, fields, textFileList, ref matchingKeyField, out missingNativeFile, missingImageFiles, out isMissingContent, missingContentFiles, misMatchedFields, misMatchedFieldsMessage, out importedImagesCount); if (m_JobParameter.IsAppend) { // Assign DCN document.DocumentControlNumber = documentCtrlNbr; //1) Construct Native Set var nativeSetDocument = GetDocumentForNativeSet(document); var doc = new DocumentDetail(); doc.CorrelationId = correlationId; doc.docType = DocumentsetType.NativeSet; doc.document = nativeSetDocument; doc.ConversationIndex = document.ConversationIndex; doc.IsNewDocument = true; //Add Native Document documentDetailList.Add(doc); //2) Construct Image Set if (m_JobParameter.IsImportImages && !string.IsNullOrEmpty(m_JobParameter.ImageSetId)) { var imageSetDocument = GetDocumentForImageSet(document, m_JobParameter.ImageSetId); imageSetDocument.IsImageFilesNotAssociated = !(importedImagesCount > 0 || missingImageFiles.Any()); var docImg = new DocumentDetail(); docImg.CorrelationId = correlationId; docImg.docType = DocumentsetType.ImageSet; docImg.document = imageSetDocument; docImg.IsNewDocument = true; //Add Image Document documentDetailList.Add(docImg); } } else { //Send original document to Search worker var doc = new DocumentDetail(); doc.document = document; doc.ConversationIndex = document.ConversationIndex; #region Create a unique file name for extracted 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()) : x.Path); #endregion doc.CorrelationId = correlationId; doc.OverlayMatchingField = matchingKeyField; doc.document.IsImageFilesNotAssociated = !(importedImagesCount > 0 || missingImageFiles.Any()); documentDetailList.Add(doc); } //3) Construct Log #region Log var imageMappingKey=string.Empty; if (m_JobParameter.IsImportImages && m_JobParameter.LoadFile.ImageFile != null) { imageMappingKey = fields[m_JobParameter.LoadFile.ImageFile.ImageMatchingFieldId]; } recordParserLog = ConstructLog(correlationId, true, document.DocumentId, missingNativeFile, missingImageFiles, isMissingContent, missingContentFiles, importedImagesCount, misMatchedFields, documentCtrlNbr, document.CrossReferenceFieldValue, misMatchedFieldsMessage, imageMappingKey); #endregion var firstDoc = documentDetailList.FirstOrDefault(); if (firstDoc != null) { firstDoc.document.ImportMessage = recordParserLog.LogInfo.Message; } return documentDetailList; }
/// <summary> /// Construct Nativeset & ImageSet /// </summary> private List <DocumentDetail> ConstructNativeImageSet(bool isNewRecord, bool isNewImageSet, DocumentDetail docDetail, List <string> misMatchedFields, List <string> misMatchedFieldsMessage) { List <DocumentDetail> documentDetailList = new List <DocumentDetail>(); //1) Construct Native Set var nativeSetDocument = GetDocumentForNativeSet(docDetail.document, misMatchedFields, misMatchedFieldsMessage); var doc = new DocumentDetail(); doc.CorrelationId = docDetail.CorrelationId; doc.docType = DocumentsetType.NativeSet; doc.document = nativeSetDocument; doc.ParentDocId = docDetail.ParentDocId; doc.IsNewDocument = isNewRecord; doc.ConversationIndex = docDetail.ConversationIndex; doc.OverlayReImportField = docDetail.OverlayReImportField; doc.Reviewsets = docDetail.Reviewsets; #region Check Same Content File string existingContentFilePath = GetExistingContentFile(nativeSetDocument.CollectionId, nativeSetDocument.DocumentId); string contentFilePath = string.Empty; if (nativeSetDocument.DocumentBinary.FileList != null && nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault() != null) { contentFilePath = (!string.IsNullOrEmpty(nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault().Path) ? nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault().Path : string.Empty); } if (!string.IsNullOrEmpty(existingContentFilePath)) //If text File is exist during Append { if (!string.IsNullOrEmpty(contentFilePath)) { if (existingContentFilePath.Trim().ToLower() != contentFilePath.Trim().ToLower()) //New Content File Used in Overlay { doc.OverlayIsNewContentFile = true; } } else //If there is no text File during overlay , Need to maintain old content File { doc.OverlayIsNewContentFile = false; RVWExternalFileBEO file = new RVWExternalFileBEO { Type = Constants.TEXT_FILE_TYPE, Path = existingContentFilePath }; doc.document.DocumentBinary.FileList.Add(file); } } else if (string.IsNullOrEmpty(nativeSetDocument.CustomFieldToPopulateText) && !string.IsNullOrEmpty(contentFilePath)) //If there is no text File during Append { doc.OverlayIsNewContentFile = true; } else if (!string.IsNullOrEmpty(contentFilePath)) { doc.OverlayIsNewContentFile = false; } #endregion doc.SystemTags = m_JobParameter.SystemTags; doc.document.DocumentControlNumber = docDetail.document.DocumentControlNumber; documentDetailList.Add(doc); //2) Construct Image Set if (m_JobParameter.IsImportImages && !string.IsNullOrEmpty(m_JobParameter.ImageSetId)) { var imageSetDocument = GetDocumentForImageSet(docDetail.document, m_JobParameter.ImageSetId); var docImg = new DocumentDetail(); docImg.CorrelationId = docDetail.CorrelationId; docImg.docType = DocumentsetType.ImageSet; docImg.document = imageSetDocument; docImg.IsNewDocument = isNewImageSet; documentDetailList.Add(docImg); } return(documentDetailList); }
/// <summary> /// Construct document based on search /// </summary> public List<DocumentDetail> ConstructDocumentFromSearch(DocumentDetail docDetail, List<DocumentResult> bulkSearchresult, out string existingThreadConstraint, out JobWorkerLog<OverlaySearchLogInfo> overlayLog) { List<DocumentDetail> documentDetailList = new List<DocumentDetail>(); existingThreadConstraint = string.Empty; #region Overlay string searchQuery = string.Empty; bool isExactMatch = false; bool isNoMatch = false; bool isNewRecord = false; string searchMessage = string.Empty; bool isImportDocument = true; bool isNewImageSet = true; string overlayField; string nonMatchingOverlayDCN = string.Empty; List<DocumentResult> documentResult = null; var misMatchedFields = new List<string>(); var misMatchedFieldsMessage = new List<string>(); string dcn = string.Empty; //Filter document from bulk Search Result if (bulkSearchresult != null && bulkSearchresult.Count > 0) documentResult = DocumentMatchFromBulkSearchResult(docDetail, bulkSearchresult); if (documentResult != null) { if (documentResult.Count == 1) { isExactMatch = true; searchMessage = Constants.MessageMatchRecord; } else { isNoMatch = true; #region Log searchMessage = (documentResult.Count == 0) ? Constants.MessageNoMatchRecord : Constants.MessageMoreThanOneRecord; //Return more than one record foreach (var result in documentResult) { if (result.Fields == null || !result.Fields.Any()) continue; var dcnField = result.Fields.FirstOrDefault(f => f.DataTypeId.Equals(Constants.DCNFieldType)); if (dcnField != null) { nonMatchingOverlayDCN = !string.IsNullOrEmpty(nonMatchingOverlayDCN) ? string.Format("{0},{1}", nonMatchingOverlayDCN, dcnField.Value) : dcnField.Value; } } if (!string.IsNullOrEmpty(nonMatchingOverlayDCN)) nonMatchingOverlayDCN = " DCN:" + nonMatchingOverlayDCN; else searchMessage = Constants.MessageNoMatchRecord; #endregion } } else { //No Match Found isNoMatch = true; } #region Log if (docDetail.OverlayMatchingField != null) searchQuery = ConstructSearchQuery(docDetail.OverlayMatchingField); overlayField = searchQuery.Replace(Constants.SearchAndCondition.Trim(), ","); #endregion if (isExactMatch) { UpdateDocumentForExactMatch(docDetail, ref existingThreadConstraint, ref isNewRecord, ref isNewImageSet, documentResult, misMatchedFields, misMatchedFieldsMessage); var dcnField = documentResult.First().Fields.FirstOrDefault(f => f.DataTypeId == Constants.DCNFieldType); if (dcnField != null) { if (docDetail.document != null) docDetail.document.DocumentControlNumber = dcnField.Value; dcn = dcnField.Value; } } else if (m_JobParameter.IsOverlayReplaceAndAppend) { //Insert as new record for non matching record isNewRecord = true; } else { // Not applicable for Insert/Update isImportDocument = false; isNewRecord = false; } #endregion #region Construct Documents if (isImportDocument) { var docdetails = ConstructNativeImageSet(isNewRecord, isNewImageSet, docDetail, misMatchedFields, misMatchedFieldsMessage); if (docdetails != null && docdetails.Count > 0) { documentDetailList.AddRange(docdetails); } } if (string.IsNullOrEmpty(dcn)) dcn = docDetail.document.DocumentControlNumber; //3) Construct Log overlayLog = ConstructLog(docDetail.CorrelationId, true, isExactMatch, isNoMatch, isImportDocument, searchMessage, overlayField, nonMatchingOverlayDCN, docDetail.document.DocumentId, dcn, isNewRecord, docDetail.document.CrossReferenceFieldValue, misMatchedFields, misMatchedFieldsMessage); #endregion return documentDetailList; }
/// <summary> /// Update Document For ExactMatch /// </summary> private void UpdateDocumentForExactMatch(DocumentDetail docDetail, ref string existingThreadConstraint, ref bool isNewRecord, ref bool isNewImageSet, List<DocumentResult> documentResult, List<string> misMatchedFields, List<string> misMatchedFieldsMessage) { //Update record docDetail.document.DocumentId = documentResult.First().DocumentID; docDetail.document.Id = Convert.ToInt32(documentResult.First().Id); DocumentAddExistingFields(docDetail, documentResult, misMatchedFields, misMatchedFieldsMessage); //Add Existing Native File Info during overlay , if Native file was not included during overlay if (m_JobParameter != null && !m_JobParameter.IsImportNativeFiles) { AddNativeFileInfo(docDetail.document); } existingThreadConstraint = documentResult.First().DocumentID.Substring(0, 32); isNewRecord = false; // Update existing document isNewImageSet = m_JobParameter.IsNewImageSet; if (!m_JobParameter.IsNewImageSet) //If Image is updated then check for each document (i.e ImageSet collection is already exist or not) { if (documentResult.FirstOrDefault() != null && documentResult.FirstOrDefault().Fields != null) { var imageSetfields = documentResult.FirstOrDefault().Fields.FirstOrDefault(f => f.Name.ToLower() == EVSystemFields.ImageSets.ToLower()); if (imageSetfields != null && !string.IsNullOrEmpty(imageSetfields.Value)) { if (!string.IsNullOrEmpty(m_JobParameter.ImageSetId)) { if (imageSetfields.Value.ToLower().Contains(m_JobParameter.ImageSetId.ToLower())) //Exists then Update imageset document, Otherwise add image { isNewImageSet = false; } else { isNewImageSet = true; } } } else //If Imageset field is not exist in Fields List then there is no imageset { isNewImageSet = true; } } } }
/// <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> /// Construct Nativeset & ImageSet /// </summary> private List<DocumentDetail> ConstructNativeImageSet(bool isNewRecord, bool isNewImageSet, DocumentDetail docDetail, List<string> misMatchedFields, List<string> misMatchedFieldsMessage) { List<DocumentDetail> documentDetailList = new List<DocumentDetail>(); //1) Construct Native Set var nativeSetDocument = GetDocumentForNativeSet(docDetail.document, misMatchedFields, misMatchedFieldsMessage); var doc = new DocumentDetail(); doc.CorrelationId = docDetail.CorrelationId; doc.docType = DocumentsetType.NativeSet; doc.document = nativeSetDocument; doc.ParentDocId = docDetail.ParentDocId; doc.IsNewDocument = isNewRecord; doc.ConversationIndex = docDetail.ConversationIndex; doc.OverlayReImportField = docDetail.OverlayReImportField; doc.Reviewsets = docDetail.Reviewsets; #region Check Same Content File string existingContentFilePath = GetExistingContentFile(nativeSetDocument.CollectionId, nativeSetDocument.DocumentId); string contentFilePath = string.Empty; if (nativeSetDocument.DocumentBinary.FileList != null && nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault() != null) { contentFilePath = (!string.IsNullOrEmpty(nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault().Path) ? nativeSetDocument.DocumentBinary.FileList.Where(f => f.Type == Constants.TEXT_FILE_TYPE).FirstOrDefault().Path : string.Empty); } if (!string.IsNullOrEmpty(existingContentFilePath)) //If text File is exist during Append { if (!string.IsNullOrEmpty(contentFilePath)) { if (existingContentFilePath.Trim().ToLower() != contentFilePath.Trim().ToLower()) //New Content File Used in Overlay { doc.OverlayIsNewContentFile = true; } } else //If there is no text File during overlay , Need to maintain old content File { doc.OverlayIsNewContentFile = false; RVWExternalFileBEO file = new RVWExternalFileBEO { Type = Constants.TEXT_FILE_TYPE, Path = existingContentFilePath }; doc.document.DocumentBinary.FileList.Add(file); } } else if (string.IsNullOrEmpty(nativeSetDocument.CustomFieldToPopulateText) && !string.IsNullOrEmpty(contentFilePath)) //If there is no text File during Append { doc.OverlayIsNewContentFile = true; } else if (!string.IsNullOrEmpty(contentFilePath)) { doc.OverlayIsNewContentFile = false; } #endregion doc.SystemTags = m_JobParameter.SystemTags; doc.document.DocumentControlNumber = docDetail.document.DocumentControlNumber; documentDetailList.Add(doc); //2) Construct Image Set if (m_JobParameter.IsImportImages && !string.IsNullOrEmpty(m_JobParameter.ImageSetId)) { var imageSetDocument = GetDocumentForImageSet(docDetail.document, m_JobParameter.ImageSetId); var docImg = new DocumentDetail(); docImg.CorrelationId = docDetail.CorrelationId; docImg.docType = DocumentsetType.ImageSet; docImg.document = imageSetDocument; docImg.IsNewDocument = isNewImageSet; documentDetailList.Add(docImg); } return documentDetailList; }
/// <summary> /// Match document fomr bulk search result /// </summary> private static List<DocumentResult> DocumentMatchFromBulkSearchResult(DocumentDetail document, List<DocumentResult> bulkSearchresult) { List<DocumentResult> resultDocuments = new List<DocumentResult>(); if (bulkSearchresult != null && bulkSearchresult.Count > 0) { foreach (DocumentResult result in bulkSearchresult) { List<RVWDocumentFieldBEO> docFields = document.OverlayMatchingField; bool isMatch = false; foreach (RVWDocumentFieldBEO field in docFields) { string value = field.FieldValue.Trim('"'); if (result.Fields.Exists(f => f.Name == field.FieldName && f.Value == value)) isMatch = true; else break; } if (isMatch) { resultDocuments.Add(result); } } } return resultDocuments; }
/// <summary> /// Sends the specified document batch to next worker in the pipeline. /// </summary> /// <param name="documentBatch">The document batch.</param> /// <param name="isIncludeOutlookMailStoreDataEntityIfAvailable">if set to <c>true</c> [includes outlook mail store data entity in the send list (when available)].</param> private void Send(IEnumerable<RVWDocumentBEO> documentBatch, bool isIncludeOutlookMailStoreDataEntityIfAvailable) { try { DocumentCollection documentCollection = null; List<DocumentDetail> documentDetailList = new List<DocumentDetail>(); if (documentBatch != null) { foreach (RVWDocumentBEO document in documentBatch) { m_CounterForCorrelationId += 1; DocumentDetail documentDetail = new DocumentDetail { CorrelationId = m_CounterForCorrelationId.ToString(), docType = DocumentsetType.NativeSet, document = document, IsNewDocument = true }; documentDetailList.Add(documentDetail); } documentCollection = new DocumentCollection { dataset = m_Dataset, documents = documentDetailList }; } if (documentCollection != null) { Pipe vaultOutDataPipe = GetOutputDataPipe("Vault"); var message = new PipeMessageEnvelope() { Body = documentCollection }; if (vaultOutDataPipe != null) { vaultOutDataPipe.Send(message); } } // All available outlook mail stores are sent to the queue. they shouldn't be sent again. So clear existing list. if (isIncludeOutlookMailStoreDataEntityIfAvailable && m_OutlookMailStoreDataEntities != null && m_OutlookMailStoreDataEntities.Count > 0) { var message = new PipeMessageEnvelope() { Body = new EDocsDocumentCollection { OutlookMailStoreDataEntity = m_OutlookMailStoreDataEntities } }; Pipe eDocsOutlookEmailGeneratorOutputDataPipe = GetOutputDataPipe("EDocsOutlookEmailGenerator"); if (eDocsOutlookEmailGeneratorOutputDataPipe != null) { eDocsOutlookEmailGeneratorOutputDataPipe.Send(message); } m_OutlookMailStoreDataEntities.Clear(); } IncreaseProcessedDocumentsCount(documentCollection.documents.Count); } catch (Exception ex) { ex.Trace().Swallow(); } }
/// <summary> /// Sets the document error. /// </summary> /// <param name="documentErrorCollection">The document error collection.</param> /// <param name="documentDetail">The document detail.</param> /// <param name="logInfo">The log information.</param> private static void SetDocumentError(DocumentErrorCollection documentErrorCollection, DocumentDetail documentDetail, SearchIndexLogInfo logInfo) { if (documentErrorCollection == null||documentErrorCollection.FailedDocumentCount==0) return; var documentError = documentErrorCollection.DocumentErrors.FirstOrDefault( d => documentDetail.document.DocumentId.Equals(d.Id, StringComparison.CurrentCultureIgnoreCase)); if (documentError != null) logInfo.Message = documentError.ErrorMessage; }
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(); } } }
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); }