Skip to content

Commit dba1f20

Browse files
authored
Merge pull request #157 from saucepleez/development-branch
taskt 3.2.2.0 PR
2 parents 9dc351b + 56547c3 commit dba1f20

14 files changed

+146
-33
lines changed

taskt/Core/Automation/Commands/HTTPRequestCommand.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ public class HTTPRequestCommand : ScriptCommand
2323
[Attributes.PropertyAttributes.Remarks("")]
2424
public string v_WebRequestURL { get; set; }
2525

26+
[XmlAttribute]
27+
[Attributes.PropertyAttributes.PropertyDescription("Execute Request as the currently logged on user?")]
28+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Yes")]
29+
[Attributes.PropertyAttributes.PropertyUISelectionOption("No")]
30+
[Attributes.PropertyAttributes.InputSpecification("Sets currently logged on user authentication information for the request.")]
31+
[Attributes.PropertyAttributes.SampleUsage("Select 'Yes' or 'No'")]
32+
[Attributes.PropertyAttributes.Remarks("")]
33+
public string v_WebRequestCredentials { get; set; }
34+
2635
[XmlAttribute]
2736
[Attributes.PropertyAttributes.PropertyDescription("Apply Result To Variable")]
2837
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")]
@@ -46,7 +55,12 @@ public override void RunCommand(object sender)
4655
{
4756
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(v_WebRequestURL.ConvertToUserVariable(sender));
4857
request.Method = "GET";
49-
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
58+
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
59+
if (v_WebRequestCredentials == "Yes")
60+
{
61+
request.Credentials = CredentialCache.DefaultCredentials;
62+
}
63+
5064
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
5165

5266
Stream dataStream = response.GetResponseStream();
@@ -63,7 +77,7 @@ public override List<Control> Render(frmCommandEditor editor)
6377

6478
//create inputs for request url
6579
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_WebRequestURL", this, editor));
66-
80+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_WebRequestCredentials", this, editor));
6781

6882
//create window name helper control
6983
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this));

taskt/Core/Automation/Commands/RunTaskCommand.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public override void RunCommand(object sender)
7676
var variableList = new List<Script.ScriptVariable>();
7777
foreach (DataRow rw in v_VariableAssignments.Rows)
7878
{
79-
var variableName = ((string)rw.ItemArray[0]).ConvertToUserVariable(sender);
79+
var variableName = (string)rw.ItemArray[0];
8080
var variableValue = ((string)rw.ItemArray[1]).ConvertToUserVariable(sender);
8181
variableList.Add(new Script.ScriptVariable
8282
{
@@ -85,8 +85,12 @@ public override void RunCommand(object sender)
8585
});
8686
}
8787

88-
Application.Run(new UI.Forms.frmScriptEngine(startFile, null, variableList));
89-
88+
UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(startFile, null, variableList, true);
89+
Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance) sender;
90+
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = false; });
91+
Application.Run(newEngine);
92+
//currentScriptEngine.tasktEngineUI.TopMost = false;
93+
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = true; });
9094
}
9195

9296
public override List<Control> Render(frmCommandEditor editor)

taskt/Core/Automation/Commands/ScriptCommand.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,14 @@ public virtual void RunCommand(object sender, Core.Script.ScriptAction command)
187187

188188
public virtual string GetDisplayValue()
189189
{
190-
return SelectionName;
190+
if (String.IsNullOrEmpty(v_Comment))
191+
{
192+
return SelectionName;
193+
}
194+
else
195+
{
196+
return SelectionName + " [" + v_Comment + "]";
197+
}
191198
}
192199

193200
public virtual List<Control> Render(UI.Forms.frmCommandEditor editor)

taskt/Core/Automation/Commands/SeleniumBrowserCreateCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class SeleniumBrowserCreateCommand : ScriptCommand
4343
[XmlAttribute]
4444
[Attributes.PropertyAttributes.PropertyDescription("Please specify Selenium command line options (optional)")]
4545
[Attributes.PropertyAttributes.InputSpecification("Select optional options to be passed to the Selenium command.")]
46-
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=/user/public/SeleniumTasktProfile")]
46+
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=c:\\users\\public\\SeleniumTasktProfile")]
4747
[Attributes.PropertyAttributes.Remarks("")]
4848
public string v_SeleniumOptions { get; set; }
4949

