From 6d024a7d78a683d895d5265fea1a778b71a8f4fe Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 15 Mar 2019 08:51:42 +0100 Subject: [PATCH] Fix gestione re-init e flush separato --- MConnectSDK/MConnectClient.cs | 29 ++++++++++++++---- MConnectSDK/MConnectSDK.csproj | 6 ++++ MConnectSDK/Utils.cs | 5 ++-- MConnectSDK/resources/userImg.png | Bin 0 -> 4459 bytes SharedAssemblyInfo.cs | 4 +-- TestClient/MainForm.Designer.cs | 47 +++++++++++++++++++----------- TestClient/MainForm.cs | 33 ++++++++++++++++++--- 7 files changed, 93 insertions(+), 31 deletions(-) create mode 100644 MConnectSDK/resources/userImg.png 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 0000000000000000000000000000000000000000..3706847f2f22ee1103bdf05e6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;n>el0yxJ?wv_pr8P6F=YUxVbIMiR(`gK@Q;vb zd-nM%Y9NB~_3Os~)Ik|m>(_Nx_L-`zKqUs;$JdvBG{C+=d=N-}G(C3iHJqvGQMb9~ z%{7v|O036|<_yDsy&>%7=vF3Uc5b-}Jp#7t9YPsx%g}BZ9CT*ytFjI}#xQrQC96eB$0QmQ%yK@3wc2vm%nmaq-D>XiRV^s*kI(IN zpW7IJ?)QkaAw=UnLu!;$5TWav!ubagam_D8r%Ifi+6iWJ+=m<-rG`^Ss{05O1mP?s zzOUYEl>0y`1yO~iYVuzukM3UUZ2a2z(qWa6gt&tR!_E;`N z-{Tr3qtZ$d&9}H-Tmsh@`#Eb77!4q)HNV)1Rvls6`Z{qD$omR6sNITlcWPJhbH7$X zt1tHk_wRymZKkwmiGZQuR((8jbu6u4WeS+vocBAh9Byc9YZt{W{Ah?Rl4>L5e0XR# zyRlq~ZE_w-sL*v5*5Ud3pW-7qnG~PD@#p^l;d`iW literal 0 HcmV?d00001 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(); + } } }