private void SetupRsapiHelper()
        {
            try
            {
                APIOptions rsapiApiOptions = new APIOptions
                {
                    WorkspaceID = -1
                };

                IRSAPIClient rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System);
                rsapiClient.APIOptions = rsapiApiOptions;
                IGenericRepository <RDO>       rdoRepository       = rsapiClient.Repositories.RDO;
                IGenericRepository <Choice>    choiceRepository    = rsapiClient.Repositories.Choice;
                IGenericRepository <Workspace> workspaceRepository = rsapiClient.Repositories.Workspace;
                IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository = rsapiClient.Repositories.User;
                IGenericRepository <Group> groupRepository = rsapiClient.Repositories.Group;

                _rsapiHelper = new RsapiHelper(
                    rsapiApiOptions: rsapiApiOptions,
                    rdoRepository: rdoRepository,
                    choiceRepository: choiceRepository,
                    workspaceRepository: workspaceRepository,
                    userRepository: userRepository,
                    groupRepository: groupRepository);
            }
            catch (Exception ex)
            {
                throw new Exception(Constants.ErrorMessages.RSAPI_HELPER_SETUP_ERROR, ex);
            }
        }
예제 #2
0
 private void ProcessGroupsMetric(IServicesMgr servicesMgr, int workspaceArtifactId, int jobArtifactId)
 {
     try
     {
         RaiseMessage("Processing groups metric", 10);
         int noOfGroups = RsapiHelper.QueryNumberOfGroups(servicesMgr);
         RsapiHelper.UpdateJobField(servicesMgr, workspaceArtifactId, jobArtifactId, Constants.Guids.Fields.InstanceMetricsJob.GroupsCount_LongText, noOfGroups);
     }
     catch (Exception ex)
     {
         throw new Exception(Constants.ErrorMessages.PROCESS_GROUPS_METRIC_ERROR, ex);
     }
 }
예제 #3
0
 private List <Guid> ConvertChoiceArtifactIdsToGuids(IServicesMgr servicesMgr, int workspaceArtifactId, List <int> choiceArtifactIds)
 {
     try
     {
         List <Guid> choiceGuids = new List <Guid>();
         foreach (int choiceArtifactId in choiceArtifactIds)
         {
             Choice choice     = RsapiHelper.RetrieveMetricChoice(servicesMgr, workspaceArtifactId, choiceArtifactId);
             Guid   choiceGuid = choice.Guids.FirstOrDefault();
             choiceGuids.Add(choiceGuid);
         }
         return(choiceGuids);
     }
     catch (Exception ex)
     {
         throw new Exception(Constants.ErrorMessages.CHOICE_ARTIFACT_ID_TO_GUID_CONVERSION_ERROR, ex);
     }
 }
예제 #4
0
 private void ProcessWorkspace(IServicesMgr servicesMgr, int workspaceArtifactId)
 {
     try
     {
         RaiseMessage($"Processing Workspace({workspaceArtifactId})", 10);
         RaiseMessage("Querying for jobs in the workspace", 10);
         List <int> newJobArtifactIds = RsapiHelper.RetrieveJobsInWorkspaceWithStatus(servicesMgr, workspaceArtifactId, Constants.JobStatus.NEW);
         foreach (int newJobArtifactId in newJobArtifactIds)
         {
             RaiseMessage($"Processing job({newJobArtifactId}) in the workspace({workspaceArtifactId})", 10);
             ProcessJob(servicesMgr, workspaceArtifactId, newJobArtifactId);
             RaiseMessage($"Finished processing job({newJobArtifactId}) in the workspace({workspaceArtifactId})", 10);
         }
         RaiseMessage($"Finished processing Workspace({workspaceArtifactId})", 10);
     }
     catch (Exception ex)
     {
         throw new Exception(Constants.ErrorMessages.PROCESS_SINGLE_WORKSPACE_ERROR, ex);
     }
 }
예제 #5
0
        public void SetUp()
        {
            MockRdoRepository       = new Mock <IGenericRepository <RDO> >();
            MockChoiceRepository    = new Mock <IGenericRepository <Choice> >();
            MockWorkspaceRepository = new Mock <IGenericRepository <Workspace> >();
            MockUserRepository      = new Mock <IGenericRepository <User> >();
            MockGroupRepository     = new Mock <IGenericRepository <Group> >();
            APIOptions rsapiApiOptions = new APIOptions
            {
                WorkspaceID = -1
            };

            Sut = new RsapiHelper(
                rsapiApiOptions: rsapiApiOptions,
                rdoRepository: MockRdoRepository.Object,
                choiceRepository: MockChoiceRepository.Object,
                workspaceRepository: MockWorkspaceRepository.Object,
                userRepository: MockUserRepository.Object,
                groupRepository: MockGroupRepository.Object);
        }
예제 #6
0
        private void ProcessJob(IServicesMgr servicesMgr, int workspaceArtifactId, int jobArtifactId)
        {
            try
            {
                //Update job status to In Progress
                RsapiHelper.UpdateJobField(servicesMgr, workspaceArtifactId, jobArtifactId, Constants.Guids.Fields.InstanceMetricsJob.Status_LongText, Constants.JobStatus.IN_PROGRESS);

                //Update job metrics
                RDO jobRdo = RsapiHelper.RetrieveJob(servicesMgr, workspaceArtifactId, jobArtifactId);
                RaiseMessage("Calculating metrics for the job", 10);
                ProcessAllMetrics(servicesMgr, workspaceArtifactId, jobArtifactId, jobRdo);
                RaiseMessage("Calculated metrics for the job", 10);

                //Update job status to Completed
                RsapiHelper.UpdateJobField(servicesMgr, workspaceArtifactId, jobArtifactId, Constants.Guids.Fields.InstanceMetricsJob.Status_LongText, Constants.JobStatus.COMPLETED);
            }
            catch (Exception ex)
            {
                //Update job status to Error
                string errorMessage = ExceptionMessageFormatter.GetInnerMostExceptionMessage(ex);
                RsapiHelper.UpdateJobField(servicesMgr, workspaceArtifactId, jobArtifactId, Constants.Guids.Fields.InstanceMetricsJob.Status_LongText, Constants.JobStatus.ERROR);
                RsapiHelper.UpdateJobField(servicesMgr, workspaceArtifactId, jobArtifactId, Constants.Guids.Fields.InstanceMetricsJob.Errors_LongText, errorMessage);
            }
        }