Beispiel #1
0
        public static Int32 GetScriptArtifactId(String scriptName, Int32 workspaceID, IRSAPIClient _client)
        {
            int ScriptArtifactId = 0;
            var query            = new Query
            {
                ArtifactTypeID = (Int32)ArtifactType.RelativityScript,
                Condition      = new TextCondition("Name", TextConditionEnum.Like, scriptName)
            };
            QueryResult result = null;

            try
            {
                result = _client.Query(_client.APIOptions, query);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: {0}", ex.Message);
            }

            if (result != null)
            {
                ScriptArtifactId = result.QueryArtifacts[0].ArtifactID;
            }

            return(ScriptArtifactId);
        }
        public static Int32 Query_For_Saved_SearchID(string savedSearchName, IRSAPIClient _client)
        {
            int searchArtifactId = 0;

            var query = new Query
            {
                ArtifactTypeID = (Int32)ArtifactType.Search,
                Condition      = new TextCondition("Name", TextConditionEnum.Like, savedSearchName)
            };
            QueryResult result = null;

            try
            {
                result = _client.Query(_client.APIOptions, query);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: {0}", ex.Message);
            }

            if (result != null)
            {
                searchArtifactId = result.QueryArtifacts[0].ArtifactID;
            }

            return(searchArtifactId);
        }
Beispiel #3
0
        internal static int ReadSavedSearchId(IRSAPIClient rsapiClient, int workspaceId, string savedSearch)
        {
            // Query the saved search artifact id from the saved search name
            var ssQuery = new Query
            {
                ArtifactTypeID = (int)ArtifactType.Search,
                Condition      = new TextCondition("Name", TextConditionEnum.Like, savedSearch)
            };

            var savedSearchResult = rsapiClient.Query(rsapiClient.APIOptions, ssQuery);

            savedSearchResult.ThrowIfUnsuccessful($"Failed to read saved search `{savedSearch}` in workspace {workspaceId}");

            return(savedSearchResult.QueryArtifacts[0].ArtifactID);
        }
        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}.");
            }
        }
Beispiel #5
0
        public static int GetScriptArtifactId(string scriptName, IRSAPIClient _client)
        {
            int ScriptArtifactId = 0;
            try
            {
                Query newQuery = new Query();
                TextCondition queryCondition = new TextCondition(RelativityScriptFieldNames.Name, TextConditionEnum.Like, scriptName);
                newQuery.Condition = queryCondition;
                newQuery.ArtifactTypeID = 28;
                _client.APIOptions.StrictMode = false;
                var results = _client.Query(_client.APIOptions, newQuery);
                ScriptArtifactId = results.QueryArtifacts[0].ArtifactID;
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: {0}", ex.Message);
            }

            return ScriptArtifactId;
        }