コード例 #1
0
        /// <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;

        }
コード例 #2
0
        /// <summary>
        /// Re-calculates the number of documents to go into a reviewset based in families & duplicates
        /// </summary>
        /// <param name="reviewsetList"></param>
        private void SaveReviewsetMasterData(List<ReviewsetDetails> reviewsetList, DocumentRecordCollection reviewsetRecord)
        {
            List<DocumentGroupById> duplicateFamilyDocuments = new List<DocumentGroupById>();
            //if splitting logic is distributed and if either keep families or keep duplicates is set


            //if both "Keep Families" & "Keep Duplicates" are set then group by both Family ID and Duplicate ID
            if (m_KeepFamilies && m_KeepDuplicates)
            {
                var familyDuplicateGroup = m_ReceivedDocuments.GroupBy(x => x.GroupId).Where(x=> !string.IsNullOrEmpty(x.Key)).ToList();
                familyDuplicateGroup.ForEach(x => duplicateFamilyDocuments.Add(new DocumentGroupById { GroupID = x.Key.ToString(), DocumentCount = x.Count() }));

                var familyGroup = m_ReceivedDocuments.Where(d=> String.IsNullOrEmpty(d.GroupId)).GroupBy(x => x.FamilyId).ToList();
                familyGroup.ForEach(x => duplicateFamilyDocuments.Add(new DocumentGroupById
                {
                    GroupID = x.Key,
                    DocumentCount = x.Count()
                }));
            }

            //if only "Keep Families" is set then group by Family ID
            if (m_KeepFamilies && !m_KeepDuplicates)
            {
                var familyGroup = m_ReceivedDocuments.GroupBy(x => x.FamilyId).ToList();
                familyGroup.ForEach(x => duplicateFamilyDocuments.Add(new DocumentGroupById
                {
                    GroupID = x.Key,
                    DocumentCount = x.Count()
                }));
            }

            //if only "Keep Duplicates" is set then group by Duplicate Id
            if (m_KeepDuplicates && !m_KeepFamilies)
            {
                var duplicateGroup = m_ReceivedDocuments.GroupBy(x => x.DuplicateId).ToList();
                duplicateGroup.ForEach(x => duplicateFamilyDocuments.Add(new DocumentGroupById { GroupID = x.Key, DocumentCount = x.Count() }));
            }            

            //for every family and duplicate group
            foreach (DocumentGroupById documentGroup in duplicateFamilyDocuments)
            {
                if (String.IsNullOrEmpty(documentGroup.GroupID))
                {
                    CalculateNumberOfDocuments(documentGroup, reviewsetList, false);
                }
                else
                {
                    CalculateNumberOfDocuments(documentGroup, reviewsetList, true);
                }
            }

            //for every reviewset in the list add the reviewset details in Vault
            foreach (ReviewsetDetails reviewset in reviewsetList)
            {
                //set reviewset name
                reviewsetRecord.ReviewsetDetails.ReviewSetName = reviewset.ReviewsetName;

                //if there is no grouping, then keep the original count as calculated count
                if (!m_KeepDuplicates && !m_KeepFamilies)
                {
                    reviewset.CalculatedNoOfDocs = reviewset.OriginalNoOfDocs;
                }

                //set number of records in a reviewset
                reviewsetRecord.ReviewsetDetails.NumberOfDocuments = reviewset.CalculatedNoOfDocs;

                string tempReviewsetId = CreateReviewset(reviewsetRecord);

                //add review set details to the dictionary
                if (!m_AllReviewsets.ContainsKey(tempReviewsetId) && (!string.IsNullOrEmpty(tempReviewsetId)))
                {
                    m_AllReviewsets.Add(tempReviewsetId, new ReviewsetDetails
                    {
                        ReviewsetName = reviewset.ReviewsetName,
                        CalculatedNoOfDocs = reviewset.CalculatedNoOfDocs,
                        OriginalNoOfDocs = reviewset.OriginalNoOfDocs
                    });
                }
            }
        }
