/// <summary>
        /// Get total document count.
        /// </summary>
        private Int64 SetTotalDocumentsCount()
        {
            var queryObject = new SearchQueryEntity();

            queryObject.QueryList.Add(new Query(_searchQuery));
            queryObject.MatterId  = Convert.ToInt32(_dataset.Matter.FolderID);
            queryObject.DatasetId = Convert.ToInt32(_dataset.FolderID);
            if (!string.IsNullOrEmpty(_reviewsetId))
            {
                queryObject.ReviewsetId = _reviewsetId;
            }
            queryObject.IsConceptSearchEnabled = _isIncludeConceptSearch;
            queryObject.LogSearchHistory       = false;
            // Getting the All document and Tag document count from DB
            if (_parametersExportLoadFile.ExportLoadFileInfo != null)
            {
                switch (_parametersExportLoadFile.ExportLoadFileInfo.DocumentSelection)
                {
                case DocumentSelection.SavedQuery:
                    var reviewerSearchService = new RVWReviewerSearchService(_webContext.Object);
                    using (var transScope = new EVTransactionScope(TransactionScopeOption.Suppress))
                    {
                        _totalDocumentCount = reviewerSearchService.GetDocumentCount(queryObject);
                    }
                    break;

                case DocumentSelection.Tag:
                    _totalDocumentCount = DocumentBO.GetNoOfDocumentsByTag(queryObject.MatterId,
                                                                           _dataset.CollectionId, _parametersExportLoadFile.ExportLoadFileInfo.TagId);
                    break;

                default:
                    _totalDocumentCount = DocumentBO.GetNoOfDocuments(queryObject.MatterId,
                                                                      _dataset.CollectionId);
                    break;
                }
            }
            return(_totalDocumentCount);
        }
