Skip to content

Commit 5cc4b77

Browse files
committed
Updated Commands to handle Await Execution
1 parent 59e393b commit 5cc4b77

File tree

4 files changed

+73
-16
lines changed

4 files changed

+73
-16
lines changed

taskt/Core/Automation/Commands/RemoteAPICommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public override void RunCommand(object sender)
6262
var server = v_BaseURL.ConvertToUserVariable(sender);
6363
var paramType = v_ParameterType.ConvertToUserVariable(sender);
6464

65-
var response = Server.LocalTCPListener.SendAutomationTask(server, paramType, "");
65+
var response = Server.LocalTCPListener.SendAutomationTask(server, paramType);
6666

6767
response.StoreInUserVariable(sender, v_userVariableName);
6868

taskt/Core/Automation/Commands/RemoteTaskCommand.cs

+13-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public class RemoteTaskCommand : ScriptCommand
3939
[Attributes.PropertyAttributes.Remarks("")]
4040
public string v_ParameterType { get; set; }
4141

42+
[XmlAttribute]
43+
[Attributes.PropertyAttributes.PropertyDescription("Wait for Script to Finish?")]
44+
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
45+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Continue Execution")]
46+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Await For Result")]
47+
[Attributes.PropertyAttributes.InputSpecification("Select the necessary method type.")]
48+
[Attributes.PropertyAttributes.Remarks("")]
49+
public string v_ExecuteAwait { get; set; }
50+
4251
[XmlAttribute]
4352
[Attributes.PropertyAttributes.PropertyDescription("Script Parameter Data")]
4453
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
@@ -61,6 +70,7 @@ public RemoteTaskCommand()
6170
this.SelectionName = "Remote Task";
6271
this.CommandEnabled = true;
6372
this.CustomRendering = true;
73+
this.v_ExecuteAwait = "Continue Execution";
6474
}
6575

6676
public override void RunCommand(object sender)
@@ -71,8 +81,9 @@ public override void RunCommand(object sender)
7181
var server = v_BaseURL.ConvertToUserVariable(sender);
7282
var paramType = v_ParameterType.ConvertToUserVariable(sender);
7383
var parameter = v_Parameter.ConvertToUserVariable(sender);
84+
var awaitPreference = v_ExecuteAwait.ConvertToUserVariable(sender);
7485

75-
var response = Server.LocalTCPListener.SendAutomationTask(server, paramType, parameter);
86+
var response = Server.LocalTCPListener.SendAutomationTask(server, paramType, parameter, awaitPreference);
7687

7788
response.StoreInUserVariable(sender, v_userVariableName);
7889

@@ -89,7 +100,7 @@ public override List<Control> Render(frmCommandEditor editor)
89100
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_BaseURL", this, editor));
90101
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_ParameterType", this, editor));
91102
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_Parameter", this, editor));
92-
103+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_ExecuteAwait", this, editor));
93104

94105
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this));
95106
var VariableNameControl = CommandControls.CreateStandardComboboxFor("v_userVariableName", this).AddVariableNames(editor);

taskt/Core/Server/LocalTCPListener.cs