コード例 #3
0
        private void Send(DocumentRecordCollection reviewsetRecord)
        {
            if (String.IsNullOrEmpty(reviewsetRecord.ReviewsetDetails.ReviewSetId))
            {
                LogMessage(false, "ReviewsetLogicWorker - reviewsetRecord.ReviewsetDetails.ReviewSetId is empty string", 
                    reviewsetRecord.ReviewsetDetails.CreatedBy, reviewsetRecord.ReviewsetDetails.ReviewSetName);
                throw new EVException().AddDbgMsg("reviewsetRecord.ReviewsetDetails.ReviewSetId is empty string");
            }

            var message = new PipeMessageEnvelope()
            {
                Body = reviewsetRecord
            };
            if (null != OutputDataPipe)
            {
                OutputDataPipe.Send(message);
                IncreaseProcessedDocumentsCount(reviewsetRecord.Documents.Count);
            }
        }
コード例 #4
0
        /// <summary>
        /// Splits the document based on number of review sets and creates the master data in DB
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void SplitDocumentsOnNumberofReviewsets(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);
            reviewsetRecord.ReviewsetDetails.NumberOfReviewSets.ShouldBeGreaterThan(0);

            //temp holder for documents grouped
            List<DocumentGroupById> duplicateFamilyDocuments = new List<DocumentGroupById>();

            //holds review set names generated and number of documents to be assigned for each reviewset
            List<ReviewsetDetails> reviewsetList = new List<ReviewsetDetails>();

            //find if there is any reminder document after calculated documents per set
            int remainderDocuments = m_TotalDocumentCount % reviewsetRecord.ReviewsetDetails.NumberOfReviewSets;

            //find number of documents in a reviewset
            int docsPerReviewset = Convert.ToInt32(m_TotalDocumentCount / reviewsetRecord.ReviewsetDetails.NumberOfReviewSets);

            //get all the reviewset names and number of documents to be associated            
            for (int i = 1; i <= reviewsetRecord.ReviewsetDetails.NumberOfReviewSets; i++)
            {
                reviewsetList.Add(new ReviewsetDetails
                {
                    ReviewsetName = (reviewsetRecord.ReviewsetDetails.Activity == Constants.SplitActivity) ?
                    (reviewsetRecord.ReviewsetDetails.ReviewSetName + (iSetStartNo + i)).ToString(CultureInfo.InvariantCulture) :
                    (reviewsetRecord.ReviewsetDetails.ReviewSetGroup + i).ToString(CultureInfo.InvariantCulture),
                    OriginalNoOfDocs = docsPerReviewset
                });
            }

            //add the remaining documents equally in the reviewsets
            for (int i = 0; i < remainderDocuments; i++)
            {
                reviewsetList[i].OriginalNoOfDocs++;
            }

            //save the manipulated reviewset details in DB
            SaveReviewsetMasterData(reviewsetList, reviewsetRecord);
        }
コード例 #5
0
        /// <summary>
        /// Creates n reviewsets distributing on documents
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void SplitReviewsetOnNumberofDocs(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);
            reviewsetRecord.ReviewsetDetails.NumberOfDocumentsPerSet.ShouldBeGreaterThan(0);

            //find if there is any reminder document after calculated documents per set
            int remainderDocuments = m_TotalDocumentCount % reviewsetRecord.ReviewsetDetails.NumberOfDocumentsPerSet;

            //find the total number of reviewsets
            int totalReviewsets = Convert.ToInt32(m_TotalDocumentCount / reviewsetRecord.ReviewsetDetails.NumberOfDocumentsPerSet);

            //if there is any reminder document then increase the total reviewset count by 1
            totalReviewsets = remainderDocuments > 0 ? totalReviewsets + 1 : totalReviewsets;

            //get all the reviewset names
            List<ReviewsetDetails> reviewsetList = new List<ReviewsetDetails>();
            for (int i = 1; i <= totalReviewsets; i++)
            {
                int numberOfDocs = reviewsetRecord.ReviewsetDetails.NumberOfDocumentsPerSet;

                //if there are any remaining documents then add to last reviewset
                if (remainderDocuments > 0 && i == totalReviewsets)
                {
                    numberOfDocs = remainderDocuments;
                }

                reviewsetList.Add(new ReviewsetDetails
                {
                    ReviewsetName = (reviewsetRecord.ReviewsetDetails.Activity == Constants.SplitActivity) ?
                    (reviewsetRecord.ReviewsetDetails.ReviewSetName + (iSetStartNo + i)).ToString(CultureInfo.InvariantCulture) :
                    (reviewsetRecord.ReviewsetDetails.ReviewSetGroup + i).ToString(CultureInfo.InvariantCulture),
                    OriginalNoOfDocs = numberOfDocs
                });
            }

            SaveReviewsetMasterData(reviewsetList, reviewsetRecord);
        }
