Exemple #1
0
        /// <summary>
        /// Get search results...
        /// </summary>
        public void GetSearchResults()
        {
            if (string.IsNullOrEmpty(_mCollectionId))
            {
                return;
            }
            //Get the dataset id

            var dataSet = DataSetBO.GetDataSetDetailForCollectionId(_mCollectionId);

            dataSet.ShouldNotBe(null);
            var dataSetId = dataSet.FolderID.ToString(CultureInfo.InvariantCulture);
            //Construct query
            var query = _mBootParameters.BulkPrintOptions.FilterOption.FilterQuery;
            var documentFilterType = _mBootParameters.BulkPrintOptions.FilterOption.DocumentFilterType;
            var index = documentFilterType == DocumentFilterTypeBEO.SavedSearch
                ? query.LastIndexOf(Constants.IsConceptSearchingEnabled, StringComparison.Ordinal)
                : 0;
            var enableConceptSearch = documentFilterType == DocumentFilterTypeBEO.SavedSearch &&
                                      bool.Parse(
                query.Substring(
                    query.LastIndexOf(Constants.IsConceptSearchingEnabled,
                                      StringComparison.Ordinal) + 30, 5).Trim());
            var includeFamilyThread = documentFilterType == DocumentFilterTypeBEO.SavedSearch &&
                                      (query.Substring(
                                           query.LastIndexOf(Constants.IncludeFamily, StringComparison.Ordinal) + 18, 4)
                                       .Contains(Constants.True));

            query = documentFilterType == DocumentFilterTypeBEO.SavedSearch ? query.Substring(0, index - 1) : query;

            var documentQueryEntity = new DocumentQueryEntity
            {
                QueryObject = new SearchQueryEntity
                {
                    ReviewsetId            = string.Empty,
                    DatasetId              = Convert.ToInt32(dataSetId),
                    MatterId               = Convert.ToInt32(_mBootParameters.DataSet.MatterId),
                    IsConceptSearchEnabled = enableConceptSearch
                },
                IgnoreDocumentSnippet = true
            };

            documentQueryEntity.QueryObject.QueryList.Add(new Query(query));
            documentQueryEntity.OutputFields.Add(new Field {
                FieldName = EVSystemFields.DcnField
            });
            documentQueryEntity.SortFields.Add(new Sort {
                SortBy = Constants.SearchResultsSortByRelevance
            });
            documentQueryEntity.TransactionName = "PrintStartupWorker - GetSearchResults";

            //Fetch search results
            _mSearchResults = JobSearchHandler.GetAllDocuments(documentQueryEntity, includeFamilyThread);
        }
        /// <summary>
        /// Generates Save Search Results Job tasks
        /// </summary>
        /// <param name="jobParameters">Job BEO</param>
        /// <param name="previouslyCommittedTaskCount">The previously committed task count.</param>
        /// <returns>
        /// List of Job Tasks (BEOs)
        /// </returns>
        protected override Tasks <SaveSearchResultsJobTaskBEO> GenerateTasks(SaveSearchResultsJobBEO jobParameters,
                                                                             out int previouslyCommittedTaskCount)
        {
            var tasks = new Tasks <SaveSearchResultsJobTaskBEO>();

            previouslyCommittedTaskCount = 0;
            LogMessage(Constants.TaskGenerationStartedMessage, false, LogCategory.Job, null);
            LogMessage(Constants.TaskGenerationStartedMessage, GetType(), Constants.GenerateTaskMethodFullName,
                       EventLogEntryType.Information, jobParameters.JobId, jobParameters.JobRunId);

            jobParameters.DocumentQuery.IgnoreDocumentSnippet = true;
            jobParameters.DocumentQuery.OutputFields.Clear();
            jobParameters.DocumentQuery.OutputFields.Add(new Field {
                FieldName = EVSystemFields.DcnField
            });
            jobParameters.DocumentQuery.QueryObject.TransactionName = "SaveSearchResultsJob - GenerateTasks (GetCount)";
            var totalResultCount = JobSearchHandler.GetSearchResultsCount(jobParameters.DocumentQuery.QueryObject);

            // getting total no. of documents present in current search List


            for (var pageno = 1;; pageno++)
            {
                var task = new SaveSearchResultsJobTaskBEO
                {
                    PageNo      = pageno - 1,
                    PageSize    = _taskBatchSize,
                    TaskNumber  = pageno,
                    TaskPercent =
                        100 /
                        Math.Ceiling((float)totalResultCount /
                                     _taskBatchSize)
                };
                tasks.Add(task);
                //pageno * _taskBatchSize exhaust
                if (pageno * _taskBatchSize >= totalResultCount)
                {
                    break;
                }
            }

            if (tasks.Count == 0)
            {
                LogMessage(Constants.NoTaskToExecuteError, GetType(), Constants.GenerateTaskMethodFullName,
                           EventLogEntryType.Information, jobParameters.JobId, jobParameters.JobRunId);
            }
            LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), false, LogCategory.Job,
                       null);
            LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), GetType(),
                       Constants.GenerateTaskMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                       jobParameters.JobRunId);
            return(tasks);
        }
