Interface IScriptService
Represents the script API service.
Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IScriptService
Examples
IScriptService _scriptService = RelativityFacade.Resolve<IScriptService>();
Methods
| Improve this Doc View SourceCreate(Int32, Script)
Creates the specified script.
Declaration
Script Create(int workspaceId, Script entity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The Artifact ID of the workspace where you want to add the new script. |
Script | entity | The entity to create. |
Returns
Type | Description |
---|---|
Script | The created entity. |
Examples
int workspaceID = 1234567;
const string action = "<action returns=\"table\"><![CDATA[ SELECT TOP(10) * FROM[eddsdbo].[Artifact]]]></action>";
var script = new Script
{
Name = "My script Name",
Description = "About my script",
Category = "My category",
ScriptBody = $"<script>{action}</script>"
};
Script result = _scriptService.Create(workspaceID, script);
|
Improve this Doc
View Source
Delete(Int32, Int32)
Deletes the script by ID.
Declaration
void Delete(int workspaceId, int entityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The Artifact ID of the workspace where you want to delete the script. |
System.Int32 | entityId | The artifact ID of the script. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
_scriptService.Delete(workspaceID, scriptID);
|
Improve this Doc
View Source
EnqueueRunJob(Int32, Int32, List<ScriptInput>, Double)
Enqueues a script run job.
Declaration
EnqueueRunJobResponse EnqueueRunJob(int workspaceId, int scriptId, List<ScriptInput> inputs = null, double timeZoneOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists and should be executed. |
System.Int32 | scriptId | The ArtifactID of the script to execute. |
System.Collections.Generic.List<ScriptInput> | inputs | Inputs and their values for the script, empty by default. |
System.Double | timeZoneOffset | The time zone offset for the script, zero by default. |
Returns
Type | Description |
---|---|
EnqueueRunJobResponse | An EnqueueRunJobResponse describing the queued job. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
var scriptInputs = new List<ScriptInput>();
scriptInputs.Add(new ScriptInput()
{
ID = "workspaceArtifactId",
Value = workspaceID
});
EnqueueRunJobResponse response = _scriptService.EnqueueRunJob(workspaceID, scriptID, scriptInputs);
|
Improve this Doc
View Source
EnsureEnvironmentCanRunScripts()
Creates and/or enables a ScriptRunManager Agent to make sure that the environment can run scripts.
Declaration
void EnsureEnvironmentCanRunScripts()
Examples
_scriptService.EnsureEnvironmentCanRunScripts();
|
Improve this Doc
View Source
Get(Int32, Int32)
Gets the script by the specified ID.
Declaration
Script Get(int workspaceId, int entityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The Artifact ID of the workspace where you want to get script. |
System.Int32 | entityId | The artifact ID of the script. |
Returns
Type | Description |
---|---|
Script | The Script entity or null. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
Script script = _scriptService.Get(workspaceID, scriptID);
|
Improve this Doc
View Source
Preview(Int32, Int32, List<ScriptInput>, Double)
Gives a preview of what the exact SQL the script will run given a set of parameters.
Declaration
string Preview(int workspaceId, int scriptId, List<ScriptInput> inputs = null, double timeZoneOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists. |
System.Int32 | scriptId | The ArtifactID of the script to preview. |
System.Collections.Generic.List<ScriptInput> | inputs | Inputs and their values for the script. |
System.Double | timeZoneOffset | The time zone offset for the script in hours. |
Returns
Type | Description |
---|---|
System.String | SQL statement with the parameters inserted into it. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
var scriptInputs = new List<ScriptInput>();
scriptInputs.Add(new ScriptInput()
{
ID = "workspaceArtifactId",
Value = workspaceID
});
string sqlStatment = _scriptService.Preview(workspaceID, scriptID, scriptInputs);
|
Improve this Doc
View Source
QueryActionJobResults(Int32, Guid, Int32, ActionQueryRequest, Int32, Int32)
Queries the results of a completed action job.
Declaration
ActionResultsQueryResponse QueryActionJobResults(int workspaceId, Guid runJobId, int actionIndex, ActionQueryRequest actionQueryRequest = null, int start = 0, int length = 100)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists and was executed. |
System.Guid | runJobId | The ID of the script run job. |
System.Int32 | actionIndex | The index of the action. This is the numeric index of the action in the script starting at 0. |
ActionQueryRequest | actionQueryRequest | The query to execute. By default takes all fields without condition. |
System.Int32 | start | The result cursor. Default value is zero. |
System.Int32 | length | The maximum length of results to return. Default value is 100. |
Returns
Type | Description |
---|---|
ActionResultsQueryResponse | The action query's result in the form of an ActionResultsQueryResponse. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
var actionQueryRequest = new ActionQueryRequest();
EnqueueRunJobResponse enqueueRunJobResponse = _scriptService.EnqueueRunJob(workspaceID, scriptID);
RunJob runJobResponse = _scriptService.ReadRunJob(workspaceID, enqueueRunJobResponse.RunJobID);
var getAction = enqueueRunJobResponse.Actions.Find(x => x.Verb == "GET");
var actionIndex = enqueueRunJobResponse.Actions.IndexOf(getAction);
var queryRequest = new ActionQueryRequest()
{
Condition = "'IsAlive' == false",
ColumnNames = new List<string>() { "*" },
Sorts = new List<ActionColumnSort>(),
}
ActionResultsQueryResponse queryResponce = _scriptService.QueryActionJobResults(workspaceID, enqueueRunJobResponse.RunJobID, actionIndex, queryRequest);
|
Improve this Doc
View Source
ReadRunJob(Int32, Guid)
Retrieves a script run job.
Declaration
RunJob ReadRunJob(int workspaceId, Guid runJobId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists and was executed. |
System.Guid | runJobId | The ID of the script run job. |
Returns
Type | Description |
---|---|
RunJob | A RunJob describing the script run job. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
EnqueueRunJobResponse enqueueRunJobResponse = _scriptService.EnqueueRunJob(workspaceID, scriptID);
RunJob runJobResponse = _scriptService.ReadRunJob(workspaceID, enqueueRunJobResponse.RunJobID);
|
Improve this Doc
View Source
RunStatusAction(Int32, Int32, List<ScriptInput>)
Executes a script with status action and parameters.
Declaration
int RunStatusAction(int workspaceId, int scriptId, List<ScriptInput> inputs = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists and should be executed. |
System.Int32 | scriptId | The ArtifactID of the script to execute. |
System.Collections.Generic.List<ScriptInput> | inputs | Inputs and their values for the script. |
Returns
Type | Description |
---|---|
System.Int32 | The count of affected rows. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
var scriptInputs = new List<ScriptInput>();
scriptInputs.Add(new ScriptInput()
{
ID = "workspaceArtifactId",
Value = workspaceID
});
int result = _scriptService.RunStatusAction(workspaceID, scriptID, scriptInputs);
|
Improve this Doc
View Source
RunTableAction(Int32, Int32, List<ScriptInput>, ActionQueryRequest)
Executes a script with table action and parameters.
Declaration
DataTable RunTableAction(int workspaceId, int scriptId, List<ScriptInput> inputs = null, ActionQueryRequest actionQueryRequest = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where the script exists and should be executed. |
System.Int32 | scriptId | The ArtifactID of the script to execute. |
System.Collections.Generic.List<ScriptInput> | inputs | Inputs and their values for the script. |
ActionQueryRequest | actionQueryRequest | The query to execute. By default takes all fields without condition. |
Returns
Type | Description |
---|---|
System.Data.DataTable | The table of results. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
var scriptInputs = new List<ScriptInput>();
scriptInputs.Add(new ScriptInput()
{
ID = "workspaceArtifactId",
Value = workspaceID
});
var queryRequest = new ActionQueryRequest()
{
Condition = "'IsAlive' == false",
ColumnNames = new List<string>() { "*" },
Sorts = new List<ActionColumnSort>(),
}
DataTable result = _scriptService.RunTableAction(workspaceID, scriptID, scriptInputs, queryRequest);
|
Improve this Doc
View Source
Update(Int32, Script)
Updates the specified script.
Declaration
void Update(int workspaceId, Script entity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The Artifact ID of the workspace where you want to update script. |
Script | entity | The entity to update. |
Examples
int workspaceID = 1234567;
int scriptID = 1987156;
Script existingScript = _scriptService.Get(workspaceID, scriptID);
existingScript.Name = "New Name";
existingScript.Description = "New Description";
_scriptService.Update(workspaceID, existingScript);