Exemplo n.º 1
0
        /// <summary>
        /// This method processes the pipe message
        /// </summary>
        /// <param name="envelope"></param>
        protected override void ProcessMessage(PipeMessageEnvelope envelope)
        {
            var searchRecord = (ReviewsetSearchRecord)envelope.Body;

            // assert checks
            searchRecord.ShouldNotBe(null);
            searchRecord.QueryEntity.ShouldNotBe(null);
            searchRecord.ReviewsetDetails.ShouldNotBe(null);

            try
            {
                // Initialize config values
                GetConfigurationValues();

                searchRecord.ReviewsetDetails.CreatedBy.ShouldNotBeEmpty();
                _createdBy = searchRecord.ReviewsetDetails.CreatedBy;


                DocumentRecordCollection reviewsetDetail;
                // Convert the ReviewsetSearchRecord to DocumentRecordCollection type
                ConvertReviewsetSearchRecordToDocumentRecordCollection(searchRecord, out reviewsetDetail);

                _dataset = DataSetBO.GetDataSetDetailForDataSetId(searchRecord.ReviewsetDetails.DatasetId);



                var documents      = new List <DocumentIdentityRecord>();
                var reviewsetLogic = searchRecord.ReviewsetDetails.ReviewSetLogic.ToLower();
                if (reviewsetLogic == "all" || reviewsetLogic == "tag")
                {
                    var searchQuery = !string.IsNullOrEmpty(_jobParameter.SearchQuery)? _jobParameter.SearchQuery.Replace("\"", ""): string.Empty;
                    Tracer.Info("Get documents from database to create reviewset is started for All/Tag options - job run id : {0}", PipelineId);
                    var resultDocuments = DocumentBO.GetDocumentsForCreateReviewsetJob(searchRecord.QueryEntity.QueryObject.MatterId,
                                                                                       _dataset.CollectionId, searchRecord.TotalDocumentCount,
                                                                                       reviewsetLogic, searchQuery.ToLower(), _batchSize);

                    documents.AddRange(resultDocuments.Select(resultDocument => new DocumentIdentityRecord
                    {
                        Id          = resultDocument.Id,
                        DocumentId  = resultDocument.DocumentID,
                        FamilyId    = resultDocument.FamilyID,
                        DuplicateId = resultDocument.DuplicateId
                    }));
                    Tracer.Info("Documents retrieved from database to create review set for All/Tag options - job run id : {0}", PipelineId);
                }
                else
                {
                    documents = GetDocuments(searchRecord);
                }


                if (documents == null || !documents.Any())
                {
                    Tracer.Error("No documents found for the job run id : {0}", PipelineId);
                    LogMessage(false, string.Format("No documents found for the job run id : {0}", PipelineId),
                               _createdBy, searchRecord.ReviewsetDetails.ReviewSetName);
                    return;
                }

                Tracer.Info("Total of {0} documents found for the job run id : {1}", documents.Count.ToString(),
                            PipelineId);
                LogMessage(true,
                           string.Format("Total of {0} documents found for the job run id : {1}", documents.Count, PipelineId),
                           _createdBy, searchRecord.ReviewsetDetails.ReviewSetName);

                // Group the results and send it in batches
                GroupDocumentsAndSend(documents, reviewsetDetail);
            }
            catch (Exception ex)
            {
                ReportToDirector(ex);
                ex.Trace().Swallow();
                LogMessage(false, ex.ToUserString(), searchRecord.ReviewsetDetails.CreatedBy,
                           searchRecord.ReviewsetDetails.ReviewSetName);
            }
        }