Add FrmProxyCmd

This commit is contained in:
2017-11-30 16:11:48 +01:00
parent 8783d0623a
commit 67115e6931
9 changed files with 413 additions and 0 deletions

114
VAR.Toolbox/FrmProxyCmd.Designer.cs generated Normal file
View File

@@ -0,0 +1,114 @@
namespace VAR.Toolbox
{
partial class FrmProxyCmd
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.splitMain = new System.Windows.Forms.SplitContainer();
this.txtOutput = new System.Windows.Forms.TextBox();
this.txtInput = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.splitMain)).BeginInit();
this.splitMain.Panel1.SuspendLayout();
this.splitMain.Panel2.SuspendLayout();
this.splitMain.SuspendLayout();
this.SuspendLayout();
//
// splitMain
//
this.splitMain.BackColor = System.Drawing.SystemColors.ControlDark;
this.splitMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitMain.Location = new System.Drawing.Point(0, 0);
this.splitMain.Name = "splitMain";
this.splitMain.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitMain.Panel1
//
this.splitMain.Panel1.Controls.Add(this.txtOutput);
//
// splitMain.Panel2
//
this.splitMain.Panel2.Controls.Add(this.txtInput);
this.splitMain.Size = new System.Drawing.Size(392, 369);
this.splitMain.SplitterDistance = 313;
this.splitMain.SplitterWidth = 10;
this.splitMain.TabIndex = 3;
this.splitMain.TabStop = false;
//
// txtOutput
//
this.txtOutput.BackColor = System.Drawing.Color.Black;
this.txtOutput.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtOutput.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtOutput.ForeColor = System.Drawing.Color.Silver;
this.txtOutput.Location = new System.Drawing.Point(0, 0);
this.txtOutput.Multiline = true;
this.txtOutput.Name = "txtOutput";
this.txtOutput.ReadOnly = true;
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtOutput.Size = new System.Drawing.Size(392, 313);
this.txtOutput.TabIndex = 1;
this.txtOutput.TabStop = false;
//
// txtInput
//
this.txtInput.BackColor = System.Drawing.Color.Black;
this.txtInput.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtInput.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtInput.ForeColor = System.Drawing.Color.Silver;
this.txtInput.Location = new System.Drawing.Point(0, 0);
this.txtInput.Multiline = true;
this.txtInput.Name = "txtInput";
this.txtInput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtInput.Size = new System.Drawing.Size(392, 46);
this.txtInput.TabIndex = 0;
this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
//
// FrmProxyCmd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(392, 369);
this.Controls.Add(this.splitMain);
this.Name = "FrmProxyCmd";
this.Text = "ProxyCmd";
this.splitMain.Panel1.ResumeLayout(false);
this.splitMain.Panel1.PerformLayout();
this.splitMain.Panel2.ResumeLayout(false);
this.splitMain.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitMain)).EndInit();
this.splitMain.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitMain;
private System.Windows.Forms.TextBox txtOutput;
private System.Windows.Forms.TextBox txtInput;
}
}

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading;
using System.Windows.Forms;
namespace VAR.Toolbox
{
public partial class FrmProxyCmd : Form
{
public FrmProxyCmd()
{
InitializeComponent();
}
private void txtOutput_AppendLine(string line)
{
BeginInvoke(new MethodInvoker(delegate
{
txtOutput.AppendText(line);
txtOutput.AppendText(Environment.NewLine);
Application.DoEvents();
}));
}
private object _executionLock = new object();
private void txtInput_KeyDown(object sender, KeyEventArgs e)
{
if (Monitor.IsEntered(_executionLock))
{
e.Handled = true;
Application.DoEvents();
return;
}
if (e.KeyCode == Keys.Return)
{
e.Handled = true;
Application.DoEvents();
string cmd = txtInput.Text.Replace("\n", "").Replace("\r", "");
txtOutput_AppendLine(cmd);
txtInput.Text = string.Empty;
new Thread(() => ExecuteCmd(cmd)).Start();
return;
}
if (e.KeyCode == Keys.Up)
{
e.Handled = true;
return;
}
if (e.KeyCode == Keys.Down)
{
e.Handled = true;
return;
}
}
private void ExecuteCmd(string cmdString)
{
Monitor.Enter(_executionLock);
SqlConnection cnx = new SqlConnection(Properties.Settings.Default.ProxyCmdConfig);
SqlCommand cmd = cnx.CreateCommand();
cmd.CommandText = "exec master.dbo.xp_cmdshell @cmd";
cmd.Parameters.Add(new SqlParameter("cmd", cmdString));
cnx.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string output = Convert.ToString(reader[0]);
txtOutput_AppendLine(output);
}
cnx.Close();
Monitor.Exit(_executionLock);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.btnBase64 = new System.Windows.Forms.Button();
this.btnProxyCmd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnBase64
@@ -41,11 +42,22 @@
this.btnBase64.UseVisualStyleBackColor = true;
this.btnBase64.Click += new System.EventHandler(this.btnBase64_Click);
//
// btnProxyCmd
//
this.btnProxyCmd.Location = new System.Drawing.Point(12, 52);
this.btnProxyCmd.Name = "btnProxyCmd";
this.btnProxyCmd.Size = new System.Drawing.Size(209, 36);
this.btnProxyCmd.TabIndex = 1;
this.btnProxyCmd.Text = "ProxyCmd";
this.btnProxyCmd.UseVisualStyleBackColor = true;
this.btnProxyCmd.Click += new System.EventHandler(this.btnProxyCmd_Click);
//
// FrmToolbox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(233, 391);
this.Controls.Add(this.btnProxyCmd);
this.Controls.Add(this.btnBase64);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
@@ -58,6 +70,7 @@
#endregion
private System.Windows.Forms.Button btnBase64;
private System.Windows.Forms.Button btnProxyCmd;
}
}

View File

@@ -22,5 +22,11 @@ namespace VAR.Toolbox
var frmBase64 = new FrmBase64();
frmBase64.Show();
}
private void btnProxyCmd_Click(object sender, EventArgs e)
{
var frmProxyCmd = new FrmProxyCmd();
frmProxyCmd.Show();
}
}
}

View File

@@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace VAR.Toolbox.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=SRV7;Initial Catalog=master;Integrated Security=True")]
public string ProxyCmdConfig {
get {
return ((string)(this["ProxyCmdConfig"]));
}
set {
this["ProxyCmdConfig"] = value;
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="VAR.Toolbox.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ProxyCmdConfig" Type="System.String" Scope="User">
<Value Profile="(Default)">Data Source=SRV7;Initial Catalog=master;Integrated Security=True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -52,6 +52,12 @@
<Compile Include="FrmBase64.Designer.cs">
<DependentUpon>FrmBase64.cs</DependentUpon>
</Compile>
<Compile Include="FrmProxyCmd.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmProxyCmd.Designer.cs">
<DependentUpon>FrmProxyCmd.cs</DependentUpon>
</Compile>
<Compile Include="FrmToolbox.cs">
<SubType>Form</SubType>
</Compile>
@@ -60,15 +66,30 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FrmBase64.resx">
<DependentUpon>FrmBase64.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmProxyCmd.resx">
<DependentUpon>FrmProxyCmd.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmToolbox.resx">
<DependentUpon>FrmToolbox.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

15
VAR.Toolbox/app.config Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="VAR.Toolbox.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<VAR.Toolbox.Properties.Settings>
<setting name="ProxyCmdConfig" serializeAs="String">
<value>Data Source=SRV7;Initial Catalog=master;Integrated Security=True</value>
</setting>
</VAR.Toolbox.Properties.Settings>
</userSettings>
</configuration>