/// <summary>
        /// Bulk search for entire batch document
        /// </summary>
        public List <DocumentDetail> BulkSearch(List <DocumentDetail> docDetailsList, UserBusinessEntity userInfo,
                                                out List <JobWorkerLog <OverlaySearchLogInfo> > overlayLogList,
                                                out Dictionary <string, string> overlayDocumentIdPair)
        {
            var documentDetailList        = new List <DocumentDetail>();
            var logList                   = new List <JobWorkerLog <OverlaySearchLogInfo> >();
            var overlayUniqueThreadString = string.Empty;

            overlayDocumentIdPair = new Dictionary <string, string>();
            var searchQueryText = new StringBuilder();
            var docCount        = 0;
            var outputFields    = new List <Field>();

            #region Construct Bulk Query

            foreach (var doc in docDetailsList)
            {
                if (docCount == 0)
                {
                    outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field {
                        FieldName = field.FieldName
                    }));
                }

                docCount++;
                searchQueryText.Append(ConstructSearchQuery(doc.OverlayMatchingField));
                if (docCount != docDetailsList.Count)
                {
                    searchQueryText.Append(" OR ");
                }
            }

            #endregion

            #region Bulk Search

            ReviewerSearchResults bulkSearchresult;
            using (new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress))
            {
                var searchHelper = new OverlaySearchHelper();
                bulkSearchresult = searchHelper.Search(searchQueryText.ToString(), _jobParams.CollectionId,
                                                       _jobParams.DatasetId, _jobParams.MatterId,
                                                       _datasetBEO.Matter.MatterDBName, _jobParams.CreatedBy, userInfo, outputFields);
            }

            #endregion

            #region Construct Document From Search

            foreach (var docDetail in docDetailsList)
            {
                JobWorkerLog <OverlaySearchLogInfo> overlayLog;
                string threadConstraint;
                var    docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments,
                                                          out threadConstraint,
                                                          out overlayLog);

                if (docs != null)
                {
                    documentDetailList.AddRange(docs);
                }
                if (overlayLog != null)
                {
                    logList.Add(overlayLog);
                }
                if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty)
                {
                    overlayUniqueThreadString = threadConstraint;
                }
            }

            overlayLogList = logList;

            #endregion


            overlayDocumentIdPair = AddKeyValues(overlayDocumentIdPair, _overlayNewAndOldDocumentIdPairs);
            #region Find and Purify Duplicate match document

            RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList);

            #endregion

            return(documentDetailList);
        }
Пример #2
0
        /// <summary>
        /// Bulk search for entire batch document
        /// </summary>
        public List <DocumentDetail> BulkSearch(List <DocumentDetail> docDetailsList, UserBusinessEntity userInfo,
                                                out List <JobWorkerLog <OverlaySearchLogInfo> > overlayLogList)
        {
            var documentDetailList        = new List <DocumentDetail>();
            var logList                   = new List <JobWorkerLog <OverlaySearchLogInfo> >();
            var overlayUniqueThreadString = string.Empty;
            var searchQueryText           = new StringBuilder();
            var outputFields              = new List <Field>();
            var docCount                  = 0;

            #region Construct Bulk Query
            foreach (var doc in docDetailsList)
            {
                if (docCount == 0)
                {
                    outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field {
                        FieldName = field.FieldName
                    }));
                }

                docCount++;
                var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList();
                if (!overlayMatchingField.Any())
                {
                    continue;
                }
                searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList()));
                if (docCount != docDetailsList.Count)
                {
                    searchQueryText.Append(Constants.SearchORCondition);
                }
            }
            var strSearchQueryText = searchQueryText.ToString();
            //To remove last OR Operator( " OR ") which added in search query.
            var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition);
            if (searchOrOperatorLastIndex != -1)
            {
                if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length)
                {
                    strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex);
                }
            }

            #endregion

            #region Bulk Search
            ReviewerSearchResults bulkSearchresult;
            using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress))
            {
                var searchHelper = new OverlaySearchHelper();
                bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId,
                                                       m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields);
            }
            #endregion

            #region Construct Document From Search
            // DEBUG
            //docDetailsList.ForEach(docDetail =>
            Parallel.ForEach(docDetailsList, docDetail =>
            {
                JobWorkerLog <OverlaySearchLogInfo> overlayLog = null;
                string threadConstraint;
                var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog);
                lock (documentDetailList)
                {
                    if (docs != null)
                    {
                        documentDetailList.AddRange(docs);
                    }
                    if (overlayLog != null)
                    {
                        logList.Add(overlayLog);
                    }
                    if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty)
                    {
                        overlayUniqueThreadString = threadConstraint;
                    }
                }
            });
            overlayLogList = logList;
            #endregion

            #region Find and Purify Duplicate match document
            RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList);
            #endregion

            return(documentDetailList);
        }
        /// <summary>
        /// Bulk search for entire batch document
        /// </summary>       
        public List<DocumentDetail> BulkSearch(List<DocumentDetail> docDetailsList, UserBusinessEntity userInfo,
            out List<JobWorkerLog<OverlaySearchLogInfo>> overlayLogList)
        {
            var documentDetailList = new List<DocumentDetail>();
            var logList = new List<JobWorkerLog<OverlaySearchLogInfo>>();
            var overlayUniqueThreadString = string.Empty;
            var searchQueryText = new StringBuilder();
            var outputFields = new List<Field>();
            var docCount = 0;
            #region Construct Bulk Query
            foreach (var doc in docDetailsList)
            {
                if (docCount == 0)
                {
                    outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field {FieldName = field.FieldName}));
                }

                docCount++;
                var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList();
                if (!overlayMatchingField.Any()) continue;
                searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList()));
                if (docCount != docDetailsList.Count)
                    searchQueryText.Append(Constants.SearchORCondition);
            }
            var strSearchQueryText = searchQueryText.ToString();
            //To remove last OR Operator( " OR ") which added in search query.
            var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition);
            if (searchOrOperatorLastIndex != -1)
            {
                if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length)
                {
                    strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex);
                }
            }

            #endregion

            #region Bulk Search
            ReviewerSearchResults bulkSearchresult;
            using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress))
            {
                var searchHelper = new OverlaySearchHelper();
                bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId,
                    m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields);
            }
            #endregion

            #region Construct Document From Search
            // DEBUG
            //docDetailsList.ForEach(docDetail =>
            Parallel.ForEach(docDetailsList, docDetail =>
            {
                JobWorkerLog<OverlaySearchLogInfo> overlayLog = null;
                string threadConstraint;
                var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog);
                lock (documentDetailList)
                {
                    if (docs != null) documentDetailList.AddRange(docs);
                    if (overlayLog != null) logList.Add(overlayLog);
                    if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) overlayUniqueThreadString = threadConstraint;
                }
            });            
            overlayLogList = logList;
            #endregion

            #region Find and Purify Duplicate match document
            RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList);
            #endregion

            return documentDetailList;
        }