public override Response Execute()
        {
            var response = new Response()
            {
                Success = true, Message = ""
            };

            try
            {
                var artifactQueries     = new ArtifactQueries();
                var workspaceArtifactId = Helper.GetActiveCaseID();
                var svcManager          = Helper.GetServicesManager();
                var identityCurrentUser = ExecutionIdentity.CurrentUser;
                var activeArtifactId    = ActiveArtifact.ArtifactID;
                var logger = GetLoggerAsync().Result;

                var exportJob = new ExportJob(svcManager, artifactQueries, workspaceArtifactId, identityCurrentUser, activeArtifactId, logger);
                response = exportJob.ExecutePreDelete().Result;
            }
            catch (Exception ex)
            {
                response.Success   = false;
                response.Exception = new SystemException("Pre Delete Failure: " + ex.Message);
            }

            return(response);
        }
Exemplo n.º 2
0
        public override Response Execute()
        {
            var response = new Response()
            {
                Success = true, Message = ""
            };

            try
            {
                var artifactQueries     = new ArtifactQueries();
                var sqlQueryHelper      = new Helpers.SQL.SqlQueryHelper();
                var workspaceArtifactId = Helper.GetActiveCaseID();
                var svcManager          = Helper.GetServicesManager();
                var identityCurrentUser = ExecutionIdentity.CurrentUser;
                var tempTableName       = TempTableNameWithParentArtifactsToDelete;
                var logger    = GetLoggerAsync().Result;
                var dbContext = Helper.GetDBContext(workspaceArtifactId);

                var exportJob = new ExportJob(svcManager, sqlQueryHelper, artifactQueries, workspaceArtifactId, identityCurrentUser, dbContext, tempTableName, logger);
                response = exportJob.ExecutePreCascadeDelete().Result;
            }
            catch (Exception ex)
            {
                response.Success   = false;
                response.Exception = new SystemException("Pre Cascade Delete Failure: " + ex.Message);
            }

            return(response);
        }
Exemplo n.º 3
0
 public async Task <UserAdminObject> ConvertUserResultToUserAdminObjectAsync(kCura.Relativity.Client.DTOs.User userResult)
 {
     return(new UserAdminObject()
     {
         ArtifactId = userResult.ArtifactID,
         FirstName = { Data = userResult.FirstName },
         LastName = { Data = userResult.LastName },
         EmailAddress = { Data = userResult.EmailAddress },
         Type = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.Type.ArtifactID) },
         Client = { Data = await ArtifactQueries.GetClientNameByArtifactID(RsapiRepositoryGroup.ClientRepository, RsapiApiOptions, userResult.Client.ArtifactID) },
         RelativityAccess = { Data = userResult.RelativityAccess.ToString() },
         DocumentSkip = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DocumentSkip.ArtifactID) },
         BetaUser = { Data = userResult.BetaUser.ToString() },
         ChangeSettings = { Data = userResult.ChangeSettings.ToString() },
         KeyboardShortcuts = { Data = userResult.KeyboardShortcuts.ToString() },
         ItemListPageLength = { Data = userResult.ItemListPageLength.ToString() },
         DefaultSelectedFileType = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DefaultSelectedFileType.ArtifactID) },
         SkipDefaultPreference = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.SkipDefaultPreference.ArtifactID) },
         EnforceViewerCompatibility = { Data = userResult.EnforceViewerCompatibility.ToString() },
         AdvancedSearchPublicByDefault = { Data = userResult.AdvancedSearchPublicByDefault.ToString() },
         NativeViewerCacheAhead = { Data = userResult.NativeViewerCacheAhead.ToString() },
         ChangeDocumentViewer = { Data = userResult.CanChangeDocumentViewer.ToString() },
         DocumentViewer = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DocumentViewer.ArtifactID) },
         Keywords = { Data = null },
         Notes = { Data = null },
         Groups = { Data = null },
         WindowsAccount = { Data = null },
         UserMustChangePasswordOnNextLogin = { Data = userResult.ChangePasswordNextLogin.GetValueOrDefault().ToString() },
         CanChangePassword = { Data = userResult.ChangePassword.GetValueOrDefault().ToString() },
         MaximumPasswordAgeInDays = { Data = userResult.MaximumPasswordAge.GetValueOrDefault().ToString() },
         TwoFactorMode = { Data = null },
         TwoFactorInfo = { Data = null }
     });
 }
Exemplo n.º 4
0
        private async Task <Boolean> AfterProcessingAllLinesAsync()
        {
            string errorContext = $"An error occured when updating total redaction count on the import job. [ImportJobArtifactId: {_importJobArtifactId}]";

            try
            {
                //update import file redaction count field on import job
                await ArtifactQueries.UpdateImportJobRedactionCountFieldValueAsync(
                    AgentHelper.GetServicesManager(),
                    ExecutionIdentity.CurrentUser,
                    WorkspaceArtifactId,
                    _importJobArtifactId,
                    Constant.Guids.Field.MarkupUtilityImportJob.ImportFileRedactionCount,
                    _importFileRedactionCount);

                RaiseMessage($"Updated import file redaction count ({_importFileRedactionCount})");

                //update expected redaction count field on import job
                await ArtifactQueries.UpdateImportJobRedactionCountFieldValueAsync(
                    AgentHelper.GetServicesManager(),
                    ExecutionIdentity.CurrentUser,
                    WorkspaceArtifactId,
                    _importJobArtifactId,
                    Constant.Guids.Field.MarkupUtilityImportJob.ExpectedRedactionCount,
                    _expectedRedactionCount);

                RaiseMessage($"Updated expected redaction count ({_expectedRedactionCount})");
            }
            catch (Exception ex)
            {
                throw new MarkupUtilityException(errorContext, ex);
            }

            return(true);
        }
        public override kCura.EventHandler.Response Execute()
        {
            var response = new kCura.EventHandler.Response {
                Success = true, Message = String.Empty
            };
            var artifactQueries     = new ArtifactQueries();
            var servicesMgr         = Helper.GetServicesManager();
            var workspaceArtifactId = Helper.GetActiveCaseID();

            try
            {
                List <ExtractorRegullarExpression> regExList = PopulateRegExList();

                //Populates Regular Expressions
                foreach (var regEx in regExList)
                {
                    artifactQueries.CreateExtractorRegularExpressionRecord(servicesMgr, Relativity.API.ExecutionIdentity.System, workspaceArtifactId, regEx.Name, regEx.RegularExpression, regEx.Description);
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = "Post-Install regular expression population failed with message: " + ex;
            }
            return(response);
        }
        public void Execute()
        {
            int expectedArtifactID;

            //create field
            expectedArtifactID = ArtifactQueries.CreateFixedLengthTextField(WorkspaceArtifactId, SvcManager, CurrentUserIdentity);

            if (expectedArtifactID == 0)
            {
                throw new Exception("Field failed to create field");
            }

            //fix
            //In a real scenario, workspace Artifact id would be coming in from a manager queue record.
            //Check to see if field exists

            /* const int newWorkspaceArtifactId = 1018783;
             *
             * _fieldArtifactId = ArtifactQueries.GetFieldArtifactId("Demo Document Field", AgentHelper.GetDBContext(newWorkspaceArtifactId));
             * if (_fieldArtifactId == 0)
             *     {
             *     Console.WriteLine("Field is already present in the database :)");
             *     }
             *
             * expectedArtifactID = ArtifactQueries.CreateFixedLengthTextField(newWorkspaceArtifactId, SvcManager, CurrentUserIdentity);*/
        }
        public async Task AttachFileToExportJobAsync(ExportManagerQueueRecord exportManagerQueueRecord, String fileLocation)
        {
            try
            {
                Int32 fileFieldArtifactId = await ArtifactQueries.RetrieveFieldArtifactIdByGuid(
                    rsapiApiOptions : RsapiApiOptions,
                    workspaceArtifactId : exportManagerQueueRecord.WorkspaceArtifactId,
                    fieldRepository : RsapiRepositoryGroup.FieldRepository,
                    fieldGuid : Constant.Guids.Field.ExportUtilityJob.ExportFile
                    );

                await ArtifactQueries.AttachFileToExportJob(
                    rsapiClient : AgentHelper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser),
                    rsapiApiOptions : RsapiApiOptions,
                    workspaceArtifactId : exportManagerQueueRecord.WorkspaceArtifactId,
                    exportJobArtifactId : exportManagerQueueRecord.ExportJobArtifactId,
                    fileFieldArtifactId : fileFieldArtifactId,
                    fileLocation : fileLocation
                    );
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.AttachFileToExportJobError, ex);
            }
        }
Exemplo n.º 8
0
        private async Task UpdateRedactionCountFieldValueAsync(Guid countFieldGuid)
        {
            var countFieldName = await GetCountFieldNameAsync(countFieldGuid);

            var countFieldValue = await GetCountFieldValueAsync(countFieldGuid);

            RaiseMessage($"Retrieving current {countFieldName}");

            //retrieve imported redaction count field on import job
            var currentRedactionCount = await ArtifactQueries.RetrieveImportJobRedactionCountFieldValueAsync(
                AgentHelper.GetServicesManager(),
                _executionIdentity,
                WorkspaceArtifactId,
                _importJobArtifactId,
                countFieldGuid);

            RaiseMessage($"Current {countFieldName} = {currentRedactionCount}");
            var newRedactionCount = currentRedactionCount + countFieldValue;

            RaiseMessage($"New {countFieldName} = {newRedactionCount}");
            RaiseMessage($"Updating current {countFieldName}");

            //update imported redaction count field on import job
            await ArtifactQueries.UpdateImportJobRedactionCountFieldValueAsync(
                AgentHelper.GetServicesManager(),
                _executionIdentity,
                WorkspaceArtifactId,
                _importJobArtifactId,
                countFieldGuid,
                newRedactionCount);

            RaiseMessage($"Updated {countFieldName}");
        }