+44-7
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static void StopAutomationListener()
374374
{
375375
automationListener.Stop();
376376
}
377-
public static string SendAutomationTask(string endpoint, string parameterType, string scriptData)
377+
public static string SendAutomationTask(string endpoint, string parameterType, string scriptData = "", string awaitPreference = "")
378378
{
379379

380380
if (!endpoint.StartsWith("http://"))
@@ -395,17 +395,33 @@ public static string SendAutomationTask(string endpoint, string parameterType, s
395395
//check type of execution needed
396396
if (parameterType == "Run Raw Script Data")
397397
{
398-
request.Resource = "/ExecuteScript";
398+
399399

400-
//remove any return lines
401-
// scriptData = scriptData.Replace("\r\n", "");
400+
//handle await preference
401+
if (awaitPreference == "Await For Result")
402+
{
403+
request.Resource = "/AwaitScript";
404+
}
405+
else
406+
{
407+
request.Resource = "/ExecuteScript";
408+
}
402409

403410
//add script data
404411
request.AddParameter("ScriptData", scriptData.ToBase64(), RestSharp.ParameterType.HttpHeader);
405412
}
406413
else if (parameterType == "Run Local File")
407414
{
408-
request.Resource = "/ExecuteScript";
415+
416+
//handle await preference
417+
if (awaitPreference == "Await For Result")
418+
{
419+
request.Resource = "/AwaitScript";
420+
}
421+
else
422+
{
423+
request.Resource = "/ExecuteScript";
424+
}
409425

410426
if (File.Exists(scriptData))
411427
{
@@ -432,7 +448,16 @@ public static string SendAutomationTask(string endpoint, string parameterType, s
432448
}
433449
else if (parameterType == "Run Remote File")
434450
{
435-
request.Resource = "/ExecuteScript";
451+
452+
//handle await preference
453+
if (awaitPreference == "Await For Result")
454+
{
455+
request.Resource = "/AwaitScript";
456+
}
457+
else
458+
{
459+
request.Resource = "/ExecuteScript";
460+
}
436461

437462
//add script parameter
438463
request.AddParameter("ScriptLocation", scriptData, RestSharp.ParameterType.HttpHeader);
@@ -446,7 +471,19 @@ public static string SendAutomationTask(string endpoint, string parameterType, s
446471
request.Resource = "/RestartTaskt";
447472
}
448473

449-
request.Timeout = 5000;
474+
475+
476+
477+
if (awaitPreference == "Await For Result")
478+
{
479+
request.Timeout = 120000;
480+
}
481+
else
482+
{
483+
request.Timeout = 5000;
484+
}
485+
486+
450487

451488
RestSharp.IRestResponse resp = client.Execute(request);
452489

taskt/Sample Scripts/3.x Use Case Samples/Remote Execution Sample [3.3.0.0].xml

+15-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ScriptCommand xsi:type="CommentCommand" CommandID="ef8115ef-11aa-4b0f-9500-6c4445a9ca5b" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="6" PauseBeforeExeucution="false" v_Comment="Scenario 2) Run a task remotely using raw taskt XML data" CommandEnabled="true" />
2121
</ScriptAction>
2222
<ScriptAction>
23-
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="1d15c255-a87b-4223-ba88-806ce53aca18" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="7" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Raw Script Data" v_Parameter="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&#xD;&#xA;&lt;Script xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;Commands&gt;&#xD;&#xA; &lt;ScriptAction&gt;&#xD;&#xA; &lt;ScriptCommand xsi:type=&quot;MessageBoxCommand&quot; CommandID=&quot;47aaa426-52ed-4b3f-ab93-9fceeff696a0&quot; CommandName=&quot;MessageBoxCommand&quot; IsCommented=&quot;false&quot; SelectionName=&quot;Show Message&quot; DefaultPause=&quot;0&quot; LineNumber=&quot;1&quot; PauseBeforeExeucution=&quot;false&quot; CommandEnabled=&quot;true&quot; v_ExecutionLocation=&quot;rem&quot; v_Message=&quot;Hello World!&quot; v_AutoCloseAfter=&quot;0&quot; /&gt;&#xD;&#xA; &lt;/ScriptAction&gt;&#xD;&#xA; &lt;/Commands&gt;&#xD;&#xA; &lt;Variables&gt;&#xD;&#xA; &lt;ScriptVariable&gt;&#xD;&#xA; &lt;VariableName&gt;vResult&lt;/VariableName&gt;&#xD;&#xA; &lt;VariableValue xsi:type=&quot;xsd:string&quot;&gt;&lt;/VariableValue&gt;&#xD;&#xA; &lt;/ScriptVariable&gt;&#xD;&#xA; &lt;/Variables&gt;&#xD;&#xA;&lt;/Script&gt;" v_userVariableName="vRes" />
23+
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="1d15c255-a87b-4223-ba88-806ce53aca18" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="7" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Raw Script Data" v_ExecuteAwait="Continue Execution" v_Parameter="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&#xD;&#xA;&lt;Script xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;Commands&gt;&#xD;&#xA; &lt;ScriptAction&gt;&#xD;&#xA; &lt;ScriptCommand xsi:type=&quot;MessageBoxCommand&quot; CommandID=&quot;47aaa426-52ed-4b3f-ab93-9fceeff696a0&quot; CommandName=&quot;MessageBoxCommand&quot; IsCommented=&quot;false&quot; SelectionName=&quot;Show Message&quot; DefaultPause=&quot;0&quot; LineNumber=&quot;1&quot; PauseBeforeExeucution=&quot;false&quot; CommandEnabled=&quot;true&quot; v_ExecutionLocation=&quot;rem&quot; v_Message=&quot;Hello World!&quot; v_AutoCloseAfter=&quot;0&quot; /&gt;&#xD;&#xA; &lt;/ScriptAction&gt;&#xD;&#xA; &lt;/Commands&gt;&#xD;&#xA; &lt;Variables&gt;&#xD;&#xA; &lt;ScriptVariable&gt;&#xD;&#xA; &lt;VariableName&gt;vResult&lt;/VariableName&gt;&#xD;&#xA; &lt;VariableValue xsi:type=&quot;xsd:string&quot;&gt;&lt;/VariableValue&gt;&#xD;&#xA; &lt;/ScriptVariable&gt;&#xD;&#xA; &lt;/Variables&gt;&#xD;&#xA;&lt;/Script&gt;" v_userVariableName="vRes" />
2424
</ScriptAction>
2525
<ScriptAction>
2626
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="5bdf2afb-ea4c-4f11-9ace-6ac12386911f" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="8" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
@@ -29,7 +29,7 @@
2929
<ScriptCommand xsi:type="CommentCommand" CommandID="20659457-2c28-4eed-88f0-f573b228e64f" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="9" PauseBeforeExeucution="false" v_Comment="Scenario 3) Run a local task (on current PC) remotely" CommandEnabled="true" />
3030
</ScriptAction>
3131
<ScriptAction>
32-
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="92fd5748-9862-40d9-aab9-a6a01bc1de22" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="10" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Local File" v_Parameter="Hello World 123.xml" v_userVariableName="vRes" />
32+
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="92fd5748-9862-40d9-aab9-a6a01bc1de22" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="10" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Local File" v_ExecuteAwait="Continue Execution" v_Parameter="Hello World 123.xml" v_userVariableName="vRes" />
3333
</ScriptAction>
3434
<ScriptAction>
3535
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="be0ce9cb-f2cc-4b33-be9b-d94a67bfd8a2" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="11" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
@@ -38,19 +38,28 @@
3838
<ScriptCommand xsi:type="CommentCommand" CommandID="feac7065-a071-43a3-a162-f07d1e202272" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="12" PauseBeforeExeucution="false" v_Comment="Scenario 4) Run a remote task" CommandEnabled="true" />
3939
</ScriptAction>
4040
<ScriptAction>
41-
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="da794a25-e73c-4421-9106-b0abaa49bb92" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="13" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Remote File" v_Parameter="Hi.xml" v_userVariableName="vRes" />
41+
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="da794a25-e73c-4421-9106-b0abaa49bb92" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="13" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Remote File" v_ExecuteAwait="Continue Execution" v_Parameter="Hi.xml" v_userVariableName="vRes" />
4242
</ScriptAction>
4343
<ScriptAction>
4444
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="f55a3ef3-4611-4649-bba8-0b8a1f992d3d" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="14" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
4545
</ScriptAction>
4646
<ScriptAction>
47-
<ScriptCommand xsi:type="CommentCommand" CommandID="e1551e0e-46ae-4fa7-9665-e87371a57c6f" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="15" PauseBeforeExeucution="false" v_Comment="Scenario 4) Remotely Restart taskt" CommandEnabled="true" />
47+
<ScriptCommand xsi:type="CommentCommand" CommandID="af6fbe61-2378-434f-bbcd-57d7875d2670" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="15" PauseBeforeExeucution="false" v_Comment="Scenario 5) Run Task and Await Result" CommandEnabled="true" />
4848
</ScriptAction>
4949
<ScriptAction>
50-
<ScriptCommand xsi:type="RemoteAPICommand" CommandID="204414e2-ba0d-4d4f-b92d-2521098a8417" CommandName="RemoteAPICommand" IsCommented="false" SelectionName="Remote API" DefaultPause="0" LineNumber="16" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Restart taskt" v_userVariableName="vRes" />
50+
<ScriptCommand xsi:type="RemoteTaskCommand" CommandID="1ec32408-6e79-43a2-a604-bba91c879833" CommandName="RunTaskRemoteCommand" IsCommented="false" SelectionName="Remote Task" DefaultPause="0" LineNumber="16" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Run Local File" v_ExecuteAwait="Await For Result" v_Parameter="Await.xml" v_userVariableName="vRes" />
5151
</ScriptAction>
5252
<ScriptAction>
53-
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="7eba73a0-42e8-404a-bcba-a81fdffb7007" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="17" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
53+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="191a6bd3-5f40-405b-8706-8aa2d38599ef" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="17" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
54+
</ScriptAction>
55+
<ScriptAction>
56+
<ScriptCommand xsi:type="CommentCommand" CommandID="e1551e0e-46ae-4fa7-9665-e87371a57c6f" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="18" PauseBeforeExeucution="false" v_Comment="Scenario 6) Remotely Restart taskt" CommandEnabled="true" />
57+
</ScriptAction>
58+
<ScriptAction>
59+
<ScriptCommand xsi:type="RemoteAPICommand" CommandID="204414e2-ba0d-4d4f-b92d-2521098a8417" CommandName="RemoteAPICommand" IsCommented="false" SelectionName="Remote API" DefaultPause="0" LineNumber="19" PauseBeforeExeucution="false" CommandEnabled="true" v_BaseURL="192.168.86.200:19312" v_ParameterType="Restart taskt" v_userVariableName="vRes" />
60+
</ScriptAction>
61+
<ScriptAction>
62+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="7eba73a0-42e8-404a-bcba-a81fdffb7007" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="20" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="vRes" v_AutoCloseAfter="0" />
5463
</ScriptAction>
5564
</Commands>
5665
<Variables>

0 commit comments

Comments
 (0)