Fix x problema token con GetLicense

This commit is contained in:
Samuele E. Locatelli
2021-02-17 12:13:45 +01:00
parent 81b5b208e4
commit 97409fac7e
5 changed files with 66 additions and 57 deletions
Vendored
+1 -1
View File
@@ -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}')
+41 -40
View File
@@ -716,46 +716,6 @@ namespace MConnectSDK
return answ;
}
/// <summary>
/// Ottiene i dati licenza da MaestroConnect
/// <summary>
/// <returns>Dati licenza<returns>
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<LicenseResponse>(taskRes.Result);
result = resp.result;
}
catch
{
result = null;
}
finally
{
Console.WriteLine(taskRes.Result.ToString());
}
}
return result;
}
/// <summary>
/// Parsing file di configurazione
/// <summary>
@@ -1512,6 +1472,47 @@ namespace MConnectSDK
return _currStatus;
}
/// <summary>
/// Ottiene i dati licenza da MaestroConnect
/// <summary>
/// <returns>Dati licenza<returns>
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<LicenseResponse>(taskRes.Result);
result = resp.result;
checkFixToken(taskRes.Result);
}
catch
{
result = null;
}
finally
{
Console.WriteLine(taskRes.Result.ToString());
}
}
return result;
}
/// <summary>
/// Recupera elenco user di Maestro connect registrati come ELIMINATI (erano importati ma NON SONO PIU' su MConnect)
/// <summary>
+12 -13
View File
@@ -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;
}
}
+11 -2
View File
@@ -155,6 +155,11 @@ namespace TestClient
lblConsole.Text = sb.ToString();
}
private void btnGetLic_Click(object sender, EventArgs e)
{
var result = MCC.GetLicenseMConnect();
}
/// <summary>
/// recupera codice organizzazione
/// </summary>
@@ -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
}
/// <summary>
@@ -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...
+1 -1
View File
@@ -13,4 +13,4 @@ conf:
Redis:
ConnectionString: "127.0.0.1,abortConnect=false,ssl=false"
DbIndex: 1
Module: "MCC"
Module: "MCC"