Exemplo n.º 9
0
 public void Setup()
 {
     Sut = new ArtifactQueries();
     MockUserRepository      = new Mock <IGenericRepository <User> >();
     MockGroupRepository     = new Mock <IGenericRepository <Group> >();
     MockRdoRepository       = new Mock <IGenericRepository <RDO> >();
     MockWorkspaceRepository = new Mock <IGenericRepository <Workspace> >();
     RsapiApiOptions         = new APIOptions();
 }
        public async Task CheckIfWorkersCompletedJob(IEnumerable <ExportManagerQueueRecord> exportManagerQueueRecords)
        {
            var jobsInTheWorkerQueue = exportManagerQueueRecords.Where(x => x.QueueStatus == Constant.Status.Queue.WAITING_FOR_WORKERS_TO_FINISH);

            foreach (var exportManagerQueueRecord in jobsInTheWorkerQueue)
            {
                try
                {
                    SetJobProperties(exportManagerQueueRecord);
                    Int32 numberOfWorkerRecords = await SqlQueryHelper.CountNumberOfExportWorkerRecordsAsync(
                        eddsDbContext : AgentHelper.GetDBContext(-1),
                        workspaceArtifactId : exportManagerQueueRecord.WorkspaceArtifactId,
                        exportJobArtifactId : exportManagerQueueRecord.ExportJobArtifactId);

                    if (numberOfWorkerRecords == 0)
                    {
                        FileInfo exportFileInfo = await ConstructExportFileNameAsync(exportManagerQueueRecord.ObjectType, exportManagerQueueRecord.ExportJobArtifactId);

                        //create export file
                        Int32 numberOfRecordsExported = await CreateExportFileAsync(exportManagerQueueRecord, exportFileInfo);

                        //attach export file to RDO
                        await AttachFileToExportJobAsync(exportManagerQueueRecord, exportFileInfo.FullName);

                        //delete export file from temp directory
                        await DeleteExportFileAsync(exportFileInfo);

                        //drop results table
                        await DropExportWorkerResultsTableAsync(exportManagerQueueRecord.ResultsTableName);

                        //delete record from export manager queue
                        await ClearRecordsFromQueueTables(exportManagerQueueRecord);

                        Boolean jobErrorsRecorded = await ArtifactQueries.JobErrorRecordExistsAsync(RsapiApiOptions, exportManagerQueueRecord.WorkspaceArtifactId, RsapiRepositoryGroup.RdoRepository, Constant.Guids.ObjectType.ExportUtilityJobErrors, Constant.Guids.Field.ExportUtilityJobErrors.ExportUtilityJob, exportManagerQueueRecord.ExportJobArtifactId);

                        await FinalizeJobStatiaticsAsync(exportManagerQueueRecord, numberOfRecordsExported);

                        //update status of export job to complete
                        if (jobErrorsRecorded)
                        {
                            await UpdateExportJobStatus(Constant.Status.Job.COMPLETED_WITH_ERRORS, exportManagerQueueRecord);
                            await SendEmail(exportManagerQueueRecord, Constant.Status.Job.COMPLETED_WITH_ERRORS);
                        }
                        else
                        {
                            await UpdateExportJobStatus(Constant.Status.Job.COMPLETED, exportManagerQueueRecord);
                            await SendEmail(exportManagerQueueRecord, Constant.Status.Job.COMPLETED);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new AdminMigrationUtilityException(Constant.ErrorMessages.CheckIfExportWorkersAreStillWorkingOnExportJobInExportWorkerQueueTableError, ex);
                }
            }
        }
Exemplo n.º 11
0
        private async Task DeleteJobErrors(IServicesMgr svcManager, ExecutionIdentity identityCurrentUser, Int32 workspaceArtifactId, Int32 jobArtifactID)
        {
            var jobErrorArtifactIDs = await ArtifactQueries.QueryJobErrors(svcManager, identityCurrentUser, workspaceArtifactId, jobArtifactID, Constant.Guids.ObjectType.ImportUtilityJobErrors, Constant.Guids.Field.ImportUtilityJobErrors.ImportUtilityJob);

            if (jobErrorArtifactIDs != null & jobErrorArtifactIDs.Any())
            {
                var artifactTypeId = SqlQueryHelper.RetrieveArtifactTypeIdByGuidAsync(DbContext, Constant.Guids.ObjectType.ImportUtilityJobErrors).Result;
                await ArtifactQueries.DeleteJobErrors(svcManager, identityCurrentUser, workspaceArtifactId, jobErrorArtifactIDs.ToList(), artifactTypeId);
            }
        }
Exemplo n.º 12
0
        private async Task <MarkupUtilityImportJob> RetrieveImportJobAsync(int importJobArtifactId)
        {
            RaiseMessage($"Retrieving import job. {_errorContext}]");

            return(await ArtifactQueries.RetrieveImportJobAsync(
                       AgentHelper.GetServicesManager(),
                       _executionIdentity,
                       WorkspaceArtifactId,
                       importJobArtifactId));
        }
Exemplo n.º 13
0
        public async Task ExecuteAsync()
        {
            var queryHelper      = new Query();
            var resourceGroupIds = GetResourceGroupIDs();
            IArtifactQueries  artifactQueries  = new ArtifactQueries();
            IImportFileParser importFileParser = new ImportFileParser();
            IWorkspaceQueries workspaceQueries = new WorkspaceQueries();
            IErrorQueries     errorQueries     = new ErrorQueries();
            IMarkupTypeHelper markupTypeHelper = new MarkupTypeHelper();
            var job = new ImportManagerJob(
                AgentID,
                Helper,
                queryHelper,
                DateTime.Now,
                resourceGroupIds,
                artifactQueries,
                importFileParser,
                workspaceQueries,
                errorQueries,
                markupTypeHelper);

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage(string.Empty, 10);
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
                RaiseMessage(string.Empty, 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());

                //Add the error to our custom Errors table
                queryHelper.InsertRowIntoImportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ImportManagerQueue, job.RecordId, job.AgentId, ex.ToString()).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    errorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                }

                //Set the status in the queue to error
                await queryHelper.UpdateStatusInImportManagerQueueAsync(Helper.GetDBContext(-1), Constant.Status.Queue.Error, job.RecordId);
            }
        }
        public async Task <String> ValidateAsync(String input)
        {
            String validationMessage = null;
            var    returnGroups      = new FieldValueList <Group>();

            if (!String.IsNullOrWhiteSpace(input))
            {
                try
                {
                    input = input.Trim(Constant.ViolationDelimiter.ToCharArray()[0]);
                    var groupList        = input.Split(Constant.ViolationDelimiter.ToCharArray()[0]);
                    var missingGroupList = new List <String>();
                    var query            = new ArtifactQueries();
                    var groupQueryResult = await query.QueryGroupsAsync(_apiOptions, _groupRepository, groupList);

                    if (groupQueryResult.Success && groupQueryResult.Results.Count > 0)
                    {
                        var results = groupQueryResult.Results;
                        foreach (var group in groupList)
                        {
                            var matchingGroup = results.FirstOrDefault(x => x.Artifact.Name == group.Trim());
                            if (matchingGroup == null)
                            {
                                missingGroupList.Add(group);
                            }
                            else
                            {
                                returnGroups.Add(new Group(matchingGroup.Artifact.ArtifactID));
                            }
                        }

                        if (missingGroupList.Any())
                        {
                            validationMessage = String.Format(Constant.Messages.Violations.GroupDoesNotExist, String.Join(Constant.ViolationDelimiter, missingGroupList));
                        }
                    }
                    else if (groupQueryResult.Success)
                    {
                        validationMessage = String.Format(Constant.Messages.Violations.GroupDoesNotExist, input);
                    }
                    else
                    {
                        validationMessage = groupQueryResult.Message;
                    }
                }
                catch (Exception ex)
                {
                    validationMessage = String.Format(Constant.Messages.Violations.Exception, $"querying the following querying the groups related to this user: {input}", ex);
                }
            }
            _callback(returnGroups);

            return(validationMessage);
        }