Exemple #3
0
        /// <summary>
        /// Generates Concvert DCB Link tasks
        /// </summary>
        /// <param name="jobParameters">Job BEO</param>
        /// <param name="previouslyCommittedTaskCount"> </param>
        /// <returns>List of Job Tasks (BEOs)</returns>
        protected override Tasks <ConvertDCBLinkTaskBusinessEntityObject> GenerateTasks(BaseJobBEO jobParameters, out int previouslyCommittedTaskCount)
        {
            Tasks <ConvertDCBLinkTaskBusinessEntityObject> tasks = null;

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Start, EventLogEntryType.Information);
                previouslyCommittedTaskCount = 0;
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId, MethodInfo.GetCurrentMethod().Name, EventLogEntryType.Information);
                tasks = GetTaskList <BaseJobBEO, ConvertDCBLinkTaskBusinessEntityObject>(jobParameters);
                previouslyCommittedTaskCount = tasks.Count;
                if (tasks.Count <= 0)
                {
                    ConvertDCBLinkTaskBusinessEntityObject convertDcbLinkTask = new ConvertDCBLinkTaskBusinessEntityObject();
                    convertDcbLinkTask = (ConvertDCBLinkTaskBusinessEntityObject)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(ConvertDCBLinkTaskBusinessEntityObject));
                    _query             = ApplicationConfigurationManager.GetValue(Constants.SearchQuery);
                    _createdByUserGuid = convertDcbLinkTask.CreateByUserGuid;
                    string pageSize = "1";
                    DocumentQueryEntity docQueryEntity = GetDocumentQueryEntity(convertDcbLinkTask.DatasetId.ToString(CultureInfo.InvariantCulture), _query, pageSize);
                    docQueryEntity.TransactionName = "ConvertDCBLinksToCaseMap - GenerateTasks";
                    ReviewerSearchResults searchResults = JobSearchHandler.GetSearchResults(docQueryEntity);
                    if (searchResults.TotalRecordCount > 0)
                    {
                        convertDcbLinkTask.TaskNumber   = 1;
                        convertDcbLinkTask.TaskPercent  = 100;
                        convertDcbLinkTask.TaskComplete = false;
                    }
                    _documentCount = searchResults.TotalHitCount;
                    tasks.Add(convertDcbLinkTask);
                }
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Success, EventLogEntryType.Information);
            }
            catch (EVJobException ex)
            {
                _isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                throw;
            }
            catch (Exception ex)
            {
                _isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                EVJobException jobException = new EVJobException(ErrorCodes.GenerateTasksError, ex, JobLogInfo);
                throw (jobException);
            }
            return(tasks);
        }
