Esempio n. 1
0
        public static IEnumerable <RDO> GetAll(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var r = new Query <RDO> {
                    ArtifactTypeGuid = Helpers.Constants.Guids.ObjectType.ProcessingProfile
                };
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.ProcessingProfile.DefaultDestinationFolder));
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.ProcessingProfile.DefaultDocumentNumberingPrefix));
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.ProcessingProfile.DefaultOcrLanguages));
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.ProcessingProfile.DefaultTimeZone));
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.ProcessingProfile.Name));
                var sort = new Sort {
                    Guid = Helpers.Constants.Guids.Fields.ProcessingProfile.Name
                };
                r.Sorts.Add(sort);

                var results = client.Repositories.RDO.Query(r);
                var res     = Response <RDO> .CompileQuerySubsets(client, results);

                if (res.Success)
                {
                    return(res.Results);
                }
                throw new Exception(res.Message.ToString());
            }
        }
        public async Task <Guid> ReadModelGuid(IServicesMgr serviceManager, int workspaceId, int modelId)
        {
            Guid returnValue = Guid.Empty;

            using (IObjectManager objectManager = serviceManager.CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                IEnumerable <FieldRef> fieldRefs = new List <FieldRef>
                {
                    new FieldRef
                    {
                        Guid = Guids.Model.MODEL_GUID_FIELD
                    }
                };

                ReadRequest readRequest = new ReadRequest
                {
                    Object = new RelativityObjectRef {
                        ArtifactID = modelId
                    },
                    Fields = fieldRefs
                };

                ReadResult readReturnValue = await objectManager.ReadAsync(workspaceId, readRequest);

                ModelGuid   = Guid.Parse(readReturnValue.Object.FieldValues.Find(x => x.Field.Guids.Contains(Guids.Model.MODEL_GUID_FIELD)).Value.ToString());
                returnValue = ModelGuid;
            }

            return(returnValue);
        }