Exemplo n.º 15
0
        public void GetInstanceOfExtractorRegullarExpressionTest()
        {
            IntegrationSettings testSettings = new IntegrationSettings();

            IntegrationServicesMgr testServiceManager = new IntegrationServicesMgr(testSettings.RsapiSettings);

            ArtifactQueries artifactQueries = new ArtifactQueries();
            ArtifactFactory artifactFactory = new ArtifactFactory(artifactQueries, testServiceManager, null);

            var extractorRegEx = artifactFactory.GetInstanceOfExtractorRegullarExpression(ExecutionIdentity.System, 1016201, 1043028);
        }
Exemplo n.º 16
0
        public async Task ExecuteAsync()
        {
            var sqlQueryHelper   = new SqlQueryHelper();
            var resourceGroupIds = GetResourceGroupIDs();

            _logger = Helper.GetLoggerFactory().GetLogger();
            var rsapiApiOptions = new APIOptions {
                WorkspaceID = -1
            };
            var rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser);

            rsapiClient.APIOptions = rsapiApiOptions;
            var rsapiGroupRepository = new RSAPIiRepositoryGroup(rsapiClient);
            var artifactQueries      = new ArtifactQueries();

            var job = new ImportWorkerJob(AgentID, Helper, sqlQueryHelper, artifactQueries, DateTime.Now, rsapiGroupRepository, resourceGroupIds, _logger, rsapiApiOptions, new SerializationHelper());

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());
                _logger.LogError(ex, $"{Constant.Names.ApplicationName} - {ex}");

                //Add the error to our custom Errors table
                sqlQueryHelper.InsertRowIntoImportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ExportWorkerQueue, job.TableRowId, job.AgentId, ex.ToString()).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                    _logger.LogError(rsapiException, $"{Constant.Names.ApplicationName} - {rsapiException}");
                }
            }
            finally
            {
                rsapiClient.Dispose();
            }
        }
 public async Task <QueryResultSet <kCura.Relativity.Client.DTOs.User> > QueryAllUserArtifactIDs()
 {
     try
     {
         return(await ArtifactQueries.QueryAllUsersArtifactIDsAsync(
                    rsapiApiOptions : RsapiApiOptions,
                    userRepository : RsapiRepositoryGroup.UserRepository));
     }
     catch (Exception ex)
     {
         throw new AdminMigrationUtilityException(Constant.ErrorMessages.QueryAllUserAdminObjectsError, ex);
     }
 }
