Skip to content

Commit

Permalink
Merge pull request saucepleez#157 from saucepleez/development-branch
Browse files Browse the repository at this point in the history
taskt 3.2.2.0 PR
  • Loading branch information
saucepleez authored Oct 6, 2019
2 parents 9dc351b + 56547c3 commit dba1f20
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 33 deletions.
18 changes: 16 additions & 2 deletions taskt/Core/Automation/Commands/HTTPRequestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ public class HTTPRequestCommand : ScriptCommand
[Attributes.PropertyAttributes.Remarks("")]
public string v_WebRequestURL { get; set; }

[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Execute Request as the currently logged on user?")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Yes")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("No")]
[Attributes.PropertyAttributes.InputSpecification("Sets currently logged on user authentication information for the request.")]
[Attributes.PropertyAttributes.SampleUsage("Select 'Yes' or 'No'")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_WebRequestCredentials { get; set; }

[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Apply Result To Variable")]
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")]
Expand All @@ -46,7 +55,12 @@ public override void RunCommand(object sender)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(v_WebRequestURL.ConvertToUserVariable(sender));
request.Method = "GET";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
if (v_WebRequestCredentials == "Yes")
{
request.Credentials = CredentialCache.DefaultCredentials;
}

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

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

//create inputs for request url
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_WebRequestURL", this, editor));

RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_WebRequestCredentials", this, editor));

//create window name helper control
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this));
Expand Down
10 changes: 7 additions & 3 deletions taskt/Core/Automation/Commands/RunTaskCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override void RunCommand(object sender)
var variableList = new List<Script.ScriptVariable>();
foreach (DataRow rw in v_VariableAssignments.Rows)
{
var variableName = ((string)rw.ItemArray[0]).ConvertToUserVariable(sender);
var variableName = (string)rw.ItemArray[0];
var variableValue = ((string)rw.ItemArray[1]).ConvertToUserVariable(sender);
variableList.Add(new Script.ScriptVariable
{
Expand All @@ -85,8 +85,12 @@ public override void RunCommand(object sender)
});
}

Application.Run(new UI.Forms.frmScriptEngine(startFile, null, variableList));

UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(startFile, null, variableList, true);
Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance) sender;
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = false; });
Application.Run(newEngine);
//currentScriptEngine.tasktEngineUI.TopMost = false;
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = true; });
}

public override List<Control> Render(frmCommandEditor editor)
Expand Down
9 changes: 8 additions & 1 deletion taskt/Core/Automation/Commands/ScriptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@ public virtual void RunCommand(object sender, Core.Script.ScriptAction command)

public virtual string GetDisplayValue()
{
return SelectionName;
if (String.IsNullOrEmpty(v_Comment))
{
return SelectionName;
}
else
{
return SelectionName + " [" + v_Comment + "]";
}
}

public virtual List<Control> Render(UI.Forms.frmCommandEditor editor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SeleniumBrowserCreateCommand : ScriptCommand
[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please specify Selenium command line options (optional)")]
[Attributes.PropertyAttributes.InputSpecification("Select optional options to be passed to the Selenium command.")]
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=/user/public/SeleniumTasktProfile")]
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=c:\\users\\public\\SeleniumTasktProfile")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_SeleniumOptions { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class SeleniumBrowserElementActionCommand : ScriptCommand
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Attribute")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Matching Elements")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Wait For Element To Exist")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Switch to frame")]
[Attributes.PropertyAttributes.InputSpecification("Select the appropriate corresponding action to take once the element has been located")]
[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**")]
[Attributes.PropertyAttributes.Remarks("Selecting this field changes the parameters that will be required in the next step")]
Expand Down Expand Up @@ -171,9 +172,8 @@ where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"

return;
}
else
else if (seleniumSearchParam != string.Empty)
{

element = FindElement(seleniumInstance, seleniumSearchParam);
}

Expand Down Expand Up @@ -319,7 +319,19 @@ where rw.Field<string>("Parameter Name") == "Variable Name"
break;
case "Clear Element":
element.Clear();
break;

case "Switch to frame":
if (seleniumSearchParam == "")
{
seleniumInstance.SwitchTo().DefaultContent();
}
else
{
seleniumInstance.SwitchTo().Frame(element);
}
break;