Esempio n. 3
0
        public void UpdateDocumentLongTextFieldValue(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 documentArtifactId, Guid documentFieldGuid, String fieldValue)
        {
            var errorContext = String.Format("An error occured when updating Document TextExtractorDetails field value. [WorkspaceArtifactId: {0}, DocumentArtifactId: {1}]", workspaceArtifactId, documentArtifactId);

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    var documentDto = new Document(documentArtifactId);
                    documentDto.Fields.Add(new FieldValue(documentFieldGuid)
                    {
                        Value = fieldValue
                    });

                    try
                    {
                        proxy.Repositories.Document.UpdateSingle(documentDto);
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }
        }
        public int GetFieldArtifactId(string fieldName, int workspaceId, IServicesMgr svcMgr, ExecutionIdentity identity)
        {
            int artifactId;

            try
            {
                using (IRSAPIClient client = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    client.APIOptions.WorkspaceID = workspaceId;

                    Query <kCura.Relativity.Client.DTOs.Field> query = new Query <kCura.Relativity.Client.DTOs.Field>();
                    query.Fields    = FieldValue.AllFields;
                    query.Condition = new TextCondition("Name", TextConditionEnum.Like, fieldName);

                    ResultSet <kCura.Relativity.Client.DTOs.Field> results       = client.Repositories.Field.Query(query);
                    kCura.Relativity.Client.DTOs.Field             fieldArtifact = results.Results.FirstOrDefault().Artifact;
                    artifactId = fieldArtifact.ArtifactID;
                }
            }
            catch (Exception)
            {
                //Instead of throwing an exception we want to set the artifactId = 0
                artifactId = 0;
            }
            return(artifactId);
        }
        /// <summary>
        /// Check to see if passed in credentials via Header Authentication is valid
        /// </summary>
        /// <param name="serviceManager"></param>
        /// <returns></returns>
        public async Task <string> RequestAuthTokenAsync(IServicesMgr serviceManager)
        {
            string retVal = null;

            using (IRSAPIClient rsapiClient = serviceManager.CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
            {
                try
                {
                    rsapiClient.APIOptions = new APIOptions {
                        WorkspaceID = -1
                    };
                    var readResult =
                        await Task.Run(() => rsapiClient.GenerateRelativityAuthenticationToken(rsapiClient.APIOptions));

                    if (readResult.Success)
                    {
                        retVal = readResult.Artifact.getFieldByName("AuthenticationToken").ToString();
                    }
                    else
                    {
                        _logHelper.LogError($"DAPI - {nameof(RequestAuthTokenAsync)} - Unable to receive authorization token");
                    }
                }
                catch (Exception ex)
                {
                    _logHelper.LogError(ex,
                                        $"DAPI - {nameof(RequestAuthTokenAsync)} - Error while requesting authorization token: {ex}");
                }
            }

            return(retVal);
        }
Esempio n. 6
0
        public String GetExtractorSetNameForArtifactId(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 extractorSetArtifactId)
        {
            String retVal;
            var    errorContext = String.Format("An error occured when querying for Extractor Set name. [WorkspaceArtifactId: {0}, ExtractorSetArtifactId: {1}]", workspaceArtifactId, extractorSetArtifactId);

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    RDO extractorSetRdo;
                    try
                    {
                        extractorSetRdo = proxy.Repositories.RDO.ReadSingle(Convert.ToInt32(extractorSetArtifactId));
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext + ". Field ReadSingle failed.", ex);
                    }

                    retVal = extractorSetRdo.TextIdentifier;
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }

            return(retVal);
        }
        /// <summary>
        /// Will retrieve the data as a string from the YAML file to be parsed later
        /// </summary>
        /// <param name="serviceManager"></param>
        /// <param name="yamlFileArtifactID"></param>
        /// <param name="authToken"></param>
        /// <returns></returns>
        private async Task <string> DownloadYamlData(IServicesMgr serviceManager, int yamlFileArtifactID, string authToken)
        {
            string yamlData = "";

            using (IRSAPIClient rsapiClient = serviceManager.CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
            {
                var domain             = rsapiClient.EndpointUri.Host;
                var urlWIthoutProtocol = String.Format(Constants.URLs.ResourceFileDownload,
                                                       domain,
                                                       yamlFileArtifactID,
                                                       authToken);

                try
                {
                    //https vs http
                    var yamlFileUrl =
                        ((HttpContext.Current.Request.IsSecureConnection) ? Constants.Protocols.Https : Constants.Protocols.Http) +
                        urlWIthoutProtocol;
                    yamlData = await DownloadYamlFileAsync(new Uri(yamlFileUrl));
                }
                catch (Exception ex)
                {
                    _logHelper.LogError(ex, $"DAPI - {nameof(DownloadYamlData)} - Error attempting to download Yaml file: {ex}");
                }
            }

            return(yamlData);
        }
Esempio n. 8
0
        public void UpdateRdoStringFieldValue(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Guid objectGuid, Guid fieldGuid, Int32 objectArtifactId, String fieldValue)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;

                try
                {
                    var rdo = new RDO(objectArtifactId);
                    rdo.ArtifactTypeGuids.Add(objectGuid);
                    rdo.Fields.Add(new FieldValue(fieldGuid, fieldValue));

                    var result = client.Repositories.RDO.Update(rdo);
                    if (!result.Success)
                    {
                        var messageList = new StringBuilder();
                        messageList.AppendLine(result.Message);
                        result.Results.ToList().ForEach(w => messageList.AppendLine(w.Message));
                        throw new Exception(messageList.ToString());
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error encountered, ", ex);
                }
            }
        }
Esempio n. 9
0
        public RDO GetExtractorSetRdo(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 extractorSetArtifactId)
        {
            var errorContext = String.Format("An error occured when querying for Extractor Set RDO. [WorkspaceArtifactId: {0}, ExtractorSetArtifactId: {1}]", workspaceArtifactId, extractorSetArtifactId);

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    RDO jobRdo;
                    try
                    {
                        jobRdo = proxy.Repositories.RDO.ReadSingle(extractorSetArtifactId);
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext + ". ReadSingle failed.", ex);
                    }
                    return(jobRdo);
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }
        }