Exemplo n.º 18
0
        private async Task UpdateImportJobStatusFieldAsync(string status)
        {
            RaiseMessage($"Updating import job status to {status}. {_errorContext}]");

            await ArtifactQueries.UpdateRdoJobTextFieldAsync(
                AgentHelper.GetServicesManager(),
                WorkspaceArtifactId,
                ExecutionIdentity.CurrentUser,
                Constant.Guids.ObjectType.MarkupUtilityImportJob,
                _importJobArtifactId,
                Constant.Guids.Field.MarkupUtilityImportJob.Status,
                status);
        }
Exemplo n.º 19
0
        private async Task UpdateImportJobDetailsFieldAsync(string details)
        {
            RaiseMessage($"Updating import job details. {_errorContext}");

            await ArtifactQueries.UpdateRdoJobTextFieldAsync(
                AgentHelper.GetServicesManager(),
                WorkspaceArtifactId,
                _executionIdentity,
                Constant.Guids.ObjectType.MarkupUtilityImportJob,
                _importJobArtifactId,
                Constant.Guids.Field.MarkupUtilityImportJob.Details,
                details);
        }
Exemplo n.º 20
0
        public void Execute()
        {
            try
            {
                switch (ButtonName)
                {
                case Constant.Names.Console.SUBMIT:
                    //verify all necessary fields are provided
                    if (SavedSearchArtifactId == null || ExtractorProfileArtifactId == null || SourceLongTextFieldArtifactId == null)
                    {
                        throw new CustomExceptions.TextExtractorSetMissingFieldsException(Constant.ErrorMessages.EXTRACTION_SET_MISSING_FIELDS);
                    }

                    var dataRow = SqlQueryHelper.RetrieveSingleInManagerQueueByArtifactId(EddsDbContext, ActiveArtifactId, WorkspaceArtifactId);

                    if (dataRow == null)
                    {
                        //Insert record into Text Extractor Manager table
                        SqlQueryHelper.InsertRowIntoManagerQueue(EddsDbContext, WorkspaceArtifactId, SavedSearchArtifactId, ActiveArtifactId, ExtractorProfileArtifactId, SourceLongTextFieldArtifactId);

                        //Call RSAPI and update Status of Job to Submitted
                        ArtifactQueries.UpdateRdoStringFieldValue(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, Constant.Guids.ObjectType.ExtractorSet, Constant.Guids.Fields.ExtractorSet.Status, ActiveArtifactId, Constant.ExtractorSetStatus.SUBMITTED);
                    }
                    break;

                case Constant.Names.Console.CANCEL:
                    //Check if status of Extractor Set is not Complete
                    var extractorSetStatus = ArtifactQueries.GetExtractorSetStatus(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, ActiveArtifactId);

                    if (extractorSetStatus != Constant.ExtractorSetStatus.COMPLETE)
                    {
                        //Update status of Extractor Set to Cancelled
                        ArtifactQueries.UpdateRdoStringFieldValue(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, Constant.Guids.ObjectType.ExtractorSet, Constant.Guids.Fields.ExtractorSet.Status, ActiveArtifactId, Constant.ExtractorSetStatus.CANCELLED);
                    }
                    else
                    {
                        throw new CustomExceptions.TextExtractorSetConsoleCancelException(Constant.ErrorMessages.EXTRACTION_SET_RECORD_COMPLETE);
                    }
                    break;
                }
            }
            catch (CustomExceptions.TextExtractorSetConsoleCancelException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0}, Error Message: {1}", Constant.ErrorMessages.DEFAULT_ERROR_PREPEND, ex));
            }
        }