コード例 #6
0
        /// <summary>
        /// This method processes the grouped documents and send it in message
        /// </summary>
        /// <param name="results"></param>
        /// <param name="reviewSetRecord"></param>
        /// <param name="groupDocuments"></param>
        /// <param name="outbox"></param>
        private void GroupSend(ref List<DocumentIdentityRecord> results,
            DocumentRecordCollection reviewSetRecord,
            IEnumerable<IGrouping<string, DocumentIdentityRecord>> groupDocuments,
            ref List<DocumentIdentityRecord> outbox)
        {
            //var outbox = new List<DocumentIdentityRecord>();
            foreach (var documentGroup in groupDocuments)
            {
                if (string.IsNullOrEmpty(documentGroup.Key)) continue;

                AddResultsToOutBox(outbox, documentGroup.ToList());

                if (outbox.Count() >= _batchSize)
                {
                    reviewSetRecord.Documents = outbox;
                    // Send
                    Send(reviewSetRecord);
                    results = results.Except(outbox).ToList();
                    outbox.Clear();
                }
            }

            if (outbox.Any())
            {
                results = results.Except(outbox).ToList();
            }
        }
コード例 #7
0
        /// <summary>
        /// Tag the documents with not reviewed tag
        /// </summary>
        /// <param name="reviewsetRecord">Reviewset Record</param>
        /// <param name="tempList">List of documents added to reviewset</param>
        private void TagDocumentsNotReviewed(DocumentRecordCollection reviewsetRecord,
            List<ReviewsetDocumentBEO> tempList)
        {
            reviewsetRecord.ShouldNotBe(null);
            tempList.ShouldNotBe(null);
            var matterId = reviewsetRecord.ReviewsetDetails.MatterId.ToString(CultureInfo.InvariantCulture);
            var collectionId = reviewsetRecord.ReviewsetDetails.CollectionId;

            //var currentUser = EVSessionManager.Get<UserSessionBEO>(Constants.UserSessionInfo);
            var documentTagObjects = new List<DocumentTagBEO>();

            var _binderDetail = BinderVaultManagerInstance.GetBinderSpecificDetails(matterId,
                reviewsetRecord.ReviewsetDetails.BinderId);
            _binderDetail.ShouldNotBe(null);
            _binderDetail.NotReviewedTagId.ShouldBeGreaterThan(0);
            _binderDetail.ReviewedTagId.ShouldBeGreaterThan(0);
            reviewsetRecord.ReviewsetDetails.NotReviewedTagId = _binderDetail.NotReviewedTagId;
            reviewsetRecord.ReviewsetDetails.ReviewedTagId = _binderDetail.ReviewedTagId;


            var docsInfo = ConvertToBulkDocumentInfoBEO(tempList);

            //dictionary to hold list of documents to update
            var documentList = docsInfo.ToDictionary(a => a.DocumentId, a => a);

            //get Effective Tags for the give tag
            var effectiveTagList =
                BulkTagBO.GetEfectiveTags(matterId, new Guid(collectionId), _binderDetail.BinderId,
                    _binderDetail.NotReviewedTagId, Constants.One).ToList();

            var currentState = new List<DocumentTagBEO>();
            var newState = new List<DocumentTagBEO>();

            //get the list of tags with current status for the documents to be tagged
            currentState.AddRange(DocumentVaultManager.GetDocumentTags(matterId, new Guid(collectionId),
                documentList.Keys.ToList()));
            //for every tag from the effective list of tags to be updated
            foreach (var tag in effectiveTagList)
            {
                newState.AddRange(
                    documentList.Values.Select(
                        x =>
                            new DocumentTagBEO
                            {
                                TagId = tag.TagId,
                                Status = tag.TagState,
                                DocumentId = x.DocumentId,
                                DCN = x.DCN,
                                TagTypeSpecifier = tag.type,
                                TagName = tag.TagName
                            }));
            }

            //get all the documents that is not part of current documents list and update to vault
            var vaultChanges = newState.Except(currentState, new DocumentTagComparer()).Distinct().ToList();
            //Remove the entries that are already untagged but are marked for untagging
            vaultChanges.RemoveAll(document => document.Status == Constants.Untagged &&
                                               currentState.Exists(
                                                   y =>
                                                       y.TagId == document.TagId &&
                                                       String.Compare(y.DocumentId, document.DocumentId,
                                                           StringComparison.OrdinalIgnoreCase) == 0) == false);

            /* The following statement will take the untagged documents in the new state and 
             * make it as list of tagged documents so that except operator in the next statement 
             * remove all the tagged documents in the current state that have 
             * been untagged now.*/
            var newstateUntaggedDocuments = newState.Where(t => t.Status != Constants.Tagged).Select(t =>
                new DocumentTagBEO {TagId = t.TagId, DocumentId = t.DocumentId, Status = Constants.Tagged}).ToList();

            //Determine Tag changes to update in search index..This has to be supplied for IndexTaggerWorker to take care in search-engine
            var indexChanges = reviewsetRecord.DocumentTags = currentState.FindAll(currentStateOfDocument =>
                (newstateUntaggedDocuments.Find(newStateOfDocument =>
                    currentStateOfDocument.TagId == newStateOfDocument.TagId &&
                    currentStateOfDocument.DocumentId == newStateOfDocument.DocumentId
                    && currentStateOfDocument.Status == newStateOfDocument.Status) == null)).Union(newState).
                Distinct(new DocumentTagBEO()).ToList();

            DocumentVaultManager.UpdateDocumentTags(matterId, new Guid(collectionId), _binderDetail.BinderId,
                vaultChanges, indexChanges, _createdBy);
            Send(reviewsetRecord);
        }