Esempio n. 10
0
        public String GetFieldNameForArtifactId(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 fieldArtifactId)
        {
            String retVal;
            var    errorContext = String.Format("An error occured when querying for Field name. [WorkspaceArtifactId: {0}, FieldArtifactId: {1}]", workspaceArtifactId, fieldArtifactId);

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    kCura.Relativity.Client.DTOs.Field fieldRdo;
                    try
                    {
                        fieldRdo = proxy.Repositories.Field.ReadSingle(Convert.ToInt32(fieldArtifactId));
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext + ". Field ReadSingle failed.", ex);
                    }

                    retVal = fieldRdo.Name;
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }

            return(retVal);
        }
Esempio n. 11
0
        public void UpdateExtractorSetDetails(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 extractorSetArtifactId, String details)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var jobRdo = new RDO(extractorSetArtifactId)
                {
                    ArtifactTypeGuids = new List <Guid> {
                        Constant.Guids.ObjectType.ExtractorSet
                    },
                    Fields = new List <FieldValue> {
                        new FieldValue(Constant.Guids.Fields.ExtractorSet.Details, details)
                    }
                };

                try
                {
                    client.Repositories.RDO.UpdateSingle(jobRdo);
                }
                catch (Exception ex)
                {
                    throw new CustomExceptions.TextExtractorException("An error occurred when updating Extractor Set Details field.", ex);
                }
            }
        }
Esempio n. 12
0
        public static Int32 GetByName(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, String custodianName)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var q = new kCura.Relativity.Client.DTOs.Query <kCura.Relativity.Client.DTOs.RDO>
                {
                    ArtifactTypeGuid = Helpers.Constants.Guids.ObjectType.Custodian,
                    Condition        = new TextCondition(Helpers.Constants.Guids.Fields.Custodian.Name, TextConditionEnum.EqualTo, custodianName)
                };

                var results = client.Repositories.RDO.Query(q);

                var res = new Response <Int32>
                {
                    Results = results.Results.Any() ? results.Results.FirstOrDefault().Artifact.ArtifactID : 0,
                    Success = results.Success,
                    Message = MessageFormatter.FormatMessage(results.Results.Select(x => x.Message).ToList(), results.Message, results.Success)
                };

                if (res.Success)
                {
                    return(res.Results);
                }
                throw new Exception(res.Message.ToString());
            }
        }
Esempio n. 13
0
        public String GetExtractorSetDetails(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 extractorSetArtifactId)
        {
            var errorContext = String.Format("An error occured when querying for Extractor Set details. [WorkspaceArtifactId: {0}, ExtractorSetArtifactId: {1}]", workspaceArtifactId, extractorSetArtifactId);

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    RDO jobRdo;
                    try
                    {
                        jobRdo = proxy.Repositories.RDO.ReadSingle(extractorSetArtifactId);
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext + ". ReadSingle failed.", ex);
                    }
                    var details = jobRdo.Fields.Get(Constant.Guids.Fields.ExtractorSet.Details).ValueAsLongText ?? string.Empty;
                    return(details);
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }
        }
Esempio n. 14
0
        public String GetDocumentIdentifierValue(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 documentArtifactId)
        {
            var    errorContext = String.Format("An error occured when querying for Document identifier value. [WorkspaceArtifactId: {0}, DocumentArtifactId: {1}]", workspaceArtifactId, documentArtifactId);
            String retVal;

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                    Document documentRdo;
                    try
                    {
                        documentRdo = proxy.Repositories.Document.ReadSingle(Convert.ToInt32(documentArtifactId));
                    }
                    catch (Exception ex)
                    {
                        throw new CustomExceptions.TextExtractorException(errorContext + ". Document ReadSingle failed.", ex);
                    }

                    retVal = documentRdo.TextIdentifier;
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext, ex);
            }

            return(retVal);
        }