Exemple #4
0
 /// <summary>
 /// Method to execute the query and get the search results
 /// </summary>
 /// <param name="searchBizEntityObj">Document Query Entity</param>
 /// <param name="query">query to execute</param>
 /// <returns></returns>
 private long GetAlertResultCount(DocumentQueryEntity searchBizEntityObj, string query)
 {
     if (searchBizEntityObj != null)
     {
         searchBizEntityObj.QueryObject.QueryList.Clear();
         searchBizEntityObj.QueryObject.QueryList.AddRange(new List <Query>
         {
             new Query
             {
                 SearchQuery = HttpUtility.HtmlDecode(query),
                 Precedence  = 1
             }
         });
         searchBizEntityObj.TransactionName = "AlertsJob - GetAlertResultCount";
         // Do the search to get all results
         return(JobSearchHandler.GetSearchResultsCount(searchBizEntityObj.QueryObject));
     }
     return(0);
 }
        /// <summary>
        /// Get the Qualified Documents
        /// </summary>
        /// <param name="jobParameters"></param>
        /// <param name="datasetId"> </param>
        /// <param name="sMatterId"></param>
        /// <param name="operation"> </param>
        /// <returns></returns>
        private static List <FilteredDocumentBusinessEntity> GetQualifiedDocuments(UpdateReviewSetJobBEO jobParameters,
                                                                                   string datasetId, string sMatterId, string sBinderId, string operation)
        {
            DocumentQueryEntity documentQueryEntity = new DocumentQueryEntity
            {
                QueryObject = new SearchQueryEntity
                {
                    DatasetId = Convert.ToInt64(datasetId),
                    MatterId  = Convert.ToInt64(sMatterId),
                    IsConceptSearchEnabled = jobParameters.DocumentSelectionContext.SearchContext.IsConceptSearchEnabled,
                    ReviewsetId            = operation.Equals(Constants.Add) ? string.Empty : jobParameters.ReviewSetId
                }
            };


            if (operation.Equals(Constants.Add))
            {
                if (!String.IsNullOrEmpty(jobParameters.DocumentSelectionContext.SearchContext.Query))
                {
                    jobParameters.DocumentSelectionContext.SearchContext.Query = string.Format("({0}) AND (NOT ({1}:\"{2}\"))",
                                                                                               jobParameters.DocumentSelectionContext.SearchContext.Query, EVSystemFields.BinderId.ToLowerInvariant(), sBinderId);
                }
                else
                {
                    jobParameters.DocumentSelectionContext.SearchContext.Query = string.Format("(NOT ({0}:\"{1}\"))",
                                                                                               EVSystemFields.BinderId.ToLowerInvariant(), sBinderId);
                }
            }

            documentQueryEntity.QueryObject.QueryList.Add(new Query(jobParameters.DocumentSelectionContext.SearchContext.Query));
            documentQueryEntity.SortFields.Add(new Sort {
                SortBy = Constants.Relevance
            });
            documentQueryEntity.IgnoreDocumentSnippet = true;
            documentQueryEntity.TransactionName       = "UpdateReviewSetJob - GetQualifiedDocuments";
            // -- get the qualified documents to beassigned for the reviewset
            List <FilteredDocumentBusinessEntity> qualifiedDocuments = JobSearchHandler.GetFilteredListOfDocuments(documentQueryEntity, jobParameters.DocumentSelectionContext);

            return(qualifiedDocuments);
        }
        /// <summary>
        /// Atomic work 1)Get old search result 2)New Search 3) Compare 4) generate report to database.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="jobParameters"></param>
        /// <returns></returns>
        protected override bool DoAtomicWork(CompareSavedSearchResultsJobTaskEntity task,
                                             CompareSavedSearchResultsJobBEO jobParameters)
        {
            task.ShouldNotBe(null);
            jobParameters.ShouldNotBe(null);
            var queryContext = _searchResultsProperty.DocumentQuery;

            queryContext.DocumentStartIndex    = 0;
            queryContext.DocumentCount         = 1;
            queryContext.IgnoreDocumentSnippet = true;
            queryContext.OutputFields.Clear();
            queryContext.OutputFields.Add(new Field {
                FieldName = EVSystemFields.DcnField
            });
            try
            {
                LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), GetType(),
                           Constants.DoAtomicMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);
                switch (task.TaskType)
                {
                case TypeOfTask.FetchRecordFromDb:
                {
                    var searchResultuuid = string.Format(SaveSearchResultIdentifierBEO.UniqueIdentifierFormat,
                                                         _searchResultsProperty.DocumentQuery.QueryObject.MatterId,
                                                         _searchResultsProperty.DocumentQuery.QueryObject.DatasetId,
                                                         _searchResultsProperty.SearchResultId);
                    _oldSearchResult = SearchResultsService.GetSavedSearchResultsWithDocument(searchResultuuid);
                }
                break;

                case TypeOfTask.FetchRecordFromSearchSubSystem:
                {
                    LogMessage(string.Format("New Search start at : {0}",
                                             DateTime.UtcNow.ConvertToUserTime()), GetType(), Constants.DoAtomicMethodFullName,
                               EventLogEntryType.Information, jobParameters.JobId, jobParameters.JobRunId);

                    //SearchContextObject searchContextObject = ConvertToSearchContextObject(queryContext);
                    ReviewerSearchResults rvwSearchBeo;
                    queryContext.QueryObject.TransactionName =
                        "CompareSavedSearchResultsJob - DoAtomicWork (GetCount)";
                    var totalResultCount = JobSearchHandler.GetSearchResultsCount(queryContext.QueryObject);
                    //searchContextObject.ItemsPerPage = totalResultCount;
                    queryContext.DocumentCount   = (int)totalResultCount;
                    queryContext.TransactionName = "CompareSavedSearchResultsJob - DoAtomicWork (GetAll)";
                    rvwSearchBeo = JobSearchHandler.GetAllDocuments(queryContext, false);
                    // Getting search result list by page index
                    LogMessage(string.Format("New Search End at : {0}", DateTime.UtcNow.ConvertToUserTime()),
                               GetType(), Constants.DoAtomicMethodFullName, EventLogEntryType.Information,
                               jobParameters.JobId, jobParameters.JobRunId);
                    //Constructing New search Result Beo
                    _newSearchResult = new SearchResultsDataContract
                    {
                        Information = new SearchResultsInformationDataContract
                        {
                            Properties =
                                new SearchResultsPropertiesDataContract
                            {
                                SearchResultId           = _searchResultsProperty.SearchResultId,
                                SearchResultsName        = _searchResultsProperty.SearchResultsName,
                                SearchResultsDescription = _searchResultsProperty.SearchResultsDescription,
                                DocumentQuery            = _searchResultsProperty.DocumentQuery
                            },
                            CreatedBy   = _userEntityOfJobOwner.UserId,
                            CreatedDate = DateTime.UtcNow.ConvertToUserTime()
                        }
                    };
                    if (rvwSearchBeo != null)
                    {
                        if (rvwSearchBeo.ResultDocuments != null && rvwSearchBeo.ResultDocuments.Any())
                        {
                            //int totalHitCount = 0;
                            foreach (var document in rvwSearchBeo.ResultDocuments)
                            {
                                var documentDeatail = new SearchResultDocumentDetailsDataContract();
                                documentDeatail.DocumentId            = document.DocumentID;
                                documentDeatail.DocumentControlNumber = document.DocumentControlNumber;
                                documentDeatail.NativeFilePath        = GetNativeFilePath(document);
                                _newSearchResult.Details.Add(documentDeatail);
                            }
                            _newSearchResult.Information.NumberOfDocuments = rvwSearchBeo.ResultDocuments.Count;
                        }
                    }
                    LogMessage(string.Format("New Search Results Construction done at : {0}",
                                             DateTime.UtcNow.ConvertToUserTime()), GetType(), Constants.DoAtomicMethodFullName,
                               EventLogEntryType.Information, jobParameters.JobId, jobParameters.JobRunId);
                }
                break;

                case TypeOfTask.CompareRecords:
                {
                    var comparisonStart = DateTime.Now;
                    _savedSearchCompareReport = new SavedSearchCompareReportBEO();
                    LogMessage(string.Format("Comparison Start at: {0}", DateTime.UtcNow.ConvertToUserTime()),
                               GetType(), Constants.DoAtomicMethodFullName, EventLogEntryType.Information,
                               jobParameters.JobId, jobParameters.JobRunId);
                    var oldResultSet = new List <SearchResultsDetailBEO>();
                    var newResultSet = new List <SearchResultsDetailBEO>();
                    _oldSearchResult.Details.SafeForEach(x => oldResultSet.Add(x.ToBusinessEntity()));
                    _newSearchResult.Details.SafeForEach(x => newResultSet.Add(x.ToBusinessEntity()));

                    // Extracting Common document details
                    (newResultSet.Intersect(oldResultSet).ToList()).SafeForEach(x =>
                                                                                _savedSearchCompareReport.CommonDocumentSet.Add(x));
                    //Extracting Unique document details from new Search result
                    (newResultSet.Except(_savedSearchCompareReport.CommonDocumentSet).ToList()).
                    SafeForEach(x => _savedSearchCompareReport.DocumentsOnlyInNewResultSet.Add(x));
                    //Extracting Unique document details from old(Saved) Search result
                    (oldResultSet.Except(_savedSearchCompareReport.CommonDocumentSet).ToList()).
                    SafeForEach(x => _savedSearchCompareReport.DocumentOnlyInOldResultSet.Add(x));
                    var comparisonStop = DateTime.Now;
                    LogMessage(string.Format("Total Time taken for comparison: {0}",
                                             (comparisonStop - comparisonStart).Milliseconds), GetType(),
                               Constants.DoAtomicMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                               jobParameters.JobRunId);
                }
                break;

                case TypeOfTask.ConstructFileContent:
                {
                    LogMessage(
                        string.Format("File Construction start at: {0}", DateTime.UtcNow.ConvertToUserTime()),
                        GetType(), Constants.DoAtomicMethodFullName, EventLogEntryType.Information,
                        jobParameters.JobId, jobParameters.JobRunId);

                    //Saving Old search results information
                    _savedSearchCompareReport.OldResultDetails = new SearchResultsInformationBEO
                    {
                        CreatedBy          = _oldSearchResult.Information.CreatedBy,
                        CreatedDate        = _oldSearchResult.Information.CreatedDate,
                        NumberOfDocuments  = _oldSearchResult.Information.NumberOfDocuments,
                        NumberOfSearchHits = _oldSearchResult.Information.NumberOfSearchHits
                    };
                    //Saving Old search results information
                    _savedSearchCompareReport.NewResultDetails = new SearchResultsInformationBEO
                    {
                        CreatedBy          = _newSearchResult.Information.CreatedBy,
                        CreatedDate        = _newSearchResult.Information.CreatedDate,
                        NumberOfDocuments  = _newSearchResult.Information.NumberOfDocuments,
                        NumberOfSearchHits = _newSearchResult.Information.NumberOfSearchHits
                    };
                    _savedSearchCompareReport.CreatedBy       = _userEntityOfJobOwner.UserId;
                    _savedSearchCompareReport.SearchQueryTerm = queryContext.QueryObject.DisplayQuery;
                    _savedSearchCompareReport.CreatedDate     = DateTime.UtcNow.ConvertToUserTime();
                    //File Creation Logic
                    CreateReportFile(out _reportString);
                    LogMessage(string.Format("File Construction End at: {0}", DateTime.UtcNow.ConvertToUserTime()),
                               GetType(), Constants.DoAtomicMethodFullName, EventLogEntryType.Information,
                               jobParameters.JobId, jobParameters.JobRunId);
                    //Clean up all class level variable
                    _oldSearchResult = null;
                    _newSearchResult = null;
                }
                break;
                }
            }
            catch (EVException ex)
            {
                _isJobFailed = true;
                WriteToEventViewer(ex, GetType(), MethodBase.GetCurrentMethod().Name, jobParameters.JobId,
                                   jobParameters.JobRunId);
                HandleTaskException(null, string.Format(Constants.TaskKeyStringFormat, task.TaskType),
                                    ErrorCodes.ProblemInDoAtomicWork);
            }
            catch (Exception ex)
            {
                _isJobFailed = true;
                // Handle exception in DoAutomic
                LogMessage(ex, GetType(), MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error,
                           jobParameters.JobId, jobParameters.JobRunId);
                HandleTaskException(ex, string.Format(Constants.TaskKeyStringFormat, task.TaskType),
                                    ErrorCodes.ProblemInDoAtomicWork);
            }
            return(true);
        }
        /// <summary>
        /// Does atomic 1)Gets document links2) Generate xml 3) Update xml file to database.
        /// </summary>
        /// <param name="task">ConvertDCBLinkTaskBusinessEntityObject</param>
        /// <param name="jobParameters">Job business entity</param>
        /// <returns></returns>
        protected override bool DoAtomicWork(SendDocumentLinksToCaseMapTaskBusinessEntity Task, BaseJobBEO jobParameters)
        {
            var StatusFlag = true; // Function return status.

            try
            {
                EvLog.WriteEntry(
                    Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture),
                    Constants.Event_Job_DoAtomicWork_Start, EventLogEntryType.Information);
                var xml        = string.Empty;
                var taskEntity =
                    (SendDocumentLinksToCaseMapTaskBusinessEntity)
                    XmlUtility.DeserializeObject(jobParameters.BootParameters,
                                                 typeof(SendDocumentLinksToCaseMapTaskBusinessEntity));
                switch (taskEntity.CaseMapSource)
                {
                case SendDocumentLinksToCaseMapTaskBusinessEntity.Source.SearchResults:
                {
                    var documentLinks = new List <DocumentLinkBEO>();
                    if (taskEntity.DocumentLinkTasks.DocumentSelectionMode ==
                        DocumentLinksTaskEntity.SelectionMode.UseSelection &&
                        taskEntity.DocumentLinkTasks.DocumentIdList != null)
                    {
                        documentLinks.AddRange(taskEntity.DocumentLinkTasks.DocumentIdList.Select(documentId =>
                                                                                                  getDocumentLink(taskEntity.DocumentLinkTasks.SearchContext.MatterId,
                                                                                                                  taskEntity.DocumentLinkTasks.SearchContext.CollectionId,
                                                                                                                  documentId, taskEntity.DocumentLinkTasks.BaseLink,
                                                                                                                  DocumentBO.GetDCNNumber(taskEntity.DocumentLinkTasks.SearchContext.MatterId,
                                                                                                                                          taskEntity.DocumentLinkTasks.SearchContext.CollectionId,
                                                                                                                                          documentId, jobParameters.JobScheduleCreatedBy
                                                                                                                                          )
                                                                                                                  )));
                    }
                    else
                    {
                        var documentQueryEntity = new DocumentQueryEntity
                        {
                            QueryObject = new SearchQueryEntity
                            {
                                ReviewsetId            = taskEntity.DocumentLinkTasks.SearchContext.ReviewsetId,
                                DatasetId              = Convert.ToInt32(taskEntity.DocumentLinkTasks.SearchContext.DatasetId),
                                MatterId               = Convert.ToInt32(taskEntity.DocumentLinkTasks.SearchContext.MatterId),
                                IsConceptSearchEnabled =
                                    taskEntity.DocumentLinkTasks.SearchContext.EnableConceptSearch
                            }
                        };
                        documentQueryEntity.QueryObject.QueryList.Add(
                            new Query(taskEntity.DocumentLinkTasks.SearchContext.Query));
                        documentQueryEntity.SortFields.Add(new Sort {
                                SortBy = Constants.Relevance
                            });
                        documentQueryEntity.IgnoreDocumentSnippet = true;
                        documentQueryEntity.TransactionName       = "SendDocumentLinksToCaseMap - DoAtomicWork";
                        var searchResults = JobSearchHandler.GetAllDocuments(documentQueryEntity, false);
                        if (taskEntity.DocumentLinkTasks.DocumentIdList != null &&
                            taskEntity.DocumentLinkTasks.DocumentIdList.Count > 0)
                        {
                            documentLinks =
                                searchResults.ResultDocuments.Where(
                                    x =>
                                    taskEntity.DocumentLinkTasks.DocumentIdList.Find(
                                        y => string.Compare(x.DocumentID, y, true) == 0) == null).
                                Select(
                                    z =>
                                    getDocumentLink(z.MatterID.ToString(), z.CollectionID, z.DocumentID,
                                                    taskEntity.DocumentLinkTasks.BaseLink, z.DocumentControlNumber)
                                    ).ToList();
                        }
                        else
                        {
                            searchResults.ResultDocuments.SafeForEach(d => documentLinks.Add(
                                                                          getDocumentLink(d.MatterID.ToString(), d.CollectionID, d.DocumentID,
                                                                                          taskEntity.DocumentLinkTasks.BaseLink, d.DocumentControlNumber)));
                        }
                    }


                    fileType = ApplicationConfigurationManager.GetValue(Constants.SearchResultsFileType);
                    xml      = DocumentFactBusinessObject.GenerateDocumentLinksXml(documentLinks,
                                                                                   jobParameters.JobScheduleCreatedBy);

                    break;
                }

                case SendDocumentLinksToCaseMapTaskBusinessEntity.Source.DocumentViewer:
                {
                    var documentFactLinks = taskEntity.DocumentFactLinks;
                    fileType = ApplicationConfigurationManager.GetValue(Constants.DocumentViewerFileType);
                    xml      = DocumentFactBusinessObject.GenerateDocumentFactXml(documentFactLinks,
                                                                                  jobParameters.JobScheduleCreatedBy);

                    break;
                }

                case SendDocumentLinksToCaseMapTaskBusinessEntity.Source.NearNative:
                {
                    var documentFactLinks = taskEntity.DocumentFactLinks;
                    fileType = ApplicationConfigurationManager.GetValue(Constants.NearNativeFileType);
                    xml      = DocumentFactBusinessObject.GenerateDocumentFactXml(documentFactLinks,
                                                                                  jobParameters.JobScheduleCreatedBy);

                    break;
                }
                }

                // Perform Atomic Task
                var encoding    = new UTF8Encoding();
                var content     = encoding.GetBytes(xml);
                var nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                nameBuilder.Append(Constants.OnDate);
                nameBuilder.Append(startedTime.ConvertToUserTime());
                var requestName = nameBuilder.ToString();

                nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                nameBuilder.Append(Constants.RequestByUser);
                nameBuilder.Append(jobParameters.JobScheduleCreatedBy);
                nameBuilder.Append(Constants.OnDate);
                nameBuilder.Append(startedTime.ConvertToUserTime());
                requestDescription = nameBuilder.ToString();


                conversionId = CaseMapDAO.SaveConversionResults(jobParameters.JobRunId, requestName, requestDescription,
                                                                content, fileType, createdByUserGuid);
                StatusFlag = true;
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId,
                                 Constants.Event_Job_DoAtomicWork_Success, EventLogEntryType.Information);
            }
            catch (EVTaskException ex)
            {
                isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message,
                                 EventLogEntryType.Error);
                LogException(TaskLogInfo, ex, LogCategory.Task, ErrorCodes.ProblemInDoAtomicWork, string.Empty);
            }
            catch (Exception ex)
            {
                isJobFailed = true;
                // Handle exception in Generate Tasks
                EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message,
                                 EventLogEntryType.Error);
                LogException(TaskLogInfo, ex, LogCategory.Task, ErrorCodes.ProblemInDoAtomicWork, string.Empty);
            }
            return(StatusFlag);
        }
