-
-
-
-
-
+
@if (ShowScanBarcode)
{
-
+ @*
*@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
-
-
@if (oprsList.Count > 0)
{
@@ -44,24 +60,17 @@
-
+
-@if (rigaOpr != null)
-{
-
@($"{MsgServ.UserAuthKey} {MsgServ.MatrOpr}")
-}
-@*@if (done)
+@if (!string.IsNullOrEmpty(txtError))
{
-
Logged In
+
+ @txtError
+
}
-else
-{
-
Not logged in
-}*@
-
diff --git a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs
index 680b6091..d3d25f29 100644
--- a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs
+++ b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs
@@ -1,18 +1,61 @@
-using EgwCoreLib.Utils;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.WebUtilities;
+
//using MongoDB.Bson.IO;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using MP.Data.Services;
using Newtonsoft.Json;
+using ZXingBlazor.Components;
namespace MP_TAB_SERV.Pages
{
public partial class RegNewDevice
{
- [Inject]
- protected TabDataService TDService { get; set; } = null!;
+ #region Protected Fields
+
+ protected int expDays = 1;
+
+ protected DateTime vetoScan = DateTime.Now;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected string _authKey { get; set; } = "";
+
+ protected int _matrOpr { get; set; } = 0;
+
+ protected string authKey
+ {
+ get
+ {
+ return _authKey;
+ }
+ set
+ {
+ if (_authKey != value)
+ {
+ _authKey = value;
+ DoLogIn().ConfigureAwait(false);
+ }
+ }
+ }
+
+ protected string CurrOprTknLS { get; set; } = null!;
+
+ protected string CurrOprTknRedis { get; set; } = null!;
+
+ protected DateTime expDT { get; set; } = DateTime.Now;
+
+ protected int matrOpr
+ {
+ get
+ {
+ return _matrOpr;
+ }
+ set => _matrOpr = value;
+ }
[Inject]
protected MessageService MsgServ { get; set; } = null!;
@@ -22,62 +65,31 @@ namespace MP_TAB_SERV.Pages
protected List
oprsList { get; set; } = new List();
- protected override async Task OnInitializedAsync()
+ protected AnagOperatoriModel rigaOpr { get; set; } = null!;
+
+ [Inject]
+ protected TabDataService TDService { get; set; } = null!;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected async Task ToggleCodeScan()
{
await Task.Delay(1);
-
- //var currOpr = await TDService.LoginOperatore(matrOpr, authKey);
- //if (currOpr.MatrOpr != 0)
- //{
- // MsgServ.RigaOper = currOpr;
- //}
- TDService.ConfigGetVal("cookieDayExpire", ref expDays);
-
- expDT = DateTime.Now.AddDays(expDays);
-
- //CurrOprTknLS = await MsgServ.getCurrOperDtoAsync();
- //var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS);
- //CurrOprTknRedis = await TDService.OperatoreGetRedis(decodedUrl);
-
- //if (CurrOprTknRedis != "")
- //{
- // NavMan.NavigateTo("status-map");
- //}
-
- //if (MsgServ.RigaOper != null)
- //{
- // NavMan.NavigateTo("status-map", true);
- //}
- oprsList = await TDService.ElencoOperatori();
+ ShowScanBarcode = !ShowScanBarcode;
}
- protected int expDays = 1;
- protected int _matrOpr { get; set; } = 0;
- protected int matrOpr
+ protected string txtError = "";
+
+ [Inject]
+ protected SharedMemService SMServ { get; set; } = null!;
+
+ protected string Traduci(string lemma)
{
- get
- {
- //_matrOpr = MsgServ.MatrOpr;
- return _matrOpr;
- }
- set => _matrOpr = value;
+ return SMServ.Traduci($"EN_{lemma}".ToUpper());
}
- protected string _authKey { get; set; } = "";
- protected string authKey
- {
- get
- {
- //_authKey = MsgServ.UserAuthKey;
- return _authKey;
- }
- set => _authKey = value;
- }
- protected AnagOperatoriModel rigaOpr { get; set; } = null!;
- protected string CurrOprTknLS { get; set; } = null!;
- protected string CurrOprTknRedis { get; set; } = null!;
-
- protected DateTime expDT { get; set; } = DateTime.Now;
- protected async Task logIn()
+ protected async Task DoLogIn()
{
rigaOpr = await TDService.OperatoreSearch(matrOpr, authKey);
if (rigaOpr == null)
@@ -85,7 +97,7 @@ namespace MP_TAB_SERV.Pages
var deHash = TDService.DecryptData(authKey);
rigaOpr = await TDService.OperatoreSearch(matrOpr, deHash);
}
- if (rigaOpr != null)
+ if (rigaOpr != null && rigaOpr.MatrOpr > 0)
{
userTknDTO newUserTkn = new userTknDTO()
{
@@ -96,21 +108,27 @@ namespace MP_TAB_SERV.Pages
var jsonTkn = JsonConvert.SerializeObject(newUserTkn);
string hash = TDService.EncryptData(jsonTkn);
MsgServ.RigaOper = rigaOpr;
- await MsgServ.setCurrOperDtoAsync(hash);
+ await MsgServ.SetCurrOperDtoAsync(hash);
+ await MsgServ.SetLastMatrOprAsync(rigaOpr.MatrOpr);
await TDService.OperatoreSetRedis(matrOpr, hash);
NavMan.NavigateTo("status-map");
}
- //StateHasChanged();
+ else
+ {
+ txtError = Traduci("UserPwdMismatch");
+ authKey = "";
+ }
}
- protected async Task btnMode()
+ protected override async Task OnInitializedAsync()
{
- await Task.Delay(1);
- ShowScanBarcode = !ShowScanBarcode;
+ txtError = "";
+ matrOpr = await MsgServ.GetLastMatrOprAsync();
+ TDService.ConfigGetVal("cookieDayExpire", ref expDays);
+ expDT = DateTime.Now.AddDays(expDays);
+ oprsList = await TDService.ElencoOperatori();
}
- protected DateTime vetoScan = DateTime.Now;
-
protected async Task ScanDoneHandler(string value)
{
DateTime adesso = DateTime.Now;
@@ -137,64 +155,20 @@ namespace MP_TAB_SERV.Pages
authKey = Uri_authKey;
}
}
- await logIn();
+ await DoLogIn();
}
}
}
+ #endregion Protected Methods
+
+ #region Private Properties
+
private bool ShowScanBarcode { get; set; } = false;
+ protected BarcodeReader barcodeReaderCustom { get; set; } = null!;
- //private async Task ProcessBarcode(string Barcode)
- //{
- // if (OrderCode != Barcode)
- // {
- // await InvokeAsync(() =>
- // {
- // OrderCode = Barcode;
- // });
- // var ordine = await DataService.OrderGetByCode(Barcode);
- // if (ordine != null)
- // {
- // if (ordine.DtExecEnd > ordine.DtOrder)
- // {
- // await InvokeAsync(() =>
- // {
- // errorDescription = "Errore: ordine già completato";
- // });
- // await Task.Run(() =>
- // {
- // Thread.Sleep(3000);
- // forceReset();
- // });
- // }
- // else if (ordine.PlantId != SelPlantId)
- // {
- // await InvokeAsync(() =>
- // {
- // errorDescription = "Errore: ordine destinato ad altro impianto";
- // });
+ #endregion Private Properties
- // await Task.Run(() =>
- // {
- // Thread.Sleep(3000);
- // forceReset();
- // });
- // }
- // else
- // {
- // // salvo...
- // MessageService.SelPlantId = $"{SelPlantId}";
- // MessageService.SelOrderCode = Barcode;
- // // rimando a pagina load....
- // NavManager.NavigateTo($"GasStationLoad");
- // }
- // }
- // else
- // {
- // errorDescription = "Errore: ordine non trovato";
- // }
- // }
- //}
}
}
\ No newline at end of file
diff --git a/MP-TAB-SERV/Pages/User.razor b/MP-TAB-SERV/Pages/User.razor
index 9662f576..31e65078 100644
--- a/MP-TAB-SERV/Pages/User.razor
+++ b/MP-TAB-SERV/Pages/User.razor
@@ -85,9 +85,9 @@
ABOUT PAGE
-
+
@if (Width > 1021)
diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html
index 01708ddc..33605a51 100644
--- a/MP-TAB-SERV/Resources/ChangeLog.html
+++ b/MP-TAB-SERV/Resources/ChangeLog.html
@@ -1,6 +1,6 @@