diff --git a/MConnectSDK/MConnectClient.cs b/MConnectSDK/MConnectClient.cs
index d1c31f0..f8fa318 100644
--- a/MConnectSDK/MConnectClient.cs
+++ b/MConnectSDK/MConnectClient.cs
@@ -469,19 +469,40 @@ namespace MConnectSDK
#region metodi public
///
- /// Inizializzazione classe specificando tutti i parametri
+ /// Inizializzazione classe specificando il file di conf con i parametri
///
- /// ID Univoco macchina
- /// ID Applicativo UTE
- ///
- public MConnectClient(string MConnectID, string ClientID, confParam configurazione)
+ ///
+ public MConnectClient(string confFilePath = "mconnect.conf.yaml")
{
- _currParam = configurazione;
- _MConnectID = MConnectID;
- _ClientID = ClientID;
+ parseConfFile(confFilePath);
+
lg = LogManager.GetCurrentClassLogger();
ML = new memLayer(_currParam);
}
+ ///
+ /// Parsing file di configurazione
+ ///
+ ///
+ private void parseConfFile(string confFilePath)
+ {
+ // imposto val da file YAML...
+ _MConnectID = "AAAA" + confFilePath;
+ _ClientID = "BBB" + confFilePath;
+
+ int currDb = 1;
+ string baseConf = "";
+ confParam param = new confParam
+ {
+ redisConn = baseConf,
+ redisConnAdmin = baseConf + ",allowAdmin=true",
+ // hard coded x ora
+ testMode = true,
+ defaultDb = currDb
+ };
+
+ _currParam = param;
+ }
+
///
/// Metodo di INIT della classe di comunicazione
///
diff --git a/TestClient/MainForm.Designer.cs b/TestClient/MainForm.Designer.cs
index 9531aba..01459cb 100644
--- a/TestClient/MainForm.Designer.cs
+++ b/TestClient/MainForm.Designer.cs
@@ -34,18 +34,15 @@
this.lblClock = new System.Windows.Forms.ToolStripStatusLabel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSetRetVal = new System.Windows.Forms.Button();
- this.txtDb = new System.Windows.Forms.TextBox();
- this.label8 = new System.Windows.Forms.Label();
this.lblTokRet = new System.Windows.Forms.Label();
this.txtTokenRet = new System.Windows.Forms.TextBox();
- this.txtClientID = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.txtConnParam = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.chkTestMode = new System.Windows.Forms.CheckBox();
- this.txtMConnectID = new System.Windows.Forms.TextBox();
+ this.txtConfFile = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.txtPwd = new System.Windows.Forms.TextBox();
+ this.label9 = new System.Windows.Forms.Label();
+ this.txtUser = new System.Windows.Forms.TextBox();
this.btnTryUserLogin = new System.Windows.Forms.Button();
this.btnGetUserList = new System.Windows.Forms.Button();
this.btnGetOrgCode = new System.Windows.Forms.Button();
@@ -61,10 +58,7 @@
this.pictBox = new System.Windows.Forms.PictureBox();
this.label6 = new System.Windows.Forms.Label();
this.lblConsole = new System.Windows.Forms.Label();
- this.txtUser = new System.Windows.Forms.TextBox();
- this.label9 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.txtPwd = new System.Windows.Forms.TextBox();
+ this.chkTestMode = new System.Windows.Forms.CheckBox();
this.statusStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -109,27 +103,21 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.AutoSize = true;
this.groupBox1.Controls.Add(this.btnSetRetVal);
- this.groupBox1.Controls.Add(this.txtDb);
- this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.lblTokRet);
this.groupBox1.Controls.Add(this.txtTokenRet);
- this.groupBox1.Controls.Add(this.txtClientID);
- this.groupBox1.Controls.Add(this.label7);
- this.groupBox1.Controls.Add(this.txtConnParam);
- this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.chkTestMode);
- this.groupBox1.Controls.Add(this.txtMConnectID);
+ this.groupBox1.Controls.Add(this.txtConfFile);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Location = new System.Drawing.Point(13, 12);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(982, 102);
+ this.groupBox1.Size = new System.Drawing.Size(982, 74);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection Parameters";
//
// btnSetRetVal
//
- this.btnSetRetVal.Location = new System.Drawing.Point(785, 30);
+ this.btnSetRetVal.Location = new System.Drawing.Point(692, 30);
this.btnSetRetVal.Name = "btnSetRetVal";
this.btnSetRetVal.Size = new System.Drawing.Size(75, 23);
this.btnSetRetVal.TabIndex = 27;
@@ -137,27 +125,10 @@
this.btnSetRetVal.UseVisualStyleBackColor = true;
this.btnSetRetVal.Click += new System.EventHandler(this.btnSetRetVal_Click);
//
- // txtDb
- //
- this.txtDb.Location = new System.Drawing.Point(454, 59);
- this.txtDb.Name = "txtDb";
- this.txtDb.Size = new System.Drawing.Size(68, 22);
- this.txtDb.TabIndex = 26;
- this.txtDb.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(422, 61);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(26, 17);
- this.label8.TabIndex = 25;
- this.label8.Text = "Db";
- //
// lblTokRet
//
this.lblTokRet.AutoSize = true;
- this.lblTokRet.Location = new System.Drawing.Point(642, 32);
+ this.lblTokRet.Location = new System.Drawing.Point(549, 32);
this.lblTokRet.Name = "lblTokRet";
this.lblTokRet.Size = new System.Drawing.Size(85, 17);
this.lblTokRet.TabIndex = 24;
@@ -165,70 +136,27 @@
//
// txtTokenRet
//
- this.txtTokenRet.Location = new System.Drawing.Point(736, 29);
+ this.txtTokenRet.Location = new System.Drawing.Point(643, 29);
this.txtTokenRet.Name = "txtTokenRet";
this.txtTokenRet.Size = new System.Drawing.Size(42, 22);
this.txtTokenRet.TabIndex = 23;
this.txtTokenRet.Text = "403";
//
- // txtClientID
+ // txtConfFile
//
- this.txtClientID.Location = new System.Drawing.Point(354, 30);
- this.txtClientID.Name = "txtClientID";
- this.txtClientID.Size = new System.Drawing.Size(168, 22);
- this.txtClientID.TabIndex = 20;
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(295, 33);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(56, 17);
- this.label7.TabIndex = 19;
- this.label7.Text = "ClientID";
- //
- // txtConnParam
- //
- this.txtConnParam.Location = new System.Drawing.Point(103, 58);
- this.txtConnParam.Name = "txtConnParam";
- this.txtConnParam.Size = new System.Drawing.Size(313, 22);
- this.txtConnParam.TabIndex = 15;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(35, 62);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(61, 17);
- this.label4.TabIndex = 14;
- this.label4.Text = "connPar";
- //
- // chkTestMode
- //
- this.chkTestMode.AutoSize = true;
- this.chkTestMode.Location = new System.Drawing.Point(528, 29);
- this.chkTestMode.Name = "chkTestMode";
- this.chkTestMode.Size = new System.Drawing.Size(97, 21);
- this.chkTestMode.TabIndex = 13;
- this.chkTestMode.Text = "Test Mode";
- this.chkTestMode.UseVisualStyleBackColor = true;
- this.chkTestMode.Click += new System.EventHandler(this.chkTestMode_Click);
- //
- // txtMConnectID
- //
- this.txtMConnectID.Location = new System.Drawing.Point(103, 30);
- this.txtMConnectID.Name = "txtMConnectID";
- this.txtMConnectID.Size = new System.Drawing.Size(185, 22);
- this.txtMConnectID.TabIndex = 12;
+ this.txtConfFile.Location = new System.Drawing.Point(103, 30);
+ this.txtConfFile.Name = "txtConfFile";
+ this.txtConfFile.Size = new System.Drawing.Size(313, 22);
+ this.txtConfFile.TabIndex = 12;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 33);
this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(84, 17);
+ this.label3.Size = new System.Drawing.Size(63, 17);
this.label3.TabIndex = 11;
- this.label3.Text = "MConnectID";
+ this.label3.Text = "Conf File";
//
// groupBox2
//
@@ -244,13 +172,45 @@
this.groupBox2.Controls.Add(this.btnTryAuth);
this.groupBox2.Controls.Add(this.btnInit);
this.groupBox2.Controls.Add(this.btnResetParam);
- this.groupBox2.Location = new System.Drawing.Point(13, 119);
+ this.groupBox2.Location = new System.Drawing.Point(13, 88);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(982, 100);
this.groupBox2.TabIndex = 14;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Metodi";
//
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(822, 45);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(33, 17);
+ this.label10.TabIndex = 23;
+ this.label10.Text = "pwd";
+ //
+ // txtPwd
+ //
+ this.txtPwd.Location = new System.Drawing.Point(874, 42);
+ this.txtPwd.Name = "txtPwd";
+ this.txtPwd.Size = new System.Drawing.Size(100, 22);
+ this.txtPwd.TabIndex = 22;
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Location = new System.Drawing.Point(822, 16);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(36, 17);
+ this.label9.TabIndex = 21;
+ this.label9.Text = "user";
+ //
+ // txtUser
+ //
+ this.txtUser.Location = new System.Drawing.Point(874, 13);
+ this.txtUser.Name = "txtUser";
+ this.txtUser.Size = new System.Drawing.Size(100, 22);
+ this.txtUser.TabIndex = 20;
+ //
// btnTryUserLogin
//
this.btnTryUserLogin.Location = new System.Drawing.Point(825, 70);
@@ -329,12 +289,12 @@
this.tableLayoutPanel1.Controls.Add(this.pictBox, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.label6, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.lblConsole, 3, 1);
- this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 225);
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 191);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10.90909F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 89.09091F));
- this.tableLayoutPanel1.Size = new System.Drawing.Size(983, 457);
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(983, 491);
this.tableLayoutPanel1.TabIndex = 15;
//
// label1
@@ -367,7 +327,7 @@
// lblReqStatus
//
this.lblReqStatus.AutoSize = true;
- this.lblReqStatus.Location = new System.Drawing.Point(3, 49);
+ this.lblReqStatus.Location = new System.Drawing.Point(3, 53);
this.lblReqStatus.Name = "lblReqStatus";
this.lblReqStatus.Size = new System.Drawing.Size(20, 17);
this.lblReqStatus.TabIndex = 3;
@@ -376,7 +336,7 @@
// lblRetData
//
this.lblRetData.AutoSize = true;
- this.lblRetData.Location = new System.Drawing.Point(199, 49);
+ this.lblRetData.Location = new System.Drawing.Point(199, 53);
this.lblRetData.Name = "lblRetData";
this.lblRetData.Size = new System.Drawing.Size(20, 17);
this.lblRetData.TabIndex = 4;
@@ -385,9 +345,9 @@
// pictBox
//
this.pictBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictBox.Location = new System.Drawing.Point(395, 52);
+ this.pictBox.Location = new System.Drawing.Point(395, 56);
this.pictBox.Name = "pictBox";
- this.pictBox.Size = new System.Drawing.Size(288, 402);
+ this.pictBox.Size = new System.Drawing.Size(288, 432);
this.pictBox.TabIndex = 5;
this.pictBox.TabStop = false;
//
@@ -406,43 +366,22 @@
this.lblConsole.BackColor = System.Drawing.SystemColors.Desktop;
this.lblConsole.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblConsole.ForeColor = System.Drawing.Color.Lime;
- this.lblConsole.Location = new System.Drawing.Point(689, 49);
+ this.lblConsole.Location = new System.Drawing.Point(689, 53);
this.lblConsole.Name = "lblConsole";
- this.lblConsole.Size = new System.Drawing.Size(291, 408);
+ this.lblConsole.Size = new System.Drawing.Size(291, 438);
this.lblConsole.TabIndex = 7;
this.lblConsole.Text = "...";
//
- // txtUser
+ // chkTestMode
//
- this.txtUser.Location = new System.Drawing.Point(874, 13);
- this.txtUser.Name = "txtUser";
- this.txtUser.Size = new System.Drawing.Size(100, 22);
- this.txtUser.TabIndex = 20;
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(822, 16);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(36, 17);
- this.label9.TabIndex = 21;
- this.label9.Text = "user";
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(822, 45);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(33, 17);
- this.label10.TabIndex = 23;
- this.label10.Text = "pwd";
- //
- // txtPwd
- //
- this.txtPwd.Location = new System.Drawing.Point(874, 42);
- this.txtPwd.Name = "txtPwd";
- this.txtPwd.Size = new System.Drawing.Size(100, 22);
- this.txtPwd.TabIndex = 22;
+ this.chkTestMode.AutoSize = true;
+ this.chkTestMode.Location = new System.Drawing.Point(435, 29);
+ this.chkTestMode.Name = "chkTestMode";
+ this.chkTestMode.Size = new System.Drawing.Size(97, 21);
+ this.chkTestMode.TabIndex = 13;
+ this.chkTestMode.Text = "Test Mode";
+ this.chkTestMode.UseVisualStyleBackColor = true;
+ this.chkTestMode.Click += new System.EventHandler(this.chkTestMode_Click);
//
// MainForm
//
@@ -475,11 +414,8 @@
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
private System.Windows.Forms.ToolStripStatusLabel lblClock;
private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.CheckBox chkTestMode;
- private System.Windows.Forms.TextBox txtMConnectID;
+ private System.Windows.Forms.TextBox txtConfFile;
private System.Windows.Forms.Label label3;
- private System.Windows.Forms.TextBox txtConnParam;
- private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnInit;
private System.Windows.Forms.Button btnResetParam;
@@ -496,17 +432,14 @@
private System.Windows.Forms.PictureBox pictBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label lblConsole;
- private System.Windows.Forms.TextBox txtClientID;
- private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label lblTokRet;
private System.Windows.Forms.TextBox txtTokenRet;
- private System.Windows.Forms.TextBox txtDb;
- private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button btnSetRetVal;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtUser;
+ private System.Windows.Forms.CheckBox chkTestMode;
}
}
diff --git a/TestClient/MainForm.cs b/TestClient/MainForm.cs
index 52082cb..3f82158 100644
--- a/TestClient/MainForm.cs
+++ b/TestClient/MainForm.cs
@@ -210,15 +210,18 @@ namespace TestClient
#region metodi chiamate TASK / async
///
- /// task x INIT
+ /// Task x INIT da file di conf
///
- ///
+ ///
///
- private async Task doInitAsync(confParam param)
+ private async Task doInitAsync(string confFilePath)
{
await Task.Run(() =>
{
- MCC = new MConnectClient(txtMConnectID.Text.Trim(), txtClientID.Text.Trim(), param);
+
+
+
+ MCC = new MConnectClient(confFilePath);
// elimino eventuali cancel presenti...
if (_cts.IsCancellationRequested)
@@ -359,12 +362,9 @@ namespace TestClient
///
private void btnResetParam_Click(object sender, EventArgs e)
{
- txtMConnectID.Text = "MCID-0000-1234-5678";
- txtClientID.Text = "HMI_TEST_CLI";
chkTestMode.Checked = true;
- txtConnParam.Text = "127.0.0.1,abortConnect=false,ssl=false";
+ txtConfFile.Text = "mconnect.conf.yaml";
txtTokenRet.Text = "403";
- txtDb.Text = "1";
fixDisplay();
}
///
@@ -392,20 +392,12 @@ namespace TestClient
///
private async void btnInit_Click(object sender, EventArgs e)
{
- int currDb = 0;
- int.TryParse(txtDb.Text.Trim(), out currDb);
- confParam param = new confParam
- {
- redisConn = txtConnParam.Text,
- redisConnAdmin = txtConnParam.Text + ",allowAdmin=true",
- testMode = chkTestMode.Checked,
- defaultDb = currDb
- };
+
// init in modalità Task based...
await Task.Run(() =>
{
- var initObj = doInitAsync(param);
+ var initObj = doInitAsync(txtConfFile.Text.Trim());
});
// aggiorno log console
diff --git a/TestClient/mconnect.conf.yaml b/TestClient/mconnect.conf.yaml
index 3bb7a9b..c52e423 100644
--- a/TestClient/mconnect.conf.yaml
+++ b/TestClient/mconnect.conf.yaml
@@ -1,9 +1,9 @@
#File di conf per MConnectClientSDK
conf:
- Client_ID: “UTE_TEST”
- MachineID: “ABCD000231234”
+ Client_ID: "HMI_TEST_CLI"
+ MachineID: "MCID-0009-1234-5678"
MemoryLayer:
Redis:
- ConnectionString: “127.0.0.1,abortConnect=false,ssl=false“
+ ConnectionString: "127.0.0.1,abortConnect=false,ssl=false"
DbIndex: 1
- Module: “MCC”
\ No newline at end of file
+ Module: "MCC"
\ No newline at end of file