Example #1
0
        static bool?VerifyEmptyTarget(IRSAPIClient client)
        {
            // build the query / condition
            DTOs.Query <DTOs.Folder> query = new DTOs.Query <DTOs.Folder>();

            // query for the folders
            DTOs.QueryResultSet <DTOs.Folder> resultSet = new DTOs.QueryResultSet <DTOs.Folder>();
            try
            {
                resultSet = client.Repositories.Folder.Query(query, 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Exception:\r\n{0}\r\n{1}", ex.Message, ex.InnerException));
                return(null);
            }

            // check for success
            if (resultSet.Success)
            {
                if (resultSet.Results.Count == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Query was not successful.");
                return(null);
            }
        }
        /// <summary>
        /// Returns the first artifact ID of a user that matches the email address.
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public int QueryUserIDByEmail(string email)
        {
            int userID;

            DTOs.QueryResultSet <DTOs.User> results;

            using (var client = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(API.ExecutionIdentity.System))
            {
                client.APIOptions.WorkspaceID = -1;

                var query = new DTOs.Query <DTOs.User>()
                {
                    Condition = new TextCondition("Email Address", TextConditionEnum.EqualTo, email),
                    Fields    = new List <FieldValue> {
                        new FieldValue("Artifact ID")
                    }
                };

                results = client.Repositories.User.Query(query);
            }

            if (results.Success)
            {
                userID = results.Results.FirstOrDefault().Artifact.ArtifactID;
            }
            else
            {
                throw new IntegrationTestException($"Failed to retrieve user by email equal to {email}");
            }

            return(userID);
        }
Example #3
0
        /// <summary>
        /// Returns the first group artifact ID that matches the name provided.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public int QueryGroupIDByName(String name)
        {
            int groupID;
            QueryResultSet <DTOs.Group> results;

            var query = new DTOs.Query <DTOs.Group>
            {
                Condition = new TextCondition("Name", TextConditionEnum.EqualTo, name),
                Fields    = new List <FieldValue> {
                    new FieldValue("Artifact ID")
                }
            };

            using (var client = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(API.ExecutionIdentity.System))
            {
                client.APIOptions.WorkspaceID = -1;
                results = client.Repositories.Group.Query(query);
            }

            if (results.Success)
            {
                groupID = results.Results[0].Artifact.ArtifactID;
            }
            else
            {
                throw new IntegrationTestException($"Failed to query group by name equal to {name}");
            }

            return(groupID);
        }
Example #4
0
        public IEnumerable <Comment> GetAll()
        {
            Comment comment = new Comment();

            DTOs.Query <DTOs.RDO>          query   = new DTOs.Query <DTOs.RDO>();
            DTOs.QueryResultSet <DTOs.RDO> results = new DTOs.QueryResultSet <DTOs.RDO>();
            query.ArtifactTypeGuid = new Guid(comment.ARTIFACT_TYPE);
            query.Fields.Add(new DTOs.FieldValue(new Guid(comment.COMMENT), "Comment"));
            List <Comment> commentList = new List <Comment>();

            try
            {
                results = client.Repositories.RDO.Query(query);
                foreach (var c in results.Results)
                {
                    Comment commentToAdd = new Comment();
                    commentList.Add(Get(c.Artifact.ArtifactID));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(commentList);
        }
        private static List <DTOs.Result <DTOs.BatchSet> > GetSourceBatches(IRSAPIClient proxy)
        {
            DTOs.Query <DTOs.BatchSet> query = new DTOs.Query <DTOs.BatchSet>();
            query.Fields = DTOs.FieldValue.AllFields;

            DTOs.QueryResultSet <DTOs.BatchSet> resultSet = new DTOs.QueryResultSet <DTOs.BatchSet>();
            try
            {
                resultSet = proxy.Repositories.BatchSet.Query(query, 0);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception when querying for batches: {message}", ex);
                return(null);
            }

            if (resultSet.Success)
            {
                if (resultSet.Results.Count > 0)
                {
                    _logger.LogInformation("{0} batch sets found in {1}", resultSet.Results.Count, proxy.APIOptions.WorkspaceID);
                    return(resultSet.Results);
                }
                else
                {
                    _logger.LogWarning("Query was successful but no batches exist.");
                    return(null);
                }
            }
            else
            {
                _logger.LogError("Unsuccessful query for batches: {message}", resultSet.Results[0].Message);
                return(null);
            }
        }
Example #6
0
        private DTOs.RelativityScript GetRelativityScriptByName()
        {
            DTOs.RelativityScript script = null;

            //Aseemble Relativity script query
            TextCondition nameCondition = new TextCondition(DTOs.RelativityScriptFieldNames.Name, TextConditionEnum.EqualTo, MainApp.Helper.Constant.SAVED_SEARCH_NAME);

            DTOs.Query <DTOs.RelativityScript> relScriptQuery =
                new DTOs.Query <DTOs.RelativityScript>
            {
                Condition = nameCondition,
                Fields    = DTOs.FieldValue.NoFields
            };

            try
            {
                // Execute query
                DTOs.QueryResultSet <DTOs.RelativityScript> relScriptQueryResults = null;

                relScriptQueryResults = Connection.Repositories.RelativityScript.Query(relScriptQuery);

                if (relScriptQueryResults.Success)
                {
                    script = relScriptQueryResults.Results[0].Artifact;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(script);
        }
Example #7
0
        static DTOs.Workspace FindWorkspace(string name, IRSAPIClient client)
        {
            client.APIOptions.WorkspaceID = -1;

            //build the query / condition
            DTOs.Query <DTOs.Workspace> query = new DTOs.Query <DTOs.Workspace>
            {
                Condition = new TextCondition(DTOs.WorkspaceFieldNames.Name, TextConditionEnum.EqualTo, name),
                Fields    = DTOs.FieldValue.AllFields
            };

            // query for the workspace
            DTOs.QueryResultSet <DTOs.Workspace> resultSet = new DTOs.QueryResultSet <DTOs.Workspace>();
            try
            {
                resultSet = client.Repositories.Workspace.Query(query, 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Exception:\r\n{0}\r\n{1}", ex.Message, ex.InnerException));
                return(null);
            }

            // check for success
            if (resultSet.Success)
            {
                if (resultSet.Results.Count > 0)
                {
                    DTOs.Workspace firstWorkspace = resultSet.Results.FirstOrDefault().Artifact;
                    Console.WriteLine(String.Format("Workspace found with artifactID {0}.", firstWorkspace.ArtifactID));
                    return(firstWorkspace);
                }
                else
                {
                    Console.WriteLine("Query was successful but workspace does not exist.");
                    return(null);
                }
            }
            else
            {
                Console.WriteLine("Query was not successful.");
                return(null);
            }
        }
        static DTOs.Workspace FindWorkspaceArtifactID(int artifactID, IRSAPIClient client)
        {
            client.APIOptions.WorkspaceID = -1;

            //build the query / condition
            DTOs.Query <DTOs.Workspace> query = new DTOs.Query <DTOs.Workspace>
            {
                Condition = new WholeNumberCondition("Artifact ID", NumericConditionEnum.EqualTo, artifactID),
                Fields    = DTOs.FieldValue.AllFields
            };

            // query for the workspace
            DTOs.QueryResultSet <DTOs.Workspace> resultSet = new DTOs.QueryResultSet <DTOs.Workspace>();
            try
            {
                resultSet = client.Repositories.Workspace.Query(query, 0);
            }
            catch
            {
                return(null);
            }

            // check for success
            if (resultSet.Success)
            {
                if (resultSet.Results.Count > 0)
                {
                    DTOs.Workspace firstWorkspace = resultSet.Results.FirstOrDefault().Artifact;
                    return(firstWorkspace);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
        public IEnumerable <DTOs.Document> GetAll()
        {
            DTOs.Query <DTOs.Document>          query     = new DTOs.Query <DTOs.Document>();
            DTOs.QueryResultSet <DTOs.Document> resultSet = new DTOs.QueryResultSet <DTOs.Document>();
            query.Fields.Add(new DTOs.FieldValue(DTOs.ArtifactFieldNames.TextIdentifier));
            List <DTOs.Document> documents = new List <DTOs.Document>();

            try
            {
                resultSet = client.Repositories.Document.Query(query);
                foreach (var d in resultSet.Results)
                {
                    documents.Add(d.Artifact);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(documents);
        }
Example #10
0
        public static List <DTOs.Result <DTOs.Folder> > GetSourceFolders(IRSAPIClient client)
        {
            // build the query / condition
            DTOs.Query <DTOs.Folder> query = new DTOs.Query <DTOs.Folder>();
            query.Fields = DTOs.FieldValue.AllFields;

            // query for the folders
            DTOs.QueryResultSet <DTOs.Folder> resultSet = new DTOs.QueryResultSet <DTOs.Folder>();
            try
            {
                resultSet = client.Repositories.Folder.Query(query, 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Exception:\r\n{0}\r\n{1}", ex.Message, ex.InnerException));
                return(null);
            }

            // check for success
            if (resultSet.Success)
            {
                if (resultSet.Results.Count > 0)
                {
                    Console.WriteLine(String.Format("{0} folders found in {1}.\r\n", resultSet.Results.Count - 1, _templateArtifactId));
                    return(resultSet.Results);
                }
                else
                {
                    Console.WriteLine("Query was successful but no folders exist.");
                    return(null);
                }
            }
            else
            {
                Console.WriteLine("Query was not successful.");
                return(null);
            }
        }
Example #11
0
        public IEnumerable <Workspace> GetAll()
        {
            List <Workspace> workspacesList = new List <Workspace>();

            DTOs.QueryResultSet <DTOs.Workspace> resultSet = new DTOs.QueryResultSet <DTOs.Workspace>();
            DTOs.Query <DTOs.Workspace>          query     = new DTOs.Query <DTOs.Workspace>();
            DTOs.QueryResultSet <DTOs.Workspace> results   = new DTOs.QueryResultSet <DTOs.Workspace>();
            query.Fields = DTOs.FieldValue.AllFields;
            try
            {
                resultSet = client.Repositories.Workspace.Query(query);

                foreach (var w in resultSet.Results)
                {
                    Workspace workspace = Get(w.Artifact.ArtifactID);
                    workspacesList.Add(workspace);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(workspacesList);
        }
Example #12
0
        public int Create(Workspace artifact)
        {
            int response           = 0;
            int?templateArtifactID = null;

            DTOs.Query <DTOs.Workspace> query = new DTOs.Query <DTOs.Workspace>();
            query.Condition = new TextCondition(DTOs.FieldFieldNames.Name, TextConditionEnum.EqualTo, "kCura Starter Template");
            query.Fields    = DTOs.FieldValue.AllFields;
            DTOs.QueryResultSet <DTOs.Workspace> results = client.Repositories.Workspace.Query(query, 0);

            if (results.Success)
            {
                templateArtifactID = results.Results.FirstOrDefault().Artifact.ArtifactID;
            }
            else
            {
                return(response);
            }
            DTOs.Workspace workspaceToCreate = new DTOs.Workspace();
            workspaceToCreate.Name     = artifact.Name;
            workspaceToCreate.Client   = client.Repositories.Client.ReadSingle(artifact.ClientId);
            workspaceToCreate.MatterID = artifact.MatterId;
            ProcessOperationResult result  = new ProcessOperationResult();
            ProcessInformation     process = new ProcessInformation();

            try
            {
                result   = client.Repositories.Workspace.CreateAsync(templateArtifactID.Value, workspaceToCreate);
                response = 1;
            }
            catch (Exception)
            {
                throw;
            }
            return(response);
        }
Example #13
0
        public override void Execute()
        {
            int contador = 0;

            //Get the current Agent artifactID
            Int32 agentArtifactID = this.AgentID;
            //Get a dbContext for the EDDS database
            IDBContext eddsDBContext = this.Helper.GetDBContext(-1);
            List <int> worksapcesID  = new List <int>();
            Comment    comment       = new Comment();


            try
            {
                using (IRSAPIClient proxy =
                           Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    RelativityAppCore.BLL.Service.RSAPIService.CommentRSAPIService commentRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(proxy);
                    IDBContext        DBContext = this.Helper.GetDBContext(-1);
                    DataRowCollection data      = DBContext.ExecuteSqlStatementAsDataTable(Queries.GetWorkspacesWithApp).Rows;
                    RaiseMessage("Find for the workspaces with the application", 1);
                    foreach (var item in data[0].ItemArray)
                    {
                        worksapcesID.Add((int)item);
                    }


                    foreach (var item in worksapcesID)
                    {
                        proxy.APIOptions.WorkspaceID = item;
                        DTOs.Query <DTOs.RDO>          query   = new DTOs.Query <DTOs.RDO>();
                        DTOs.QueryResultSet <DTOs.RDO> results = new DTOs.QueryResultSet <DTOs.RDO>();
                        query.ArtifactTypeGuid = new Guid(comment.ARTIFACT_TYPE);
                        query.Fields           = DTOs.FieldValue.AllFields;
                        // query.Condition = new BooleanCondition(new Guid(guidSet), BooleanConditionEnum.EqualTo, false);

                        try
                        {
                            results = proxy.Repositories.RDO.Query(query);

                            foreach (var c in results.Results)

                            {
                                RaiseMessage($"verifying if the comment:  {c.Artifact.ArtifactID} already has the thumnails", 1);
                                DTOs.RDO commentDto = new DTOs.RDO(c.Artifact.ArtifactID);
                                commentDto.ArtifactTypeGuids.Add(new Guid(comment.ARTIFACT_TYPE));
                                commentDto.Fields = DTOs.FieldValue.AllFields;
                                commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet)));
                                commentDto = proxy.Repositories.RDO.ReadSingle(c.Artifact.ArtifactID);
                                //bool fieldValue = (bool)commentDto[new Guid(guidSet)].Value;
                                string image = (string)commentDto[new Guid(Image_guid_field)].Value;

                                if (!string.IsNullOrEmpty(image))
                                {
                                    RaiseMessage($"Creating Thumbnails for the comment {c.Artifact.ArtifactID}", 1);
                                    string thumbnail = getImage(c.Artifact.ArtifactID, this.Helper.GetDBContext(proxy.APIOptions.WorkspaceID));
                                    commentDto.Fields.Add(new DTOs.FieldValue(new Guid(thumbnailsImage), thumbnail));
                                    commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet), true));
                                    proxy.Repositories.RDO.UpdateSingle(commentDto);
                                }
                                else
                                {
                                    contador = contador + 1;
                                    commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet), false));
                                    proxy.Repositories.RDO.UpdateSingle(commentDto);
                                }
                            }
                        }


                        catch (Exception)
                        {
                            throw;
                        }
                    }
                }


                RaiseMessage($"There are {contador} comments without thumbnail", 1);
            }
            catch (System.Exception ex)
            {
                //Your Agent caught an exception
                this.RaiseError(ex.Message, ex.Message);
            }
        }