/// <summary> /// To Update docs to Review set or Remove docs from Review set /// </summary> /// <param name="reviewsetId">string</param> /// <param name="rsDocBeoList">IEnumerable<ReviewsetDocumentBEO/></param> /// <param name="datasetId">string</param> /// <returns>boolean</returns> private bool RemoveDocumentsBychunk(string datasetId, string reviewsetId, IEnumerable <ReviewsetDocumentBEO> rsDocBeoList) { const bool bFlag = true; int iChunkSize = Convert.ToInt32(ConfigurationManager.AppSettings.Get(Constants.DocumentsChunkSize)); if (rsDocBeoList != null) { int iRsDocCount = rsDocBeoList.Count(); int iNoOfChunks = iRsDocCount / iChunkSize; int remValue = iRsDocCount % iChunkSize; for (int i = 0; i < iNoOfChunks; i++) { List <ReviewsetDocumentBEO> tempList = rsDocBeoList.ToList().GetRange(iChunkSize * i, iChunkSize); ReviewSetService.DeleteDocumentFromReviewSet(datasetId, reviewsetId, tempList); } if (remValue > 0) { List <ReviewsetDocumentBEO> remainderList = rsDocBeoList.ToList().GetRange(iChunkSize * iNoOfChunks, remValue); ReviewSetService.DeleteDocumentFromReviewSet(datasetId, reviewsetId, remainderList); } } return(bFlag); }
/// <summary> /// Atomic work 1) Delete search sub-system Data 2) Delete Vault Data 3) Delete EVMaster Data /// </summary> /// <param name="task"></param> /// <param name="jobParameters"></param> /// <returns></returns> protected override bool DoAtomicWork(UpdateReviewSetTaskBEO task, UpdateReviewSetJobBEO jobParameters) { bool output = false; try { //Fetching the dataset details DataSetService.GetDataSet(task.DatasetId.ToString(CultureInfo.InvariantCulture)); string activity = task.Activity; switch (activity) { case Constants.Add: { //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task, task.Documents, jobParameters.CreatedByGUID); AddDocumentsBychunk(task.DatasetId.ToString(CultureInfo.InvariantCulture), task.reviewSetId, rsDocBeoList); //Update Review set service task.NumberOfDocuments += rsDocBeoList.Count(); task.StatusId = 1; task.Action = "Add"; task.IsAuditable = true; ReviewSetService.UpdateReviewSetJob(task); break; } case Constants.Remove: { //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task, task.Documents, jobParameters.CreatedByGUID); //Remove documents from vault and search sub-system RemoveDocumentsBychunk(task.DatasetId.ToString(CultureInfo.InvariantCulture), task.reviewSetId, rsDocBeoList); //Update Review set service task.NumberOfDocuments -= rsDocBeoList.Count(); task.StatusId = 1; task.Action = "Remove"; task.IsAuditable = true; ReviewSetService.UpdateReviewSetJob(task); break; } case Constants.Archive: { if (task.Documents.Count > 0) { //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task, task.Documents, jobParameters.CreatedByGUID); //Remove documents from vault and search sub-system RemoveDocumentsBychunk(task.DatasetId.ToString(CultureInfo.InvariantCulture), task.reviewSetId, rsDocBeoList); } //Update Review set service - Archiving ReviewSetService.UpdateReviewSetJob(task); break; } default: { //If the reviewset is getting archived if (task.StatusId.Equals(2)) { //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task, task.Documents, jobParameters.CreatedByGUID); //Remove documents from vault and search sub-system RemoveDocumentsBychunk(task.DatasetId.ToString(CultureInfo.InvariantCulture), task.reviewSetId, rsDocBeoList); //Update Review set service - Archiving ReviewSetService.UpdateReviewSetJob(task); } break; } } } catch (Exception ex) { ex.AddDbgMsg("Problem in DoAtomicWork of the UpdateReviewset"); ex.Trace().Swallow(); } return(output); }
/// <summary> /// Atomic work 1) Delete search sub-system Data 2) Delete Vault Data 3) Delete EVMaster Data /// </summary> /// <param name="task"></param> /// <param name="jobParameters"></param> /// <returns></returns> protected override bool DoAtomicWork(MergeReviewSetTaskBEO task, MergeReviewSetJobBEO jobParameters) { bool output = false; try { string datasetId = task.DatasetId.ToString(CultureInfo.InvariantCulture); switch (task.Activity) { case Constants.Create: { /*since documents not needed for create reviewset, removing the docouments from the ReviewsetTaskBeo*/ List <RVWDocumentBEO> taskDocs = new List <RVWDocumentBEO>(); task.Documents.SafeForEach(taskDocs.Add); task.Documents.Clear(); CreateReviewSetTaskBEO createReviewSetTaskBeo = ConvertToCTaskBeo(task); createReviewSetTaskBeo.StatusId = 1; createReviewSetTaskBeo.Activity = Constants.Merge; createReviewSetTaskBeo.SplittingOption = Constants.Single; /*Create Reviewset*/ task.reviewSetId = ReviewSetService.CreateReviewSetJob(createReviewSetTaskBeo); taskDocs.SafeForEach(o => task.Documents.Add(o)); UpdateReviewSetTaskBEO updateReviewSetTaskBeo = ConvertToUTaskBeo(task); updateReviewSetTaskBeo.StatusId = 1; updateReviewSetTaskBeo.Activity = Constants.Merge; updateReviewSetTaskBeo.SplittingOption = Constants.Single; ReviewSetService.UpdateReviewSetJob(updateReviewSetTaskBeo); //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task.ReviewSetId, task.Documents); output = AddDocumentsBychunk(datasetId, task.reviewSetId, rsDocBeoList); output = true; break; } default: { if (task.Documents.Count > 0) { //Assigning the reviewset id to the documents IEnumerable <ReviewsetDocumentBEO> rsDocBeoList = PopulateReviewSetDocumentEntites(task.ReviewSetId, task.Documents); //Delete documents from vault and from search sub-system output = RemoveDocumentsBychunk(datasetId, task.reviewSetId, rsDocBeoList); } //Update Review set service - Archiving UpdateReviewSetTaskBEO updateReviewSetTaskBeo = ConvertToUTaskBeo(task); ReviewSetService.UpdateReviewSetJob(updateReviewSetTaskBeo); output = true; break; } } } catch (Exception ex) { ex.AddResMsg(ErrorCodes.ProblemInDoAtomicWork).Trace().Swallow(); } return(output); }
/// <summary> /// Generates No.of Reviewsets to be created tasks /// </summary> /// <param name="jobParameters">Create Reviewset BEO</param> /// <param name="lastCommitedTaskCount">int</param> /// <returns>List of Create ReviewsetJob Tasks (BEOs)</returns> protected override Tasks <MergeReviewSetTaskBEO> GenerateTasks(MergeReviewSetJobBEO jobParameters, out int lastCommitedTaskCount) { Tasks <MergeReviewSetTaskBEO> tasks = new Tasks <MergeReviewSetTaskBEO>(); lastCommitedTaskCount = 0; try { if (jobParameters != null) { string datasetId = jobParameters.DatasetId.ToString(CultureInfo.InvariantCulture); /* Get Dataset Details for dataset id to get know about the Collection id and the Matter ID*/ DatasetBEO datasetEntity = DataSetService.GetDataSet(datasetId); string sMatterId = datasetEntity.Matter.FolderID.ToString(CultureInfo.InvariantCulture); jobParameters.Activity = Constants.Create; List <RVWDocumentBEO> docList = new List <RVWDocumentBEO>(); List <MergeReviewSetTaskBEO> mergedRsList = new List <MergeReviewSetTaskBEO>(); foreach (string reviewsetId in jobParameters.MergedReviewSetIds) { ReviewsetDetailsBEO reviewsetDetailsBeo = ReviewSetService.GetReviewSetDetails(sMatterId, reviewsetId); ReviewerSearchResults qualifiedDocuments = new ReviewerSearchResults(); jobParameters.ReviewSetId = reviewsetId; var queryContext = ConstructDocQueryEntity(jobParameters, datasetEntity); queryContext.TransactionName = "MergeReviewSetJob - DoAtomicWork"; ReviewerSearchResults searchDocs = JobSearchHandler.GetAllDocuments(queryContext, false); if (searchDocs != null) { searchDocs.ResultDocuments.SafeForEach(x => qualifiedDocuments.ResultDocuments.Add(x)); } List <RVWDocumentBEO> iterationDocuments = qualifiedDocuments.ResultDocuments. Select(d => new RVWDocumentBEO { DocumentId = d.DocumentID, MatterId = d.MatterID, CollectionId = d.CollectionID, FamilyId = d.FamilyID }).ToList(); reviewsetDetailsBeo.Documents.Clear(); reviewsetDetailsBeo.Documents.AddRange(iterationDocuments); reviewsetDetailsBeo.StatusId = 2; MergeReviewSetTaskBEO mReviewsetDetailsBeo = ConvertToTaskBeo(reviewsetDetailsBeo); docList.AddRange(reviewsetDetailsBeo.Documents); mergedRsList.Add(mReviewsetDetailsBeo); } jobParameters.Documents.AddRange(docList); tasks.Add(mergedRsList); MergeReviewSetTaskBEO lstUpdateReviewSetTaskBeo = ConvertToTaskBeo(jobParameters); tasks.Add(lstUpdateReviewSetTaskBeo); for (int i = 1; i <= tasks.Count; i++) { tasks[i - 1].TaskNumber = i; } } else { lastCommitedTaskCount = 0; EvLog.WriteEntry(Constants.JobLogName + Constants.GenerateTasks, Constants.JobParamND, EventLogEntryType.Error); JobLogInfo.AddParameters(Constants.JobParamND); JobLogInfo.IsError = true; } } catch (Exception ex) { LogException(JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInGenerateTasks); } return(tasks); }