/// <summary> /// Logs the message. /// </summary> /// <param name="customMessage">The custom message.</param> /// <param name="isError">if set to <c>true</c> [is error].</param> /// <param name="category">The category.</param> /// <param name="additionalDetail">The additional detail.</param> private void LogMessage(string customMessage, bool isError, LogCategory category, List <KeyValuePair <string, string> > additionalDetail) { if (category == LogCategory.Job) { JobLogInfo.AddParameters(customMessage); if (additionalDetail != null && additionalDetail.Count > 0) { foreach (var keyValue in additionalDetail) { JobLogInfo.AddParameters(keyValue.Key, keyValue.Value); } } JobLogInfo.IsError = isError; } else if (category == LogCategory.Task) { TaskLogInfo.AddParameters(customMessage); if (additionalDetail != null && additionalDetail.Count > 0) { foreach (var keyValue in additionalDetail) { TaskLogInfo.AddParameters(keyValue.Key, keyValue.Value); } } TaskLogInfo.IsError = isError; } }
/// <summary> /// Logs the message. /// </summary> /// <param name="customMessage">The custom message.</param> /// <param name="isError">if set to <c>true</c> [is error].</param> /// <param name="category">The category.</param> /// <param name="additionalDetail">The additional detail.</param> private void LogMessage(string customMessage, bool isError, LogCategory category, List <KeyValuePair <string, string> > additionalDetail) { switch (category) { case LogCategory.Job: JobLogInfo.AddParameters(customMessage); JobLogInfo.IsError = isError; if (additionalDetail != null && additionalDetail.Count > 0) { foreach (KeyValuePair <string, string> keyValue in additionalDetail) { JobLogInfo.AddParameters(keyValue.Key, keyValue.Value); } } break; case LogCategory.Task: TaskLogInfo.AddParameters(customMessage); TaskLogInfo.IsError = isError; if (additionalDetail != null && additionalDetail.Count > 0) { foreach (KeyValuePair <string, string> keyValue in additionalDetail) { TaskLogInfo.AddParameters(keyValue.Key, keyValue.Value); } } break; } }
/// <summary> /// This is the overriden Shutdown() method. /// </summary> /// <param name="jobParameters">Input settings / parameters of the job.</param> protected override void Shutdown(GlobalReplaceJobBEO jobParameters) { try { LogMessage(Constants.ShutdownLogMessage, false, LogCategory.Job, null); GetGlobalReplaceBEO(jobParameters.BootParameters); JobLogInfo.CustomMessage = Constants.JobSummary; JobLogInfo.AddParameters(Constants.JobName, Constants.JOB_NAME); JobLogInfo.AddParameters(Constants.EV_AUDIT_ACTUAL_STRING, jobParameters.ActualString); JobLogInfo.AddParameters(Constants.EV_AUDIT_REPLACE_STRING, jobParameters.ReplaceString); } catch (EVException ex) { EvLog.WriteEntry(Constants.JOB_NAME + Constants.ShutdownErrorMessage, ex.ToUserString(), EventLogEntryType.Error); LogException(jobParameters.JobId, ex, Constants.ShutdownErrorMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobExecution); } catch (Exception ex) { EvLog.WriteEntry(Constants.JOB_NAME + Constants.ShutdownErrorMessage, ex.Message, EventLogEntryType.Error); LogException(jobParameters.JobId, ex, Constants.ShutdownErrorMessage, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobExecution); } finally { _mMatter = null; _mOrginatorField = null; } }
/// <summary> /// Handles the exception. /// </summary> /// <param name="category">The category.</param> /// <param name="customMessage">The custom message.</param> /// <param name="ex">The ex.</param> /// <param name="errorCode">Error Code</param> private void HandleException(LogCategory category, string customMessage, Exception ex, string errorCode) { if (category == LogCategory.Job) { JobLogInfo.AddParameters(customMessage); EVJobException jobException = new EVJobException(errorCode, ex, JobLogInfo); throw (jobException); } TaskLogInfo.AddParameters(customMessage); EVTaskException taskException = new EVTaskException(errorCode, ex, TaskLogInfo); throw (taskException); }
/// <summary> /// Handles the exception. /// </summary> /// <param name="category">The category.</param> /// <param name="ex">The ex.</param> /// <param name="taskKey">string</param> /// <param name="errorCode">Error Code</param> private void HandleException(LogCategory category, Exception ex, string taskKey, string errorCode) { if (category == LogCategory.Job) { JobLogInfo.AddParameters(ex.Message); var jobException = new EVJobException(errorCode, ex, JobLogInfo); throw jobException; } TaskLogInfo.AddParameters(ex.Message); TaskLogInfo.TaskKey = taskKey; var taskException = new EVTaskException(errorCode, ex, TaskLogInfo); throw taskException; }
/// <summary> /// Override version of Initialize /// </summary> /// <param name="jobId">Job Id</param> /// <param name="jobRunId">Run Id</param> /// <param name="bootParameters">Parameters xml</param> /// <param name="createdByGuid">User Guid</param> /// <returns>Job Business Object</returns> protected override DeduplicationJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdByGuid) { DeduplicationJobBEO jobBeo = null; try { jobBeo = new DeduplicationJobBEO { JobId = jobId, JobName = Constants.JobName, JobRunId = jobRunId }; var userEntityOfJobOwner = UserBO.GetUserUsingGuid(createdByGuid); jobBeo.JobScheduleCreatedBy = (userEntityOfJobOwner.DomainName.Equals("N/A")) ? userEntityOfJobOwner.UserId : userEntityOfJobOwner.DomainName + "\\" + userEntityOfJobOwner.UserId; jobBeo.JobTypeName = Constants.JobTypeName; _createdByUserName = jobBeo.JobScheduleCreatedBy; EvLog.WriteEntry(jobId.ToString(CultureInfo.InvariantCulture), Constants.EVENT_JOB_INITIALIZATION_VALUE, EventLogEntryType.Information); jobBeo.StatusBrokerType = BrokerType.Database; jobBeo.CommitIntervalBrokerType = BrokerType.ConfigFile; jobBeo.CommitIntervalSettingType = SettingType.CommonSetting; var deduplicationProfileBeo = GetDeduplicationProfileBEO(bootParameters); if (deduplicationProfileBeo != null) { jobBeo.DatasetInfo.Clear(); deduplicationProfileBeo.DatasetInfo.SafeForEach(o => jobBeo.DatasetInfo.Add(o)); jobBeo.CompareType = deduplicationProfileBeo.CompareType; jobBeo.Algorithm = deduplicationProfileBeo.Algorithm; jobBeo.IsDelete = deduplicationProfileBeo.IsDelete && deduplicationProfileBeo.IsDelete; jobBeo.IsGroup = deduplicationProfileBeo.IsGroup && deduplicationProfileBeo.IsGroup; } else { EvLog.WriteEntry(jobId.ToString(CultureInfo.InvariantCulture), Constants.EVENT_JOB_INITIALIZATION_KEY, EventLogEntryType.Information); JobLogInfo.AddParameters(Constants.EVENT_JOB_INITIALIZATION_KEY); } } catch (Exception exp) { EvLog.WriteEntry(jobId + Constants.EVENT_INITIALIZATION_EXCEPTION_VALUE, exp.Message, EventLogEntryType.Error); LogException(jobId, exp, Constants.EVENT_INITIALIZATION_EXCEPTION_VALUE, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } return(jobBeo); }
/// <summary> /// Logs the exception message. /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="exp">exception received</param> /// <param name="msg">message to be logged</param> /// <param name="category">To identify the job or task to log the message</param> /// <param name="taskKey">Key value pair to identify the Task, need for task log only</param> /// <param name="errorCode">string</param> private void LogException(int jobId, Exception exp, string msg, LogCategory category, string taskKey, string errorCode) { if (category == LogCategory.Job) { JobLogInfo.AddParameters(jobId + msg); var jobException = new EVJobException(errorCode, exp, JobLogInfo); throw (jobException); } TaskLogInfo.AddParameters(jobId + msg); TaskLogInfo.TaskKey = taskKey; var taskException = new EVTaskException(errorCode, exp, TaskLogInfo); throw (taskException); }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Job created by</param> /// <returns>Job Business Entity</returns> protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { BaseJobBEO jobBeo = new BaseJobBEO(); try { EvLog.WriteEntry(Constants.JobTypeName + " - " + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Start, EventLogEntryType.Information); //Initialize the JobBEO object jobBeo.JobId = jobId; jobBeo.JobRunId = jobRunId; jobBeo.JobName = Constants.JobTypeName + " " + DateTime.UtcNow; //fetch UserEntity UserBusinessEntity userBusinessEntity = UserBO.GetUserUsingGuid(createdBy); jobBeo.JobScheduleCreatedBy = (userBusinessEntity.DomainName.Equals("N/A")) ? userBusinessEntity.UserId : userBusinessEntity.DomainName + "\\" + userBusinessEntity.UserId; userBusinessEntity = null; jobBeo.JobTypeName = Constants.JobTypeName; // Default settings jobBeo.StatusBrokerType = BrokerType.Database; jobBeo.CommitIntervalBrokerType = BrokerType.ConfigFile; jobBeo.CommitIntervalSettingType = SettingType.CommonSetting; if (bootParameters != null) { jobBeo.BootParameters = bootParameters; } else { throw new EVException().AddDbgMsg("{0}:{1}:{2}", jobId, Constants.Event_Job_Initialize_Start, Constants.XmlNotWellFormed). AddResMsg(ErrorCodes.XmlStringNotWellFormed); } Tracer.Info("{0} - {1}:{2}", Constants.JobTypeName, jobId, Constants.Event_Job_Initialize_Success); } catch (EVJobException ex) { _isJobFailed = true; ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name); throw; } catch (Exception ex) { _isJobFailed = true; ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name); JobLogInfo.AddParameters("Problem in" + Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name); EVJobException jobException = new EVJobException(ErrorCodes.InitializeError, ex, JobLogInfo); throw (jobException); } return(jobBeo); }
/// <summary> /// Before job shuts down, shall update job next run /// </summary> /// <param name="jobParameters">Job Business Object</param> protected override void Shutdown(BaseJobBEO jobParameters) { try { EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId, Constants.Event_Job_ShutDown, EventLogEntryType.Information); #region Notification section //get job details var jobDetails = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString()); if (jobDetails != null && jobDetails.NotificationId > 0) { var defaultMessage = string.Empty; defaultMessage = isJobFailed ? string.Format(Constants.NotificationErrorMessageFormat, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName) : documentCount > 0 ? string.Format(Constants.NotificationSuccessMessageFormat, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName, documentCount, ApplicationConfigurationManager.GetValue(Constants.CaseMapUrl), conversionId, fileType) : string.Format(Constants.NotificationSuccessMessageFormatZeroDocs, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName); CustomNotificationMessage = defaultMessage; } JobLogInfo.AddParameters(Constants.CreatedBy, jobParameters.JobScheduleCreatedBy); JobLogInfo.AddParameters(Constants.DocumentIncludedInXml, Convert.ToString(documentCount)); #endregion } catch (EVJobException ex) { EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); LogException(JobLogInfo, ex, LogCategory.Job, ErrorCodes.ProblemInShutDown, string.Empty); } catch (Exception ex) { isJobFailed = true; // Handle exception in Generate Tasks EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); LogException(JobLogInfo, ex, LogCategory.Job, ErrorCodes.ProblemInShutDown, string.Empty); } }
/// <summary> /// This is the overridden GenerateTasks() method. /// </summary> /// <param name="jobParameters">Input settings / parameters of the job.</param> /// <param name="previouslyCommittedTaskCount">integer</param> /// <returns>List of tasks to be performed.</returns> protected override Tasks <BaseJobTaskBusinessEntity> GenerateTasks(BaseJobBEO jobParameters, out int previouslyCommittedTaskCount) { previouslyCommittedTaskCount = 0; Tasks <BaseJobTaskBusinessEntity> tasks = new Tasks <BaseJobTaskBusinessEntity>(); try { EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Start, EventLogEntryType.Information); //De serialize the Boot parameters SendEmailServiceRequestBEO request = (SendEmailServiceRequestBEO)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(SendEmailServiceRequestBEO)); int i = 0; //Construct The Task if (tasks.Count <= 0) { int docCount = request.Documents.Count; for (int k = 0; k < docCount; k++) { BaseJobTaskBusinessEntity task = new BaseJobTaskBusinessEntity { TaskNumber = ++i, TaskComplete = false, TaskPercent = (float)100 / docCount }; //Construct The Task tasks.Add(task); } } } catch (Exception ex) { //Send Email Failure notification SendEmailBO.SendNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), false); //Update Delivery Status to Failed DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Failed + ":" + ex.Message, EventLogEntryType.Error); //LogInfo logMsg = new LogInfo(); JobLogInfo.AddParameters(Constants.Event_Job_GenerateTask_Failed + Constants.Colon + ex.Message); EVJobException jobException = new EVJobException(ErrorCodes.ProblemInGenerateTasks, ex, JobLogInfo); throw (jobException); } return(tasks); }
/// <summary> /// Before job shuts down, shall update job next run /// </summary> /// <param name="jobParameters">Job Business Object</param> protected override void Shutdown(BaseJobBEO jobParameters) { try { EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_ShutDown, EventLogEntryType.Information); #region Notification section //get job details JobBusinessEntity jobDetails = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString(CultureInfo.InvariantCulture)); if (jobDetails != null && jobDetails.NotificationId > 0) { string defaultMessage = string.Empty; defaultMessage = _isJobFailed ? string.Format(Constants.NotificationErrorMessageFormat, !string.IsNullOrEmpty(_requestDescription) ? _requestDescription : Constants.TaskName) : string.Format(Constants.NotificationSuccessMessageFormat, _requestDescription, _documentCount, ApplicationConfigurationManager.GetValue(Constants.CaseMapUrl), _conversionId.ToString()); CustomNotificationMessage = defaultMessage; } #endregion JobLogInfo.AddParameters(Constants.CreatedBy, jobParameters.JobScheduleCreatedBy); JobLogInfo.AddParameters(Constants.DocumentIncludedInXml, Convert.ToString(_documentCount)); JobLogInfo.AddParameters(Constants.TaskStartTime, Convert.ToString(startedTime)); JobLogInfo.AddParameters(Constants.TaskEndTime, Convert.ToString(DateTime.UtcNow)); } catch (EVJobException ex) { EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); throw; } catch (Exception ex) { _isJobFailed = true; // Handle exception in Generate Tasks EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); EVJobException jobException = new EVJobException(ErrorCodes.DoAtomicError, ex); JobLogInfo.AddParameters(Constants.JobRunId, jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture)); jobException.LogMessge = JobLogInfo; throw (jobException); } }
/// <summary> /// Generates No.of Reviewsets to be created tasks /// </summary> /// <param name="jobParameters">Create Reviewset BEO</param> /// <param name="lastCommitedTaskCount"> </param> /// <returns>List of Create ReviewsetJob Tasks (BEOs)</returns> protected override Tasks <UpdateReviewSetTaskBEO> GenerateTasks(UpdateReviewSetJobBEO jobParameters, out int lastCommitedTaskCount) { Tasks <UpdateReviewSetTaskBEO> tasks = new Tasks <UpdateReviewSetTaskBEO>(); lastCommitedTaskCount = 0; try { if (jobParameters != null) { /* Get Dataset Details for dataset id to get know about the Collection id and the Matter ID*/ DatasetBEO datasetEntity = DataSetService.GetDataSet(jobParameters.datasetId.ToString(CultureInfo.InvariantCulture)); string sMatterId = datasetEntity.Matter.FolderID.ToString(CultureInfo.InvariantCulture); var _reviewSetEntity = ReviewSetBO.GetReviewSetDetails(sMatterId, jobParameters.ReviewSetId); List <FilteredDocumentBusinessEntity> qualifiedDocuments = null; if (jobParameters.Activity.Equals(Constants.Add)) { qualifiedDocuments = GetQualifiedDocuments(jobParameters, jobParameters.datasetId.ToString(CultureInfo.InvariantCulture), sMatterId, _reviewSetEntity.BinderId, Constants.Add); } else if (jobParameters.Activity.Equals(Constants.Remove) || jobParameters.Activity.Equals(Constants.Archive)) { qualifiedDocuments = GetQualifiedDocuments(jobParameters, jobParameters.datasetId.ToString(CultureInfo.InvariantCulture), sMatterId, _reviewSetEntity.BinderId, Constants.Remove); } jobParameters.Documents.Clear(); if (qualifiedDocuments != null && qualifiedDocuments.Count > 0) { List <RVWDocumentBEO> iterationDocuments = qualifiedDocuments. Select(d => new RVWDocumentBEO { DocumentId = d.Id, MatterId = Convert.ToInt64(d.MatterId), CollectionId = d.CollectionId, FamilyId = d.FamilyId, DocumentControlNumber = d.DCN, DuplicateId = d.DuplicateId }).ToList(); jobParameters.Documents.AddRange(iterationDocuments); } UpdateReviewSetTaskBEO updateReviewSetTaskBeo = ConvertToTaskBeo(jobParameters, _reviewSetEntity); tasks.Add(updateReviewSetTaskBeo); 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, ErrorCodes.ProblemInGenerateTasks, string.Empty); } return(tasks); }
/// <summary> /// This method helps to create multiple tasks and task generation is based on no. of duplicate documents in the collection /// </summary> protected override Tasks <DeduplicationJobTaskBEO> GenerateTasks(DeduplicationJobBEO jobParameters, out int previouslyCommittedTaskCount) { #region Pre-condition asserts jobParameters.ShouldNotBe(null); #endregion previouslyCommittedTaskCount = 0; try { _tasks = GetTaskList <DeduplicationJobBEO, DeduplicationJobTaskBEO>(jobParameters); previouslyCommittedTaskCount = _tasks.Count; EvLog.WriteEntry(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EVENT_JOB_GENERATETASK_VALUE, EventLogEntryType.Information); _jobid = jobParameters.JobId; _jobName = jobParameters.JobName; _jobrunId = jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture); _jobid.ShouldBeGreaterThan(0); _jobName.ShouldNotBe(null); _jobrunId.ShouldNotBe(null); _jobrunId.ShouldNotBe(string.Empty); //Get DocumentsHashValues count>0 var lsDocumentHash = GetDocumentHashValues(jobParameters.DatasetInfo, jobParameters.Algorithm, jobParameters.CompareType); if (lsDocumentHash != null && lsDocumentHash.Count > 0) { lsDocumentHash.RemoveAll(doc => string.IsNullOrEmpty(doc.HashValue)); } //Get Duplicate docs excluding original documents var lsdupDoc = GetDuplicatesDocuments(lsDocumentHash); if (_tasks.Count <= 0) { if (lsDocumentHash != null && lsDocumentHash.Count > 0) { if (jobParameters.IsDelete) { GeneratetasksForDeleteOperation(lsDocumentHash, lsdupDoc); } if (jobParameters.IsGroup) { var strDuplicateFiledVal = GetDuplicateFieldValue(jobParameters.Algorithm); GeneratetasksForGroupOperation(lsDocumentHash, strDuplicateFiledVal); } } else { NoOfDuplicate = 0; EvLog.WriteEntry(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.GenerateTaskNoDuplicates, EventLogEntryType.Information); JobLogInfo.AddParameters(Constants.GenerateTaskNoDuplicates); } LogDetails = CommonLogInfo(); } } catch (Exception exp) { EvLog.WriteEntry(jobParameters.JobId + Constants.EVENT_GENERATE_TASKS_EXCEPTION_VALUE, exp.Message, EventLogEntryType.Error); LogException(jobParameters.JobId, exp, Constants.EVENT_GENERATE_TASKS_EXCEPTION_VALUE, LogCategory.Job, string.Empty, ErrorCodes.ProblemInGenerateTasks); } #region Post-condition asserts jobParameters.ShouldNotBe(null); #endregion return(_tasks); }
/// <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); }