Fix refresh
This commit is contained in:
+43
-34
@@ -32,10 +32,8 @@ namespace TestClient
|
||||
/// </summary>
|
||||
protected requestStatus reqStatus;
|
||||
/// <summary>
|
||||
/// Semaforo x auth
|
||||
/// Form principale
|
||||
/// </summary>
|
||||
protected bool doAuthSemap = false;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -49,6 +47,7 @@ namespace TestClient
|
||||
protected void myInit()
|
||||
{
|
||||
var clockTask = updateClockAsync();
|
||||
_cts = new CancellationTokenSource();
|
||||
fixDisplay();
|
||||
lblConsole.Text = "";
|
||||
}
|
||||
@@ -143,11 +142,11 @@ namespace TestClient
|
||||
// aggiorno console...
|
||||
lblConsole.Text = authData.outMessage;
|
||||
// verifico se sia AUTH (altrimenti NON mostro codice e QR...)
|
||||
if (reqStatus.isAuth)
|
||||
if (authData.hasAuth || reqStatus.isAuth)
|
||||
{
|
||||
var currColor = Color.Orange;
|
||||
// se fosse ANCHE enrolled cambio colore...
|
||||
if (reqStatus.isHmiEnrolled)
|
||||
if (authData.isEnrolled || reqStatus.isHmiEnrolled)
|
||||
{
|
||||
currColor = Color.Green;
|
||||
}
|
||||
@@ -173,18 +172,21 @@ namespace TestClient
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine("device_code:");
|
||||
sb.AppendLine(authData.deviceCode.ToString());
|
||||
sb.AppendLine("");
|
||||
sb.AppendLine("user_code:");
|
||||
sb.AppendLine(authData.userCode.ToString());
|
||||
sb.AppendLine("");
|
||||
lblRetData.Text = sb.ToString();
|
||||
// mostro QR-code
|
||||
Zen.Barcode.CodeQrBarcodeDraw qrcode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
|
||||
pictBox.Image = qrcode.Draw(authData.qrCode, 50);
|
||||
// mostro info SE disponibili...
|
||||
if (authData.userCode != "")
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine("device_code:");
|
||||
sb.AppendLine(authData.deviceCode.ToString());
|
||||
sb.AppendLine("");
|
||||
sb.AppendLine("user_code:");
|
||||
sb.AppendLine(authData.userCode.ToString());
|
||||
sb.AppendLine("");
|
||||
lblRetData.Text = sb.ToString();
|
||||
Zen.Barcode.CodeQrBarcodeDraw qrcode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
|
||||
pictBox.Image = qrcode.Draw(authData.qrCode, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +232,7 @@ namespace TestClient
|
||||
}), "");
|
||||
});
|
||||
}
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Task x AUTH
|
||||
/// </summary>
|
||||
@@ -298,7 +301,8 @@ namespace TestClient
|
||||
resetAuthData();
|
||||
}
|
||||
doAuthSemap = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Recupero OrgCode
|
||||
/// </summary>
|
||||
@@ -452,7 +456,10 @@ namespace TestClient
|
||||
lblConsole.Text = sb.ToString();
|
||||
// resetto aspetti grafici
|
||||
resetAuthData();
|
||||
doAuthSemap = false;
|
||||
if (_cts != null)
|
||||
{
|
||||
_cts.Cancel();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Simulazione auth (SE non abilitato)
|
||||
@@ -461,10 +468,15 @@ namespace TestClient
|
||||
/// <param name="e"></param>
|
||||
private async void btnTryAuth_Click(object sender, EventArgs e)
|
||||
{
|
||||
// init variabili accessorie x chiamata
|
||||
doAuthSemap = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
// init variabili accessorie x chiamata
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// elimino eventuali cancel presenti...
|
||||
if (_cts.IsCancellationRequested)
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
}
|
||||
CancellationToken token = _cts.Token;
|
||||
// gestione progress...
|
||||
var progressHandler = new Progress<userAuthData>(value =>
|
||||
{
|
||||
// mostro i dati SPECIFICI x AUTH...
|
||||
@@ -477,29 +489,26 @@ namespace TestClient
|
||||
// init in modalità Task based...
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (false)
|
||||
{
|
||||
var initObj = doOAuthCycle();
|
||||
}
|
||||
else
|
||||
{
|
||||
var initObj = MCC.doOAuthCycleTask(token, progress);
|
||||
}
|
||||
var initObj = MCC.doOAuthCycleTask(token, progress);
|
||||
});
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
//label2.Text = "Cancelled.";
|
||||
sb = new StringBuilder();
|
||||
sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine(string.Format("{0:HH.mm.ss.fff} | CANCELLED OAuth process", DateTime.Now));
|
||||
sb.AppendLine("--------------------------------------------------");
|
||||
lblConsole.Text = sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//label2.Text = ex.GetType().Name + ": " + ex.Message;
|
||||
}
|
||||
|
||||
// aggiorno log console
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// aggiorno log console
|
||||
sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine(string.Format("{0:HH.mm.ss.fff} | STARTING OAuth process", DateTime.Now));
|
||||
sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine(string.Format("{0:HH.mm.ss.fff} | START OAuth process", DateTime.Now));
|
||||
lblConsole.Text = sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user