load different profile.json

fix bugs relating to profile loading
This commit is contained in:
AnD
2026-04-15 18:05:45 -06:00
parent f07fe51193
commit 7d35ac2b37
16 changed files with 684 additions and 460 deletions

View File

@@ -1,4 +1,4 @@
namespace SSH_Test namespace FHT
{ {
partial class FormConfiguration partial class FormConfiguration
{ {
@@ -41,14 +41,17 @@
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.textBoxTftpIP = new System.Windows.Forms.TextBox(); this.textBoxTftpIP = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.buttonProfilePath = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox(); this.groupBox4 = new System.Windows.Forms.GroupBox();
this.buttonTasklistDec = new System.Windows.Forms.Button(); this.buttonTasklistDec = new System.Windows.Forms.Button();
this.buttonTasklistEnc = new System.Windows.Forms.Button(); this.buttonTasklistEnc = new System.Windows.Forms.Button();
this.buttonEncryptTaskList = new System.Windows.Forms.Button(); this.buttonEncryptTaskList = new System.Windows.Forms.Button();
this.openFileDialogTasklist = new System.Windows.Forms.OpenFileDialog(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox4.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -154,6 +157,7 @@
// //
// groupBox3 // groupBox3
// //
this.groupBox3.Controls.Add(this.groupBox5);
this.groupBox3.Controls.Add(this.groupBox4); this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Controls.Add(this.buttonEncryptTaskList); this.groupBox3.Controls.Add(this.buttonEncryptTaskList);
this.groupBox3.Location = new System.Drawing.Point(307, 12); this.groupBox3.Location = new System.Drawing.Point(307, 12);
@@ -161,7 +165,27 @@
this.groupBox3.Size = new System.Drawing.Size(240, 177); this.groupBox3.Size = new System.Drawing.Size(240, 177);
this.groupBox3.TabIndex = 6; this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false; this.groupBox3.TabStop = false;
this.groupBox3.Text = "Encryption"; this.groupBox3.Text = "Profile && Encryption";
//
// groupBox5
//
this.groupBox5.Controls.Add(this.buttonProfilePath);
this.groupBox5.Location = new System.Drawing.Point(8, 87);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(200, 54);
this.groupBox5.TabIndex = 10;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Profile Path";
//
// buttonProfilePath
//
this.buttonProfilePath.Location = new System.Drawing.Point(15, 18);
this.buttonProfilePath.Name = "buttonProfilePath";
this.buttonProfilePath.Size = new System.Drawing.Size(163, 29);
this.buttonProfilePath.TabIndex = 9;
this.buttonProfilePath.Text = "profile.json";
this.buttonProfilePath.UseVisualStyleBackColor = true;
this.buttonProfilePath.Click += new System.EventHandler(this.buttonProfilePath_Click);
// //
// groupBox4 // groupBox4
// //
@@ -203,12 +227,12 @@
this.buttonEncryptTaskList.Text = "Encrypt"; this.buttonEncryptTaskList.Text = "Encrypt";
this.buttonEncryptTaskList.UseVisualStyleBackColor = true; this.buttonEncryptTaskList.UseVisualStyleBackColor = true;
// //
// openFileDialogTasklist // openFileDialog
// //
this.openFileDialogTasklist.DefaultExt = "json"; this.openFileDialog.DefaultExt = "json";
this.openFileDialogTasklist.FileName = "tasklisk.json"; this.openFileDialog.FileName = "*.json";
this.openFileDialogTasklist.Filter = "json file|*.json|Powershell scrips|*.ps1"; this.openFileDialog.Filter = "json file|*.json|Powershell scrips|*.ps1";
this.openFileDialogTasklist.Title = "Task list file"; this.openFileDialog.Title = "File Path";
// //
// FormConfiguration // FormConfiguration
// //
@@ -228,6 +252,7 @@
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout(); this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false); this.groupBox3.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox4.ResumeLayout(false); this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@@ -251,6 +276,8 @@
private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button buttonTasklistDec; private System.Windows.Forms.Button buttonTasklistDec;
private System.Windows.Forms.Button buttonTasklistEnc; private System.Windows.Forms.Button buttonTasklistEnc;
private System.Windows.Forms.OpenFileDialog openFileDialogTasklist; private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.Button buttonProfilePath;
private System.Windows.Forms.GroupBox groupBox5;
} }
} }

