/// <summary> /// Get the tag location /// </summary> /// <param name="bulkTagRecord"></param> /// <returns></returns> private static string GetTaggingLocation(BulkTagJobBusinessEntity bulkTagJobBeo) { var location = string.Empty; if (!string.IsNullOrEmpty(bulkTagJobBeo.DocumentListDetails.SearchContext.ReviewSetId)) { var reviewSetDetails = ReviewSetBO.GetReviewSetDetails (bulkTagJobBeo.DocumentListDetails.SearchContext.MatterId.ToString(CultureInfo.InvariantCulture), bulkTagJobBeo.DocumentListDetails.SearchContext.ReviewSetId); if (reviewSetDetails != null) { location = reviewSetDetails.ReviewSetName; } } else { var dataSetDetails = DataSetBO.GetDataSetDetailForDataSetId(bulkTagJobBeo.DocumentListDetails.SearchContext.DataSetId); if (dataSetDetails != null) { location = dataSetDetails.FolderName; } } return(location); }
/// <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> /// Absorb the boot parameters, deserialize and pass on the messages to the Search Worker /// </summary> public void DoBeginWork(string bootParameter) { bootParameter.ShouldNotBeEmpty(); // Deserialize and determine the boot object _bootObject = GetBootObject(bootParameter); // Assert condition to check for jobscheduled by _bootObject.CreatedByGUID.ShouldNotBeEmpty(); // Get Dataset Details to know about the Collection id and the Matter ID details _datasetEntity = DataSetBO.GetDataSetDetailForDataSetId(_bootObject.datasetId); _bootObject.BinderFolderId.ShouldNotBe(0); _binderEntity = BinderBO.GetBinderDetails(_bootObject.BinderFolderId.ToString()); _binderEntity.ShouldNotBe(null); //Assert condition to check for dataset details _datasetEntity.ShouldNotBe(null); _datasetEntity.Matter.ShouldNotBe(null); _reviewSetRecord = ConvertToReviewSetRecord(_bootObject, _datasetEntity); // Construct the document query entity to determine the total documents _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, 1, null); _docQueryEntity.TransactionName = _docQueryEntity.QueryObject.TransactionName = "ReviewsetStartupWorker - DoBeginWork (GetCount)"; // Mock the user session MockSession(); var reviewSetDetails = ReviewSetBO.GetReviewSetDetails(_datasetEntity.Matter.FolderID.ToString(), _bootObject.ReviewSetId); if (reviewSetDetails != null) { reviewSetDetails.Action = _reviewSetRecord.Activity; reviewSetDetails.BinderName = _binderEntity.BinderName; //Audit Logging for existing review set ReviewSetBO.UpdateReviewSet(reviewSetDetails, false, false); } // Retrieve the total documents qualified _totalDocumentCount = ReviewerSearchInstance.GetDocumentCount(_docQueryEntity.QueryObject); Tracer.Info("Split Reviewset Startup Worker : {0} matching documents determined for the requested query", _totalDocumentCount); if (_totalDocumentCount < 1) { var message = String.Format("Search engine does not return any documents for Reviewset {0}", _reviewSetRecord.ReviewSetName); throw new ApplicationException(message); } // Construct the document query entity to write the resultant documents in xml file var outputFields = new List <Field>(); outputFields.AddRange(new List <Field> { new Field { FieldName = EVSystemFields.FamilyId }, new Field { FieldName = EVSystemFields.DocumentKey }, new Field { FieldName = EVSystemFields.ReviewSetId }, new Field { FieldName = EVSystemFields.DuplicateId }, new Field { FieldName = EVSystemFields.Tag.ToLower() }, new Field { FieldName = _datasetEntity.DocumentControlNumberName } }); _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, Convert.ToInt32(_totalDocumentCount), outputFields); }
/// <summary> /// This method is used to construct the notification message and send the notification for the alert /// </summary> /// <param name="task"></param> /// <param name="originalQuery"></param> /// <param name="searchBizEntityObj"></param> private void ConstructNotificationMessage(SearchAlertsTaskBEO task, string originalQuery, DocumentQueryEntity searchBizEntityObj) { /* send notification only if * - All result count between prev alert and current alert is changed * - All result count is same but new results found for current alert * - if alert is running for the first time * - if the prev query and current query is not same */ if ((m_LastResultCount != m_AllResultCount) || ((m_LastResultCount == m_AllResultCount) && m_NewResultCount > 0) || (m_AlertLastRunTimestamp.Equals(DateTime.MinValue) || m_AlertLastRunTimestamp.Equals(Constants.MSSQL2005_MINDATE)) || (!String.IsNullOrEmpty(m_PrevSearchQuery) && (!m_PrevSearchQuery.Equals(originalQuery)))) { var dataSetName = (searchBizEntityObj != null && searchBizEntityObj.QueryObject.DatasetId > 0) ? FolderBO.GetFolderDetails(searchBizEntityObj.QueryObject.DatasetId.ToString()).FolderName : String.Empty; var reviewSetName = (searchBizEntityObj != null && searchBizEntityObj.QueryObject.MatterId > 0 && !String.IsNullOrEmpty(searchBizEntityObj.QueryObject.ReviewsetId)) ? ReviewSetBO.GetReviewSetDetails(searchBizEntityObj.QueryObject.MatterId.ToString(), searchBizEntityObj.QueryObject.ReviewsetId).ReviewSetName : String.Empty; // Send notification var alertMessage = Constants.ALERT_NOTIFICATION_MESSAGE; // modify the notification message if this needs to be sent as part of manual alert if (m_ManualAlertNextRunDate != DateTime.MinValue) { alertMessage += Constants.MANUAL_ALERT_MESSAGE; } if (string.IsNullOrEmpty(reviewSetName)) { alertMessage = m_AllResultCount + alertMessage + Constants.Hyphen + HttpUtility.HtmlDecode(task.SearchAlert.Name) + Constants.FOR + Constants.DATASET + HttpUtility.HtmlDecode(dataSetName); } else { alertMessage = m_AllResultCount + alertMessage + Constants.Hyphen + HttpUtility.HtmlDecode(task.SearchAlert.Name) + Constants.FOR + Constants.DATASET + HttpUtility.HtmlDecode(dataSetName) + Constants.INREVIEWSET + HttpUtility.HtmlDecode(reviewSetName); } if ((((m_LastResultCount == m_AllResultCount) && m_NewResultCount > 0) || ((m_LastResultCount > m_AllResultCount) && m_NewResultCount == 0)) && (m_AlertLastRunTimestamp != DateTime.MinValue)) { alertMessage += Constants.SEARCH_ALERT_RESULTS_CHANGED; } // this is required to get the details of the person who actually created the alert if (!string.IsNullOrEmpty(task.SearchAlert.CreatedBy)) { m_UserBusinessEntity = UserBO.GetUserUsingGuid(task.SearchAlert.CreatedBy); } var messageBuilder = new StringBuilder(); messageBuilder.Append(Constants.Table); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(HttpUtility.HtmlEncode(alertMessage)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageSearchQuery); messageBuilder.Append(HttpUtility.HtmlDecode(originalQuery)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageDatasetName); messageBuilder.Append(HttpUtility.HtmlDecode(dataSetName)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); if (!(string.IsNullOrEmpty(reviewSetName))) { messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageReviewsetName); messageBuilder.Append(HttpUtility.HtmlDecode(reviewSetName)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); } messageBuilder.Append(Constants.CloseTable); SendNotification(task.SearchAlert, alertMessage, messageBuilder.ToString()); } }