Exemplo n.º 2
0
        public Guid SubmitSearch(SearchSpecification search)
        {
            if (search == null)
            {
                throw new ArgumentNullException("search");
            }

            ValidateExecutableArgs(search.ExecutableArgs);

            var db = _databaseProvider.GetDatabase(search.DatabaseName);

            if (db == null)
            {
                throw new ArgumentException(string.Format("Cannot find database {0}", search.DatabaseName));
            }
            var fragments = _databaseProvider.GetDatabaseFragments(search.DatabaseName);

            if (fragments == null || fragments.Count == 0)
            {
                throw new ArgumentException(string.Format("Database has no fragments {0}", search.DatabaseName));
            }

            var searchEntity = CreateSearchEntity(search, db);

            try
            {
                // Upload all the inputs to storage
                Parallel.ForEach(search.SearchInputFiles, queryFile =>
                {
                    var filename = Path.GetFileName(queryFile.Filename);
                    _blobStorageProvider.UploadBlobFromStream(searchEntity.InputContainer, filename, queryFile.Content);
                });

                var queryIndex    = 0;
                var searchQueries = new List <SearchQueryEntity>();
                foreach (var queryFile in search.SearchInputFiles)
                {
                    var query = new SearchQueryEntity(searchEntity.Id, queryIndex.ToString());
                    query.OutputContainer     = searchEntity.OutputContainer;
                    query.QueryFilename       = Path.GetFileName(queryFile.Filename);
                    query.State               = QueryState.Waiting;
                    query.QueryOutputFilename = GetQueryOutputFilename(searchEntity.OutputfileFormat, queryIndex.ToString());
                    query.LogOutputFilename   = GetLogFilename(searchEntity.OutputfileFormat, queryIndex.ToString());
                    searchQueries.Add(query);
                    queryIndex++;
                }

                _tableStorageProvider.InsertEntities(searchQueries);

                // Stage the generic batch scripts to storage
                var resourceFiles = InputFileStager.StageImportScripts(_blobStorageProvider);
                SubmitBatchJob(searchEntity, searchQueries, resourceFiles);

                searchEntity.State = SearchState.WaitingForResources;
                _tableStorageProvider.UpdateEntity(searchEntity);
            }
            catch (Exception e)
            {
                if (e is AggregateException)
                {
                    e = e.InnerException;
                }

                searchEntity.State  = SearchState.Error;
                searchEntity.Errors = e.ToString();
                _tableStorageProvider.UpdateEntity(searchEntity);

                throw e;
            }

            return(searchEntity.Id);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     This is the overridden GenerateTasks() method.
        /// </summary>
        /// <param name="jobParameters">GlobalReplaceJobBEO</param>
        /// <param name="previouslyCommittedTaskCount">int</param>
        /// <returns>list of GlobalReplaceTaskBEO object</returns>
        protected override Tasks <GlobalReplaceTaskBEO> GenerateTasks(GlobalReplaceJobBEO jobParameters,
                                                                      out int previouslyCommittedTaskCount)
        {
            var tasks = new Tasks <GlobalReplaceTaskBEO>();

            previouslyCommittedTaskCount = 0;
            try
            {
                LogMessage(Constants.TaskGenerationStartedMessage, false, LogCategory.Job, null);
                LogMessage(Constants.TaskGenerationStartedMessage, GetType(),
                           "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                           jobParameters.JobId, jobParameters.JobRunId);

                var searchQueryEntity = new SearchQueryEntity
                {
                    MatterId               = jobParameters.SearchContext.MatterId,
                    ReviewsetId            = jobParameters.SearchContext.ReviewSetId,
                    DatasetId              = jobParameters.SearchContext.DataSetId,
                    IsConceptSearchEnabled = jobParameters.SearchContext.IsConceptSearchEnabled
                };
                searchQueryEntity.TransactionName = "FindandReplaceJob - GenerateTasks (GetCount)";
                searchQueryEntity.QueryList.Add(new Query(jobParameters.SearchContext.Query));
                long totalResultCount = JobSearchHandler.GetSearchResultsCount(searchQueryEntity);

                if (totalResultCount > 0)
                {
                    //estimated enqueue time for a document is 30 seconds
                    _mEstimatedTimeToIndexInMinutes = (totalResultCount * 30) / 60;
                    for (int pageno = 1;; pageno++)
                    {
                        var task = new GlobalReplaceTaskBEO
                        {
                            PageNumber        = pageno - 1,
                            PageSize          = _mTaskBatchSize,
                            TaskNumber        = pageno,
                            SearchQueryObject = searchQueryEntity,
                            TaskPercent       = 100 / Math.Ceiling((float)totalResultCount / _mTaskBatchSize),
                            TaskComplete      = false,
                            ActualString      = jobParameters.ActualString,
                            ReplaceString     = jobParameters.ReplaceString
                        };
                        tasks.Add(task);
                        //pageno * _taskBatchSize exhaust
                        if (pageno * _mTaskBatchSize >= totalResultCount)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    CustomNotificationMessage = string.Format(Constants.SearchTextNotFound,
                                                              jobParameters.ActualString);
                }
                if (tasks.Count == 0)
                {
                    LogMessage(Constants.NoTaskToExecuteError, GetType(),
                               "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                               jobParameters.JobId, jobParameters.JobRunId);
                }
                LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.TaskGenerationCompletedMessage, tasks.Count), GetType(),
                           "LexisNexis.Evolution.BatchJobs.FindandReplaceJob.GenerateTasks", EventLogEntryType.Information,
                           jobParameters.JobId, jobParameters.JobRunId);
            }
            catch (EVException ex)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + " : " + jobParameters.JobId + Constants.TaskGenerationFails,
                                 ex.ToUserString(), EventLogEntryType.Error);
                LogException(jobParameters.JobId, ex, string.Empty, LogCategory.Job, string.Empty,
                             ErrorCodes.ProblemInGenerateTasks);
            }
            catch (Exception exp)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + " : " + jobParameters.JobId + Constants.TaskGenerationFails,
                                 exp.Message, EventLogEntryType.Error);
                LogException(jobParameters.JobId, exp, string.Empty, LogCategory.Job, string.Empty,
                             ErrorCodes.ProblemInGenerateTasks);
            }
            return(tasks);
        }