コード例 #1
0
        /// <summary>
        /// This method helps to generate tasks to group duplicate documents from vault and  search sub-system
        /// </summary>
        private void GeneratetasksForGroupOperation(List <DocumentHashMapEntity> lsDocumentHash,
                                                    string strDuplicateFiledVal)
        {
            if (lsDocumentHash.Count > 0)
            {
                foreach (var docHasMap in lsDocumentHash)
                {
                    _task = new DeduplicationJobTaskBEO
                    {
                        IsGroup                = true,
                        CollectionId           = docHasMap.CollectionId.ToString(),
                        MatterId               = _matterId,
                        DocumentReferenceId    = docHasMap.DocumentReferenceId,
                        HashValue              = docHasMap.HashValue,
                        DuplicateField         = strDuplicateFiledVal,
                        DuplicateDocumentCount = lsDocumentHash.Count
                    };
                    _taskNumber++;
                    _task.TaskNumber   = _taskNumber;
                    _task.TaskComplete = false;
                    _task.TaskPercent  = 100.0 / lsDocumentHash.Count;
                    _task.TaskKey      = DocumentBO.GetDCNNumber(_matterId, docHasMap.CollectionId.ToString(),
                                                                 docHasMap.DocumentReferenceId, _createdByUserName);
                    _tasks.Add(_task);

                    var document = _vault.GetDocumentMasterData(new Guid(_task.CollectionId), _task.DocumentReferenceId);
                    GroupingLogInfo(document, docHasMap, lsDocumentHash);
                }
                TaskCount        = _tasks.Count;
                _affectedDocList = _lsAffectedDocument;
                EvLog.WriteEntry(_jobid + Constants.GenerateTaskGrouping, string.Empty, EventLogEntryType.Information);
            }
        }
コード例 #2
0
        /// <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);
        }