コード例 #8
0
        /// <summary>
        /// splits into different batches to send to vault worker
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void SendtoVaultWorker(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);
            int batchSize = m_BatchSize;

            //when the batch size is reached send to next worker
            if (m_ReceivedDocuments.Count >= batchSize)
            {
                //find the pending documents to update to reviewset
                int pendingDocsBeforeUpdate = m_AllReviewsets[reviewsetRecord.ReviewsetDetails.ReviewSetId].CalculatedNoOfDocs - m_AllReviewsets[reviewsetRecord.ReviewsetDetails.ReviewSetId].FilledDocs;
                int groupSize = batchSize;
                if (m_ReceivedDocuments.Count >= pendingDocsBeforeUpdate)
                {
                    groupSize = pendingDocsBeforeUpdate;
                }
                SendBatches(groupSize, reviewsetRecord.ReviewsetDetails.ReviewSetId, reviewsetRecord);
            }

            //find the pending documents to update to reviewset
            int pendingDocsAfterUpdate = m_AllReviewsets[reviewsetRecord.ReviewsetDetails.ReviewSetId].CalculatedNoOfDocs - m_AllReviewsets[reviewsetRecord.ReviewsetDetails.ReviewSetId].FilledDocs;

            //if there are any documents still pending
            if (m_ReceivedDocuments.Count > 0)
            {
                //if pending document is equal to excess document after batching then add all
                //the remaining documents and send as last instance to vault worker
                // or if the review set if filled with calculated number of documents even if it is less than batch count
                // still send the review set               
                if (m_ReceivedDocuments.Count.Equals(pendingDocsAfterUpdate) || pendingDocsAfterUpdate.Equals(m_AllReviewsets[reviewsetRecord.ReviewsetDetails.ReviewSetId].CalculatedNoOfDocs))
                {
                    SendBatches(((m_ReceivedDocuments.Count >= pendingDocsAfterUpdate) ? pendingDocsAfterUpdate : m_ReceivedDocuments.Count),
                        reviewsetRecord.ReviewsetDetails.ReviewSetId, reviewsetRecord);
                }
            }
        }
