forked from saucepleez/taskt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GetDataRowCountCommand, fixed RunTask bug
- Loading branch information
1 parent
7ff1808
commit b50ea1e
Showing
7 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Xml.Serialization; | ||
using System.Data; | ||
using System.Windows.Forms; | ||
using System.Collections.Generic; | ||
using taskt.UI.Forms; | ||
using taskt.UI.CustomControls; | ||
|
||
namespace taskt.Core.Automation.Commands | ||
{ | ||
[Serializable] | ||
[Attributes.ClassAttributes.Group("DataTable Commands")] | ||
[Attributes.ClassAttributes.Description("This command allows you to add a datarow to a DataTable")] | ||
[Attributes.ClassAttributes.UsesDescription("Use this command when you want to add a datarow to a DataTable.")] | ||
[Attributes.ClassAttributes.ImplementationDescription("")] | ||
public class GetDataRowCountCommand : ScriptCommand | ||
{ | ||
[XmlAttribute] | ||
[Attributes.PropertyAttributes.PropertyDescription("Please indicate the DataTable Name")] | ||
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] | ||
[Attributes.PropertyAttributes.InputSpecification("Enter a existing DataTable to add rows to.")] | ||
[Attributes.PropertyAttributes.SampleUsage("**myData**")] | ||
[Attributes.PropertyAttributes.Remarks("")] | ||
public string v_DataTableName { get; set; } | ||
|
||
[XmlAttribute] | ||
[Attributes.PropertyAttributes.PropertyDescription("Assign to Variable")] | ||
[Attributes.PropertyAttributes.InputSpecification("Select or provide a variable from the variable list")] | ||
[Attributes.PropertyAttributes.SampleUsage("**vSomeVariable**")] | ||
[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.")] | ||
public string v_UserVariableName { get; set; } | ||
|
||
public GetDataRowCountCommand() | ||
{ | ||
this.CommandName = "GetDataRowCountCommand"; | ||
this.SelectionName = "Get DataRow Count"; | ||
this.CommandEnabled = true; | ||
this.CustomRendering = true; | ||
|
||
} | ||
|
||
public override void RunCommand(object sender) | ||
{ | ||
var engine = (Core.Automation.Engine.AutomationEngineInstance)sender; | ||
var dataSetVariable = LookupVariable(engine); | ||
DataTable dataTable = (DataTable)dataSetVariable.VariableValue; | ||
|
||
var count = dataTable.Rows.Count.ToString(); | ||
|
||
count.StoreInUserVariable(sender, v_UserVariableName); | ||
|
||
} | ||
private Script.ScriptVariable LookupVariable(Core.Automation.Engine.AutomationEngineInstance sendingInstance) | ||
{ | ||
//search for the variable | ||
var requiredVariable = sendingInstance.VariableList.Where(var => var.VariableName == v_DataTableName).FirstOrDefault(); | ||
|
||
//if variable was not found but it starts with variable naming pattern | ||
if ((requiredVariable == null) && (v_DataTableName.StartsWith(sendingInstance.engineSettings.VariableStartMarker)) && (v_DataTableName.EndsWith(sendingInstance.engineSettings.VariableEndMarker))) | ||
{ | ||
//reformat and attempt | ||
var reformattedVariable = v_DataTableName.Replace(sendingInstance.engineSettings.VariableStartMarker, "").Replace(sendingInstance.engineSettings.VariableEndMarker, ""); | ||
requiredVariable = sendingInstance.VariableList.Where(var => var.VariableName == reformattedVariable).FirstOrDefault(); | ||
} | ||
|
||
return requiredVariable; | ||
} | ||
public override List<Control> Render(frmCommandEditor editor) | ||
{ | ||
base.Render(editor); | ||
|
||
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_DataTableName", this, editor)); | ||
RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_UserVariableName", this)); | ||
var VariableNameControl = CommandControls.CreateStandardComboboxFor("v_UserVariableName", this).AddVariableNames(editor); | ||
RenderedControls.AddRange(CommandControls.CreateUIHelpersFor("v_UserVariableName", this, new Control[] { VariableNameControl }, editor)); | ||
RenderedControls.Add(VariableNameControl); | ||
|
||
return RenderedControls; | ||
} | ||
|
||
|
||
|
||
public override string GetDisplayValue() | ||
{ | ||
return base.GetDisplayValue() + $" [From '{v_DataTableName}', Store In: '{v_UserVariableName}']"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters