From 97409fac7e57014aa031fe927f054e7b4b6a15b7 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 17 Feb 2021 12:13:45 +0100 Subject: [PATCH] Fix x problema token con GetLicense --- Jenkinsfile | 2 +- MConnectSDK/MConnectClient.cs | 81 +++++++++++++++++---------------- TestClient/MainForm.Designer.cs | 25 +++++----- TestClient/MainForm.cs | 13 +++++- TestClient/mconnect.conf.yaml | 2 +- 5 files changed, 66 insertions(+), 57 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 90a2ae9..93e7f14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=223']) { + withEnv(['NEXT_BUILD_NUMBER=224']) { // env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.versionNumberBeta = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') diff --git a/MConnectSDK/MConnectClient.cs b/MConnectSDK/MConnectClient.cs index 313e3c6..80b6cd8 100644 --- a/MConnectSDK/MConnectClient.cs +++ b/MConnectSDK/MConnectClient.cs @@ -716,46 +716,6 @@ namespace MConnectSDK return answ; } - /// - /// Ottiene i dati licenza da MaestroConnect - /// - /// Dati licenza - private LicenseData GetLicenseMConnect() - { - LicenseData result = null; - - // controllo preliminare ping/cloud.. - if (pingOk && cloudOk) - { - //controllo con la chiamata della clientInfo... - var taskCliInfo = Task.Run(() => GetClientStatusAsync()); - taskCliInfo.Wait(); - - // parametri chiamata - string shortBaseUrl = BaseUrl.Replace(".com/api", ".com/clients"); - - string pageUrl = $"{shortBaseUrl}/{organizationCode}/machines/{MachineID}/license"; - // effettuo call - Console.WriteLine("-> " + verifResp.access_token); - var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl, verifResp.access_token)); - taskRes.Wait(); - try - { - var resp = JsonConvert.DeserializeObject(taskRes.Result); - result = resp.result; - } - catch - { - result = null; - } - finally - { - Console.WriteLine(taskRes.Result.ToString()); - } - } - return result; - } - /// /// Parsing file di configurazione /// @@ -1512,6 +1472,47 @@ namespace MConnectSDK return _currStatus; } + /// + /// Ottiene i dati licenza da MaestroConnect + /// + /// Dati licenza + public LicenseData GetLicenseMConnect() + { + LicenseData result = null; + + // controllo preliminare ping/cloud.. + if (pingOk && cloudOk) + { + // controllo con la chiamata della clientInfo... + var taskCliInfo = Task.Run(() => GetClientStatusAsync()); + taskCliInfo.Wait(); + + // parametri chiamata + string shortBaseUrl = BaseUrl.Replace(".com/api", ".com/clients"); + + string pageUrl = $"{shortBaseUrl}/{organizationCode}/machines/{MachineID}/license"; + // effettuo call + Console.WriteLine("-> " + verifResp.access_token); + var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl, verifResp.access_token)); + taskRes.Wait(); + try + { + var resp = JsonConvert.DeserializeObject(taskRes.Result); + result = resp.result; + checkFixToken(taskRes.Result); + } + catch + { + result = null; + } + finally + { + Console.WriteLine(taskRes.Result.ToString()); + } + } + return result; + } + /// /// Recupera elenco user di Maestro connect registrati come ELIMINATI (erano importati ma NON SONO PIU' su MConnect) /// diff --git a/TestClient/MainForm.Designer.cs b/TestClient/MainForm.Designer.cs index 398b5e8..7f8c14a 100644 --- a/TestClient/MainForm.Designer.cs +++ b/TestClient/MainForm.Designer.cs @@ -41,7 +41,7 @@ this.txtConfFile = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.btnStartClient = new System.Windows.Forms.Button(); + this.btnGetLic = new System.Windows.Forms.Button(); this.chkGetImg = new System.Windows.Forms.CheckBox(); this.btnTryEnroll = new System.Windows.Forms.Button(); this.btnDeleteUserCloud = new System.Windows.Forms.Button(); @@ -208,7 +208,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.btnStartClient); + this.groupBox2.Controls.Add(this.btnGetLic); this.groupBox2.Controls.Add(this.chkGetImg); this.groupBox2.Controls.Add(this.btnTryEnroll); this.groupBox2.Controls.Add(this.btnDeleteUserCloud); @@ -236,17 +236,16 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Metodi"; // - // btnStartClient + // btnGetLic // - this.btnStartClient.Location = new System.Drawing.Point(105, 47); - this.btnStartClient.Margin = new System.Windows.Forms.Padding(2); - this.btnStartClient.Name = "btnStartClient"; - this.btnStartClient.Size = new System.Drawing.Size(83, 26); - this.btnStartClient.TabIndex = 32; - this.btnStartClient.Text = "A2 GetClient"; - this.btnStartClient.UseVisualStyleBackColor = true; - this.btnStartClient.Visible = false; - this.btnStartClient.Click += new System.EventHandler(this.btnStartClient_Click); + this.btnGetLic.Location = new System.Drawing.Point(105, 47); + this.btnGetLic.Margin = new System.Windows.Forms.Padding(2); + this.btnGetLic.Name = "btnGetLic"; + this.btnGetLic.Size = new System.Drawing.Size(83, 26); + this.btnGetLic.TabIndex = 32; + this.btnGetLic.Text = "GetLicense"; + this.btnGetLic.UseVisualStyleBackColor = true; + this.btnGetLic.Click += new System.EventHandler(this.btnGetLic_Click); // // chkGetImg // @@ -616,7 +615,7 @@ private System.Windows.Forms.CheckBox chkGetImg; private System.Windows.Forms.Label lblUrl; private System.Windows.Forms.Label lblMachineId; - private System.Windows.Forms.Button btnStartClient; + private System.Windows.Forms.Button btnGetLic; } } diff --git a/TestClient/MainForm.cs b/TestClient/MainForm.cs index 8a7639b..7254fc0 100644 --- a/TestClient/MainForm.cs +++ b/TestClient/MainForm.cs @@ -155,6 +155,11 @@ namespace TestClient lblConsole.Text = sb.ToString(); } + private void btnGetLic_Click(object sender, EventArgs e) + { + var result = MCC.GetLicenseMConnect(); + } + /// /// recupera codice organizzazione /// @@ -272,7 +277,9 @@ namespace TestClient } private async void btnStartClient_Click(object sender, EventArgs e) - { // reset x iniziare... + { +#if false + // reset x iniziare... if (_cts != null) { _cts.Cancel(); @@ -291,6 +298,7 @@ namespace TestClient lblConsole.Text = sb.ToString(); // resetto aspetti grafici resetAuthData(); +#endif } /// @@ -684,8 +692,9 @@ namespace TestClient btnGetUserCreatedList.Enabled = enableBtn; btnImportUser.Enabled = enableBtn; btnDeleteUserHMI.Enabled = enableBtn; - // controllo se visualizzare parametri di testing... + btnGetLic.Enabled = enableBtn; + // controllo se visualizzare parametri di testing... if (reqStatus != null) { // se NON enrolled --> abilita tryAuth... diff --git a/TestClient/mconnect.conf.yaml b/TestClient/mconnect.conf.yaml index c2b306a..33ae0ec 100644 --- a/TestClient/mconnect.conf.yaml +++ b/TestClient/mconnect.conf.yaml @@ -13,4 +13,4 @@ conf: Redis: ConnectionString: "127.0.0.1,abortConnect=false,ssl=false" DbIndex: 1 - Module: "MCC" + Module: "MCC" \ No newline at end of file