public override async Task ExecuteAsync()
        {
            try
            {
                //Check for jobs which stopped unexpectedly on this agent thread
                RaiseMessage($"Resetting records which failed. [Table = {QueueTable}]");
                await ResetUnfishedJobsAsync(AgentHelper.GetDBContext(-1));

                //Retrieve the next record to work on
                RaiseMessage($"Retrieving next record(s) in the queue. [Table = {QueueTable}]");
                var delimitedListOfResourceGroupIds = GetCommaDelimitedListOfResourceIds(AgentResourceGroupIds);

                if (delimitedListOfResourceGroupIds != string.Empty)
                {
                    var next = await RetrieveNextAsync(delimitedListOfResourceGroupIds);

                    if (TableIsNotEmpty(next))
                    {
                        var firstExportWorkerQueueRecord = new ExportWorkerQueueRecord(next.Rows[0]);
                        WorkspaceArtifactId = firstExportWorkerQueueRecord.WorkspaceArtifactId;

                        //Retrieve export job
                        _markupUtilityExportJob = await _artifactQueries.RetrieveExportJobAsync(_serviceMgr, ExecutionIdentity.CurrentUser, WorkspaceArtifactId, firstExportWorkerQueueRecord.ExportJobArtifactId);

                        //Create Export Worker Job holding table
                        await CreateExportWorkerHoldingTableAsync();

                        //Set the status of the Export Job to In Progess - Export Worker
                        await UpdateStatusFieldAsync(firstExportWorkerQueueRecord.ExportJobArtifactId, Constant.Status.Job.IN_PROGRESS_WORKER);

                        //Process document redactions
                        await ProcessDocumentRedactionsAsync(next, firstExportWorkerQueueRecord.WorkspaceArtifactId, firstExportWorkerQueueRecord.ExportJobArtifactId);

                        RaiseMessage($"Retrieved record(s) in the queue. [Table = {QueueTable}, ID = {RecordId}, Workspace Artifact ID = {WorkspaceArtifactId}]");
                    }
                    else
                    {
                        RaiseMessage("No records in the queue for this resource pool.");
                    }
                }
                else
                {
                    RaiseMessage(Constant.AgentRaiseMessages.AGENT_SERVER_NOT_PART_OF_ANY_RESOURCE_POOL);
                }
            }
            catch (Exception ex)
            {
                RaiseMessage($"Logging error.");
                await LogErrorAsync(ex);
            }
            finally
            {
                //Remove the Export Worker Holding table
                await FinishHoldingTableAsync();

                //Remove records from Batch table and Delete the Export Worker Batch table
                await FinishAsync();
            }
        }
示例#2
0
 private void MockRetrieveExportJobAsync(MarkupUtilityExportJob markupUtilityExportJob)
 {
     MockArtifactQueries.Setup(x => x.RetrieveExportJobAsync(
                                   It.IsAny <IServicesMgr>(),
                                   It.IsAny <ExecutionIdentity>(),
                                   It.IsAny <int>(),
                                   It.IsAny <int>()
                                   ))
     .Returns(Task.FromResult(markupUtilityExportJob))
     .Verifiable();
 }
示例#3
0
        private static MarkupUtilityExportJob GetMarkupUtilityExportJob()
        {
            var retVal = new MarkupUtilityExportJob(
                123,
                string.Empty,
                123,
                Constant.MarkupSubTypeCategory.SupportedMarkupUtilityTypes,
                123,
                123,
                string.Empty,
                string.Empty,
                123);

            return(retVal);
        }
示例#4
0
        private MarkupUtilityExportJob GetMigrationRedactionExportJob(string jobstatus)
        {
            var exportManagerJob = new MarkupUtilityExportJob(
                3456789,                                                    // artifact
                "Test Name",                                                // Name
                5677,                                                       // markupsetartifactid
                Constant.MarkupSubTypeCategory.SupportedMarkupUtilityTypes, // redaction type
                6776,                                                       // saved search
                345345,                                                     // file artifact id
                jobstatus,
                It.IsAny <string>(),
                It.IsAny <int>())
            ;

            return(exportManagerJob);
        }
示例#5
0
        public async Task ProcessRecordsAsync(ExportManagerQueueRecord exportManagerQueueRecord)
        {
            RaiseMessage($"Processing record(s). [Table = {QueueTable}, ID = {RecordId}, Workspace Artifact ID = {WorkspaceArtifactId}]");

            try
            {
                //Retrieve export job
                _markupUtilityExportJob = await _artifactQueries.RetrieveExportJobAsync(_serviceMgr, ExecutionIdentity.CurrentUser, WorkspaceArtifactId, exportManagerQueueRecord.ExportJobArtifactId);

                //Update status of the Export Job to Manager In Progress
                await UpdateStatusFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, Constant.Status.Job.IN_PROGRESS_MANAGER);

                //Flush the Details of the Export Job
                await UpdateDetailsFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, string.Empty);

                //Generate MarkupSubTypes
                var markupSubTypes = await GenerateMarkupSubTypesAsync();

                //Create holding table
                await CreateHoldingTableAsync();

                //Add Documents from Saved Search in the Export Worker Queue
                var isSuccessful = await AddDocumentsToHoldingTableAsync();

                if (isSuccessful)
                {
                    //Copy records from Holding table to Export Worker Queue table
                    await CopyRecordsToExportWorkerQueueAsync(markupSubTypes, exportManagerQueueRecord.ExportJobArtifactId, exportManagerQueueRecord.ResourceGroupId);

                    //Update status of the Export Job to Completed - Manager
                    await UpdateStatusFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, Constant.Status.Job.COMPLETED_MANAGER);

                    //Flush the Details of the Export Job
                    await UpdateDetailsFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, string.Empty);
                }
                else
                {
                    //Update status of the Export Job to Completed
                    await UpdateStatusFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, Constant.Status.Job.COMPLETED);

                    //Update Details of the Export Job indicating no Documents in Saved Search
                    await UpdateDetailsFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, "No Documents found in the selected Saved Search.");

                    //Update Exported Redation Count to 0
                    await _artifactQueries.UpdateRdoJobTextFieldAsync(_serviceMgr, WorkspaceArtifactId, ExecutionIdentity.CurrentUser, Constant.Guids.ObjectType.MarkupUtilityExportJob, _markupUtilityExportJob.ArtifactId, Constant.Guids.Field.MarkupUtilityExportJob.ExportedRedactionCount, "0");
                }
            }
            catch (Exception ex)
            {
                //Update status of the Export Job to Error
                await UpdateStatusFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, Constant.Status.Job.ERROR);

                //Update Details of the Export Job
                await UpdateDetailsFieldAsync(exportManagerQueueRecord.ExportJobArtifactId, ex.ToString());

                //Delete Holding table
                await DeleteHoldingTableAsync();

                //log error
                await LogErrorAsync(ex);
            }

            //delete import job from queue
            RaiseMessage($"Removing record(s) from the queue. [Table = {QueueTable}, ID = {RecordId}, Workspace Artifact ID = {WorkspaceArtifactId}]");
            await FinishAsync();
            await DeleteHoldingTableAsync();

            RaiseMessage($"Removed record(s) from the queue. [Table = {QueueTable}, ID = {RecordId}, Workspace Artifact ID = {WorkspaceArtifactId}]");
            RaiseMessage($"Processed record(s). [Table = {QueueTable}, ID = {RecordId}, Workspace Artifact ID = {WorkspaceArtifactId}]");
        }