Esempio n. 15
0
        public static void UpdateJobField(IServicesMgr servicesMgr, int workspaceArtifactId, int jobArtifactId, Guid fieldGuid, object fieldValue)
        {
            try
            {
                using (IRSAPIClient rsapiClient = servicesMgr.CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    rsapiClient.APIOptions.WorkspaceID = workspaceArtifactId;
                    RDO jobRdo = new RDO(jobArtifactId);
                    jobRdo.ArtifactTypeGuids.Add(Constants.Guids.ObjectType.InstanceMetricsJob);
                    jobRdo.Fields.Add(new FieldValue(fieldGuid, fieldValue));

                    try
                    {
                        rsapiClient.Repositories.RDO.UpdateSingle(jobRdo);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"{Constants.ErrorMessages.UPDATE_APPLICATION_JOB_STATUS_ERROR}. UpdateSingle. [{nameof(workspaceArtifactId)}= {workspaceArtifactId}, {nameof(jobArtifactId)}= {jobArtifactId}, {nameof(fieldGuid)}= {fieldGuid}, {nameof(fieldValue)}= {fieldValue}]", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(Constants.ErrorMessages.UPDATE_APPLICATION_JOB_STATUS_ERROR, ex);
            }
        }
Esempio n. 16
0
        public static RDO RetrieveJob(IServicesMgr servicesMgr, int workspaceArtifactId, int jobArtifactId)
        {
            RDO jobRdo;

            try
            {
                using (IRSAPIClient rsapiClient = servicesMgr.CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    rsapiClient.APIOptions.WorkspaceID = workspaceArtifactId;
                    try
                    {
                        jobRdo = rsapiClient.Repositories.RDO.ReadSingle(jobArtifactId);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"{Constants.ErrorMessages.RETRIEVE_APPLICATION_JOB_ERROR}. ReadSingle. [{nameof(workspaceArtifactId)}= {workspaceArtifactId}, {nameof(jobArtifactId)}= {jobArtifactId}]", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(Constants.ErrorMessages.RETRIEVE_APPLICATION_JOB_ERROR, ex);
            }
            return(jobRdo);
        }
Esempio n. 17
0
        private IRSAPIClient CreateProxy()
        {
            var proxy = servicesManager.CreateProxy <IRSAPIClient>(this.CurrentExecutionIdentity);

            proxy.APIOptions.WorkspaceID = workspaceId;

            return(proxy);
        }
 public static kCura.Relativity.Client.DTOs.Artifact Read(IServicesMgr svcMgr, ExecutionIdentity identity,
                                                          Int32 workspaceArtifactId, Int32 artifactId)
 {
     using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
     {
         client.APIOptions.WorkspaceID = workspaceArtifactId;
         return(client.Repositories.RDO.ReadSingle(artifactId));
     }
 }
Esempio n. 19
0
        public String GetDocumentLongTextFieldValue(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 documentArtifactId, Guid fieldGuid)
        {
            var    errorContext = String.Format("An error occured when updating Document TextExtractorDetails field value. [WorkspaceArtifactId: {0}, DocumentArtifactId: {1}]", workspaceArtifactId, documentArtifactId);
            String retVal;

            try
            {
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    proxy.APIOptions.WorkspaceID = workspaceArtifactId;

                    Document documentDto = new Document(documentArtifactId)
                    {
                        Fields = new List <FieldValue> {
                            new FieldValue(fieldGuid)
                        }
                    };
                    var resultSet = proxy.Repositories.Document.Read(documentDto);                     //we are using Read instead of ReadSingle since ReadSingle will get all the fields and to avoid any issues with the fields which we are not part of this application and cause any trouble due to size limitations

                    if (resultSet.Success)
                    {
                        if (resultSet.Results != null && resultSet.Results.Count == 1)
                        {
                            var firstOrDefault = resultSet.Results.FirstOrDefault();
                            if (firstOrDefault != null)
                            {
                                var documentArtifact = firstOrDefault.Artifact;
                                var fieldValue       = documentArtifact.Fields.Get(fieldGuid).Value;
                                retVal = fieldValue != null?fieldValue.ToString() : null;
                            }
                            else
                            {
                                //error
                                throw new CustomExceptions.TextExtractorException(errorContext);
                            }
                        }
                        else
                        {
                            //error
                            throw new CustomExceptions.TextExtractorException(errorContext);
                        }
                    }
                    else
                    {
                        //error
                        throw new CustomExceptions.TextExtractorException(string.Format(errorContext + ". Error Message: {0}.", resultSet.Message));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CustomExceptions.TextExtractorException(errorContext + ". Document Read failed.", ex);
            }

            return(retVal);
        }
Esempio n. 20
0
 public static RDO GetByArtifactId(IServicesMgr svcMgr, ExecutionIdentity identity,
                                   Int32 workspaceArtifactId, Int32 artifactId)
 {
     using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
     {
         client.APIOptions.WorkspaceID = workspaceArtifactId;
         var results = client.Repositories.RDO.ReadSingle(artifactId);
         return(results);
     }
 }
Esempio n. 21
0
        public QueryResultSet <Document> GetSubsequentBatchOfDocuments(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 batchSize, Int32 startIndex, String token, Query <Document> query, Int32 workspaceArtifactId)
        {
            QueryResultSet <Document> results;

            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;

                results = client.Repositories.Document.QuerySubset(token, startIndex, batchSize);
            }
            return(results);
        }
Esempio n. 22
0
        public static void WriteError(IServicesMgr svcMgr, ExecutionIdentity identity, int workspaceArtifactId, Exception ex)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;

                var res = WriteError(client, workspaceArtifactId, ex);
                if (!res.Success)
                {
                    throw new Exception(res.Message);
                }
            }
        }
        /// <summary>
        /// Gets the YAML file in the Relativity Instance and returns their ArtifactID and LastModifiedOn (essentially last uploaded date for comparisons later)
        /// </summary>
        /// <param name="serviceManager"></param>
        /// <param name="yamlFileName"></param>
        /// <returns></returns>
        public async Task <List <Tuple <int, DateTime?> > > QueryYamlFileArtifactIDsByNameAsync(IServicesMgr serviceManager, string yamlFileName)
        {
            List <Tuple <int, DateTime?> > retVal = new List <Tuple <int, DateTime?> >();

            using (IObjectManager objectManager = serviceManager.CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                try
                {
                    Condition condition1 = new Relativity.Services.TextCondition(PermissionFieldNames.Name,
                                                                                 Relativity.Services.TextConditionEnum.EqualTo, yamlFileName);

                    QueryRequest queryRequest = new QueryRequest()
                    {
                        ObjectType = new ObjectTypeRef()
                        {
                            ArtifactTypeID = Constants.ArtifactTypes.ResourceFileId
                        },
                        Condition = condition1.ToQueryString(),
                        Fields    = new List <FieldRef>
                        {
                            new FieldRef
                            {
                                Name = "LastModifiedOn"
                            }
                        }
                    };

                    QueryResult results =
                        await objectManager.QueryAsync(Constants.Connections.WorkspaceIdAdmin, queryRequest, 1, 100);

                    if (results.TotalCount > 0)
                    {
                        //retVal.AddRange(results.Results.Select(a => Tuple.Create(a.Artifact.ArtifactID, a.Artifact.Fields.Find(x => x.Name.Equals("LastModifiedOn")).ValueAsDate)));
                        retVal.AddRange(results.Objects.Select(a =>
                                                               Tuple.Create(a.ArtifactID, (DateTime?)a["LastModifiedOn"].Value)));
                    }
                    else
                    {
                        _logHelper.LogError(
                            $"DAPI - {nameof(QueryYamlFileArtifactIDsByNameAsync)} - Unable to find YAML file ({yamlFileName})");
                    }
                }
                catch (Exception ex)
                {
                    _logHelper.LogError(
                        $"DAPI - {nameof(QueryYamlFileArtifactIDsByNameAsync)} - Error while querying resource file ArtifactID: {ex}");
                }
            }

            return(retVal);
        }
        public static kCura.Relativity.Client.DTOs.Artifact Create(IServicesMgr svcMgr, ExecutionIdentity identity,
                                                                   Int32 workspaceArtifactId, String processingSetName, Int32 processingProfileArtifactId, string emailRecipients)
        {
            kCura.Relativity.Client.DTOs.WriteResultSet <kCura.Relativity.Client.DTOs.RDO> results;
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var r = new kCura.Relativity.Client.DTOs.RDO
                {
                    ArtifactTypeGuids = new List <Guid> {
                        Helpers.Constants.Guids.ObjectType.ProcessingSet
                    }
                };
                r.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue(Helpers.Constants.Guids.Fields.ProcessingSet.Name,
                                                                         processingSetName));
                r.Fields.Add(
                    new kCura.Relativity.Client.DTOs.FieldValue(Helpers.Constants.Guids.Fields.ProcessingSet.RelatedProcessingProfile,
                                                                processingProfileArtifactId));
                r.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue(
                                 Helpers.Constants.Guids.Fields.ProcessingSet.DiscoverStatus,
                                 Helpers.Constants.Guids.Choices.ProcessingSet.DiscoverStatusNotStarted));
                r.Fields.Add(
                    new kCura.Relativity.Client.DTOs.FieldValue(Helpers.Constants.Guids.Fields.ProcessingSet.InventoryStatus,
                                                                Helpers.Constants.Guids.Choices.ProcessingSet.InventoryStatusNotStarted));
                r.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue(
                                 Helpers.Constants.Guids.Fields.ProcessingSet.PublishStatus,
                                 Helpers.Constants.Guids.Choices.ProcessingSet.PublishStatusNotStarted));

                if (emailRecipients != String.Empty)
                {
                    r.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue(Helpers.Constants.Guids.Fields.ProcessingSet.EmailRecipients,
                                                                             emailRecipients));
                }

                results = client.Repositories.RDO.Create(r);
                var res = new Response <kCura.Relativity.Client.DTOs.Artifact>
                {
                    Results = results.Results.Any() ? results.Results.FirstOrDefault().Artifact : null,
                    Success = results.Success,
                    Message =
                        MessageFormatter.FormatMessage(results.Results.Select(x => x.Message).ToList(), results.Message, results.Success)
                };

                if (res.Success)
                {
                    return(res.Results);
                }
                throw new Exception(res.Message.ToString());
            }
        }