Exemplo n.º 21
0
        public async Task ExecuteAsync()
        {
            try
            {
                switch (ButtonName)
                {
                case Constant.Buttons.SUBMIT:
                    Logger.LogDebug($"{Constant.Names.ApplicationName} - {Constant.Buttons.SUBMIT} button clicked.");
                    var recordExists = await DoesRecordExistAsync();

                    if (recordExists == false)
                    {
                        await DeleteJobErrors(SvcManager, IdentityCurrentUser, WorkspaceArtifactId, CurrentArtifactId);

                        //Add the record to the Export Manager queue table
                        var resourceGroupId = await ArtifactQueries.GetResourcePoolArtifactIdAsync(SvcManager, IdentitySystem, WorkspaceArtifactId);

                        await SqlQueryHelper.InsertRowIntoExportManagerQueueAsync(DbContextEdds, WorkspaceArtifactId, Priority, CurrentArtifactId, resourceGroupId, SelectedObjectType);

                        //Clear reset Job Statistics
                        await ResetJobStatisticsAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, CurrentArtifactId);

                        //Set the Export Job RDO status to Validating
                        await UpdateJobStatusAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, Constant.Guids.ObjectType.ExportUtilityJob, CurrentArtifactId, Constant.Guids.Field.ExportUtilityJob.Status, Constant.Status.Job.SUBMITTED);
                    }
                    break;

                case Constant.Buttons.CANCEL:
                    Logger.LogDebug($"{Constant.Names.ApplicationName} - {Constant.Buttons.CANCEL} button clicked.");
                    var artifactId = await RetrieveIdByArtifactIdAsync();

                    //Clear reset Job Statistics
                    await ResetJobStatisticsAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, CurrentArtifactId);

                    if (artifactId > 0)
                    {
                        //Set the Export Job RDO status to Cancel Requested
                        await UpdateJobStatusAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, Constant.Guids.ObjectType.ExportUtilityJob, CurrentArtifactId, Constant.Guids.Field.ExportUtilityJob.Status, Constant.Status.Job.CANCELREQUESTED);

                        //Set the Export Job record in the Manager Queue to Cancel Requested
                        await UpdateJobStatusInManagerQueueAsync(DbContextEdds, WorkspaceArtifactId, CurrentArtifactId, Constant.Status.Queue.CANCELLATION_REQUESTED);
                    }
                    break;
                }
            }
            catch (AdminMigrationUtilityException ex)
            {
                throw new AdminMigrationUtilityException(ex.Message);
            }
        }
Exemplo n.º 22
0
        public override void Execute()
        {
            var sqlQueryHelper  = new SqlQueryHelper();
            var artifactQueries = new ArtifactQueries();

            var errorLogModel        = new ErrorLogModel(sqlQueryHelper, Helper.GetDBContext(-1), AgentID, Constant.Tables.WorkerQueue);
            var uniqueBatchTableName = "[" + Constant.Names.TablePrefix + "Worker_" + Guid.NewGuid() + "_" + AgentID + "]";
            var artifactFactory      = new ArtifactFactory(artifactQueries, Helper.GetServicesManager(), errorLogModel);

            var agentWorkerJob   = new WorkerJob(AgentID, Helper.GetServicesManager(), ExecutionIdentity.CurrentUser, new SqlQueryHelper(), new ArtifactQueries(), artifactFactory, Constant.AgentType.Worker, uniqueBatchTableName, Helper.GetDBContext(-1));
            var textExtractorLog = new TextExtractorLog();

            textExtractorLog.OnUpdate      += MessageRaised;
            agentWorkerJob.TextExtractorLog = textExtractorLog;

            try
            {
                RaiseMessage("Enter Agent", 10);
                agentWorkerJob.Execute();
                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());
                //Add the error to our custom Errors table
                sqlQueryHelper.InsertRowIntoErrorLog(Helper.GetDBContext(-1), agentWorkerJob.WorkspaceArtifactId, Constant.Tables.WorkerQueue, agentWorkerJob.RecordId, agentWorkerJob.AgentId, ex.ToString());
                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.CurrentUser, agentWorkerJob.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                }
                //Set the status in the queue to error
                if (uniqueBatchTableName != string.Empty)
                {
                    sqlQueryHelper.UpdateStatusInWorkerQueue(Helper.GetDBContext(-1), Constant.QueueStatus.Error, uniqueBatchTableName);
                }
            }
            finally
            {
                textExtractorLog.RaiseUpdate("Dropping Worker Queue Batch table.");
                //drop temp table
                sqlQueryHelper.DropTable(Helper.GetDBContext(-1), uniqueBatchTableName);
            }
        }
        public async Task UpdateExportJobExpectedNumberOfExports(Int32 expectedNumberOfExports, ExportManagerQueueRecord exportManagerQueueRecord)
        {
            try
            {
                RaiseAndLogDebugMessage("Updating export job expected number of exports.");

                await ArtifactQueries.UpdateExportJobStatitics(RsapiRepositoryGroup.RdoRepository, RsapiApiOptions, exportManagerQueueRecord.WorkspaceArtifactId, exportManagerQueueRecord.ExportJobArtifactId, expectedNumberOfExports, 0, 0, 0);

                RaiseAndLogDebugMessage("Updated export job expected number of exports.");
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.UpdateExportJobExpectedNumberError, ex);
            }
        }