コード例 #9
0
        private void SendBatches(int size, string id, DocumentRecordCollection reviewsetRecord)
        {
            int numberOfFullBatches = size / m_BatchSize;
            int lastBatchSize = size % m_BatchSize;

            for (int fullBatchNumber = 0; fullBatchNumber < numberOfFullBatches; fullBatchNumber++)
            {
                SendBatch(m_BatchSize, id, reviewsetRecord);
            }

            if (lastBatchSize > 0)
            {
                SendBatch(lastBatchSize, id, reviewsetRecord);
            }
        }
コード例 #10
0
 private void Send(DocumentRecordCollection reviewsetRecord)
 {
     var message = new PipeMessageEnvelope
     {
         Body = reviewsetRecord
     };
     if (null != OutputDataPipe)
     {
         OutputDataPipe.Send(message);
         IncreaseProcessedDocumentsCount(reviewsetRecord.Documents.Count);
     }
 }
コード例 #11
0
        /// <summary>
        /// Creates single reviewset and generates the reviewset id
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void CreateSingleReviewset(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);

            //create reviewset in vault and get reviewset id
            if (String.IsNullOrWhiteSpace(m_LastUsedReviewSetId))
            {
                if (reviewsetRecord.ReviewsetDetails.Activity == Constants.SplitActivity)
                {
                    reviewsetRecord.ReviewsetDetails.ReviewSetName = string.Format("{0}{1}",
                        reviewsetRecord.ReviewsetDetails.ReviewSetName, (iSetStartNo + 1).ToString(CultureInfo.InvariantCulture));
                }
                m_LastUsedReviewSetId = CreateReviewset(reviewsetRecord);
            }
            //add review set details to the dictionary
            if (!m_AllReviewsets.ContainsKey(m_LastUsedReviewSetId) && (!string.IsNullOrEmpty(m_LastUsedReviewSetId)))
            {
                m_AllReviewsets.Add(m_LastUsedReviewSetId, new ReviewsetDetails { ReviewsetName = reviewsetRecord.ReviewsetDetails.ReviewSetName, CalculatedNoOfDocs = m_TotalDocumentCount });
            }
        }
コード例 #12
0
        /// <summary>
        /// Update the binder >> not_reviewed tag for the documents
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void UpdateTag(DocumentRecordCollection reviewsetRecord)
        {
            var indexManagerProxy = new IndexManagerProxy(reviewsetRecord.ReviewsetDetails.MatterId, reviewsetRecord.ReviewsetDetails.CollectionId);
            var documentList = reviewsetRecord.DocumentTags.
                GroupBy(item => item.DocumentId).ToDictionary(group => group.Key, group => group.ToList());
            var tagsList = new Dictionary<string, KeyValuePair<string, string>>();

            // create key value pair for every document to be updated in Search Sub System
            foreach (var document in documentList)
            {
                var strTags = string.Join(",", document.Value.Where(x => x.Status == 1).
                    Select(t => String.Format(EVSearchSyntax.TagValueFormat + "{0}", t.TagId)).ToArray());
                tagsList.Add(document.Key,
                             string.IsNullOrEmpty(strTags)
                                 ? new KeyValuePair<string, string>(EVSystemFields.Tag, string.Empty)
                                 : new KeyValuePair<string, string>(EVSystemFields.Tag, strTags));
            }

            const int batchSize = 1000;
            var processedCount = 0;
            while (processedCount != tagsList.Count)
            {
                Dictionary<string, KeyValuePair<string, string>> batchTags;
                if ((tagsList.Count - processedCount) < batchSize)
                {
                    batchTags = tagsList.Skip(processedCount).Take(tagsList.Count - processedCount).ToDictionary(x => x.Key, x => x.Value);
                    processedCount += tagsList.Count - processedCount;
                }
                else
                {
                    batchTags = tagsList.Skip(processedCount).Take(batchSize).ToDictionary(x => x.Key, x => x.Value);
                    processedCount += batchSize;
                }

                if (!batchTags.Any()) continue;

                var docs = batchTags.Select(doc => new DocumentBeo()
                {
                    Id = doc.Key,
                    Fields = new Dictionary<string, string> { { doc.Value.Key, doc.Value.Value } }
                }).ToList();

                indexManagerProxy.BulkUpdateDocumentsAsync(docs);
            }
        }
