Пример #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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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>
        /// Converts the RVW reviewer search results to reviewer search results.
        /// </summary>
        /// <param name="rvwReviewerSearchResults">The RVW reviewer search results.</param>
        /// <returns></returns>
        private static ReviewerSearchResults ConvertRvwReviewerSearchResultsToReviewerSearchResults(RvwReviewerSearchResults rvwReviewerSearchResults)
        {
            var queryBEO = new QueryContainerBEO();
            queryBEO.QuerySearchTerms.AddRange(rvwReviewerSearchResults.MatchContextQueries);

            var reviewerSearchResults = new ReviewerSearchResults
            {
                TotalRecordCount = rvwReviewerSearchResults.Documents.Count,
                TotalHitCount = rvwReviewerSearchResults.TotalHitResultCount,
                SearchRequest = new RVWSearchBEO
                {
                    QueryContainerEntity = queryBEO
                }
            };

            foreach (ResultDocument resultDocument in rvwReviewerSearchResults.Documents)
            {
                reviewerSearchResults.ResultDocuments.Add(ConvertResultDocumentToDocumentResult(resultDocument));
            }
            return reviewerSearchResults;
        }
Пример #6
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);
        }
        /// <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);
        }