Exemplo n.º 24
0
        public void CreateExtractorRegularExpressionRecordTest()
        {
            IntegrationSettings    testSettings        = new IntegrationSettings();
            IntegrationDBContext   testDBContext       = new IntegrationDBContext(testSettings.DBContextSettings);
            IntegrationServicesMgr testServiceManager  = new IntegrationServicesMgr(testSettings.RsapiSettings);
            SqlQueryHelper         testSqlQueryHelpers = new SqlQueryHelper();
            ArtifactQueries        artifactQueries     = new ArtifactQueries();

            Int32  workspaceArtifactId = 1016201;
            string regExName           = "RegEx created from Unit Test";
            string regEx       = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
            string description = "Matches emails";

            artifactQueries.CreateExtractorRegularExpressionRecord(testServiceManager, ExecutionIdentity.CurrentUser, workspaceArtifactId, regExName, regEx, description);
        }
Exemplo n.º 25
0
        private async Task <StreamReader> ReadImportJobFileContentsAsync(string tempFileLocation)
        {
            RaiseMessage($"Reading contents of import file for import job. {_errorContext}");

            //Obtain ArtifactID of File Field on Markup Utility File object
            var markupFileFieldArtifactId = await QueryHelper.GetArtifactIdByGuidAsync(AgentHelper.GetDBContext(WorkspaceArtifactId), Constant.Guids.Field.MarkupUtilityFile.File);

            return(await ArtifactQueries.GetFileFieldContentsAsync(
                       AgentHelper.GetServicesManager(),
                       ExecutionIdentity.CurrentUser,
                       WorkspaceArtifactId,
                       markupFileFieldArtifactId,
                       _markupUtilityImportJob.FileArtifactId,
                       tempFileLocation));
        }
Exemplo n.º 26
0
        private async Task QueryMarkupSetRelatedFieldValuesAsync(int markupSetArtifactId)
        {
            //retrieve markup set multipe choice field name
            var markupSetName = await ArtifactQueries.RetreiveMarkupSetNameAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetArtifactId);

            string markupSetMultichoiceFieldName = $"{Constant.MarkupSet.MARKUP_SET_FIELD_NAME_PREFIX}{markupSetName}";

            //retrieve markup set multipe choice field artifact id
            _markupSetMultiplechoiceFieldChoiceTypeId = await ArtifactQueries.RetreiveMarkupSetMultipleChoiceFieldTypeIdAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetMultichoiceFieldName);

            //retrieve markup set multipe choice field choice values artifact id's
            var choices = await ArtifactQueries.QueryAllMarkupSetMultipleChoiceFieldValuesAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetMultichoiceFieldName);

            _hasRedactionsChoiceModel = choices.First(x => x.Name.Equals(Constant.MarkupSet.MarkupSetMultiChoiceValues.HAS_REDACTIONS));
            _hasHighlightsChoiceModel = choices.First(x => x.Name.Equals(Constant.MarkupSet.MarkupSetMultiChoiceValues.HAS_HIGHLIGHTS));
        }