taskt/Core/Automation/Commands/SeleniumBrowserElementActionCommand.cs

+22-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class SeleniumBrowserElementActionCommand : ScriptCommand
6464
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Attribute")]
6565
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Matching Elements")]
6666
[Attributes.PropertyAttributes.PropertyUISelectionOption("Wait For Element To Exist")]
67+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Switch to frame")]
6768
[Attributes.PropertyAttributes.InputSpecification("Select the appropriate corresponding action to take once the element has been located")]
6869
[Attributes.PropertyAttributes.SampleUsage("Select from **Invoke Click**, **Left Click**, **Right Click**, **Middle Click**, **Double Left Click**, **Clear Element**, **Set Text**, **Get Text**, **Get Attribute**, **Wait For Element To Exist**")]
6970
[Attributes.PropertyAttributes.Remarks("Selecting this field changes the parameters that will be required in the next step")]
@@ -171,9 +172,8 @@ where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"
171172

172173
return;
173174
}
174-
else
175+
else if (seleniumSearchParam != string.Empty)
175176
{
176-
177177
element = FindElement(seleniumInstance, seleniumSearchParam);
178178
}
179179

@@ -319,7 +319,19 @@ where rw.Field<string>("Parameter Name") == "Variable Name"
319319
break;
320320
case "Clear Element":
321321
element.Clear();
322+
break;
323+
324+
case "Switch to frame":
325+
if (seleniumSearchParam == "")
326+
{
327+
seleniumInstance.SwitchTo().DefaultContent();
328+
}
329+
else
330+
{
331+
seleniumInstance.SwitchTo().Frame(element);
332+
}
322333
break;
334+
323335
default:
324336
throw new Exception("Element Action was not found");
325337
}
@@ -546,7 +558,15 @@ public void seleniumAction_SelectionChangeCommitted(object sender, EventArgs e)
546558
{
547559
actionParameters.Rows.Add("Timeout (Seconds)");
548560
}
561+
break;
562+
563+
case "Switch to frame":
564+
foreach (var ctrl in ElementParameterControls)
565+
{
566+
ctrl.Hide();
567+
}
549568
break;
569+
550570
default:
551571
break;
552572
}

taskt/Core/Automation/Commands/StartProcessCommand.cs

+19-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ public class StartProcessCommand : ScriptCommand
3131
[Attributes.PropertyAttributes.SampleUsage(" **-a** or **-version**")]
3232
[Attributes.PropertyAttributes.Remarks("You will need to consult documentation to determine if your executable supports arguments or flags on startup.")]
3333
public string v_ProgramArgs { get; set; }
34+
[XmlAttribute]
35+
[Attributes.PropertyAttributes.PropertyDescription("Wait for the process to complete?")]
36+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Yes")]
37+
[Attributes.PropertyAttributes.PropertyUISelectionOption("No")]
38+
[Attributes.PropertyAttributes.InputSpecification("Wait For Exit.")]
39+
[Attributes.PropertyAttributes.SampleUsage("Select 'Yes' or 'No'")]
40+
[Attributes.PropertyAttributes.Remarks("")]
41+
public string v_WaitForExit { get; set; }
3442

3543
public StartProcessCommand()
3644
{
@@ -45,27 +53,34 @@ public override void RunCommand(object sender)
4553

4654
string vProgramName = v_ProgramName.ConvertToUserVariable(sender);
4755
string vProgramArgs = v_ProgramArgs.ConvertToUserVariable(sender);
56+
System.Diagnostics.Process p;
4857

4958
if (v_ProgramArgs == "")
5059
{
51-
System.Diagnostics.Process.Start(vProgramName);
60+
p = System.Diagnostics.Process.Start(vProgramName);
5261
}
5362
else
5463
{
55-
System.Diagnostics.Process.Start(vProgramName, vProgramArgs);
64+
p = System.Diagnostics.Process.Start(vProgramName, vProgramArgs);
65+
}
66+
67+
if (v_WaitForExit == "Yes")
68+
{
69+
p.WaitForExit();
5670
}
5771

5872
System.Threading.Thread.Sleep(2000);
5973
}
74+
6075
public override List<Control> Render(frmCommandEditor editor)
6176
{
6277
base.Render(editor);
6378

6479
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_ProgramName", this, editor));
6580

6681
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_ProgramArgs", this, editor));
67-
68-
82+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_WaitForExit", this, editor));
83+
6984
return RenderedControls;
7085
}
7186
public override string GetDisplayValue()

