diff --git a/MConnectSDK/MConnectClient.cs b/MConnectSDK/MConnectClient.cs index 37f849e..fc06237 100644 --- a/MConnectSDK/MConnectClient.cs +++ b/MConnectSDK/MConnectClient.cs @@ -2,6 +2,7 @@ using NLog; using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Security.Cryptography; using System.Text; @@ -528,7 +529,14 @@ namespace MConnectSDK _currParam = param; ML = new memLayer(_currParam); } - + /// + /// Forza svuotamento di TUTTI i dati in REDIS + /// + public void forceRedisFlush() + { + // svuoto TUTTI i dati x INIT... + ML.redFlushKey(_currParam.module + "*", _currParam.defaultDb); + } /// /// Metodo di INIT della classe di comunicazione /// @@ -543,9 +551,6 @@ namespace MConnectSDK Result _currStatus = new Result(); await Task.Run(() => { - // svuoto TUTTI i dati x INIT... - ML.redFlushKey(_currParam.module + "*", _currParam.defaultDb); - enrollDate = DateTime.Now.AddYears(100); // iniziod a watchdog... setWatchdog(); // init output @@ -803,6 +808,18 @@ namespace MConnectSDK UserData _newUser; if (_currParam.testMode) { + Image userImg = Image.FromFile(@"resources\userImg.png"); +#if false + Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + using (Graphics graphics = Graphics.FromImage(bitmap)) + { + using (System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.DimGray)) + { + graphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 200)); + } + } +#endif + // cerco se li ho in cache... sennò genero ex-novo if (userListCache.Count > 0) { @@ -811,7 +828,7 @@ namespace MConnectSDK else { Random r = new Random(); - int numUser = r.Next(5, 50); + int numUser = 10; // genero tanti utenti random... for (int i = 0; i < numUser; i++) { @@ -823,7 +840,7 @@ namespace MConnectSDK Email = string.Format("USER_{0:000}@{1}.org", numUser + i, organizationCode), Cognome = string.Format("COGNOME_{0:000}", numUser + i), Nome = string.Format("NOME_{0:000}", numUser + i), - ImgUrl = string.Format(@"http://{{BASE_URL}}/{0}/user/{1}/image.png", organizationCode, numUser + i) + UserImage = userImg }; answ.Add(_newUser); } diff --git a/MConnectSDK/MConnectSDK.csproj b/MConnectSDK/MConnectSDK.csproj index e763e2e..8c53497 100644 --- a/MConnectSDK/MConnectSDK.csproj +++ b/MConnectSDK/MConnectSDK.csproj @@ -52,6 +52,7 @@ ..\packages\System.Diagnostics.PerformanceCounter.4.5.0\lib\net461\System.Diagnostics.PerformanceCounter.dll + ..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll @@ -98,5 +99,10 @@ + + + Always + + \ No newline at end of file diff --git a/MConnectSDK/Utils.cs b/MConnectSDK/Utils.cs index b2d595a..ed714da 100644 --- a/MConnectSDK/Utils.cs +++ b/MConnectSDK/Utils.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Drawing; namespace MConnectSDK { @@ -252,9 +253,9 @@ namespace MConnectSDK /// public string Nome = ""; /// - /// URL immagine utente (es http://{{BASE_URL}}/{{Org_code }}/user/img/{{IMG_URL}}.png)) + /// Immagine utente /// - public string ImgUrl = ""; + public Image UserImage = null; } /// /// Classe info UTENTE + pwd (cifrata...) x cache localedi login diff --git a/MConnectSDK/resources/userImg.png b/MConnectSDK/resources/userImg.png new file mode 100644 index 0000000..3706847 Binary files /dev/null and b/MConnectSDK/resources/userImg.png differ diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index cd03378..128acb4 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © Steamware 2019")] [assembly: AssemblyTrademark("_")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.0.1903.23")] -[assembly: AssemblyFileVersion("1.0.1903.23")] +[assembly: AssemblyVersion("1.0.1903.25")] +[assembly: AssemblyFileVersion("1.0.1903.25")] diff --git a/TestClient/MainForm.Designer.cs b/TestClient/MainForm.Designer.cs index 4f1ef2b..399efec 100644 --- a/TestClient/MainForm.Designer.cs +++ b/TestClient/MainForm.Designer.cs @@ -40,6 +40,7 @@ this.txtConfFile = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.btnGetClientStatus = new System.Windows.Forms.Button(); this.label10 = new System.Windows.Forms.Label(); this.txtPwd = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); @@ -59,7 +60,7 @@ this.pictBox = new System.Windows.Forms.PictureBox(); this.label6 = new System.Windows.Forms.Label(); this.lblConsole = new System.Windows.Forms.Label(); - this.btnGetClientStatus = new System.Windows.Forms.Button(); + this.btnFlush = new System.Windows.Forms.Button(); this.statusStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -174,6 +175,7 @@ // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.btnFlush); this.groupBox2.Controls.Add(this.btnGetClientStatus); this.groupBox2.Controls.Add(this.label10); this.groupBox2.Controls.Add(this.txtPwd); @@ -192,6 +194,16 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Metodi"; // + // btnGetClientStatus + // + this.btnGetClientStatus.Location = new System.Drawing.Point(525, 32); + this.btnGetClientStatus.Name = "btnGetClientStatus"; + this.btnGetClientStatus.Size = new System.Drawing.Size(111, 49); + this.btnGetClientStatus.TabIndex = 24; + this.btnGetClientStatus.Text = "getClientStatus"; + this.btnGetClientStatus.UseVisualStyleBackColor = true; + this.btnGetClientStatus.Click += new System.EventHandler(this.btnGetClientStatus_Click); + // // label10 // this.label10.AutoSize = true; @@ -238,7 +250,7 @@ // this.btnGetUserList.Location = new System.Drawing.Point(760, 32); this.btnGetUserList.Name = "btnGetUserList"; - this.btnGetUserList.Size = new System.Drawing.Size(118, 49); + this.btnGetUserList.Size = new System.Drawing.Size(111, 49); this.btnGetUserList.TabIndex = 18; this.btnGetUserList.Text = "getUserList"; this.btnGetUserList.UseVisualStyleBackColor = true; @@ -246,9 +258,9 @@ // // btnGetOrgCode // - this.btnGetOrgCode.Location = new System.Drawing.Point(636, 32); + this.btnGetOrgCode.Location = new System.Drawing.Point(643, 32); this.btnGetOrgCode.Name = "btnGetOrgCode"; - this.btnGetOrgCode.Size = new System.Drawing.Size(118, 49); + this.btnGetOrgCode.Size = new System.Drawing.Size(111, 49); this.btnGetOrgCode.TabIndex = 17; this.btnGetOrgCode.Text = "getOrgCode"; this.btnGetOrgCode.UseVisualStyleBackColor = true; @@ -256,9 +268,9 @@ // // btnTryAuth // - this.btnTryAuth.Location = new System.Drawing.Point(298, 32); + this.btnTryAuth.Location = new System.Drawing.Point(388, 32); this.btnTryAuth.Name = "btnTryAuth"; - this.btnTryAuth.Size = new System.Drawing.Size(118, 49); + this.btnTryAuth.Size = new System.Drawing.Size(111, 49); this.btnTryAuth.TabIndex = 16; this.btnTryAuth.Text = "tryAuthorize"; this.btnTryAuth.UseVisualStyleBackColor = true; @@ -266,9 +278,9 @@ // // btnInit // - this.btnInit.Location = new System.Drawing.Point(152, 32); + this.btnInit.Location = new System.Drawing.Point(123, 32); this.btnInit.Name = "btnInit"; - this.btnInit.Size = new System.Drawing.Size(118, 49); + this.btnInit.Size = new System.Drawing.Size(111, 49); this.btnInit.TabIndex = 15; this.btnInit.Text = "Init"; this.btnInit.UseVisualStyleBackColor = true; @@ -278,7 +290,7 @@ // this.btnResetParam.Location = new System.Drawing.Point(6, 32); this.btnResetParam.Name = "btnResetParam"; - this.btnResetParam.Size = new System.Drawing.Size(118, 49); + this.btnResetParam.Size = new System.Drawing.Size(111, 49); this.btnResetParam.TabIndex = 14; this.btnResetParam.Text = "Reset Param"; this.btnResetParam.UseVisualStyleBackColor = true; @@ -385,15 +397,15 @@ this.lblConsole.TabIndex = 7; this.lblConsole.Text = "..."; // - // btnGetClientStatus + // btnFlush // - this.btnGetClientStatus.Location = new System.Drawing.Point(512, 32); - this.btnGetClientStatus.Name = "btnGetClientStatus"; - this.btnGetClientStatus.Size = new System.Drawing.Size(118, 49); - this.btnGetClientStatus.TabIndex = 24; - this.btnGetClientStatus.Text = "getClientStatus"; - this.btnGetClientStatus.UseVisualStyleBackColor = true; - this.btnGetClientStatus.Click += new System.EventHandler(this.btnGetClientStatus_Click); + this.btnFlush.Location = new System.Drawing.Point(257, 32); + this.btnFlush.Name = "btnFlush"; + this.btnFlush.Size = new System.Drawing.Size(111, 49); + this.btnFlush.TabIndex = 25; + this.btnFlush.Text = "Flush REDIS"; + this.btnFlush.UseVisualStyleBackColor = true; + this.btnFlush.Click += new System.EventHandler(this.btnFlush_Click); // // MainForm // @@ -453,6 +465,7 @@ private System.Windows.Forms.TextBox txtUser; private System.Windows.Forms.CheckBox chkTestMode; private System.Windows.Forms.Button btnGetClientStatus; + private System.Windows.Forms.Button btnFlush; } } diff --git a/TestClient/MainForm.cs b/TestClient/MainForm.cs index 8f80feb..7300519 100644 --- a/TestClient/MainForm.cs +++ b/TestClient/MainForm.cs @@ -54,6 +54,14 @@ namespace TestClient private void fixDisplay() { + // verifico SE ho inizializzato x cui POSSO mostrare alcuni buttons... + bool enableBtn = (MCC != null); + btnFlush.Enabled = enableBtn; + btnTryAuth.Enabled = enableBtn; + btnGetClientStatus.Enabled = enableBtn; + btnGetOrgCode.Enabled = enableBtn; + btnGetUserList.Enabled = enableBtn; + btnTryUserLogin.Enabled = enableBtn; // controllo se visualizzare parametri di testing... bool showTP = chkTestMode.Checked; lblTokRet.Visible = showTP; @@ -271,6 +279,14 @@ namespace TestClient refreshRequestStatus(); }), ""); }); + // ora attendo get client... + await Task.Run(() => + { + synchronizationContext.Post(new SendOrPostCallback(o => + { + fixDisplay(); + }), ""); + }); } /// /// Recupero OrgCode @@ -335,10 +351,11 @@ namespace TestClient sb.AppendLine(string.Format("UserName: {0}", userList[0].Username)); sb.AppendLine(string.Format("Email: {0}", userList[0].Email)); sb.AppendLine(string.Format("Cognome: {0}", userList[0].Cognome)); - sb.AppendLine(string.Format("Nome: {0}", userList[0].Nome)); - sb.AppendLine(string.Format("ImgUrl: {0}", userList[0].ImgUrl)); lblConsole.Text = sb.ToString(); - + sb.AppendLine(string.Format("Nome: {0}", userList[0].Nome)); + // aggiungo IMG user... + pictBox.Image = userList[0].UserImage; + // refresh! refreshRequestStatus(); }), ""); }); @@ -375,7 +392,8 @@ namespace TestClient sb.AppendLine(string.Format("Email: {0}", userData.Email)); sb.AppendLine(string.Format("Cognome: {0}", userData.Cognome)); sb.AppendLine(string.Format("Nome: {0}", userData.Nome)); - sb.AppendLine(string.Format("ImgUrl: {0}", userData.ImgUrl)); + // aggiungo IMG user... + pictBox.Image = userList[0].UserImage; } else { @@ -600,5 +618,12 @@ namespace TestClient } #endregion + + private void btnFlush_Click(object sender, EventArgs e) + { + MCC.forceRedisFlush(); + MCC = null; + fixDisplay(); + } } }