Exemple #8
0
        /// <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);
        }
Exemple #9
0
        /// <summary>
        /// Does atomic 1)Gets DCB document 2) Generate xml 3) Update xml file to database.
        /// </summary>
        /// <param name="task">ConvertDCBLinkTaskBusinessEntityObject</param>
        /// <param name="jobParameters">Job business entity</param>
        /// <returns></returns>
        protected override bool DoAtomicWork(ConvertDCBLinkTaskBusinessEntityObject task, BaseJobBEO jobParameters)
        {
            bool StatusFlag = true;// Function return status.

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Start, EventLogEntryType.Information);
                // Perform Atomic Task
                DCBLinkCollectionBEO  dcbLinks = new DCBLinkCollectionBEO();
                DCBLinkBEO            dcbLink;
                ReviewerSearchResults searchResults = null;
                if (_documentCount > 0)
                {
                    DocumentQueryEntity documentQueryEntity = GetDocumentQueryEntity(task.DatasetId.ToString(CultureInfo.InvariantCulture), _query, _documentCount.ToString(CultureInfo.InvariantCulture));
                    documentQueryEntity.TransactionName = "ConvertDCBLinksToCaseMap - DoAtomicWork";
                    searchResults = JobSearchHandler.GetSearchResults(documentQueryEntity);
                }
                List <DCBLinkBEO> linkList = new List <DCBLinkBEO>();
                string            uuid     = string.Empty;
                int count = 0;
                foreach (DocumentResult document in searchResults.ResultDocuments)
                {
                    dcbLink = new DCBLinkBEO();
                    DocumentIdentifierBEO docIdentifier = new DocumentIdentifierBEO(document.MatterID.ToString(CultureInfo.InvariantCulture), document.CollectionID, document.DocumentID);
                    if (count == 0)
                    {
                        uuid = docIdentifier.UniqueIdentifier.Replace(docIdentifier.DocumentId, string.Empty);
                    }
                    dcbLink.NewDocumentId = docIdentifier.DocumentId;

                    List <FieldResult> fieldValues = document.Fields.Where(f => System.String.Compare(f.Name, EVSystemFields.DcbId, System.StringComparison.OrdinalIgnoreCase) == 0).ToList();
                    dcbLink.OldDocumentId = fieldValues.Any() ? fieldValues.First().Value.Replace("[", "(").Replace("]", ")") : string.Empty;
                    linkList.Add(dcbLink);
                    dcbLink.CollectionId = docIdentifier.CollectionId;
                    dcbLink.DCN          = docIdentifier.DCN;
                    if (docIdentifier.MatterId != null)
                    {
                        dcbLink.MatterId = long.Parse(docIdentifier.MatterId);
                    }

                    count++;
                }
                linkList.SafeForEach(l => dcbLinks.Links.Add(l));
                dcbLinks.UrlApplicationLink = task.LinkBackUrl;

                string        xml         = DocumentFactBusinessObject.GenerateDcbLinksXml(dcbLinks, uuid);
                UTF8Encoding  encoding    = new UTF8Encoding();
                byte[]        content     = encoding.GetBytes(xml);
                StringBuilder nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                nameBuilder.Append(Constants.OnDate);
                nameBuilder.Append(startedTime.ConvertToUserTime());
                string requestName = nameBuilder.ToString();

                nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                _requestDescription = nameBuilder.ToString();

                string fileType = ApplicationConfigurationManager.GetValue(Constants.FileType);
                _conversionId = CaseMapDAO.SaveConversionResults(jobParameters.JobRunId, requestName, _requestDescription, content, fileType, _createdByUserGuid);
                StatusFlag    = true;
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Success, EventLogEntryType.Information);
                TaskLogInfo.AddParameters(Constants.DataSetName, task.DatasetName);
            }
            catch (EVTaskException ex)
            {
                _isJobFailed = true;
                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);
                EVTaskException jobException = new EVTaskException(ErrorCodes.DoAtomicError, ex);
                TaskLogInfo.StackTrace = ex.Message + Constants.LineBreak + ex.StackTrace;
                TaskLogInfo.AddParameters(Constants.DataSetId, task.DatasetId.ToString(CultureInfo.InvariantCulture));
                TaskLogInfo.AddParameters(Constants.DataSetName, task.DatasetName);
                TaskLogInfo.TaskKey    = Constants.DataSetName + ":" + task.DatasetName;
                jobException.LogMessge = TaskLogInfo;
                throw (jobException);
            }
            return(StatusFlag);
        }
        /// <summary>
        /// Atomic work 1) Search 2) Insert to DB 3) Audit Log.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="jobParameters"></param>
        /// <returns></returns>
        protected override bool DoAtomicWork(SaveSearchResultsJobTaskBEO task, SaveSearchResultsJobBEO jobParameters)
        {
            #region Pre-condition asserts

            task.ShouldNotBe(null);
            jobParameters.ShouldNotBe(null);

            #endregion

            var searchResultsDataEntityObject = new SearchResultsDataContract();
            var searchContext = jobParameters.DocumentQuery;
            searchContext.DocumentStartIndex    = (task.PageNo * task.PageSize);
            searchContext.DocumentCount         = task.PageSize;
            searchContext.IgnoreDocumentSnippet = true;
            searchContext.OutputFields.Clear();
            searchContext.OutputFields.Add(new Field {
                FieldName = EVSystemFields.DcnField
            });
            LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), false, LogCategory.Job, null);
            LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), GetType(),
                       Constants.DoAtomicMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                       jobParameters.JobRunId);
            try
            {
                // Perform Atomic Task
                //ReviewerSearchResults rvwSearchBeo = JobSearchHandler.GetSearchResultsWithMatchContext(searchContext);
                // we get the search results from   search sub-system in batches of 1000
                searchContext.TransactionName = "SaveSearchResultJob - DoAtomicWork";
                var rvwSearchBeo = JobSearchHandler.GetSearchResults(searchContext);

                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), false, LogCategory.Job, null);
                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), GetType(),
                           Constants.DoAtomicMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);
                if (rvwSearchBeo != null)
                {
                    if (rvwSearchBeo.ResultDocuments != null && rvwSearchBeo.ResultDocuments.Any())
                    {
                        searchResultsDataEntityObject = new SearchResultsDataContract();

                        foreach (var searchDocument in rvwSearchBeo.ResultDocuments)
                        {
                            var documentDetail =
                                new SearchResultDocumentDetailsDataContract
                            {
                                DocumentId            = searchDocument.DocumentID,
                                DocumentControlNumber = searchDocument.DocumentControlNumber,
                                NativeFilePath        = GetNativeFilePath(searchDocument),
                                DatasetId             = _jobBeo.DocumentQuery.QueryObject.DatasetId
                            };
                            searchResultsDataEntityObject.Information = new SearchResultsInformationDataContract
                            {
                                Properties = new SearchResultsPropertiesDataContract
                                {
                                    SearchResultId = _jobBeo.SearchQueryId,
                                    DocumentQuery  = _jobBeo.DocumentQuery
                                },
                                CreatedBy   = _userEntityOfJobOwner.UserGUID,
                                CreatedDate = DateTime.UtcNow
                            };
                            documentDetail.SearchHitCount = searchDocument.SearchHitCount;
                            searchResultsDataEntityObject.Details.Add(documentDetail);
                        }
                        // perform db insertion
                        LogMessage(Constants.InsertDocumentDetailMessage, false, LogCategory.Job, null);
                        LogMessage(Constants.InsertDocumentDetailMessage, GetType(), Constants.DoAtomicMethodFullName,
                                   EventLogEntryType.Information, jobParameters.JobId, jobParameters.JobRunId);

                        #region Audit for each document

                        if (rvwSearchBeo.ResultDocuments != null && rvwSearchBeo.ResultDocuments.Count > 0)
                        {
                            foreach (var searchDocument in rvwSearchBeo.ResultDocuments)
                            {
                                var additionalDetails = new List <KeyValuePair <string, string> >();

                                var additionalDetail = new KeyValuePair <string, string>(Constants.AuditFor,
                                                                                         jobParameters.JobName);
                                additionalDetails.Add(additionalDetail);
                                additionalDetail = new KeyValuePair <string, string>(Constants.DocumentControlNumber,
                                                                                     searchDocument.DocumentControlNumber);
                                additionalDetails.Add(additionalDetail);
                                additionalDetail = new KeyValuePair <string, string>(Constants.DocumentGuid,
                                                                                     searchDocument.DocumentID);
                                additionalDetails.Add(additionalDetail);
                            }
                        }

                        #endregion

                        searchResultsDataEntityObject =
                            SearchResultsService.SaveSearchResultsDocumentDetails(searchResultsDataEntityObject);

                        LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), false,
                                   LogCategory.Job, null);
                        LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), GetType(),
                                   Constants.DoAtomicMethodFullName, EventLogEntryType.Information, jobParameters.JobId,
                                   jobParameters.JobRunId);
                    }
                }
            }
            finally
            {
                if (searchResultsDataEntityObject.Details != null && searchResultsDataEntityObject.Details.Count > 0)
                {
                    searchResultsDataEntityObject.Details.SafeForEach(x => _dcnList.Add(x.DocumentControlNumber));
                }
            }

            #region Post-condition and class invariant asserts

            task.ShouldNotBe(null);
            jobParameters.ShouldNotBe(null);

            #endregion

            return(true);
        }