Esempio n. 25
0
        public static Int32 Create(IServicesMgr svcMgr,
                                   ExecutionIdentity identity,
                                   Int32 workspaceArtifactId,
                                   String fullName,
                                   String firstName,
                                   String lastName,
                                   DestinationEnum destination)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var r = new RDO
                {
                    ArtifactTypeGuids = new List <Guid> {
                        Helpers.Constants.Guids.ObjectType.Custodian
                    }
                };
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.Name, fullName));
                if (destination == DestinationEnum.Custodian)
                {
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.FirstName, firstName));
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.LastName, lastName));
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.CustodianType,
                                                Helpers.Constants.Guids.Choices.ProcessingSet.CustodianTypePerson));
                }
                else
                {
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.CustodianType,
                                                Helpers.Constants.Guids.Choices.ProcessingSet.CustodianTypeEntity));
                }

                var results = client.Repositories.RDO.Create(r);

                var res = new Response <Int32>
                {
                    Results = results.Results.Any() ? results.Results.FirstOrDefault().Artifact.ArtifactID : 0,
                    Success = results.Success,
                    Message = MessageFormatter.FormatMessage(results.Results.Select(x => x.Message).ToList(), results.Message, results.Success)
                };

                if (res.Success)
                {
                    return(res.Results);
                }
                throw new Exception(res.Message.ToString());
            }
        }