Exemplo n.º 27
0
        private async Task ProcessSingleImportJobAsync(DataRow dataRow)
        {
            _duplicateRedactionInserted = false;

            try
            {
                //convert datarow to object
                _importWorkerQueueRecord = new ImportWorkerQueueRecord(dataRow);

                //set _imporJobArtifactId
                _importJobArtifactId = _importWorkerQueueRecord.ImportJobArtifactId;

                //create error context
                _errorContext = $"[RecordId = {_importWorkerQueueRecord.Id}, WorkspaceArtifactId = {WorkspaceArtifactId}, ImportJobArtifactId = {_importWorkerQueueRecord.ImportJobArtifactId}]";

                //retrieve import job
                var markupUtilityImportJob = await RetrieveImportJobAsync(_importJobArtifactId);

                //construct redaction data for history record
                _redactionData = await ConstructRedactionDataAsync();

                //get document artifact id
                var documentArtifactId = await GetDocumentArtifactIdAsync();

                //get fileGuid for the document and fileOrder
                var fileGuid = await GetFileGuidForDocumentFileOrderAsync(documentArtifactId);

                //check if markup set exists
                await ArtifactQueries.VerifyIfMarkupSetExistsAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupUtilityImportJob.MarkupSetArtifactId);

                //insert redaction into redaction table
                await InsertMarkupIntoRedactionTableAsync(fileGuid, markupUtilityImportJob, documentArtifactId);
            }
            catch (Exception ex)
            {
                RaiseMessage($"An exception occured when processing import job. {_errorContext}. [Error Message = {ex.Message}]");

                //create Markup Utility history record as completed with errors
                await CreateFailureHistoryRecordAsync(ex);

                //update error redaction count
                _errorRedactionCount++;

                //log error
                await LogErrorAsync(ex);
            }
        }
Exemplo n.º 28
0
        public async Task <Response> ExecutePreDelete()
        {
            Logger.LogDebug($"{Constant.Names.ApplicationName} - Entering ExecutePreDelete().");

            var response = new Response {
                Success = true, Message = string.Empty
            };

            try
            {
                var setStatus = await ArtifactQueries.RetrieveRdoJobStatusAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, ActiveArtifactId);

                if (!string.IsNullOrEmpty(setStatus))
                {
                    switch (setStatus)
                    {
                    case Constant.Status.Job.SUBMITTED:
                    case Constant.Status.Job.IN_PROGRESS_MANAGER:
                    case Constant.Status.Job.IN_PROGRESS_WORKER:
                    case Constant.Status.Job.COMPLETED_MANAGER:
                    case Constant.Status.Job.CANCELREQUESTED:
                    case Constant.Status.Job.RETRY:
                        response.Success   = false;
                        response.Exception = new SystemException(Constant.ErrorMessages.NotSupportedJobDeletion);
                        break;

                    case Constant.Status.Job.CANCELLED:
                    case Constant.Status.Job.COMPLETED:
                    case Constant.Status.Job.COMPLETED_WITH_ERRORS:
                    case Constant.Status.Job.ERROR:
                    case Constant.Status.Job.NEW:
                        //Do nothing
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                response.Success   = false;
                response.Exception = new SystemException($"{Constant.ErrorMessages.DefaultErrorPrepend}, Error Message: {ex}");
            }

            Logger.LogDebug($"{Constant.Names.ApplicationName} - Exiting ExecutePreDelete().");
            return(response);
        }
Exemplo n.º 29
0
        public async Task <IEnumerable <String> > QueryGroupsNamesUserIsPartOfAsync(kCura.Relativity.Client.DTOs.User user)
        {
            try
            {
                var userGroupArtifactIDs           = user.Groups.Select(x => x.ArtifactID).ToList();
                IEnumerable <String> groupNameList = await ArtifactQueries.QueryGroupsNamesForArtifactIdsAsync(
                    rsapiApiOptions : RsapiApiOptions,
                    eddsWorkspaceArtifactId : -1,
                    groupRepository : RsapiRepositoryGroup.GroupRepository,
                    groupArtifactIdList : userGroupArtifactIDs);

                return(groupNameList);
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.QueryGroupNamesUserIsPartOfError, ex);
            }
        }
Exemplo n.º 30
0
        public async Task <Response> ExecutePreSave(bool isArtifactNew, Int32 statusFieldArtifactId)
        {
            var response = new Response {
                Success = true, Message = string.Empty
            };

            try
            {
                ValidateEmailTo(response);

                if (isArtifactNew)
                {
                    //Update the Status field
                    ActiveArtifact.Fields[statusFieldArtifactId].Value.Value = Constant.Status.Job.NEW;
                }
                else
                {
                    var status = await ArtifactQueries.RetrieveRdoJobStatusAsync(SvcManager, WorkspaceArtifactId, IdentityCurrentUser, ActiveArtifact.ArtifactID);

                    if (!string.IsNullOrEmpty(status))
                    {
                        switch (status)
                        {
                        case Constant.Status.Job.SUBMITTED:
                        case Constant.Status.Job.IN_PROGRESS:
                        case Constant.Status.Job.IN_PROGRESS_MANAGER:
                        case Constant.Status.Job.IN_PROGRESS_WORKER:
                        case Constant.Status.Job.COMPLETED_MANAGER:
                        case Constant.Status.Job.CANCELREQUESTED:
                        case Constant.Status.Job.RETRY:
                            response.Success = false;
                            response.Message = Constant.ErrorMessages.NotSupportedJobEdit;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = $"{Constant.ErrorMessages.DefaultErrorPrepend}, Error Message: {ex}";
            }
            return(response);
        }