Riorganizzazione lettura parametri tipo login

This commit is contained in:
Samuele Locatelli
2024-01-05 08:23:24 +01:00
parent 2634f60fd1
commit dc4b2b5db5
8 changed files with 149 additions and 129 deletions
+4 -5
View File
@@ -1,23 +1,22 @@
<div class="row bg-dark text-light px-2 small">
<div class="col-4 text-left text-nowrap pe-0">
<b>MP-TAB3 @(DateTime.Today.Year)</b> <span class="small" style="font-size:0.6rem;">v.@version</span>
<b>MP-TAB3 @(adesso.Year)</b> <span class="small" style="font-size:0.6rem;">v.@version</span>
</div>
<div class="col-4 d-flex flex-column justify-content-center">
@if (typeScadLogin > 0)
@if (TypeScadLogin > 0)
{
@if (CurrExpVal < 0)
{
<div class="text-danger">TIMER SCADUTO!</div>
<div class="alert alert-danger text-center p-0">TIMER SCADUTO!</div>
}
else
{
<ProgBar currVal="@CurrExpVal" maxVal="@MaxExpVal" singleLine="true" baseUM="m" yelLim="@yLimit" redLim="@rLimit"></ProgBar>
}
}
</div>
<div class="col-4 text-end d-flex align-items-center justify-content-end">
<span class="small">@($"{DateTime.Now:HH:mm:ss}")</span> | <a class="text-light text-decoration-none" href="https://www.egalware.com/" target="_blank"><img class="img-fluid" width="16" src="images/LogoEgw.png" /> Egalware </a>
<span class="small">@($"{adesso:HH:mm:ss}")</span> | <a class="text-light text-decoration-none" href="https://www.egalware.com/" target="_blank"><img class="img-fluid" width="16" src="images/LogoEgw.png" /> Egalware </a>
</div>
</div>
+83 -76
View File
@@ -6,6 +6,16 @@ namespace MP_TAB3.Components
{
public partial class CmpFooter : IDisposable
{
#region Public Properties
[Parameter]
public int DtScadLogin { get; set; } = 0;
[Parameter]
public int TypeScadLogin { get; set; } = -1;
#endregion Public Properties
#region Public Methods
public void Dispose()
@@ -18,12 +28,79 @@ namespace MP_TAB3.Components
}
}
public double CurrExpVal { get; set; } = 50;
public double MaxExpVal { get; set; } = 100;
public double yLimit { get; set; } = 30;
public double rLimit { get; set; } = 10;
#endregion Public Methods
public string timeUm
#region Protected Properties
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected SharedMemService SMServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
{
var pUpd = Task.Run(async () =>
{
if (TypeScadLogin > 0)
{
var diffOfTime = DateTime.Now.Subtract(MsgServ.dtLastAction);
CurrExpVal = MaxExpVal - diffOfTime.TotalMinutes;
}
else
{
}
adesso = DateTime.Now;
await InvokeAsync(() => StateHasChanged());
});
pUpd.Wait();
}
protected override void OnParametersSet()
{
var rawVers = typeof(Program).Assembly.GetName().Version;
version = rawVers != null ? rawVers : new Version("0.0.0.0");
DtScadLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
MaxExpVal = DtScadLogin;
yLimit = MaxExpVal * 0.3;
rLimit = MaxExpVal * 0.1;
StartTimer();
}
protected void StartTimer()
{
int tOutPeriod = 1000;
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
aTimer.Enabled = true;
aTimer.Start();
}
#endregion Protected Methods
#region Private Fields
private DateTime adesso = DateTime.Now;
private System.Timers.Timer aTimer = null!;
private Version version = null!;
#endregion Private Fields
#region Private Properties
private double CurrExpVal { get; set; } = 50;
private double MaxExpVal { get; set; } = 100;
private double rLimit { get; set; } = 10;
private string timeUm
{
get
{
@@ -40,77 +117,7 @@ namespace MP_TAB3.Components
}
}
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
{
var pUpd = Task.Run(async () =>
{
if (typeScadLogin > 0)
{
var diffOfTime = DateTime.Now.Subtract(MsgServ.dtLastAction);
CurrExpVal = MaxExpVal - diffOfTime.TotalMinutes;
}
await InvokeAsync(() => StateHasChanged());
});
pUpd.Wait();
}
public void StartTimer()
{
int tOutPeriod = 1000;
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
aTimer.Enabled = true;
aTimer.Start();
}
#endregion Public Methods
#region Protected Properties
protected int dtScadLogin { get; set; } = 0;
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected SharedMemService SMServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected int typeScadLogin { get; set; } = 0;
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
var rawVers = typeof(Program).Assembly.GetName().Version;
version = rawVers != null ? rawVers : new Version("0.0.0.0");
typeScadLogin = SMServ.GetConfInt("TAB_TypeScadLogin");
dtScadLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
MaxExpVal = dtScadLogin;
yLimit = MaxExpVal * 0.3;
rLimit = MaxExpVal * 0.1;
StartTimer();
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private System.Timers.Timer aTimer = null!;
private Version version = null!;
#endregion Private Fields
#region Private Properties
private int dtTimerScadenzaLogin { get; set; } = 0;
private double yLimit { get; set; } = 30;
#endregion Private Properties
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2401.419</Version>
<Version>6.16.2401.508</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB3</RootNamespace>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2401.419</h4>
<h4>Versione: 6.16.2401.508</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2401.419
6.16.2401.508
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2401.419</version>
<version>6.16.2401.508</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -24,5 +24,5 @@
</main>
</div>
<div class="fixed-bottom">
<CmpFooter></CmpFooter>
<CmpFooter TypeScadLogin="@typeScadLogin" DtScadLogin="@dtScadLogin"></CmpFooter>
</div>
+57 -43
View File
@@ -27,6 +27,13 @@ namespace MP_TAB3.Shared
#region Protected Properties
protected string bodyType
{
get => pageOk ? "mainBodyNoSide" : "mainBody";
}
protected Guid currDevGuid { get; set; } = new Guid();
/// <summary>
/// Livello corrente del menu
/// </summary>
@@ -37,11 +44,19 @@ namespace MP_TAB3.Shared
/// </summary>
protected List<LinkMenu> CurrMenuItems { get; set; } = new List<LinkMenu>();
/// <summary>
/// Scadenza del login
/// </summary>
protected int dtScadLogin { get; set; } = 0;
protected bool HideMenu
{
get => NavMan.Uri.Contains("reg-new-device");
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected ListSelectDataSrv MDataService { get; set; } = null!;
@@ -54,21 +69,6 @@ namespace MP_TAB3.Shared
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected TabDataService TDataService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected string bodyType
{
get => pageOk ? "mainBodyNoSide" : "mainBody";
}
protected bool pageOk
{
get
@@ -78,26 +78,19 @@ namespace MP_TAB3.Shared
}
}
[Inject]
protected TabDataService TDataService { get; set; } = null!;
protected async Task handleBodyClick()
{
await Task.Delay(1);
if (!pageOk)
{
await checkDtDiff2Logout();
}
}
private int MatrOpr
{
get => MsgServ.MatrOpr;
}
/// <summary>
/// Tipo scadenza login, a -1 di default così da NON avere problemi in caso di setuop errato...
/// Tipo scadenza login Postoa -1 di default così da NON avere problemi in caso di setuop errato...
/// </summary>
protected int typeScadLogin { get; set; } = -1;
protected int dtScadLogin { get; set; } = 0;
protected Guid currDevGuid { get; set; } = new Guid();
protected bool userIsOk { get; set; } = false;
#endregion Protected Properties
#region Protected Methods
protected async Task checkDtDiff2Logout()
{
@@ -135,53 +128,65 @@ namespace MP_TAB3.Shared
}
}
break;
case 2:
if (tsDeltaAct.TotalMinutes >= dtScadLogin)
{
NavMan.NavigateTo("logout");
}
break;
case 0:
case -1:
await ReloadMemStor();
typeScadLogin = MStor.GetConfInt("TAB_TypeScadLogin");
dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin");
break;
}
}
protected async Task checkIfUserOk(bool isOk)
{
await Task.Delay(1);
userIsOk = isOk;
}
protected async Task handleBodyClick()
{
await Task.Delay(1);
if (!pageOk)
{
await checkDtDiff2Logout();
}
}
/// <summary>
/// Init struttura dati
/// </summary>
/// <returns></returns>
protected override async Task OnInitializedAsync()
{
typeScadLogin = MStor.GetConfInt("TAB_TypeScadLogin");
dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin");
NavMan.LocationChanged += HandleLocationChanged;
currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
// verifica preliminare setup mdati
if (!MStor.MenuOk)
{
await ReloadMemStor();
}
// leggo resto della configurazione
typeScadLogin = MStor.GetConfInt("TAB_TypeScadLogin");
dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin");
CurrLevel = MStor.PageLevel(NavMan.Uri);
// recupero men
// recupero menu corrente
if (MStor.DictMenu.ContainsKey(CurrLevel))
{
CurrMenuItems = MStor.DictMenu[CurrLevel];
}
await Task.Delay(1);
}
protected bool userIsOk { get; set; } = false;
protected async Task checkIfUserOk(bool isOk)
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await Task.Delay(1);
userIsOk = isOk;
currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
}
protected async Task ReloadMemStor()
@@ -229,6 +234,15 @@ namespace MP_TAB3.Shared
#endregion Private Fields
#region Private Properties
private int MatrOpr
{
get => MsgServ.MatrOpr;
}
#endregion Private Properties
#region Private Methods
private void HandleLocationChanged(object? sender, LocationChangedEventArgs e)