View File

@@ -12,7 +12,7 @@ using System.Windows.Forms;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace SSH_Test namespace FHT
{ {
public partial class FormConfiguration : Form public partial class FormConfiguration : Form
{ {
@@ -29,15 +29,17 @@ namespace SSH_Test
public static ILog log; public static ILog log;
public FormConfiguration(string tftp_IP, string sftpIP, string sftp_Username, string sftp_Password, bool bencryption public FormConfiguration(string tftp_IP, string sftpIP, string sftp_Username, string sftp_Password, bool bencryption
, Aes aaes, ILog Log) , Aes aaes, string sprofilepath, ILog Log)
{ {
InitializeComponent(); InitializeComponent();
this.textBoxTftpIP.Text = Tftp_IP = tftp_IP; this.textBoxTftpIP.Text = Tftp_IP = tftp_IP;
this.textBoxSftpIP.Text = Sftp_IP = sftpIP; this.textBoxSftpIP.Text = Sftp_IP = sftpIP;
this.textBoxSftpUsername.Text = Sftp_Username = sftp_Username; this.textBoxSftpUsername.Text = Sftp_Username = sftp_Username;
this.textBoxSftpPassword.Text = Sftp_Password = sftp_Password; this.textBoxSftpPassword.Text = Sftp_Password = sftp_Password;
buttonProfilePath.Text = sProfilePath = sprofilepath;
aes = aaes; aes = aaes;
log = Log; log = Log;
this.Update(); this.Update();
} }
@@ -66,10 +68,10 @@ namespace SSH_Test
private void buttonTasklistEnc_Click(object sender, EventArgs e) private void buttonTasklistEnc_Click(object sender, EventArgs e)
{ {
Utilities utilities = new Utilities(log); Utilities utilities = new Utilities(log);
if (openFileDialogTasklist.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
string Jsonfilename = openFileDialogTasklist.FileName; string Jsonfilename = openFileDialog.FileName;
string buttonTasklistPath = openFileDialogTasklist.SafeFileName; string buttonTasklistPath = openFileDialog.SafeFileName;
if (File.Exists(Jsonfilename)) if (File.Exists(Jsonfilename))
{ {
try try
@@ -99,10 +101,10 @@ namespace SSH_Test
private void buttonTasklistDec_Click(object sender, EventArgs e) private void buttonTasklistDec_Click(object sender, EventArgs e)
{ {
Utilities utilities = new Utilities(log); Utilities utilities = new Utilities(log);
if (openFileDialogTasklist.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
string JsonFileName = openFileDialogTasklist.FileName; string JsonFileName = openFileDialog.FileName;
string buttonTasklistPath = openFileDialogTasklist.SafeFileName; string buttonTasklistPath = openFileDialog.SafeFileName;
if (File.Exists(JsonFileName)) if (File.Exists(JsonFileName))
{ {
try try
@@ -126,5 +128,14 @@ namespace SSH_Test
} }
} }
} }
private void buttonProfilePath_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
sProfilePath = openFileDialog.FileName;
buttonProfilePath.Text = openFileDialog.SafeFileName;
}
}
} }
} }

View File

@@ -117,7 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="openFileDialogTasklist.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

View File

@@ -6,8 +6,8 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{73DED4CD-B2B1-491E-87B7-BC1F11759C53}</ProjectGuid> <ProjectGuid>{73DED4CD-B2B1-491E-87B7-BC1F11759C53}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>SSH_Test</RootNamespace> <RootNamespace>FHT</RootNamespace>
<AssemblyName>SSH_Test</AssemblyName> <AssemblyName>FHT</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -86,8 +86,8 @@
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL"> <Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>packages\BouncyCastle.Cryptography.2.6.2\lib\net461\BouncyCastle.Cryptography.dll</HintPath> <HintPath>packages\BouncyCastle.Cryptography.2.6.2\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net, Version=3.2.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=3.3.1.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.3.2.0\lib\net462\log4net.dll</HintPath> <HintPath>packages\log4net.3.3.1\lib\net462\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.10.0.2\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> <HintPath>packages\Microsoft.Bcl.AsyncInterfaces.10.0.2\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
@@ -135,6 +135,7 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath> <HintPath>packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@@ -27,14 +27,14 @@ using System.Windows.Forms;
using System.Xml; using System.Xml;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SSH_Test namespace FHT
{ {
public partial class TastList : Form public partial class TastList : Form
{ {
// set to false to enable Encrypt , Decrypt Buttons // set to false to enable Encrypt , Decrypt Buttons
public const bool IsAdminDisabled = true; public const bool IsAdminDisabled = false;
public List<cTask> Tasks = new List<cTask>(); public List<cTask> Tasks = new List<cTask>();
@@ -133,27 +133,41 @@ namespace SSH_Test
dataGridViewTask.AllowDrop = true; dataGridViewTask.AllowDrop = true;
dataGridViewTask.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; dataGridViewTask.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
dataGridViewTask.RowTemplate.ContextMenuStrip = contextMenuStripRow; dataGridViewTask.RowTemplate.ContextMenuStrip = contextMenuStripRow;
//Load Profile list from "profile.json"
Profiles = utilities.LoadProfile("profile.json", aes);
// Configure Profile list to dropdown menu //ask for AES key
// AES button will update the dropdown menu when AES key is inputed. buttonAESString_Click(null, null);
//try
//{
// foreach (Profile p in Profiles)
// {
// log.Info(string.Format("Profile: {0}", p.ProfileName));
// }
// var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7]; //Load Profile list from "Profilefilename"
// comboBoxColumn.DataSource = Profiles; // Set the data source of the ComboBox column Profiles = utilities.LoadProfile(Profilefilename, aes);
// comboBoxColumn.DisplayMember = "profileName"; // Displayed property name
// comboBoxColumn.ValueMember = "profileName"; //The property name of the value if (!Profiles.Any())
//} {
//catch (Exception ex) //load "do nothing" to Profiles
//{ Profile temp = new Profile();
// log.Error(ex.Message); temp.ProfileType = "";
//} temp.ProfileName = "Do nothing";
temp.ProfileCommands = new string[] { "echo Do nothing" };
temp.ProfileParameters = new string[] { "" };
Profiles.Add(temp);
}
try
{
foreach (Profile p in Profiles)
{
log.Info(string.Format("Profile: {0}", p.ProfileName));
}
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7];
comboBoxColumn.DataSource = Profiles; // Set the data source of the ComboBox column
comboBoxColumn.DisplayMember = "profileName"; // Displayed property name
comboBoxColumn.ValueMember = "profileName"; //The property name of the value
}
catch (Exception ex)
{
log.Error(ex.Message);
}
dataGridViewTask.Refresh(); dataGridViewTask.Refresh();
@@ -316,10 +330,12 @@ namespace SSH_Test
row.Cells[1].Value = task.sTaskDescription; row.Cells[1].Value = task.sTaskDescription;
row.Cells[2].Value = task.sTaskDevice; row.Cells[2].Value = task.sTaskDevice;
row.Cells[4].Value = task.bTaskSelect; row.Cells[4].Value = task.bTaskSelect;
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7]; // var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7];
// test if task.sprofile name mach any in Profiles, if true, assign that name // test if task.sprofile name mach any in Profiles, if true, assign that name
if (Profiles.Any(pr => pr.ProfileName == task.sProfile)) if (Profiles.Any(pr => pr.ProfileName == task.sProfile))
row.Cells[7].Value = task.sProfile; row.Cells[7].Value = task.sProfile;
else
row.Cells[7].Value = null;
dataGridViewTask.Rows.Add(row); dataGridViewTask.Rows.Add(row);
} }
catch (Exception ex) catch (Exception ex)
@@ -335,18 +351,63 @@ namespace SSH_Test
{ {
FormConfiguration formConfiguration = new FormConfiguration(conInfo.sTftpIP, conInfo.sSftpIP, FormConfiguration formConfiguration = new FormConfiguration(conInfo.sTftpIP, conInfo.sSftpIP,
conInfo.sSftpUsername, conInfo.sSftpPassword, conInfo.sSftpUsername, conInfo.sSftpPassword,
bEncryption, aes, log); bEncryption, aes, Profilefilename,log);
// Disable Encrypt, Decrypt buttons // Disable Encrypt, Decrypt buttons
if(IsAdminDisabled) if(IsAdminDisabled)
{ {
formConfiguration.AdminDisable(); formConfiguration.AdminDisable();
} }
formConfiguration.ShowDialog(); formConfiguration.ShowDialog();
//reload profile and task list
Profilefilename = formConfiguration.sProfilePath;
//try reloading Profilefilename
Profiles.Clear();
Profiles = utilities.LoadProfile(Profilefilename, aes);
// Configure Profile list to dropdown menu, first to check if profiles is empty
if (!Profiles.Any())
{
//load "do nothing" to Profiles
Profile temp = new Profile();
temp.ProfileType = "";
temp.ProfileName = "Do nothing";
temp.ProfileCommands = new string[] { "echo Do nothing" };
temp.ProfileParameters = new string[] { "" };
Profiles.Add(temp);
}
try
{
foreach (Profile p in Profiles)
{
log.Info(string.Format("Profile: {0}", p.ProfileName));
}
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridViewTask.Columns[7];
comboBoxColumn.DataSource = Profiles; // Set the data source of the ComboBox column
comboBoxColumn.DisplayMember = "profileName"; // Displayed property name
comboBoxColumn.ValueMember = "profileName"; //The property name of the value
}
catch (Exception ex)
{
log.Error(ex.Message);
}
//reload tasklist
buttonLoad_Click(null, null);
conInfo.sTftpIP = formConfiguration.Tftp_IP; conInfo.sTftpIP = formConfiguration.Tftp_IP;
conInfo.sSftpIP = formConfiguration.Sftp_IP; conInfo.sSftpIP = formConfiguration.Sftp_IP;
conInfo.sSftpUsername = formConfiguration.Sftp_Username; conInfo.sSftpUsername = formConfiguration.Sftp_Username;
conInfo.sSftpPassword = formConfiguration.Sftp_Password; conInfo.sSftpPassword = formConfiguration.Sftp_Password;
dataGridViewTask.Refresh();
} }
private void dataGridViewTask_CellClick(object sender, DataGridViewCellEventArgs e) private void dataGridViewTask_CellClick(object sender, DataGridViewCellEventArgs e)
@@ -451,50 +512,43 @@ namespace SSH_Test
{ {
profile = Profiles.Find(x => x.ProfileName == currentTask.sProfile.ToString()); profile = Profiles.Find(x => x.ProfileName == currentTask.sProfile.ToString());
if (profile !=null && profile.ProfileName != "Do nothing")
// print out task
log.Info(string.Format("Current task profile {0}:", currentTask.sTaskDevice.ToString()));
foreach (string c in profile.ProfileCommands)
log.Info(c);
//hostInfo.Commands = profile.ProfileCommands;
//check if task has parameters and get parameters list
//foreach (string c in profile.ProfileParameters)
//{
// if (currentTask.dParameters[c] == "")
// currentTask.dParameters.Add(c, "");
//}
if (profile.ProfileParameters.Length > 0)
{ {
//Get Values for Parameters // print out task
FormParameters formParameter = new FormParameters(currentTask.dParameters, richTextBoxOutput.Text, log.Info(string.Format("Current task profile {0}:", currentTask.sTaskDevice.ToString()));
string.Format("{0}: {1}", currentTask.sTaskDescription, currentTask.sProfile));
if (formParameter.ShowDialog() == DialogResult.Cancel) foreach (string c in profile.ProfileCommands)
log.Info(c);
if (profile.ProfileParameters.Length > 0)
{ {
log.Info("formParameter returns with Cancel"); //Get Values for Parameters
break; FormParameters formParameter = new FormParameters(currentTask.dParameters, richTextBoxOutput.Text,
string.Format("{0}: {1}", currentTask.sTaskDescription, currentTask.sProfile));
if (formParameter.ShowDialog() == DialogResult.Cancel)
{
log.Info("formParameter returns with Cancel");
break;
}
//foreach (var c in currentTask.dParameters)
// log.Info(string.Format("Parameter {0}: {1}", c.Key, c.Value));
} }
//foreach (var c in currentTask.dParameters) //clear richtextboxoutput
// log.Info(string.Format("Parameter {0}: {1}", c.Key, c.Value)); richTextBoxOutput.Clear();
// Run a Task and display result on the textbox
richTextBoxOutput.AppendText(Utilities.RunaTask(currentTask, profile, conInfo, aes));
richTextBoxOutput.SelectionStart = richTextBoxOutput.Text.Length;
richTextBoxOutput.ScrollToCaret();
//update Status LastRun
string ttt = DateTime.Now.ToString(("HH:mm:ss"));
dataGridViewTask.Rows[e.RowIndex].Cells[6].Value = ttt;
} }
else
//clear richtextboxoutput log.Info("Profile = Null");
richTextBoxOutput.Clear();
// Run a Task and display result on the textbox
richTextBoxOutput.AppendText(Utilities.RunaTask(currentTask, profile, conInfo,aes));
richTextBoxOutput.SelectionStart = richTextBoxOutput.Text.Length;
richTextBoxOutput.ScrollToCaret();
//update Status LastRun
string ttt = DateTime.Now.ToString(("HH:mm:ss"));
dataGridViewTask.Rows[e.RowIndex].Cells[6].Value = ttt;
} }
catch catch
{ {
@@ -547,7 +601,12 @@ namespace SSH_Test
break; break;
case 1: case 1:
if (dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)
{
dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
}
Tasks[e.RowIndex].sTaskDescription = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; Tasks[e.RowIndex].sTaskDescription = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break; break;
case 2: case 2:
Tasks[e.RowIndex].sTaskDevice = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; Tasks[e.RowIndex].sTaskDevice = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
@@ -556,7 +615,8 @@ namespace SSH_Test
break; break;
case 4: case 4:
Tasks[e.RowIndex].bTaskSelect = (bool)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; if ((string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
Tasks[e.RowIndex].bTaskSelect = (bool)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break; break;
case 5: case 5:
@@ -567,18 +627,21 @@ namespace SSH_Test
Tasks[e.RowIndex].sProfile = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; Tasks[e.RowIndex].sProfile = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
else else
Tasks[e.RowIndex].sProfile = "Do nothing"; Tasks[e.RowIndex].sProfile = "Do nothing";
if (!Profiles.Any())
profile = Profiles.Find(x => x.ProfileName == Tasks[e.RowIndex].sProfile.ToString());
if ( (profile != null) && (profile.ProfileParameters.Length > 0))
{ {
//clear task profile parameters first profile = Profiles.Find(x => x.ProfileName == Tasks[e.RowIndex].sProfile.ToString());
Tasks[e.RowIndex].dParameters.Clear(); if ((profile != null) && (profile.ProfileParameters.Length > 0))
//add new parameters
foreach (string c in profile.ProfileParameters)
{ {
Tasks[e.RowIndex].dParameters.Add(c, ""); //clear task profile parameters first
Tasks[e.RowIndex].dParameters.Clear();
//add new parameters
foreach (string c in profile.ProfileParameters)
{
Tasks[e.RowIndex].dParameters.Add(c, "");
}
} }
} }
log.Info(string.Format("Task {0}, profile {1}", e.RowIndex, Tasks[e.RowIndex].sProfile)); log.Info(string.Format("Task {0}, profile {1}", e.RowIndex, Tasks[e.RowIndex].sProfile));
@@ -752,11 +815,23 @@ namespace SSH_Test
try try
{ {
aes.Key = Convert.FromBase64String(formParameter.dParameters["AES string"]); aes.Key = Convert.FromBase64String(formParameter.dParameters["AES string"]);
//try reloading profile.json //try reloading Profilefilename
Profiles.Clear(); Profiles.Clear();
Profiles = utilities.LoadProfile("profile.json", aes); Profiles = utilities.LoadProfile(Profilefilename, aes);
// Configure Profile list to dropdown menu // Configure Profile list to dropdown menu, first to check if Profiles is empty
if (!Profiles.Any())
{
//load "do nothing" to Profiles
Profile temp = new Profile();
temp.ProfileType = "";
temp.ProfileName = "Do nothing";
temp.ProfileCommands = new string[] { "echo Do nothing" };
temp.ProfileParameters = new string[]{ "" };
Profiles.Add(temp);
}
try try
{ {
foreach (Profile p in Profiles) foreach (Profile p in Profiles)
@@ -773,7 +848,7 @@ namespace SSH_Test
{ {
log.Error(ex.Message); log.Error(ex.Message);
} }
dataGridViewTask.Refresh(); dataGridViewTask.Refresh();
} }
catch catch
@@ -782,6 +857,9 @@ namespace SSH_Test
} }
} }
//reload tasklist
buttonLoad_Click(null, null);
} }
} }

