/// <summary>
        /// Processes the data.
        /// </summary>
        /// <param name="searchRecord"></param>
        public List <DocumentIdentityRecord> GetDocuments(ReviewsetSearchRecord searchRecord)
        {
            var documents = new List <DocumentIdentityRecord>();

            try
            {
                var searchContext = searchRecord.QueryEntity;

                searchContext.DocumentCount                         = searchRecord.TotalDocumentCount;
                searchContext.DocumentStartIndex                    = 0;
                searchRecord.QueryEntity.TransactionName            =
                    searchContext.TransactionName                   = "SearchWorker - GetDocuments";
                searchContext.TotalRecallConfigEntity.IsTotalRecall = true;
                MockSession();

                var searchResults = SearchBo.Search(searchContext, true);

                if (searchResults != null && searchResults.Documents != null &&
                    searchResults.Documents.Any())
                {
                    searchResults.Documents.ForEach(r => documents.Add(ConvertToDocumentIdentityRecord(r)));
                }
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
                Tracer.Error("SearchWorker - GetDocuments : {0}", ex);
                throw;
            }
            return(documents);
        }
 /// <summary>
 /// Send Worker response to Pipe.
 /// </summary>
 /// <param name="documentCollection"></param>
 private void Send(ReviewsetSearchRecord searchRecord)
 {
     try
     {
         var message = new PipeMessageEnvelope
         {
             Body = searchRecord
         };
         OutputDataPipe.Send(message);
         IncreaseProcessedDocumentsCount(searchRecord.TotalDocumentCount);
     }
     catch (Exception ex)
     {
         Tracer.Error("SplitReviewsetStartupWorker: Send: {0}", ex);
     }
 }
        /// <summary>
        /// Generates the message.
        /// </summary>
        /// <returns></returns>
        protected override bool GenerateMessage()
        {
            var searchRecord = new ReviewsetSearchRecord();

            try
            {
                ////Send the document to the pipe to process once it reach the batchsize
                searchRecord.ReviewsetDetails = _reviewSetRecord;
                _docQueryEntity.ShouldNotBe(null);

                searchRecord.QueryEntity        = _docQueryEntity;
                searchRecord.TotalDocumentCount = (int)_totalDocumentCount;
                Send(searchRecord);
                LogMessage(true, "Split Reviewset: Message successfully sent to acquire all the qualified documents");
            }
            catch (Exception ex)
            {
                LogMessage(false, "Split Reviewset: Failed to determine the qualifying documents");
                ex.Trace();
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// This method converts the ReviewsetSearchRecord type to DocumentRecordCollection
        /// </summary>
        /// <param name="searchRecord">ReviewsetSearchRecord</param>
        /// <param name="documentRecordCollection">ReviewsetSearchRecord</param>
        /// <returns></returns>
        private void ConvertReviewsetSearchRecordToDocumentRecordCollection
            (ReviewsetSearchRecord searchRecord, out DocumentRecordCollection documentRecordCollection)
        {
            documentRecordCollection = new DocumentRecordCollection();
            var reviewsetRecord = new ReviewsetRecord
            {
                Activity             = searchRecord.ReviewsetDetails.Activity,
                CreatedBy            = searchRecord.ReviewsetDetails.CreatedBy,
                DatasetId            = searchRecord.ReviewsetDetails.DatasetId,
                MatterId             = searchRecord.QueryEntity.QueryObject.MatterId,
                ReviewSetId          = searchRecord.ReviewsetDetails.ReviewSetId,
                BinderFolderId       = searchRecord.ReviewsetDetails.BinderFolderId,
                BinderId             = searchRecord.ReviewsetDetails.BinderId,
                BinderName           = searchRecord.ReviewsetDetails.BinderName,
                ReviewSetName        = searchRecord.ReviewsetDetails.ReviewSetName,
                ReviewSetDescription = searchRecord.ReviewsetDetails.ReviewSetDescription,
                DueDate = searchRecord.ReviewsetDetails.DueDate,
                KeepDuplicatesTogether = searchRecord.ReviewsetDetails.KeepDuplicatesTogether,
                KeepFamilyTogether     = searchRecord.ReviewsetDetails.KeepFamilyTogether,
                ReviewSetGroup         = searchRecord.ReviewsetDetails.ReviewSetName,
                ReviewSetLogic         = searchRecord.ReviewsetDetails.ReviewSetLogic,
                SearchQuery            = searchRecord.ReviewsetDetails.SearchQuery,
                SplittingOption        = searchRecord.ReviewsetDetails.SplittingOption,
                StartDate               = searchRecord.ReviewsetDetails.StartDate,
                NumberOfDocuments       = searchRecord.ReviewsetDetails.NumberOfDocuments,
                NumberOfReviewedDocs    = searchRecord.ReviewsetDetails.NumberOfReviewedDocs,
                NumberOfDocumentsPerSet = searchRecord.ReviewsetDetails.NumberOfDocumentsPerSet,
                NumberOfReviewSets      = searchRecord.ReviewsetDetails.NumberOfReviewSets,
                CollectionId            = searchRecord.ReviewsetDetails.CollectionId,
                AssignTo = searchRecord.ReviewsetDetails.AssignTo
            };

            reviewsetRecord.ReviewSetUserList.AddRange(searchRecord.ReviewsetDetails.ReviewSetUserList);
            reviewsetRecord.DsTags.AddRange(searchRecord.ReviewsetDetails.DsTags);
            documentRecordCollection.ReviewsetDetails   = reviewsetRecord;
            documentRecordCollection.TotalDocumentCount = searchRecord.TotalDocumentCount;
        }