Esempio n. 26
0
        public async Task <IEnumerable <int> > ReadDocumentsInSavedSeach(IServicesMgr serviceManager, int workspaceId, int savedSearchArtifactId)
        {
            List <int> returnVal = new List <int>();

            const int indexOfFirstDocumentInResult = 1;  //1-based index of first document in query results to retrieve
            const int lengthOfResults = 100;             //max number of results to return in this query call.

            string searchCondition =
                "('Artifact ID' IN SAVEDSEARCH @savedSearchId)".Replace("@savedSearchId", savedSearchArtifactId.ToString());


            QueryRequest queryRequest = new QueryRequest()
            {
                ObjectType = new ObjectTypeRef {
                    Guid = Guids.Document.OBJECT_TYPE
                },
                Condition = searchCondition,                                                        //query condition syntax is used to build query condtion.  See Relativity's developer documentation for more details
                Fields    = new List <global::Relativity.Services.Objects.DataContracts.FieldRef>() //array of fields to return.  ArtifactId will always be returned.
                {
                    new FieldRef {
                        Name = "Artifact ID"
                    },
                },
                IncludeIDWindow         = false,
                RelationalField         = null,         //name of relational field to expand query results to related objects
                SampleParameters        = null,
                SearchProviderCondition = null,         //see documentation on building search providers
                QueryHint = "waitfor:5"
            };

            using (IObjectManager objectManager = serviceManager.CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                QueryResultSlim queryResult = await objectManager.QuerySlimAsync(workspaceId, queryRequest, indexOfFirstDocumentInResult, lengthOfResults);

                if (queryResult.ResultCount > 0)
                {
                    foreach (RelativityObjectSlim resultObject in queryResult.Objects)
                    {
                        returnVal.Add(resultObject.ArtifactID);
                    }
                }
            }

            DocsInSearch = returnVal;

            return(returnVal);
        }