BIN
bin/Debug/FHT.exe Normal file

Binary file not shown.

31
bin/Debug/FHT.exe.config Normal file
View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.2" newVersion="10.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.6.0" newVersion="4.1.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.2" newVersion="10.0.0.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

BIN
bin/Debug/FHT.pdb Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="BouncyCastle.Cryptography" version="2.6.2" targetFramework="net48" /> <package id="BouncyCastle.Cryptography" version="2.6.2" targetFramework="net48" />
<package id="log4net" version="3.2.0" targetFramework="net48" /> <package id="log4net" version="3.3.1" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.2" targetFramework="net48" /> <package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.2" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net48" /> <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.3" targetFramework="net48" /> <package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.3" targetFramework="net48" />

View File

@@ -417,7 +417,10 @@
"ProfileCommands": [ "ProfileCommands": [
"racadm set iDRAC.Users.{Index}.Username {Username}", "racadm set iDRAC.Users.{Index}.Username {Username}",
"racadm set iDRAC.Users.{Index}.Password {Password}", "racadm set iDRAC.Users.{Index}.Password {Password}",
"racadm get iDRAC.Users.{Index}.Username" "racadm get iDRAC.Users.{Index}.Username",
"racadm set iDRAC.Users.{Index}.Enable 1",
"racadm set iDRAC.Users.{Index}.IpmiLanPriv 4"
], ],
"ProfileParameters": [ "{Index}", "{Username}", "{Password}" ] "ProfileParameters": [ "{Index}", "{Username}", "{Password}" ]
}, },
@@ -433,7 +436,11 @@
"racadm set iDRAC.Users.4.Password {Password 4}", "racadm set iDRAC.Users.4.Password {Password 4}",
"racadm get iDRAC.Users.2.Username", "racadm get iDRAC.Users.2.Username",
"racadm get iDRAC.Users.3.Username", "racadm get iDRAC.Users.3.Username",
"racadm get iDRAC.Users.4.Username" "racadm get iDRAC.Users.4.Username",
"racadm set iDRAC.Users.3.Enable 1",
"racadm set iDRAC.Users.3.IpmiLanPriv 4",
"racadm set iDRAC.Users.4.Enable 1",
"racadm set iDRAC.Users.4.IpmiLanPriv 4"
], ],
"ProfileParameters": [ "ProfileParameters": [
"{Password 2 root}", "{Password 2 root}",