Exemple #11
0
        /// <summary>
        ///     This is the overridden DoAtomicWork() method.
        /// </summary>
        /// <param name="task">A task to be performed.</param>
        /// <param name="jobParameters">Input settings / parameters of the job.</param>
        /// <returns>Status of the operation.</returns>
        protected override bool DoAtomicWork(GlobalReplaceTaskBEO task, GlobalReplaceJobBEO jobParameters)
        {
            bool   isSuccess = false;
            string taskKey   = string.Empty;

            try
            {
                LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);

                var documentQueryEntity = new DocumentQueryEntity
                {
                    DocumentCount      = task.PageSize,
                    DocumentStartIndex = task.PageNumber * task.PageSize,
                    QueryObject        = task.SearchQueryObject
                };
                documentQueryEntity.IgnoreDocumentSnippet = true;
                documentQueryEntity.TransactionName       = "FindAndReplaceJob - DoAtomicWork";
                ReviewerSearchResults reviewerSearchResults = JobSearchHandler.GetSearchResults(documentQueryEntity);

                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), false, LogCategory.Job,
                           null);
                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);

                if (reviewerSearchResults.ResultDocuments != null && reviewerSearchResults.ResultDocuments.Count > 0)
                {
                    foreach (DocumentResult document in reviewerSearchResults.ResultDocuments)
                    {
                        List <RVWDocumentFieldBEO> documentFieldBeoList = GetFieldValuesToUpdate
                                                                              (document, task.ActualString, task.ReplaceString, jobParameters.JobScheduleCreatedBy);
                        if (documentFieldBeoList != null && documentFieldBeoList.Count > 0)
                        {
                            var documentData = new RVWDocumentBEO
                            {
                                MatterId     = document.MatterID,
                                CollectionId = document.CollectionID
                            };
                            taskKey = Constants.CollectionId + document.CollectionID;
                            documentData.DocumentId = document.DocumentID;
                            taskKey += Constants.DocumentId + document.DocumentID;
                            documentData.ModifiedBy   = jobParameters.JobScheduleCreatedBy;
                            documentData.ModifiedDate = DateTime.UtcNow;
                            documentFieldBeoList.SafeForEach(x => documentData.FieldList.Add(x));

                            _mIsFindTextExist = true;
                            //Update the field value information in vault for the appropriate fields matching
                            isSuccess =
                                DocumentService.UpdateDocumentFields(
                                    document.MatterID.ToString(CultureInfo.InvariantCulture), document.CollectionID,
                                    document.DocumentID, documentData);
                            if (!isSuccess)
                            {
                                break;
                            }
                        }
                    }
                }

                CustomNotificationMessage = !_mIsFindTextExist
                    ? string.Format(Constants.SearchTextNotFound, task.ActualString)
                    : string.Format(Constants.SearchTextFound, _mOccurrences);

                LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);
            }
            catch (EVException ex)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + Constants.DoAtomicWorkFailMessage,
                                 ex.ToUserString() + Constants.TaskNumber + task.TaskNumber, EventLogEntryType.Error);
                LogException(jobParameters.JobId, ex, string.Empty, LogCategory.Task, taskKey,
                             ErrorCodes.ProblemInDoAtomicWork);
            }
            catch (Exception exp)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + Constants.DoAtomicWorkFailMessage,
                                 exp.Message + Constants.TaskNumber + task.TaskNumber, EventLogEntryType.Error);
                LogException(jobParameters.JobId, exp, string.Empty, LogCategory.Task, taskKey,
                             ErrorCodes.ProblemInDoAtomicWork);
            }
            return(isSuccess);
        }