default:
throw new Exception("Element Action was not found");
}
Expand Down Expand Up @@ -546,7 +558,15 @@ public void seleniumAction_SelectionChangeCommitted(object sender, EventArgs e)
{
actionParameters.Rows.Add("Timeout (Seconds)");
}
break;

case "Switch to frame":
foreach (var ctrl in ElementParameterControls)
{
ctrl.Hide();
}
break;

default:
break;
}
Expand Down
23 changes: 19 additions & 4 deletions taskt/Core/Automation/Commands/StartProcessCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public class StartProcessCommand : ScriptCommand
[Attributes.PropertyAttributes.SampleUsage(" **-a** or **-version**")]
[Attributes.PropertyAttributes.Remarks("You will need to consult documentation to determine if your executable supports arguments or flags on startup.")]
public string v_ProgramArgs { get; set; }
[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Wait for the process to complete?")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Yes")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("No")]
[Attributes.PropertyAttributes.InputSpecification("Wait For Exit.")]
[Attributes.PropertyAttributes.SampleUsage("Select 'Yes' or 'No'")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_WaitForExit { get; set; }

public StartProcessCommand()
{
Expand All @@ -45,27 +53,34 @@ public override void RunCommand(object sender)

string vProgramName = v_ProgramName.ConvertToUserVariable(sender);
string vProgramArgs = v_ProgramArgs.ConvertToUserVariable(sender);
System.Diagnostics.Process p;

if (v_ProgramArgs == "")
{
System.Diagnostics.Process.Start(vProgramName);
p = System.Diagnostics.Process.Start(vProgramName);
}
else
{
System.Diagnostics.Process.Start(vProgramName, vProgramArgs);
p = System.Diagnostics.Process.Start(vProgramName, vProgramArgs);
}

if (v_WaitForExit == "Yes")
{
p.WaitForExit();
}

System.Threading.Thread.Sleep(2000);
}

public override List<Control> Render(frmCommandEditor editor)
{
base.Render(editor);

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

RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_ProgramArgs", this, editor));

RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_WaitForExit", this, editor));

return RenderedControls;
}
public override string GetDisplayValue()
Expand Down
2 changes: 1 addition & 1 deletion taskt/Core/Automation/Commands/UserInputCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override void RunCommand(object sender)
//translate variables for each label
foreach (DataRow rw in clonedCommand.v_UserInputConfig.Rows)
{
rw["Label"] = rw["Label"].ToString().ConvertToUserVariable(sender);
rw["DefaultValue"] = rw["DefaultValue"].ToString().ConvertToUserVariable(sender);

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

Expand Down
30 changes: 19 additions & 11 deletions taskt/Core/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
namespace taskt.Core
{
public class Theme
{
public LinearGradientBrush CreateGradient(Rectangle rect)
{
var tasktBlue = Color.FromArgb(20, 136, 204);
var tasktPurple = Color.FromArgb(43, 50, 178);
LinearGradientBrush linearGradientBrush =
new LinearGradientBrush(rect, tasktPurple, tasktBlue, 180);
return linearGradientBrush;

//e.Graphics.FillRectangle(linearGradientBrush, pnlMain.ClientRectangle);

{

Color _BgGradientStartColor = Color.FromArgb(20, 136, 204);
public Color BgGradientStartColor
{
get { return _BgGradientStartColor; }
set { _BgGradientStartColor = value; }
}

Color _BgGradientEndColor = Color.FromArgb(43, 50, 178);
public Color BgGradientEndColor
{
get { return _BgGradientEndColor; }
set { _BgGradientEndColor = value; }
}

public LinearGradientBrush CreateGradient(Rectangle rect)
{
return new LinearGradientBrush(rect, _BgGradientStartColor, _BgGradientEndColor, 180);
}

}
}
2 changes: 1 addition & 1 deletion taskt/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.0.*")]
[assembly: AssemblyFileVersion("3.2.1.0")]
[assembly: AssemblyFileVersion("3.2.2.0")]
//[assembly: AssemblyVersion("0.0.0.2")]
//[assembly: AssemblyFileVersion("0.0.0.2")]
9 changes: 8 additions & 1 deletion taskt/UI/CustomControls/CustomControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ public class UITabControl : TabControl

public partial class UIPanel : Panel
{
private taskt.Core.Theme _Theme = new taskt.Core.Theme();
public taskt.Core.Theme Theme
{
get { return _Theme; }
set { _Theme = value; }
}

protected override void OnPaint(PaintEventArgs e)
{


var brush = new Core.Theme().CreateGradient(this.ClientRectangle);
var brush = this.Theme.CreateGradient(this.ClientRectangle);
e.Graphics.FillRectangle(brush, this.ClientRectangle);


Expand Down
20 changes: 19 additions & 1 deletion taskt/UI/Forms/ThemedForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -21,9 +22,26 @@ private void ThemedForm_Load(object sender, EventArgs e)
{

}

protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (this.ClientSize.Height > Screen.PrimaryScreen.WorkingArea.Height - this.CurrentAutoScaleDimensions.Height) // Resizes if too tall to fit
{
this.ClientSize = new Size(this.ClientSize.Width, Screen.PrimaryScreen.WorkingArea.Height - (int)this.CurrentAutoScaleDimensions.Height);
}
}

private taskt.Core.Theme _Theme = new taskt.Core.Theme();
public taskt.Core.Theme Theme
{
get { return _Theme; }
set { _Theme = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(new Core.Theme().CreateGradient(this.ClientRectangle), this.ClientRectangle);
e.Graphics.FillRectangle(this.Theme.CreateGradient(this.ClientRectangle), this.ClientRectangle);
base.OnPaint(e);
}
public static void MoveFormToBottomRight(Form sender)
Expand Down
10 changes: 9 additions & 1 deletion taskt/UI/Forms/frmScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,8 +1366,9 @@ private void BeginImportProcess()
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//import
Cursor.Current = Cursors.WaitCursor;
Import(openFileDialog.FileName);

Cursor.Current = Cursors.Default;
}

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

//import
PopulateExecutionCommands(deserializedScript.Commands);
foreach (Core.Script.ScriptVariable var in deserializedScript.Variables)
{
if (scriptVariables.Find(alreadyExists => alreadyExists.VariableName == var.VariableName) == null)
{
scriptVariables.Add(var);
}
}

//comment
lstScriptActions.Items.Add(CreateScriptCommandListViewItem(new Core.Automation.Commands.CommentCommand() { v_Comment = "End Import From " + fileName + " @ " + dateTimeNow }));
Expand Down
17 changes: 15 additions & 2 deletions taskt/UI/Forms/frmScriptEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ private void Engine_ScriptFinishedEvent(object sender, ScriptFinishedEventArgs e
AddStatus("Total Execution Time: " + e.ExecutionTime.ToString());

if(CloseWhenDone)
{
this.Close();
{
engineInstance.tasktEngineUI.Invoke((Action)delegate () { this.Close(); });
}

}
Expand Down Expand Up @@ -313,6 +313,19 @@ private void UpdateUI(string mainLogoText)
pbBotIcon.Image = Properties.Resources.error;
}

if (mainLogoText.Contains("(error)"))
{
this.Theme.BgGradientStartColor = Color.DarkRed;
this.Theme.BgGradientEndColor = Color.LightCoral;
this.Invalidate();
}
else if (mainLogoText.Contains("(success)"))
{
this.Theme.BgGradientStartColor = Color.DarkGreen;
this.Theme.BgGradientEndColor = Color.LightGreen;
this.Invalidate();
}

//reset debug line
if (callBackForm != null)
callBackForm.DebugLine = 0;
Expand Down
3 changes: 1 addition & 2 deletions taskt/UI/Forms/frmScriptVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ private TreeNode GetSelectedTopNode()

private void panel2_Paint(object sender, PaintEventArgs e)
{
var brush = new Core.Theme().CreateGradient(panel2.ClientRectangle);
e.Graphics.FillRectangle(brush, panel2.ClientRectangle);
e.Graphics.FillRectangle(this.Theme.CreateGradient(panel2.ClientRectangle), panel2.ClientRectangle);
}
}
}

0 comments on commit dba1f20

Please sign in to comment.