Esempio n. 27
0
        public async Task <int> GetResourcePoolAsync(IServicesMgr svcMgr, ExecutionIdentity identity, int workspaceArtifactId)
        {
            return(await Task.Run(() =>
            {
                var resourcePoolId = 0;
                using (var proxy = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    var result = proxy.Repositories.Workspace.ReadSingle(workspaceArtifactId).ResourcePoolID;

                    if (result.HasValue)
                    {
                        resourcePoolId = result.Value;
                    }

                    return resourcePoolId;
                }
            }));
        }
        public int GetFieldCount(int fieldArtifactId, int workspaceId, IServicesMgr svcMgr, ExecutionIdentity identity)
        {
            try
            {
                using (IRSAPIClient client = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    client.APIOptions.WorkspaceID = workspaceId;

                    Query query = new Query();
                    query.Condition = new WholeNumberCondition("Artifact ID", NumericConditionEnum.EqualTo, fieldArtifactId);
                    QueryResult result = client.Query(client.APIOptions, query);
                    return(result.TotalCount);
                }
            }
            catch (Exception)
            {
                throw new Exception($"Failed to get the field count for artifact id {fieldArtifactId}.");
            }
        }
Esempio n. 29
0
        public async Task <int> CreateRelativity(IServicesMgr serviceManager, int workspaceId, string name, int savedSearchId)
        {
            int returnValue = 0;

            using (IObjectManager objectManager = serviceManager.CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                List <FieldRefValuePair> fieldValues = new List <FieldRefValuePair>
                {
                    new FieldRefValuePair
                    {
                        Field = new FieldRef()
                        {
                            Guid = Guids.Model.NAME_FIELD
                        },
                        Value = name
                    },
                    new FieldRefValuePair
                    {
                        Field = new FieldRef()
                        {
                            Guid = Guids.Model.SAVED_SEARCH_FIELD
                        },
                        Value = new RelativityObjectRef {
                            ArtifactID = savedSearchId
                        }
                    }
                };

                CreateRequest createRequest = new CreateRequest
                {
                    ObjectType = new ObjectTypeRef {
                        Guid = Guids.Model.OBJECT_TYPE
                    },
                    FieldValues = fieldValues
                };

                CreateResult result = await objectManager.CreateAsync(workspaceId, createRequest);

                returnValue = result.Object.ArtifactID;
            }

            return(returnValue);
        }
Esempio n. 30
0
        public void UpdateNumberOfUpdatesWithValues(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, Int32 extractorSetArtifactId, Int32 numberOfUpdatesWithValues)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;

                var jobRdo = new RDO(extractorSetArtifactId)
                {
                    ArtifactTypeGuids = new List <Guid> {
                        Constant.Guids.ObjectType.ExtractorSet
                    },
                    Fields = new List <FieldValue> {
                        new FieldValue(Constant.Guids.Fields.ExtractorSet.NumberOfUpdatesWithValues, numberOfUpdatesWithValues)
                    }
                };

                client.Repositories.RDO.UpdateSingle(jobRdo);
            }
        }