Skip to content

Commit dbb0101

Browse files
authored
Merge pull request #114 from saucepleez/development-branch
Development branch
2 parents 484f104 + ee9e572 commit dbb0101

39 files changed

+1662
-51
lines changed

taskt/Core/ApplicationSettings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class EngineSettings
116116
public bool TrackExecutionMetrics { get; set; }
117117
public string VariableStartMarker { get; set; }
118118
public string VariableEndMarker { get; set; }
119+
public System.Windows.Forms.Keys CancellationKey { get; set; }
119120
public int DelayBetweenCommands { get; set; }
120121
public bool OverrideExistingAppInstances { get; set; }
121122
public bool AutoCloseMessagesOnServerExecution { get; set; }
@@ -131,6 +132,7 @@ public EngineSettings()
131132
TrackExecutionMetrics = true;
132133
VariableStartMarker = "[";
133134
VariableEndMarker = "]";
135+
CancellationKey = System.Windows.Forms.Keys.Pause;
134136
DelayBetweenCommands = 250;
135137
OverrideExistingAppInstances = false;
136138
AutoCloseMessagesOnServerExecution = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Management;
4+
using System.Windows.Forms;
5+
using System.Xml.Serialization;
6+
using taskt.UI.CustomControls;
7+
using taskt.UI.Forms;
8+
9+
namespace taskt.Core.Automation.Commands
10+
{
11+
[Serializable]
12+
[Attributes.ClassAttributes.Group("System Commands")]
13+
[Attributes.ClassAttributes.Description("This command allows you to exclusively select a system/environment variable")]
14+
[Attributes.ClassAttributes.UsesDescription("Use this command to exclusively retrieve a system variable")]
15+
[Attributes.ClassAttributes.ImplementationDescription("")]
16+
public class EnvironmentVariableCommand : ScriptCommand
17+
{
18+
[XmlAttribute]
19+
[Attributes.PropertyAttributes.PropertyDescription("Select the required environment variable")]
20+
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
21+
[Attributes.PropertyAttributes.InputSpecification("Select from one of the options")]
22+
[Attributes.PropertyAttributes.SampleUsage("")]
23+
[Attributes.PropertyAttributes.Remarks("")]
24+
public string v_EnvVariableName { get; set; }
25+
26+
[XmlAttribute]
27+
[Attributes.PropertyAttributes.PropertyDescription("Please select the variable to receive output")]
28+
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
29+
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")]
30+
[Attributes.PropertyAttributes.SampleUsage("**vSomeVariable**")]
31+
[Attributes.PropertyAttributes.Remarks("If you have enabled the setting **Create Missing Variables at Runtime** then you are not required to pre-define your variables, however, it is highly recommended.")]
32+
public string v_applyToVariableName { get; set; }
33+
34+
35+
[XmlIgnore]
36+
[NonSerialized]
37+
public ComboBox VariableNameComboBox;
38+
39+
[XmlIgnore]
40+
[NonSerialized]
41+
public Label VariableValue;
42+
public EnvironmentVariableCommand()
43+
{
44+
this.CommandName = "EnvironmentVariableCommand";
45+
this.SelectionName = "Environment Variable";
46+
this.CommandEnabled = true;
47+
this.CustomRendering = true;
48+
}
49+
50+
public override void RunCommand(object sender)
51+
{
52+
var environmentVariable = (string)v_EnvVariableName.ConvertToUserVariable(sender);
53+
54+
var variables = Environment.GetEnvironmentVariables();
55+
var envValue = (string)variables[environmentVariable];
56+
57+
envValue.StoreInUserVariable(sender, v_applyToVariableName);
58+
59+
60+
}
61+
public override List<Control> Render(frmCommandEditor editor)
62+
{
63+
base.Render(editor);
64+
65+
var ActionNameComboBoxLabel = CommandControls.CreateDefaultLabelFor("v_EnvVariableName", this);
66+
VariableNameComboBox = (ComboBox)CommandControls.CreateDropdownFor("v_EnvVariableName", this);
67+
68+
69+
foreach (System.Collections.DictionaryEntry env in Environment.GetEnvironmentVariables())
70+
{
71+
var envVariableKey = env.Key.ToString();
72+
var envVariableValue = env.Value.ToString();
73+
VariableNameComboBox.Items.Add(envVariableKey);
74+
}
75+
76+
77+
VariableNameComboBox.SelectedValueChanged += VariableNameComboBox_SelectedValueChanged;
78+
79+
80+
81+
RenderedControls.Add(ActionNameComboBoxLabel);
82+
RenderedControls.Add(VariableNameComboBox);
83+
84+
VariableValue = new Label();
85+
VariableValue.Font = new System.Drawing.Font("Segoe UI", 12);
86+
VariableValue.ForeColor = System.Drawing.Color.White;
87+
88+
RenderedControls.Add(VariableValue);
89+
90+
91+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_applyToVariableName", this, editor));
92+
93+
94+
return RenderedControls;
95+
}
96+
97+
private void VariableNameComboBox_SelectedValueChanged(object sender, EventArgs e)
98+
{
99+
var selectedValue = VariableNameComboBox.SelectedItem;
100+
101+
if (selectedValue == null)
102+
return;
103+
104+
105+
var variable = Environment.GetEnvironmentVariables();
106+
var value = variable[selectedValue];
107+
108+
VariableValue.Text = "[ex. " + value + "]";
109+
110+
111+
}
112+
113+
public override string GetDisplayValue()
114+
{
115+
return base.GetDisplayValue() + " [Apply '" + v_EnvVariableName + "' to Variable '" + v_applyToVariableName + "']";
116+
}
117+
}
118+
119+
}

