コード例 #1
0
        /// <summary>
        /// This method helps to perform each task generated from GenerateTask method
        /// </summary>
        protected override bool DoAtomicWork(DeduplicationJobTaskBEO doAtomicTask, DeduplicationJobBEO jobParameters)
        {
            var isFailed = false;

            List <CollectionFieldEntity> lsColFieldEntity = null;

            try
            {
                if (doAtomicTask.IsDelete)
                {
                    try
                    {
                        DocumentBO.BatchDelete(doAtomicTask.MatterId, doAtomicTask.CollectionId,
                                               doAtomicTask.DeleteDocumentList);
                        _successCount += doAtomicTask.DeleteDocumentList.Count;
                    }
                    catch (Exception ex)
                    {
                        isFailed       = true;
                        _failureCount += doAtomicTask.DeleteDocumentList.Count;
                        EvLog.WriteEntry(
                            jobParameters.JobId + Constants.DO_ATOMIC_TASK + ":" +
                            Constants.DO_ATOMIC_ERR_DEL_DUP_DOC_VAULT, ex.Message);
                        LogException(_jobid, ex,
                                     Constants.DO_ATOMIC_TASK + ":" + Constants.DO_ATOMIC_ERR_DEL_DUP_DOC_VAULT, LogCategory.Task,
                                     _task.TaskKey, ErrorCodes.ProblemInDoAtomicWork);
                    }
                }
                else if (doAtomicTask.IsGroup)
                {
                    try
                    {
                        lsColFieldEntity = _vault.GetCollectionFields(DataSetCollectionId, EVSystemFields.Duplicate);
                    }
                    catch (Exception ex)
                    {
                        isFailed = true;
                        EvLog.WriteEntry(
                            jobParameters.JobId + Constants.DO_ATOMIC_TASK + ":" + Constants.DO_ATOMIC_ERR_GET_COL_FIELD,
                            ex.Message);
                        LogException(_jobid, ex, Constants.DO_ATOMIC_TASK + ":" + Constants.DO_ATOMIC_ERR_GET_COL_FIELD,
                                     LogCategory.Task, _task.TaskKey, ErrorCodes.ProblemInDoAtomicWork);
                    }
                    var document = _vault.GetDocumentMasterData(new Guid(doAtomicTask.CollectionId),
                                                                doAtomicTask.DocumentReferenceId);

                    #region "Insert Fields for Document in vault"

                    if (lsColFieldEntity != null)
                    {
                        var documentFieldEntity = new DocumentFieldEntity
                        {
                            CreatedBy           = document.CreatedBy,
                            DocumentReferenceId = document.DocumentReferenceId,
                            CollectionId        = document.CollectionId,
                            FieldId             = lsColFieldEntity[0].FieldId,
                            FieldValue          = doAtomicTask.DuplicateField
                        };
                        try
                        {
                            _vault.CreateDocumentField(documentFieldEntity);
                        }
                        catch (Exception ex)
                        {
                            EvLog.WriteEntry(jobParameters.JobId + Constants.DO_ATOMIC_TASK,
                                             Constants.DO_ATOMIC_ERR_INS_DUP_FIELD_VAULT + ex.Message);
                        }
                    }

                    #endregion

                    document.CollectionId.ShouldNotBe(Guid.Empty);
                    var rvwDocumentBeo = new RVWDocumentBEO {
                        DocumentId = document.DocumentReferenceId
                    };

                    rvwDocumentBeo.CollectionId = document.CollectionId.ToString();
                    rvwDocumentBeo.DuplicateId  = doAtomicTask.HashValue;
                    rvwDocumentBeo.MatterId     = Convert.ToInt64(doAtomicTask.MatterId);
                    DocumentBO.UpdateDuplicateId(rvwDocumentBeo);

                    #region "Insert Fields for Document into search sub-system"

                    var fieldValues = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>(EVSystemFields.Duplicate.ToLower(), doAtomicTask.DuplicateField),
                        new KeyValuePair <string, string>(EVSystemFields.DuplicateId.ToLower(), doAtomicTask.HashValue)
                    };


                    var indexManagerProxy = new IndexManagerProxy(Convert.ToInt64(doAtomicTask.MatterId), doAtomicTask.CollectionId);
                    var documentBeos      = new List <DocumentBeo>
                    {
                        DocumentBO.ToDocumentBeo(document.DocumentReferenceId, fieldValues)
                    };
                    indexManagerProxy.BulkUpdateDocumentsAsync(documentBeos);

                    #endregion
                }
            }
            catch (Exception exp)
            {
                EvLog.WriteEntry(jobParameters.JobId + Constants.EVENT_DO_ATOMIC_WORK_EXCEPTION_VALUE, exp.Message,
                                 EventLogEntryType.Error);
                LogException(_jobid, exp, Constants.EVENT_DO_ATOMIC_WORK_EXCEPTION_VALUE, LogCategory.Task,
                             _task.TaskKey, ErrorCodes.ProblemInDoAtomicWork);
                isFailed = true;
            }
            return(!isFailed);
        }