Exemple #12
0
        /// <summary>
        ///     This is the overridden GenerateTasks() method.
        /// </summary>
        /// <param name="jobParameters">GlobalReplaceJobBEO</param>
        /// <param name="previouslyCommittedTaskCount">int</param>
        /// <returns>list of GlobalReplaceTaskBEO object</returns>
        protected override Tasks <GlobalReplaceTaskBEO> GenerateTasks(GlobalReplaceJobBEO jobParameters,
                                                                      out int previouslyCommittedTaskCount)
        {
            var tasks = new Tasks <GlobalReplaceTaskBEO>();

            previouslyCommittedTaskCount = 0;
            try
            {
                LogMessage(Constants.TaskGenerationStartedMessage, false, LogCategory.Job, null);
                LogMessage(Constants.TaskGenerationStartedMessage, GetType(),
                           "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                           jobParameters.JobId, jobParameters.JobRunId);

                var searchQueryEntity = new SearchQueryEntity
                {
                    MatterId               = jobParameters.SearchContext.MatterId,
                    ReviewsetId            = jobParameters.SearchContext.ReviewSetId,
                    DatasetId              = jobParameters.SearchContext.DataSetId,
                    IsConceptSearchEnabled = jobParameters.SearchContext.IsConceptSearchEnabled
                };
                searchQueryEntity.TransactionName = "FindandReplaceJob - GenerateTasks (GetCount)";
                searchQueryEntity.QueryList.Add(new Query(jobParameters.SearchContext.Query));
                long totalResultCount = JobSearchHandler.GetSearchResultsCount(searchQueryEntity);

                if (totalResultCount > 0)
                {
                    //estimated enqueue time for a document is 30 seconds
                    _mEstimatedTimeToIndexInMinutes = (totalResultCount * 30) / 60;
                    for (int pageno = 1;; pageno++)
                    {
                        var task = new GlobalReplaceTaskBEO
                        {
                            PageNumber        = pageno - 1,
                            PageSize          = _mTaskBatchSize,
                            TaskNumber        = pageno,
                            SearchQueryObject = searchQueryEntity,
                            TaskPercent       = 100 / Math.Ceiling((float)totalResultCount / _mTaskBatchSize),
                            TaskComplete      = false,
                            ActualString      = jobParameters.ActualString,
                            ReplaceString     = jobParameters.ReplaceString
                        };
                        tasks.Add(task);
                        //pageno * _taskBatchSize exhaust
                        if (pageno * _mTaskBatchSize >= totalResultCount)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    CustomNotificationMessage = string.Format(Constants.SearchTextNotFound,
                                                              jobParameters.ActualString);
                }
                if (tasks.Count == 0)
                {
                    LogMessage(Constants.NoTaskToExecuteError, GetType(),
                               "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                               jobParameters.JobId, jobParameters.JobRunId);
                }
                LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), GetType(),
                           "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                           jobParameters.JobId, jobParameters.JobRunId);
            }
            catch (EVException ex)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + " : " + jobParameters.JobId + Constants.TaskGenerationFails,
                                 ex.ToUserString(), EventLogEntryType.Error);
                LogException(jobParameters.JobId, ex, string.Empty, LogCategory.Job, string.Empty,
                             ErrorCodes.ProblemInGenerateTasks);
            }
            catch (Exception exp)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + " : " + jobParameters.JobId + Constants.TaskGenerationFails,
                                 exp.Message, EventLogEntryType.Error);
                LogException(jobParameters.JobId, exp, string.Empty, LogCategory.Job, string.Empty,
                             ErrorCodes.ProblemInGenerateTasks);
            }
            return(tasks);
        }