Exemplo n.º 1
0
        public RelativityScriptResult ExecuteScript_Update_Duplicate_status(String scriptName, Int32 workspaceArtifactId, String savedSearchName, Guid duplicateStatusFieldGuid,
                                                                            String relationalFieldColumnName, String sortOrderFieldColumnName)
        {
            //Retrieve script by name
            Query <RelativityScript> relScriptQuery = new Query <RelativityScript>
            {
                Condition = new TextCondition(RelativityScriptFieldNames.Name, TextConditionEnum.EqualTo, scriptName),
                Fields    = FieldValue.AllFields
            };

            QueryResultSet <RelativityScript> relScriptQueryResults = _client.Repositories.RelativityScript.Query(relScriptQuery);

            if (!relScriptQueryResults.Success)
            {
                throw new Exception(String.Format("An error occurred finding the script: {0}", relScriptQueryResults.Message));
            }

            if (!relScriptQueryResults.Results.Any())
            {
                throw new Exception(String.Format("No results returned: {0}", relScriptQueryResults.Message));
            }

            //Retrieve script inputs
            var   script                         = relScriptQueryResults.Results[0].Artifact;
            var   inputnames                     = Execute.GetRelativityScriptInput(_client, scriptName, workspaceArtifactId, dbContext);
            int   savedsearchartifactid          = APIHelpers.Query_For_Saved_SearchID(savedSearchName, _client);
            Int32 duplicateStatusFieldCodeTypeId = GetFieldCodeTypeId(_client, workspaceArtifactId);

            //Set inputs for script
            RelativityScriptInput input  = new RelativityScriptInput(inputnames[0], savedsearchartifactid.ToString());
            RelativityScriptInput input2 = new RelativityScriptInput(inputnames[1], duplicateStatusFieldCodeTypeId.ToString());
            RelativityScriptInput input3 = new RelativityScriptInput(inputnames[2], relationalFieldColumnName);
            RelativityScriptInput input4 = new RelativityScriptInput(inputnames[3], sortOrderFieldColumnName);

            //Execute the script
            List <RelativityScriptInput> inputList = new List <RelativityScriptInput> {
                input, input2, input3, input4
            };
            RelativityScriptResult scriptResult = _client.Repositories.RelativityScript.ExecuteRelativityScript(script, inputList);

            return(scriptResult);
        }