コード例 #13
0
        /// <summary>
        /// Helper method to update the reviewset identifiers in search index
        /// </summary>
        /// <param name="documentRecords"></param>
        private void UpdateDocuments(DocumentRecordCollection documentRecords)
        {
            documentRecords.ReviewsetDetails.ReviewSetId.ShouldNotBeEmpty();
            var indexManagerProxy = new IndexManagerProxy
                (documentRecords.ReviewsetDetails.MatterId, documentRecords.ReviewsetDetails.CollectionId);

            var fields = new Dictionary<string, string>
            {
                {EVSystemFields.ReviewSetId, documentRecords.ReviewsetDetails.ReviewSetId},
                {EVSystemFields.BinderId, documentRecords.ReviewsetDetails.BinderId}
            };

            const int batchSize = 1000;
            var processedCount = 0;
            while (processedCount != documentRecords.Documents.Count)
            {
                List<DocumentIdentityRecord> documents;
                if ((documentRecords.Documents.Count - processedCount) < batchSize)
                {
                    documents =
                        documentRecords.Documents.Skip(processedCount)
                            .Take(documentRecords.Documents.Count - processedCount)
                            .ToList();
                    processedCount += documentRecords.Documents.Count - processedCount;
                }
                else
                {
                    documents = documentRecords.Documents.Skip(processedCount).Take(batchSize).ToList();
                    processedCount += batchSize;
                }

                var docs = documents.Select(doc => new DocumentBeo() { Id = doc.DocumentId, Fields = fields }).ToList();
                indexManagerProxy.BulkAppendFields(docs);

            }
        }
コード例 #14
0
        private void Send(DocumentRecordCollection reviewsetRecord)
        {
            var message = new PipeMessageEnvelope
            {
                Body = reviewsetRecord
            };

            if (null != OutputDataPipe)
            {
                OutputDataPipe.Send(message);
            }
        }
コード例 #15
0
 /// <summary> 
 /// Send Worker response to Pipe.
 /// </summary>
 /// <param name="reviewsetRecord"></param>
 private void Send(DocumentRecordCollection reviewsetRecord)
 {
     try
     {
         var message = new PipeMessageEnvelope
         {
             Body = reviewsetRecord
         };
         OutputDataPipe.Send(message);
         IncreaseProcessedDocumentsCount(reviewsetRecord.Documents.Count);
     }
     catch (Exception ex)
     {
         Tracer.Error("SearchWorker: Send: {0}", ex);
     }
 }