taskt/Core/Automation/Commands/UserInputCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public override void RunCommand(object sender)
9292
//translate variables for each label
9393
foreach (DataRow rw in clonedCommand.v_UserInputConfig.Rows)
9494
{
95-
rw["Label"] = rw["Label"].ToString().ConvertToUserVariable(sender);
95+
rw["DefaultValue"] = rw["DefaultValue"].ToString().ConvertToUserVariable(sender);
9696

9797
var targetVariable = rw["ApplyToVariable"] as string;
9898

taskt/Core/Theme.cs

+19-11
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@
99
namespace taskt.Core
1010
{
1111
public class Theme
12-
{
13-
public LinearGradientBrush CreateGradient(Rectangle rect)
14-
{
15-
var tasktBlue = Color.FromArgb(20, 136, 204);
16-
var tasktPurple = Color.FromArgb(43, 50, 178);
17-
LinearGradientBrush linearGradientBrush =
18-
new LinearGradientBrush(rect, tasktPurple, tasktBlue, 180);
19-
return linearGradientBrush;
20-
21-
//e.Graphics.FillRectangle(linearGradientBrush, pnlMain.ClientRectangle);
22-
12+
{
13+
14+
Color _BgGradientStartColor = Color.FromArgb(20, 136, 204);
15+
public Color BgGradientStartColor
16+
{
17+
get { return _BgGradientStartColor; }
18+
set { _BgGradientStartColor = value; }
2319
}
2420

21+
Color _BgGradientEndColor = Color.FromArgb(43, 50, 178);
22+
public Color BgGradientEndColor
23+
{
24+
get { return _BgGradientEndColor; }
25+
set { _BgGradientEndColor = value; }
26+
}
27+
28+
public LinearGradientBrush CreateGradient(Rectangle rect)
29+
{
30+
return new LinearGradientBrush(rect, _BgGradientStartColor, _BgGradientEndColor, 180);
31+
}
32+
2533
}
2634
}

taskt/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
// You can specify all the values or you can default the Build and Revision Numbers
4646
// by using the '*' as shown below:
4747
[assembly: AssemblyVersion("0.0.*")]
48-
[assembly: AssemblyFileVersion("3.2.1.0")]
48+
[assembly: AssemblyFileVersion("3.2.2.0")]
4949
//[assembly: AssemblyVersion("0.0.0.2")]
5050
//[assembly: AssemblyFileVersion("0.0.0.2")]

taskt/UI/CustomControls/CustomControls.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,18 @@ public class UITabControl : TabControl
107107

108108
public partial class UIPanel : Panel
109109
{
110+
private taskt.Core.Theme _Theme = new taskt.Core.Theme();
111+
public taskt.Core.Theme Theme
112+
{
113+
get { return _Theme; }
114+
set { _Theme = value; }
115+
}
116+
110117
protected override void OnPaint(PaintEventArgs e)
111118
{
112119

113120

114-
var brush = new Core.Theme().CreateGradient(this.ClientRectangle);
121+
var brush = this.Theme.CreateGradient(this.ClientRectangle);
115122
e.Graphics.FillRectangle(brush, this.ClientRectangle);
116123

117124

taskt/UI/Forms/ThemedForm.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.ComponentModel;
44
using System.Data;
55
using System.Drawing;
6+
using System.Drawing.Drawing2D;
67
using System.Linq;
78
using System.Text;
89
using System.Threading.Tasks;
@@ -21,9 +22,26 @@ private void ThemedForm_Load(object sender, EventArgs e)
2122
{
2223

2324
}
25+
26+
protected override void OnShown(EventArgs e)
27+
{
28+
base.OnShown(e);
29+
if (this.ClientSize.Height > Screen.PrimaryScreen.WorkingArea.Height - this.CurrentAutoScaleDimensions.Height) // Resizes if too tall to fit
30+
{
31+
this.ClientSize = new Size(this.ClientSize.Width, Screen.PrimaryScreen.WorkingArea.Height - (int)this.CurrentAutoScaleDimensions.Height);
32+
}
33+
}
34+
35+
private taskt.Core.Theme _Theme = new taskt.Core.Theme();
36+
public taskt.Core.Theme Theme
37+
{
38+
get { return _Theme; }
39+
set { _Theme = value; }
40+
}
41+
2442
protected override void OnPaint(PaintEventArgs e)
2543
{
26-
e.Graphics.FillRectangle(new Core.Theme().CreateGradient(this.ClientRectangle), this.ClientRectangle);
44+
e.Graphics.FillRectangle(this.Theme.CreateGradient(this.ClientRectangle), this.ClientRectangle);
2745
base.OnPaint(e);
2846
}
2947
public static void MoveFormToBottomRight(Form sender)

taskt/UI/Forms/frmScriptBuilder.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,9 @@ private void BeginImportProcess()
13661366
if (openFileDialog.ShowDialog() == DialogResult.OK)
13671367
{
13681368
//import
1369+
Cursor.Current = Cursors.WaitCursor;
13691370
Import(openFileDialog.FileName);
1370-
1371+
Cursor.Current = Cursors.Default;
13711372
}
13721373

13731374
}
@@ -1393,6 +1394,13 @@ private void Import(string filePath)
13931394

13941395
//import
13951396
PopulateExecutionCommands(deserializedScript.Commands);
1397+
foreach (Core.Script.ScriptVariable var in deserializedScript.Variables)
1398+
{
1399+
if (scriptVariables.Find(alreadyExists => alreadyExists.VariableName == var.VariableName) == null)
1400+
{
1401+
scriptVariables.Add(var);
1402+
}
1403+
}
13961404

13971405
//comment
13981406
lstScriptActions.Items.Add(CreateScriptCommandListViewItem(new Core.Automation.Commands.CommentCommand() { v_Comment = "End Import From " + fileName + " @ " + dateTimeNow }));

taskt/UI/Forms/frmScriptEngine.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ private void Engine_ScriptFinishedEvent(object sender, ScriptFinishedEventArgs e
238238
AddStatus("Total Execution Time: " + e.ExecutionTime.ToString());
239239

240240
if(CloseWhenDone)
241-
{
242-
this.Close();
241+
{
242+
engineInstance.tasktEngineUI.Invoke((Action)delegate () { this.Close(); });
243243
}
244244

245245
}
@@ -313,6 +313,19 @@ private void UpdateUI(string mainLogoText)
313313
pbBotIcon.Image = Properties.Resources.error;
314314
}
315315

316+
if (mainLogoText.Contains("(error)"))
317+
{
318+
this.Theme.BgGradientStartColor = Color.DarkRed;
319+
this.Theme.BgGradientEndColor = Color.LightCoral;
320+
this.Invalidate();
321+
}
322+
else if (mainLogoText.Contains("(success)"))
323+
{
324+
this.Theme.BgGradientStartColor = Color.DarkGreen;
325+
this.Theme.BgGradientEndColor = Color.LightGreen;
326+
this.Invalidate();
327+
}
328+
316329
//reset debug line
317330
if (callBackForm != null)
318331
callBackForm.DebugLine = 0;

taskt/UI/Forms/frmScriptVariables.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ private TreeNode GetSelectedTopNode()
251251

252252
private void panel2_Paint(object sender, PaintEventArgs e)
253253
{
254-
var brush = new Core.Theme().CreateGradient(panel2.ClientRectangle);
255-
e.Graphics.FillRectangle(brush, panel2.ClientRectangle);
254+
e.Graphics.FillRectangle(this.Theme.CreateGradient(panel2.ClientRectangle), panel2.ClientRectangle);
256255
}
257256
}
258257
}

0 commit comments

Comments
 (0)