taskt/Core/Automation/Commands/ExecuteDLLCommand.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ public override void RunCommand(object sender)
101101
//get type
102102
Type t = requiredAssembly.GetType(className);
103103

104+
//get all methods
105+
MethodInfo[] availableMethods = t.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
106+
104107
//get method
105-
MethodInfo m = t.GetMethod(methodName);
108+
MethodInfo m = availableMethods.Where(f => f.ToString() == methodName).FirstOrDefault();
109+
106110

107111
//create instance
108112
var instance = requiredAssembly.CreateInstance(className);
@@ -174,6 +178,11 @@ where rws.Field<string>("Parameter Name") == paramName
174178
{
175179
parameters.Add(requiredParameterValue);
176180
}
181+
else if ((param.ParameterType.FullName == "System.DateTime"))
182+
{
183+
var parseResult = DateTime.Parse(requiredParameterValue);
184+
parameters.Add(parseResult);
185+
}
177186
else
178187
{
179188
throw new NotImplementedException("Only system parameter types are supported!");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Windows.Forms;
4+
using System.Xml.Serialization;
5+
using taskt.UI.CustomControls;
6+
using taskt.UI.Forms;
7+
8+
namespace taskt.Core.Automation.Commands
9+
{
10+
[Serializable]
11+
[Attributes.ClassAttributes.Group("Data Commands")]
12+
[Attributes.ClassAttributes.Description("This command allows you to trim a string")]
13+
[Attributes.ClassAttributes.UsesDescription("Use this command when you want to select a subset of text or variable")]
14+
[Attributes.ClassAttributes.ImplementationDescription("This command uses the String.Substring method to achieve automation.")]
15+
public class ModifyVariableCommand : ScriptCommand
16+
{
17+
[XmlAttribute]
18+
[Attributes.PropertyAttributes.PropertyDescription("Please select a variable or text to modify")]
19+
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")]
20+
[Attributes.PropertyAttributes.SampleUsage("**vSomeVariable**")]
21+
[Attributes.PropertyAttributes.Remarks("")]
22+
public string v_userVariableName { get; set; }
23+
24+
[XmlAttribute]
25+
[Attributes.PropertyAttributes.PropertyDescription("Select the case type")]
26+
[Attributes.PropertyAttributes.InputSpecification("Indicate if only so many characters should be kept")]
27+
[Attributes.PropertyAttributes.SampleUsage("-1 to keep remainder, 1 for 1 position after start index, etc.")]
28+
[Attributes.PropertyAttributes.Remarks("")]
29+
[Attributes.PropertyAttributes.PropertyUISelectionOption("To Upper Case")]
30+
[Attributes.PropertyAttributes.PropertyUISelectionOption("To Lower Case")]
31+
[Attributes.PropertyAttributes.PropertyUISelectionOption("To Base64 String")]
32+
[Attributes.PropertyAttributes.PropertyUISelectionOption("From Base64 String")]
33+
public string v_ConvertType { get; set; }
34+
35+
[XmlAttribute]
36+
[Attributes.PropertyAttributes.PropertyDescription("Please select the variable to receive the changes")]
37+
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")]
38+
[Attributes.PropertyAttributes.SampleUsage("**vSomeVariable**")]
39+
[Attributes.PropertyAttributes.Remarks("If you have enabled the setting **Create Missing Variables at Runtime** then you are not required to pre-define your variables, however, it is highly recommended.")]
40+
public string v_applyToVariableName { get; set; }
41+
public ModifyVariableCommand()
42+
{
43+
this.CommandName = "ModifyVariableCommand";
44+
this.SelectionName = "Modify Variable";
45+
this.CommandEnabled = true;
46+
this.CustomRendering = true;
47+
;
48+
}
49+
public override void RunCommand(object sender)
50+
{
51+
52+
53+
var stringValue = v_userVariableName.ConvertToUserVariable(sender);
54+
55+
var caseType = v_ConvertType.ConvertToUserVariable(sender);
56+
57+
switch (caseType)
58+
{
59+
case "To Upper Case":
60+
stringValue = stringValue.ToUpper();
61+
break;
62+
case "To Lower Case":
63+
stringValue = stringValue.ToLower();
64+
break;
65+
case "To Base64 String":
66+
byte[] textAsBytes = System.Text.Encoding.ASCII.GetBytes(stringValue);
67+
stringValue = Convert.ToBase64String(textAsBytes);
68+
break;
69+
case "From Base64 String":
70+
byte[] encodedDataAsBytes = System.Convert.FromBase64String(stringValue);
71+
stringValue = System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
72+
break;
73+
default:
74+
throw new NotImplementedException("Conversion Type '" + caseType + "' not implemented!");
75+
}
76+
77+
stringValue.StoreInUserVariable(sender, v_applyToVariableName);
78+
}
79+
public override List<Control> Render(frmCommandEditor editor)
80+
{
81+
base.Render(editor);
82+
83+
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this));
84+
var userVariableName = CommandControls.CreateStandardComboboxFor("v_userVariableName", this).AddVariableNames(editor);
85+
RenderedControls.AddRange(CommandControls.CreateUIHelpersFor("v_userVariableName", this, new Control[] { userVariableName }, editor));
86+
RenderedControls.Add(userVariableName);
87+
88+
//create standard group controls
89+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_ConvertType", this, editor));
90+
91+
92+
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_applyToVariableName", this));
93+
var VariableNameControl = CommandControls.CreateStandardComboboxFor("v_applyToVariableName", this).AddVariableNames(editor);
94+
RenderedControls.AddRange(CommandControls.CreateUIHelpersFor("v_applyToVariableName", this, new Control[] { VariableNameControl }, editor));
95+
RenderedControls.Add(VariableNameControl);
96+
97+
return RenderedControls;
98+
99+
}
100+
public override string GetDisplayValue()
101+
{
102+
return base.GetDisplayValue() + " [Convert '" + v_userVariableName + "' " + v_ConvertType + "']";
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)