Skip to content

Commit

Permalink
added pingcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
naga1992 committed Jun 3, 2020
1 parent 5037b67 commit b03ace1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
66 changes: 66 additions & 0 deletions taskt/Core/Automation/Commands/PingCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Windows.Forms;
using System.Xml.Serialization;
using taskt.UI.CustomControls;
using taskt.UI.Forms;

namespace taskt.Core.Automation.Commands
{
[Serializable]
[Attributes.ClassAttributes.Group("Misc Commands")]
[Attributes.ClassAttributes.Description("This command allows you to add an in-line comment to the script.")]
[Attributes.ClassAttributes.UsesDescription("Use this command when you want to add code comments or document code. Usage of variables (ex. [vVar]) within the comment block will be parsed and displayed when running the script.")]
[Attributes.ClassAttributes.ImplementationDescription("This command is for visual purposes only")]
public class PingCommand : ScriptCommand
{

[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please Enter ip address or host name that you want to ping")]
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
[Attributes.PropertyAttributes.InputSpecification("Ip address or hostname you want to ping")]
[Attributes.PropertyAttributes.SampleUsage("** 192.168.0.1 or www.google.com**")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_hostname { get; set; }


public PingCommand()
{
this.CommandName = "PingCommand";
this.SelectionName = "Ping Command";
this.DisplayForeColor = System.Drawing.Color.ForestGreen;
this.CommandEnabled = true;
this.CustomRendering = true;
}
public override List<Control> Render(frmCommandEditor editor)
{
base.Render(editor);
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_hostname", this, editor));

return RenderedControls;
}

public override void RunCommand(object sender)
{

Ping ping = new Ping();
string hstname = v_hostname.ConvertToUserVariable(sender);
PingReply pingresult = ping.Send(hstname);
if (pingresult.Status.ToString() == "Success")
{

}
else
{
throw new Exception();
}

}

public override string GetDisplayValue()
{
return "Pinging " + this.v_hostname;
}
}
}
1 change: 1 addition & 0 deletions taskt/Core/Automation/Commands/ScriptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace taskt.Core.Automation.Commands
{
[Serializable]
[XmlInclude(typeof(PingCommand))]
[XmlInclude(typeof(SendKeysCommand))]
[XmlInclude(typeof(SendAdvancedKeyStrokesCommand))]
[XmlInclude(typeof(CreateDictionaryCommand))]
Expand Down
1 change: 1 addition & 0 deletions taskt/taskt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<Compile Include="Core\Automation\Commands\AddDictionaryCommand.cs" />
<Compile Include="Core\Automation\Commands\BeginLoopCommand.cs" />
<Compile Include="Core\Automation\Commands\BeginMultiLoopCommand.cs" />
<Compile Include="Core\Automation\Commands\PingCommand.cs" />
<Compile Include="Core\Automation\Commands\CreateDictionaryCommand.cs" />
<Compile Include="Core\Automation\Commands\BeginMutliIfCommand.cs" />
<Compile Include="Core\Automation\Commands\CreateFolderCommand.cs" />
Expand Down

0 comments on commit b03ace1

Please sign in to comment.