コード例 #16
0
        private void SendBatch(int size, string id, DocumentRecordCollection reviewsetRecord)
        {
            size.ShouldBeGreaterThan(0);
            id.ShouldNotBe(null);
            reviewsetRecord.ShouldNotBe(null);

            if (m_ReceivedDocuments.Count > 0)
            {
                //temporary list to hold the documents
                var tempList = new List<DocumentIdentityRecord>();

                //add the batch size to temporary list
                tempList.AddRange(m_ReceivedDocuments.GetRange(0, size));

                //remove all the associated documents from the received documents list
                var remainingList = m_ReceivedDocuments.Except(tempList).ToList();
                m_ReceivedDocuments.Clear();
                m_ReceivedDocuments.AddRange(remainingList);

                //assign the current filling review set id to all the documents in the temp list
                tempList.ForEach(x => x.ReviewsetId = id);

                //do not want to maintain this when there is no logic for Keep Families & Keep Duplicates
                if (m_KeepFamilies || m_KeepDuplicates)
                {
                    tempList.ForEach(
                        x =>
                            m_SentDocuments.Add(x.DocumentId,
                                new DocumentDetails { DuplicateID = x.DuplicateId, FamilyID = x.FamilyId }));
                }

                //clear the documents and add the temp list with all the details
                reviewsetRecord.Documents.Clear();
                reviewsetRecord.Documents.AddRange(tempList);

                //update the documents filled count for the review set
                m_AllReviewsets[id].FilledDocs += tempList.Count;

                Send(reviewsetRecord);


            }
        }
コード例 #17
0
        /// <summary>
        /// This method groups the results into families and send it in batches
        /// </summary>
        /// <param name="results">DocumentIdentityRecord List</param>
        /// <param name="reviewSetRecord">DocumentRecordCollection</param>
        private bool GroupDocumentsAndSend(List<DocumentIdentityRecord> results,
            DocumentRecordCollection reviewSetRecord)
        {
            var documentsCopy = new List<DocumentIdentityRecord>(results);
            var outbox = new List<DocumentIdentityRecord>();

            // Process the duplicates first
            if (reviewSetRecord.ReviewsetDetails.KeepDuplicatesTogether && reviewSetRecord.ReviewsetDetails.KeepFamilyTogether)
            {
                var duplicates = documentsCopy.GroupBy(d => d.DuplicateId);
                GroupCombinationsSend(ref results, reviewSetRecord, duplicates, ref outbox);
            }

            // Process the duplicates first
            if (reviewSetRecord.ReviewsetDetails.KeepDuplicatesTogether)
            {
                var duplicates = documentsCopy.GroupBy(d => d.DuplicateId);
                GroupSend(ref results, reviewSetRecord, duplicates, ref outbox);
            }

            // Process the families next
            if (reviewSetRecord.ReviewsetDetails.KeepFamilyTogether)
            {
                documentsCopy = new List<DocumentIdentityRecord>(results);
                var families = documentsCopy.GroupBy(d => d.FamilyId);
                GroupSend(ref results, reviewSetRecord, families, ref outbox);
            }

            // Process the orphan documents finally
            var proceesedCount = 0;

            documentsCopy = new List<DocumentIdentityRecord>(results);
            foreach (var document in documentsCopy)
            {
                outbox.Add(document);
                if (outbox.Count() >= _batchSize)
                {
                    reviewSetRecord.Documents = outbox;
                    // Send
                    Send(reviewSetRecord);
                    results = results.Except(outbox).ToList();
                    proceesedCount = outbox.Count;
                    outbox.Clear();
                }
            }


            // if any, left over documents
            if (outbox != null && outbox.Any())
            {
                reviewSetRecord.Documents = outbox;
                // Send
                Send(reviewSetRecord);
                results = results.Except(outbox).ToList();
                proceesedCount = outbox.Count;
                outbox.Clear();
            }
            return true;
        }
コード例 #18
0
        /// <summary>
        /// creates reviewset with given details
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        /// <returns></returns>
        private string CreateReviewset(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);
            string reviewsetName = reviewsetRecord.ReviewsetDetails.ReviewSetName;

            if (m_AllReviewSetinBinder.Exists(o => o.ReviewSetName.ToLower() == reviewsetName.ToLower()))
            {
                throw new Exception(string.Format("{0}{1}{2}", Constants.ReviewsetNameLog, reviewsetRecord.ReviewsetDetails.ReviewSetName, Constants.AlreadyExistsLog));
            }

            //create the review set with the details sent
            using (EVTransactionScope transScope = new EVTransactionScope(TransactionScopeOption.Suppress))
            {
                CreateReviewSetTaskBEO reviewSetBusinesssEntity = ConverttoReviewsetBusinessEntity(reviewsetRecord.ReviewsetDetails);
                //Creates the reviewset
                string reviewsetId = ReviewSetBO.CreateReviewSetJob(reviewSetBusinesssEntity);
                
                return reviewsetId;
            };
        }
コード例 #19
0
        /// <summary>
        /// This method Groups the documents by duplicates + families together, and send it in message
        /// </summary>
        /// <param name="results"></param>
        /// <param name="reviewSetRecord"></param>
        /// <param name="groupDocuments"></param>
        /// <param name="outbox"></param>
        private void GroupCombinationsSend(ref List<DocumentIdentityRecord> results,
            DocumentRecordCollection reviewSetRecord,
            IEnumerable<IGrouping<string, DocumentIdentityRecord>> groupDocuments, ref List<DocumentIdentityRecord> outbox)
        {
            foreach (var dupGroup in groupDocuments)
            {
                if (string.IsNullOrEmpty(dupGroup.Key)) continue;

                var dupGroupDocs = dupGroup.ToList();
                var groupDocs = new List<DocumentIdentityRecord>();                
                foreach (var dupDoc in dupGroupDocs)
                {                    
                    var resultDoc = results.FirstOrDefault(r => r.DocumentId == dupDoc.DocumentId);
                    if (resultDoc != null)
                    {
                        //Assign the duplicate-id as the "Group Identifier" for the actual duplicate doc
                        resultDoc.GroupId = dupGroup.Key;

                        // Add the actual duplicate document, first.
                        groupDocs.Add(resultDoc);
                        
                        if (!string.IsNullOrEmpty(dupDoc.FamilyId))
                        {
                            // Identify all the family documents for the duplicte doc
                            var familyDocs = results.Where(r => r.FamilyId == resultDoc.FamilyId);
                            if (familyDocs != null && familyDocs.Any())
                            {
                                // Assign the duplicate-id of the actual duplicate doc as "Group Identifier", for all the family documents
                                familyDocs.SafeForEach(f => f.GroupId = dupGroup.Key);
                                //Include the family documents too, in the group
                                groupDocs.AddRange(familyDocs);
                            }
                        }
                        // Pass on the grouped documents it to outbox
                        AddResultsToOutBox(outbox, groupDocs);
                        groupDocs.Clear();
                    }
                }
                
                
                if (outbox.Count() >= _batchSize)
                {
                    reviewSetRecord.Documents = outbox;
                    // Send
                    Send(reviewSetRecord);
                    results = results.Except(outbox).ToList();
                    outbox.Clear();
                }
            }

            if (outbox.Any())
            {
                results = results.Except(outbox).ToList();
            }
        }
コード例 #20
0
        /// <summary>
        /// writes the list of documents into Vault
        /// </summary>
        /// <param name="reviewsetRecord"></param>
        private void WriteDocumentstoVault(DocumentRecordCollection reviewsetRecord)
        {
            reviewsetRecord.ShouldNotBe(null);
            var tempList = new List<ReviewsetDocumentBEO>();
            reviewsetRecord.ReviewsetDetails.CreatedBy.ShouldNotBeEmpty();
            reviewsetRecord.Documents.ShouldNotBe(null);
            _createdBy = reviewsetRecord.ReviewsetDetails.CreatedBy;
            _totalDocumentCount = reviewsetRecord.TotalDocumentCount;

            //stores converted document list
            tempList = ConvertDocumentRecordtoReviewsetDocument(reviewsetRecord.Documents,
                reviewsetRecord.ReviewsetDetails);

            if (EVHttpContext.CurrentContext == null)
            {
                // Moq the session
                MockSession();
            }

            ReviewSetBO.AddDocumentsToReviewSetForOverDrive(reviewsetRecord.ReviewsetDetails.MatterId.ToString(),
                reviewsetRecord.ReviewsetDetails.CollectionId, tempList);
        }