/// <summary> /// Updates the reviewset status to Active in DB /// </summary> /// <param name="reviewsetRecord"></param> private void UpdateReviewSetStatus(ReviewsetRecord reviewsetRecord) { var reviewsetEntity = ConvertToReviewsetBusinessEntity(reviewsetRecord); reviewsetEntity.IsAuditable = false; using (var transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { //if all the documents are added successfully then update the status of review set ReviewSetBO.UpdateReviewSet(reviewsetEntity, false); } }
/// <summary> /// Updates the reviewset status to Active in DB /// </summary> /// <param name="reviewsetRecord"></param> /// <param name="status"></param> /// <param name="isAuditable"></param> private void UpdateReviewSetStatus(ReviewsetRecord reviewsetRecord, int status, bool isAuditable = true) { ReviewsetDetailsBEO reviewsetEntity = ConvertToReviewsetBusinessEntity(reviewsetRecord, status); reviewsetEntity.IsAuditable = isAuditable; using (EVTransactionScope transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { //if all the documents are added successfully then update the status of review set ReviewSetBO.UpdateReviewSet(reviewsetEntity, false); } }
/// <summary> /// Get Native File Path /// </summary> private String GetNativeFilePath(String documentId) { string nativeFile = string.Empty; var documentVaultManager = new DocumentVaultManager(); using (EVTransactionScope transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { nativeFile = documentVaultManager.GetNativeFilePath(m_Dataset.Matter.FolderID, new Guid(m_JobParameter.CollectionId), documentId); } return(nativeFile); }
/// <summary> /// Unassigns the reviewset id for the list of documents from Vault /// </summary> /// <param name="documents">List<ReviewsetDocumentBEO></param> /// <param name="datasetId">long</param> private void UnAssignReviewsetInVault(List <ReviewsetDocumentBEO> documents, long datasetId) { //adds to DB using (var transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { //Get dataset details var dsBeo = DataSetBO.GetDataSetDetailForDataSetId(datasetId); dsBeo.ShouldNotBe(null); //Remove the reviewset association for the documents ReviewSetBO.DeleteDocumentsFromReviewSetForOverdrive(dsBeo.Matter.FolderID.ToString(), dsBeo.CollectionId, documents); } }
/// <summary> /// creates reviewset with given details /// </summary> /// <param name="reviewsetRecord"></param> /// <returns></returns> private string CreateReviewset(DocumentRecordCollection reviewsetRecord) { reviewsetRecord.ShouldNotBe(null); string reviewsetName = reviewsetRecord.ReviewsetDetails.ReviewSetName; if (m_AllReviewSetinBinder.Exists(o => o.ReviewSetName.ToLower() == reviewsetName.ToLower())) { throw new Exception(string.Format("{0}{1}{2}", Constants.ReviewsetNameLog, reviewsetRecord.ReviewsetDetails.ReviewSetName, Constants.AlreadyExistsLog)); } //create the review set with the details sent using (EVTransactionScope transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { CreateReviewSetTaskBEO reviewSetBusinesssEntity = ConverttoReviewsetBusinessEntity(reviewsetRecord.ReviewsetDetails); //Creates the reviewset string reviewsetId = ReviewSetBO.CreateReviewSetJob(reviewSetBusinesssEntity); return(reviewsetId); }; }
/// <summary> /// Bulks the update process set status. /// </summary> /// <param name="documentConversionLogBeos">The document conversion log beos.</param> private void BulkUpdateProcessSetStatus(IList <DocumentConversionLogBeo> documentConversionLogBeos) { try { using (var transScope = new EVTransactionScope(TransactionScopeOption.Required)) { if (!documentConversionLogBeos.Any()) { return; } documentVaultMngr.BulkUpdateConversionLogs(_matterId, documentConversionLogBeos); transScope.Complete(); } } catch (Exception exception) { //continue the production process with out updating the conversion /process status exception.Trace().Swallow(); } }
/// <summary> /// Overlay- Check ContentFile (i.e same file as used during Append) /// </summary> /// <param name="collectionId"></param> /// <param name="documentId"></param> /// <param name="textFilePath"></param> /// <param name="newTextFile"></param> /// <returns></returns> private string GetExistingContentFile(string collectionId, string documentId) { string contentFilePath = null; DocumentVaultManager docVaultManager = new DocumentVaultManager(); var collectionGUILD = new Guid(collectionId); RVWDocumentBEO document = null; using (EVTransactionScope transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { document = docVaultManager.GetDocumentFileDetails(m_Dataset.Matter.FolderID, new Guid(collectionId), documentId, 1, string.Empty); } if (document != null && document.DocumentBinary != null && document.DocumentBinary.FileList != null && document.DocumentBinary.FileList.Count > 0) { var contentFile = document.DocumentBinary.FileList.Where(f => f.Type == Constants.ExtractedText_FILE_TYPE); if (contentFile != null && contentFile.FirstOrDefault() != null) { contentFilePath = (!string.IsNullOrEmpty(contentFile.FirstOrDefault().Path) ? contentFile.FirstOrDefault().Path : string.Empty); } } return(contentFilePath); }
/// <summary> /// Get total document count. /// </summary> private Int64 SetTotalDocumentsCount() { var queryObject = new SearchQueryEntity(); queryObject.QueryList.Add(new Query(_searchQuery)); queryObject.MatterId = Convert.ToInt32(_dataset.Matter.FolderID); queryObject.DatasetId = Convert.ToInt32(_dataset.FolderID); if (!string.IsNullOrEmpty(_reviewsetId)) { queryObject.ReviewsetId = _reviewsetId; } queryObject.IsConceptSearchEnabled = _isIncludeConceptSearch; queryObject.LogSearchHistory = false; // Getting the All document and Tag document count from DB if (_parametersExportLoadFile.ExportLoadFileInfo != null) { switch (_parametersExportLoadFile.ExportLoadFileInfo.DocumentSelection) { case DocumentSelection.SavedQuery: var reviewerSearchService = new RVWReviewerSearchService(_webContext.Object); using (var transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { _totalDocumentCount = reviewerSearchService.GetDocumentCount(queryObject); } break; case DocumentSelection.Tag: _totalDocumentCount = DocumentBO.GetNoOfDocumentsByTag(queryObject.MatterId, _dataset.CollectionId, _parametersExportLoadFile.ExportLoadFileInfo.TagId); break; default: _totalDocumentCount = DocumentBO.GetNoOfDocuments(queryObject.MatterId, _dataset.CollectionId); break; } } return(_totalDocumentCount); }
/// <summary> /// Unassigns the reviewset id for the list of documents from Vault /// </summary> /// <param name="documents">List<ReviewsetDocumentBEO></param> /// <param name="datasetId">long</param> private void UnAssignReviewsetInVault(List<ReviewsetDocumentBEO> documents, long datasetId) { //adds to DB using (var transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { //Get dataset details var dsBeo = DataSetBO.GetDataSetDetailForDataSetId(datasetId); dsBeo.ShouldNotBe(null); //Remove the reviewset association for the documents ReviewSetBO.DeleteDocumentsFromReviewSetForOverdrive(dsBeo.Matter.FolderID.ToString(), dsBeo.CollectionId, documents); } }
/// <summary> /// Bulk search for entire batch document /// </summary> public List <DocumentDetail> BulkSearch(List <DocumentDetail> docDetailsList, UserBusinessEntity userInfo, out List <JobWorkerLog <OverlaySearchLogInfo> > overlayLogList) { var documentDetailList = new List <DocumentDetail>(); var logList = new List <JobWorkerLog <OverlaySearchLogInfo> >(); var overlayUniqueThreadString = string.Empty; var searchQueryText = new StringBuilder(); var outputFields = new List <Field>(); var docCount = 0; #region Construct Bulk Query foreach (var doc in docDetailsList) { if (docCount == 0) { outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field { FieldName = field.FieldName })); } docCount++; var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList(); if (!overlayMatchingField.Any()) { continue; } searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList())); if (docCount != docDetailsList.Count) { searchQueryText.Append(Constants.SearchORCondition); } } var strSearchQueryText = searchQueryText.ToString(); //To remove last OR Operator( " OR ") which added in search query. var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition); if (searchOrOperatorLastIndex != -1) { if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length) { strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex); } } #endregion #region Bulk Search ReviewerSearchResults bulkSearchresult; using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { var searchHelper = new OverlaySearchHelper(); bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId, m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields); } #endregion #region Construct Document From Search // DEBUG //docDetailsList.ForEach(docDetail => Parallel.ForEach(docDetailsList, docDetail => { JobWorkerLog <OverlaySearchLogInfo> overlayLog = null; string threadConstraint; var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog); lock (documentDetailList) { if (docs != null) { documentDetailList.AddRange(docs); } if (overlayLog != null) { logList.Add(overlayLog); } if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) { overlayUniqueThreadString = threadConstraint; } } }); overlayLogList = logList; #endregion #region Find and Purify Duplicate match document RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList); #endregion return(documentDetailList); }
/// <summary> /// Get Native File Path /// </summary> private String GetNativeFilePath(String documentId) { string nativeFile = string.Empty; var documentVaultManager = new DocumentVaultManager(); using (EVTransactionScope transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { nativeFile = documentVaultManager.GetNativeFilePath(m_Dataset.Matter.FolderID, new Guid(m_JobParameter.CollectionId), documentId); } return nativeFile; }
/// <summary> /// Bulk search for entire batch document /// </summary> public List<DocumentDetail> BulkSearch(List<DocumentDetail> docDetailsList, UserBusinessEntity userInfo, out List<JobWorkerLog<OverlaySearchLogInfo>> overlayLogList) { var documentDetailList = new List<DocumentDetail>(); var logList = new List<JobWorkerLog<OverlaySearchLogInfo>>(); var overlayUniqueThreadString = string.Empty; var searchQueryText = new StringBuilder(); var outputFields = new List<Field>(); var docCount = 0; #region Construct Bulk Query foreach (var doc in docDetailsList) { if (docCount == 0) { outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field {FieldName = field.FieldName})); } docCount++; var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList(); if (!overlayMatchingField.Any()) continue; searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList())); if (docCount != docDetailsList.Count) searchQueryText.Append(Constants.SearchORCondition); } var strSearchQueryText = searchQueryText.ToString(); //To remove last OR Operator( " OR ") which added in search query. var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition); if (searchOrOperatorLastIndex != -1) { if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length) { strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex); } } #endregion #region Bulk Search ReviewerSearchResults bulkSearchresult; using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { var searchHelper = new OverlaySearchHelper(); bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId, m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields); } #endregion #region Construct Document From Search // DEBUG //docDetailsList.ForEach(docDetail => Parallel.ForEach(docDetailsList, docDetail => { JobWorkerLog<OverlaySearchLogInfo> overlayLog = null; string threadConstraint; var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog); lock (documentDetailList) { if (docs != null) documentDetailList.AddRange(docs); if (overlayLog != null) logList.Add(overlayLog); if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) overlayUniqueThreadString = threadConstraint; } }); overlayLogList = logList; #endregion #region Find and Purify Duplicate match document RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList); #endregion return documentDetailList; }
/// <summary> /// Updates the reviewset status to Active in DB /// </summary> /// <param name="reviewsetRecord"></param> /// <param name="status"></param> /// <param name="isAuditable"></param> private void UpdateReviewSetStatus(ReviewsetRecord reviewsetRecord, int status,bool isAuditable=true) { ReviewsetDetailsBEO reviewsetEntity = ConvertToReviewsetBusinessEntity(reviewsetRecord, status); reviewsetEntity.IsAuditable = isAuditable; using (EVTransactionScope transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { //if all the documents are added successfully then update the status of review set ReviewSetBO.UpdateReviewSet(reviewsetEntity, false); } }
/// <summary> /// creates reviewset with given details /// </summary> /// <param name="reviewsetRecord"></param> /// <returns></returns> private string CreateReviewset(DocumentRecordCollection reviewsetRecord) { reviewsetRecord.ShouldNotBe(null); string reviewsetName = reviewsetRecord.ReviewsetDetails.ReviewSetName; if (m_AllReviewSetinBinder.Exists(o => o.ReviewSetName.ToLower() == reviewsetName.ToLower())) { throw new Exception(string.Format("{0}{1}{2}", Constants.ReviewsetNameLog, reviewsetRecord.ReviewsetDetails.ReviewSetName, Constants.AlreadyExistsLog)); } //create the review set with the details sent using (EVTransactionScope transScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { CreateReviewSetTaskBEO reviewSetBusinesssEntity = ConverttoReviewsetBusinessEntity(reviewsetRecord.ReviewsetDetails); //Creates the reviewset string reviewsetId = ReviewSetBO.CreateReviewSetJob(reviewSetBusinesssEntity); return reviewsetId; }; }
/// <summary> /// Overlay- Check ContentFile (i.e same file as used during Append) /// </summary> /// <param name="collectionId"></param> /// <param name="documentId"></param> /// <param name="textFilePath"></param> /// <param name="newTextFile"></param> /// <returns></returns> private string GetExistingContentFile(string collectionId, string documentId) { string contentFilePath = null; DocumentVaultManager docVaultManager = new DocumentVaultManager(); var collectionGUILD = new Guid(collectionId); RVWDocumentBEO document = null; using (EVTransactionScope transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { document = docVaultManager.GetDocumentFileDetails(m_Dataset.Matter.FolderID, new Guid(collectionId), documentId, 1, string.Empty); } if (document != null && document.DocumentBinary != null && document.DocumentBinary.FileList != null && document.DocumentBinary.FileList.Count > 0) { var contentFile = document.DocumentBinary.FileList.Where(f => f.Type == Constants.ExtractedText_FILE_TYPE); if (contentFile != null && contentFile.FirstOrDefault() != null) { contentFilePath = (!string.IsNullOrEmpty(contentFile.FirstOrDefault().Path) ? contentFile.FirstOrDefault().Path : string.Empty); } } return contentFilePath; }
/// <summary> /// Bulks the update process set status. /// </summary> /// <param name="documentConversionLogBeos">The document conversion log beos.</param> private void BulkUpdateProcessSetStatus(IList<DocumentConversionLogBeo> documentConversionLogBeos) { try { using (var transScope = new EVTransactionScope(TransactionScopeOption.Required)) { if (!documentConversionLogBeos.Any()) return; documentVaultMngr.BulkUpdateConversionLogs(_matterId, documentConversionLogBeos); transScope.Complete(); } } catch (Exception exception) { //continue the production process with out updating the conversion /process status exception.Trace().Swallow(); } }
/// <summary> /// To assign document control number for new documents /// </summary> /// <param name="documents"></param> private void AssignDocumentControlNumber(List<RVWDocumentBEO> documents) { long numericPartOfDcn; #region Delegate - logic to get complete DCN readily, given the numeric value as input Func<string, string> getDcn = delegate(string newLastDcnNumericPart) { var padString = string.Empty; // pad zeros if (newLastDcnNumericPart.Length < _datasetDetails.DCNStartWidth.Length) { var numberOfZerosTobePadded = _datasetDetails.DCNStartWidth.Length - newLastDcnNumericPart.Length; for (var i = 0; i < numberOfZerosTobePadded; i++) { padString += "0"; } } return _datasetDetails.DCNPrefix + padString + newLastDcnNumericPart; }; #endregion Delegate - logic to get complete DCN readily, given the numeric value as input using (var lowerTransScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { var currentDcn = DataSetBO.GetLastDocumentControlNumber(_datasetDetails.FolderID); // If DCN is not obtained, no documents are imported for the dataset till now. // So set current DCN to first DCN value. if (string.IsNullOrWhiteSpace(currentDcn)) { currentDcn = _datasetDetails.DCNPrefix + Constants.StringZero; } else { if (!currentDcn.Contains(_datasetDetails.DCNPrefix)) { var currentNumber = Convert.ToInt32(currentDcn); currentNumber = currentNumber - 1; currentDcn = currentNumber.ToString(CultureInfo.InvariantCulture); currentDcn = _datasetDetails.DCNPrefix + currentDcn; } } // 1) Get Last DCN from EVMaster DB and 2) Pick Numeric part of it // throws exception if numeric part couldn't be retrieved, throw Exception. if (IsNumeric(currentDcn.Substring(_datasetDetails.DCNPrefix.Length), out numericPartOfDcn)) { // Update new DCN after bulk add, assuming bulk add would be successful. // The delegate, GetNewLastDCNAfterBulkAdd gets DCN to be updated back to DB. // Delegates takes numeric part of WOULD BE DCN value as input, returns complete DCN - so that it can readily be updated back to Dataset table. var newDcn = getDcn((numericPartOfDcn + documents.Count()).ToString(CultureInfo.InvariantCulture)); DataSetBO.UpdateLastDocumentControlNumber(_datasetDetails.FolderID, newDcn); lowerTransScope.Complete(); } else { throw new Exception(ErrorCodes.InvalidDCNValueObtainedForDataset); } } #region Assign DCN to all documents var dCnIncrementalCounter = numericPartOfDcn; foreach (var document in documents) { dCnIncrementalCounter += 1; document.DocumentControlNumber = getDcn(dCnIncrementalCounter.ToString(CultureInfo.InvariantCulture)); } #endregion }
private void AssignDocumentControlNumber(List <LoadFileRecord> records) { long numericPartOfDcn = 0; #region Delegate - logic to get complete DCN readily, given the numeric value as input Func <string, string> getDcn = delegate(string newLastDcnNumericPart) { var padString = string.Empty; // pad zeros if (newLastDcnNumericPart.Length < m_Dataset.DCNStartWidth.Length) { var numberOfZerosTobePadded = m_Dataset.DCNStartWidth.Length - newLastDcnNumericPart.Length; for (var i = 0; i < numberOfZerosTobePadded; i++) { padString += "0"; } } return(m_Dataset.DCNPrefix + padString + newLastDcnNumericPart); }; #endregion Delegate - logic to get complete DCN readily, given the numeric value as input using (var lowerTransScope = new EVTransactionScope(TransactionScopeOption.Suppress)) { m_CurrentDcn = DataSetBO.GetLastDocumentControlNumber(m_Dataset.FolderID); // If DCN is not obtained, no documents are imported for the dataset till now. // So set current DCN to first DCN value. if (string.IsNullOrWhiteSpace(m_CurrentDcn)) { m_CurrentDcn = m_Dataset.DCNPrefix + Constants.StringZero; } else { if (!m_CurrentDcn.Contains(m_Dataset.DCNPrefix)) { var currentNumber = Convert.ToInt32(m_CurrentDcn); currentNumber = currentNumber - 1; m_CurrentDcn = currentNumber.ToString(); m_CurrentDcn = m_Dataset.DCNPrefix + m_CurrentDcn; } } // 1) Get Last DCN from EVMaster DB and 2) Pick Numeric part of it // throws exception if numeric part couldn't be retrieved, throw Exception. if (IsNumeric(m_CurrentDcn.Substring(m_Dataset.DCNPrefix.Length), out numericPartOfDcn)) { // Update new DCN after bulk add, assuming bulk add would be successful. // The delegate, GetNewLastDCNAfterBulkAdd gets DCN to be updated back to DB. // Delegates takes numeric part of WOULD BE DCN value as input, returns complete DCN - so that it can readily be updated back to Dataset table. m_NewDcn = getDcn((numericPartOfDcn + records.Count()).ToString(CultureInfo.InvariantCulture)); DataSetBO.UpdateLastDocumentControlNumber(m_Dataset.FolderID, m_NewDcn); lowerTransScope.Complete(); } else { throw new Exception(ErrorCodes.InvalidDCNValueObtainedForDataset); } } #region Assign DCN to all documents var dCNIncrementalCounter = numericPartOfDcn; records.ForEach(p => { dCNIncrementalCounter += 1; p.DocumentControlNumber = getDcn(dCNIncrementalCounter.ToString(CultureInfo.InvariantCulture)); }); #endregion }