Cleanup MainLayout x spostmento funzionalità
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<PackageReference Include="MailKit" Version="4.7.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Identity.Client" Version="4.72.1" />
|
||||
<PackageReference Include="NLog" Version="5.4.0" />
|
||||
<PackageReference Include="NLog" Version="6.1.1" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.37" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.25" />
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
</ItemGroup>-->
|
||||
<ItemGroup>
|
||||
<!-- API Blazor necessarie per ComponentBase, InvokeAsync, StateHasChanged -->
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.25" />
|
||||
<PackageReference Include="NLog" Version="6.1.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GPW.CORE\GPW.CORE.csproj" />
|
||||
|
||||
@@ -1,61 +1,40 @@
|
||||
using GPW.CORE.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GPW.CORE.Smart8.Client.Components
|
||||
{
|
||||
public partial class NavBottom
|
||||
public partial class NavBottom : IDisposable
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public ConfigDTO CurrConf { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public int IdxDipendente { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
#region Public Methods
|
||||
|
||||
protected bool isActive { get; set; } = false;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_subscribed)
|
||||
{
|
||||
UState.OnChange -= UState_OnChange;
|
||||
_subscribed = false;
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavMan { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void goTo(string target)
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
NavMan.NavigateTo($"{CurrConf.BaseUrl}{target}", true);
|
||||
Console.WriteLine($"NavBottom | NavTo: {target}");
|
||||
}
|
||||
|
||||
protected void goToAbout()
|
||||
{
|
||||
goTo("About");
|
||||
}
|
||||
|
||||
protected void goToAdmin()
|
||||
{
|
||||
goTo("Admin");
|
||||
}
|
||||
|
||||
protected void goToIndex()
|
||||
{
|
||||
goTo("Index");
|
||||
}
|
||||
|
||||
protected void goToMPF()
|
||||
{
|
||||
goTo("DayOff");
|
||||
}
|
||||
|
||||
protected void hideMenu()
|
||||
{
|
||||
isVisible = false;
|
||||
hideMenuCSS = "hidden; height: 0%;";
|
||||
hideButtonCSS = "visible";
|
||||
//base.OnAfterRender(firstRender);
|
||||
if (!_subscribed)
|
||||
{
|
||||
_subscribed = true;
|
||||
UState.OnChange += UState_OnChange;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -70,7 +49,66 @@ namespace GPW.CORE.Smart8.Client.Components
|
||||
Console.WriteLine($"NavBottom | Params | baseUrl: {CurrConf.BaseUrl} | ver: {CurrConf.Versione} | idxDip: {IdxDipendente}");
|
||||
}
|
||||
|
||||
protected void showMenu()
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool _subscribed = false;
|
||||
private string hideButtonCSS = "visible";
|
||||
private string hideMenuCSS = "hidden";
|
||||
private int IdxDipendente = 0;
|
||||
private bool isVisible = false;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool isActive { get; set; } = false;
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavMan { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private UserStateService UState { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void goTo(string target)
|
||||
{
|
||||
NavMan.NavigateTo($"{CurrConf.BaseUrl}{target}", true);
|
||||
Console.WriteLine($"NavBottom | NavTo: {target}");
|
||||
}
|
||||
|
||||
private void goToAbout()
|
||||
{
|
||||
goTo("About");
|
||||
}
|
||||
|
||||
private void goToAdmin()
|
||||
{
|
||||
goTo("Admin");
|
||||
}
|
||||
|
||||
private void goToIndex()
|
||||
{
|
||||
goTo("Index");
|
||||
}
|
||||
|
||||
private void goToMPF()
|
||||
{
|
||||
goTo("DayOff");
|
||||
}
|
||||
|
||||
private void hideMenu()
|
||||
{
|
||||
isVisible = false;
|
||||
hideMenuCSS = "hidden; height: 0%;";
|
||||
hideButtonCSS = "visible";
|
||||
}
|
||||
|
||||
private void showMenu()
|
||||
{
|
||||
if (IdxDipendente > 0)
|
||||
{
|
||||
@@ -80,24 +118,18 @@ namespace GPW.CORE.Smart8.Client.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected void slideIn()
|
||||
private void UState_OnChange()
|
||||
{
|
||||
isActive = false;
|
||||
// siamo in un callback non-UI thread: usa InvokeAsync
|
||||
_ = InvokeAsync(() =>
|
||||
{
|
||||
if (UState.CurrentUser != null)
|
||||
IdxDipendente = UState.CurrentUser.IdxDip;
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
protected void slideOut()
|
||||
{
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private string hideButtonCSS = "visible";
|
||||
private string hideMenuCSS = "hidden";
|
||||
private bool isVisible = false;
|
||||
|
||||
#endregion Private Fields
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using GPW.CORE.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NLog;
|
||||
|
||||
namespace GPW.CORE.Smart8.Shared.Components.Common
|
||||
{
|
||||
@@ -10,32 +11,17 @@ namespace GPW.CORE.Smart8.Shared.Components.Common
|
||||
[Parameter]
|
||||
public ConfigDTO CurrConf { get; set; } = null!;
|
||||
|
||||
private UserDTO? CurrUser = null;
|
||||
#if false
|
||||
[Parameter]
|
||||
public UserDTO? CurrUser { get; set; } = null;
|
||||
#endif
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> EC_ForceReset { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> EC_ReturnHome { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool IpIsLocal { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public string LocalNet { get; set; } = "###";
|
||||
|
||||
[Parameter]
|
||||
public string CurrIpv4 { get; set; } = "0.0.0.0";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
[Inject]
|
||||
private UserStateService UState { get; set; } = null!;
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
@@ -50,59 +36,6 @@ namespace GPW.CORE.Smart8.Shared.Components.Common
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await Task.Delay(10);
|
||||
//await InvokeAsync(StateHasChanged);
|
||||
//return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
private bool _subscribed = false;
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
//if (firstRender)
|
||||
//{
|
||||
// // iscriviti qui nell'istanza client
|
||||
// UState.OnChange += UState_OnChange;
|
||||
// _subscribed = true;
|
||||
//}
|
||||
if (!_subscribed)
|
||||
{
|
||||
_subscribed = true;
|
||||
UState.OnChange += UState_OnChange;
|
||||
}
|
||||
if (CurrUser == null)
|
||||
{
|
||||
if (UState.CurrentUser != null)
|
||||
{
|
||||
CurrUser = UState.CurrentUser;
|
||||
//await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
//await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
private void UState_OnChange()
|
||||
{
|
||||
// siamo in un callback non-UI thread: usa InvokeAsync
|
||||
_ = InvokeAsync(() =>
|
||||
{
|
||||
if (UState.CurrentUser != null)
|
||||
CurrUser = UState.CurrentUser;
|
||||
|
||||
if (UState.CurrIpv4 != null)
|
||||
{
|
||||
CurrIpv4 = UState.CurrIpv4;
|
||||
if (!string.IsNullOrEmpty(CurrIpv4))
|
||||
{
|
||||
IpIsLocal = CurrIpv4.Contains(LocalNet);
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string currDip
|
||||
@@ -131,20 +64,79 @@ namespace GPW.CORE.Smart8.Shared.Components.Common
|
||||
|
||||
protected async Task ForceReset()
|
||||
{
|
||||
Console.WriteLine($"IsBrowser: {OperatingSystem.IsBrowser()}");
|
||||
Console.WriteLine($"IsServer: {OperatingSystem.IsWindows()}");
|
||||
Console.WriteLine("CmpTop.ForceReset");
|
||||
//Log.Debug($"IsBrowser: {OperatingSystem.IsBrowser()}");
|
||||
//Log.Debug($"IsServer: {OperatingSystem.IsWindows()}");
|
||||
//Log.Debug("CmpTop.ForceReset");
|
||||
await EC_ForceReset.InvokeAsync(true);
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!_subscribed)
|
||||
{
|
||||
_subscribed = true;
|
||||
UState.OnChange += UState_OnChange;
|
||||
}
|
||||
if (CurrUser == null)
|
||||
{
|
||||
if (UState.CurrentUser != null)
|
||||
{
|
||||
CurrUser = UState.CurrentUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task ReturnHome()
|
||||
{
|
||||
Console.WriteLine($"IsBrowser: {OperatingSystem.IsBrowser()}");
|
||||
Console.WriteLine($"IsServer: {OperatingSystem.IsWindows()}");
|
||||
Console.WriteLine("CmpTop.ReturnHome");
|
||||
//Log.Debug($"IsBrowser: {OperatingSystem.IsBrowser()}");
|
||||
//Log.Debug($"IsServer: {OperatingSystem.IsWindows()}");
|
||||
//Log.Debug("CmpTop.ReturnHome");
|
||||
await EC_ReturnHome.InvokeAsync(true);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _subscribed = false;
|
||||
private string CurrIpv4 = "0.0.0.0";
|
||||
private UserDTO? CurrUser = null;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool IpIsLocal { get; set; } = false;
|
||||
|
||||
[Inject]
|
||||
private UserStateService UState { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void UState_OnChange()
|
||||
{
|
||||
// siamo in un callback non-UI thread: usa InvokeAsync
|
||||
_ = InvokeAsync(() =>
|
||||
{
|
||||
if (UState.CurrentUser != null)
|
||||
CurrUser = UState.CurrentUser;
|
||||
|
||||
if (UState.CurrIpv4 != null)
|
||||
{
|
||||
CurrIpv4 = UState.CurrIpv4;
|
||||
if (!string.IsNullOrEmpty(CurrIpv4))
|
||||
{
|
||||
IpIsLocal = CurrIpv4.Contains(LocalNet);
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@
|
||||
<ItemGroup>
|
||||
<!-- Questo è il pezzo mancante: porta dentro ComponentBase & co. -->
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.25" />
|
||||
<PackageReference Include="NLog" Version="6.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
@using EgwCoreLib.Razor.Data
|
||||
@using GPW.CORE.Data.DbModels
|
||||
@using NLog
|
||||
@* @rendermode InteractiveServer *@
|
||||
@* @rendermode @(new InteractiveServerRenderMode(prerender: false)) *@
|
||||
@inject IJSRuntime JS
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
private CoreSmartDataService CDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavMan { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private LicenseServiceLoc LicServ { get; set; } = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
// await Task.Delay(1);
|
||||
if (firstRender)
|
||||
{
|
||||
var val = await JS.InvokeAsync<string>("localStorage.getItem", "currUser");
|
||||
// setta stato e notifica layout via callback/cascading
|
||||
|
||||
if (!NavMan.Uri.Contains("jumper"))
|
||||
{
|
||||
await VerifyActiv();
|
||||
}
|
||||
Log.Info($"LicenseBootstrap.OnAfterRenderAsync | firstrender: {firstRender}");
|
||||
}
|
||||
// return base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
private async Task VerifyActiv()
|
||||
{
|
||||
// preliminarmente verifica shared info
|
||||
await checkSharedInfo();
|
||||
// refresh attivazioni se necessario
|
||||
await checkActivations();
|
||||
}
|
||||
/// <summary>
|
||||
/// Verifica informazioni condivise applicazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> checkActivations()
|
||||
{
|
||||
bool allOk = false;
|
||||
if (LicServ.ValidData)
|
||||
{
|
||||
// se non fosse tutto ok
|
||||
if (!LicServ.HasActivData)
|
||||
{
|
||||
// chiamo refresh licenze da remoto
|
||||
allOk = await LicServ.RefreshLicense();
|
||||
}
|
||||
// se non avesse info applicativo...
|
||||
if (!LicServ.HasAppData)
|
||||
{
|
||||
await LicServ.RefreshApplic();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
return allOk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica informazioni condivise applicazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> checkSharedInfo()
|
||||
{
|
||||
bool allOk = false;
|
||||
if (!LicServ.ValidData)
|
||||
{
|
||||
// salvo cod app da Conf...
|
||||
LicServ.Applicazione = CDService.CodApp;
|
||||
// effettuo lettura dati preliminari da AKV (eventualmente in cache...)
|
||||
List<AnagKeyValueModel>? rawAkvList = await CDService.AKVList();
|
||||
if (rawAkvList != null)
|
||||
{
|
||||
LicServ.AKVList = rawAkvList;
|
||||
allOk = LicServ.InitAkv();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
return allOk;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
/// Verifica info specifiche utente
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> checkUserLicense()
|
||||
private async Task<bool> checkUserLicense()
|
||||
{
|
||||
bool answ = false;
|
||||
// verifico utente attivo
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
<ForceInteractive></ForceInteractive>
|
||||
<UserBootstrap />
|
||||
<LicenseBootstrap />
|
||||
|
||||
<PageTitle>GPW.CORE.Smart</PageTitle>
|
||||
|
||||
<div class="page vh-100">
|
||||
<main class="vw-100">
|
||||
<CmpTop @rendermode="InteractiveAuto" IpIsLocal=@isIpLocal LocalNet=@LocalNet CurrIpv4=@currIpv4 EC_ReturnHome=@ReturnHome EC_ForceReset=@ForceReset></CmpTop>
|
||||
<CmpTop @rendermode="InteractiveAuto" LocalNet=@LocalNet EC_ReturnHome=@ReturnHome EC_ForceReset=@ForceReset></CmpTop>
|
||||
<article class="content p-2">
|
||||
@Body
|
||||
</article>
|
||||
@if (dataLoaded)
|
||||
{
|
||||
@* <NavBottom @rendermode="InteractiveAuto" CurrConf=@currConfig></NavBottom> *@
|
||||
<NavBottom @rendermode="InteractiveAuto" CurrConf=@currConfig IdxDipendente=@currUser.IdxDip></NavBottom>
|
||||
<NavBottom @rendermode="InteractiveAuto" CurrConf=@currConfig></NavBottom>
|
||||
}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using EgwCoreLib.Razor.Data;
|
||||
using GPW.CORE.Data.DbModels;
|
||||
using GPW.CORE.Services;
|
||||
using GPW.CORE.Smart8.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -9,6 +7,8 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
{
|
||||
public partial class MainLayout : IDisposable
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_subscribed)
|
||||
@@ -18,143 +18,22 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
Log.Info($"MainLayout unsubscribed in Dispose instance {_instanceId}");
|
||||
}
|
||||
}
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected CoreSmartDataService CDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration configuration { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected LicenseServiceLoc LicServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected MessageServiceLoc MService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavMan { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica informazioni condivise applicazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> checkActivations()
|
||||
{
|
||||
bool allOk = false;
|
||||
if (LicServ.ValidData)
|
||||
{
|
||||
// se non fosse tutto ok
|
||||
if (!LicServ.HasActivData)
|
||||
{
|
||||
// chiamo refresh licenze da remoto
|
||||
allOk = await LicServ.RefreshLicense();
|
||||
}
|
||||
// se non avesse info applicativo...
|
||||
if (!LicServ.HasAppData)
|
||||
{
|
||||
await LicServ.RefreshApplic();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
return allOk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica informazioni condivise applicazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> checkSharedInfo()
|
||||
{
|
||||
bool allOk = false;
|
||||
if (!LicServ.ValidData)
|
||||
{
|
||||
// salvo cod app da Conf...
|
||||
LicServ.Applicazione = CDService.CodApp;
|
||||
// effettuo lettura dati preliminari da AKV (eventualmente in cache...)
|
||||
List<AnagKeyValueModel>? rawAkvList = await CDService.AKVList();
|
||||
if (rawAkvList != null)
|
||||
{
|
||||
LicServ.AKVList = rawAkvList;
|
||||
allOk = LicServ.InitAkv();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
return allOk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica info specifiche utente
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> checkUserLicense()
|
||||
{
|
||||
bool answ = false;
|
||||
// verifico utente attivo
|
||||
answ = MService.IsActive;
|
||||
if (answ)
|
||||
{
|
||||
var rawActList = LicServ.ActivList;
|
||||
// recupero hash utente
|
||||
string hashImpiego = MService.HashDip;
|
||||
// confronto con elenco attivazioni dello shared service...
|
||||
var foundRec = rawActList.Where(x => x.CodImpiego == hashImpiego);
|
||||
answ = foundRec.Count() > 0;
|
||||
// salvo status payloadOk
|
||||
MService.PayloadOk = answ;
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async Task DoVerifyActiv()
|
||||
{
|
||||
MService.PayloadOk = false;
|
||||
await Task.Delay(1);
|
||||
await VerifyActiv();
|
||||
}
|
||||
|
||||
protected async Task ForceReset()
|
||||
{
|
||||
Console.WriteLine("MainLayout.ForceReset (Server)");
|
||||
string nextPage = NavMan.ToBaseRelativePath(NavMan.Uri);
|
||||
// tengo solo parte finale...
|
||||
if (nextPage.Contains("/"))
|
||||
{
|
||||
nextPage = nextPage.Substring(nextPage.LastIndexOf("/") + 1);
|
||||
}
|
||||
await Task.Delay(1);
|
||||
await DoVerifyActiv();
|
||||
NavMan.NavigateTo($"{baseUrl}ForceReset?nextPage={nextPage}", true);
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstrender)
|
||||
{
|
||||
UState.OnChange += UState_OnChange;
|
||||
await Task.Delay(1);
|
||||
if (firstrender)
|
||||
if (!_subscribed)
|
||||
{
|
||||
if (!NavMan.Uri.Contains("jumper"))
|
||||
{
|
||||
await checkOtherData();
|
||||
// verifico attivazione dipendente...
|
||||
await checkUserLicense();
|
||||
}
|
||||
UState.OnChange += UState_OnChange;
|
||||
_subscribed = true;
|
||||
Log.Info("MainLayout.OnAfterRenderAsync subscribed to UserState in instance {Id}", _instanceId);
|
||||
}
|
||||
Log.Info($"MainLayout.OnAfterRenderAsync | firstrender: {firstrender} | {_instanceId}");
|
||||
}
|
||||
|
||||
|
||||
private readonly Guid _instanceId = Guid.NewGuid();
|
||||
private bool _subscribed = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Iscriviti qui, nell'istanza interattiva
|
||||
@@ -162,9 +41,8 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
{
|
||||
UState.OnChange += UState_OnChange;
|
||||
_subscribed = true;
|
||||
Log.Info("MainLayout subscribed to UserState in instance {Id}", _instanceId);
|
||||
Log.Info("MainLayout.OnInitializedAsync subscribed to UserState in instance {Id}", _instanceId);
|
||||
}
|
||||
await DoVerifyActiv();
|
||||
string baseUrl = configuration.GetValue<string>("OptConf:BaseUrl") ?? "~/";
|
||||
var versione = typeof(Program).Assembly.GetName().Version;
|
||||
currConfig = new ConfigDTO()
|
||||
@@ -174,70 +52,20 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
};
|
||||
|
||||
await ReloadData();
|
||||
#if false
|
||||
if (!DipOk)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!NavMan.Uri.Contains("jumper"))
|
||||
{
|
||||
await checkUser();
|
||||
// verifico attivazione dipendente...
|
||||
await checkUserLicense();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"MainLayout | No user data: reloading{Environment.NewLine}{exc}");
|
||||
await Task.Delay(1500);
|
||||
NavMan.NavigateTo($"{baseUrl}Index");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Log.Info($"MainLayout.OnInitialized | url: {baseUrl} | v:{versione}");
|
||||
}
|
||||
|
||||
private void UState_OnChange()
|
||||
{
|
||||
// siamo in un callback non-UI thread: usa InvokeAsync
|
||||
_ = InvokeAsync(() =>
|
||||
{
|
||||
currUser = UState.CurrentUser;
|
||||
|
||||
if (DipOk)
|
||||
dataLoaded = true;
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task ReturnHome()
|
||||
{
|
||||
Console.WriteLine("MainLayout.ReturnHome (Server)");
|
||||
// svuoto cache
|
||||
await CDService.FlushRedisCache();
|
||||
// ritorno in home
|
||||
NavMan.NavigateTo($"{currConfig.BaseUrl}Home", true);
|
||||
}
|
||||
|
||||
protected async Task VerifyActiv()
|
||||
{
|
||||
// preliminarmente verifica shared info
|
||||
await checkSharedInfo();
|
||||
// refresh attivazioni se necessario
|
||||
await checkActivations();
|
||||
// verifico e salvo dati attivazione dipendente...
|
||||
userOk = await checkUserLicense();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly Guid _instanceId = Guid.NewGuid();
|
||||
|
||||
private bool _subscribed = false;
|
||||
|
||||
private ConfigDTO currConfig = new ConfigDTO();
|
||||
private string currIpv4 = "";
|
||||
|
||||
/// <summary>
|
||||
/// Info utente corrente x display
|
||||
@@ -257,50 +85,41 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
get => configuration.GetValue<string>("OptConf:BaseUrl") ?? "~/";
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private CoreSmartDataService CDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private IConfiguration configuration { get; set; } = null!;
|
||||
|
||||
private bool DipOk
|
||||
{
|
||||
get => (currUser != null && currUser.IdxDip > 0);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private IHttpContextAccessor httpContextAccessor { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se IP sia locale
|
||||
/// </summary>
|
||||
private bool isIpLocal
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (!string.IsNullOrEmpty(currIpv4))
|
||||
{
|
||||
answ = currIpv4.Contains(LocalNet);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
[Inject]
|
||||
private NavigationManager NavMan { get; set; } = null!;
|
||||
|
||||
private bool userOk { get; set; } = false;
|
||||
|
||||
[Inject]
|
||||
private UserStateService UState { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task checkOtherData()
|
||||
|
||||
private async Task ForceReset()
|
||||
{
|
||||
currIpv4 = await MService.getDevIpAsync();
|
||||
if (string.IsNullOrEmpty(currIpv4))
|
||||
Console.WriteLine("MainLayout.ForceReset (Server)");
|
||||
string nextPage = NavMan.ToBaseRelativePath(NavMan.Uri);
|
||||
// tengo solo parte finale...
|
||||
if (nextPage.Contains("/"))
|
||||
{
|
||||
// ricalcolo e salvo...
|
||||
if (httpContextAccessor.HttpContext != null)
|
||||
{
|
||||
var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
|
||||
// provo a recuperare ipV4...
|
||||
currIpv4 = IpUtils.getLocalIpv4(remoteIp);
|
||||
await MService.setDevIpv4Async(currIpv4);
|
||||
}
|
||||
nextPage = nextPage.Substring(nextPage.LastIndexOf("/") + 1);
|
||||
}
|
||||
NavMan.NavigateTo($"{baseUrl}ForceReset?nextPage={nextPage}", true);
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
@@ -309,77 +128,27 @@ namespace GPW.CORE.Smart8.Components.Layout
|
||||
LocalNet = confNet != null ? confNet.valore : "10";
|
||||
}
|
||||
|
||||
private async Task setupUserData()
|
||||
private async Task ReturnHome()
|
||||
{
|
||||
if (DipOk)
|
||||
{
|
||||
// verifico o calcolo IP...
|
||||
await checkOtherData();
|
||||
|
||||
Log.Info($"MainLayout.setupUserData | idxDip: {currUser.IdxDip} | {_instanceId}");
|
||||
|
||||
dataLoaded = true;
|
||||
// segnalo update...
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
Console.WriteLine("MainLayout.ReturnHome (Server)");
|
||||
// svuoto cache
|
||||
await CDService.FlushRedisCache();
|
||||
// ritorno in home
|
||||
NavMan.NavigateTo($"{currConfig.BaseUrl}Home", true);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private UserStateService UState { get; set; } = null!;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Prova login da dati Device (in LocalStorage)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task tryDeviceLogin()
|
||||
private void UState_OnChange()
|
||||
{
|
||||
// cerco in localstorage il devicesecret
|
||||
string devSecret = await MService.getDevSecretAsync();
|
||||
await Task.Delay(50);
|
||||
if (!string.IsNullOrEmpty(devSecret))
|
||||
// siamo in un callback non-UI thread: usa InvokeAsync
|
||||
_ = InvokeAsync(() =>
|
||||
{
|
||||
// cerco sul DB...
|
||||
var rigaDev = await CDService.DeviceBySecret(devSecret);
|
||||
// se trovato
|
||||
if (rigaDev != null)
|
||||
{
|
||||
// recupero dati dip e inizializzo message service
|
||||
var elencoDip = await CDService.DipendentiGetAll();
|
||||
if (elencoDip != null)
|
||||
{
|
||||
var rigaDip = elencoDip.FirstOrDefault(x => x.IdxDipendente == rigaDev.IdxDipendente);
|
||||
if (rigaDip != null)
|
||||
{
|
||||
MService.RigaDip = rigaDip;
|
||||
currUser = new UserDTO()
|
||||
{
|
||||
IdxDip = rigaDip.IdxDipendente,
|
||||
Cognome = rigaDip.Cognome ?? "-",
|
||||
Nome = rigaDip.Nome ?? "...",
|
||||
Attivo = rigaDip.Attivo,
|
||||
AuthKey = rigaDip.AuthKey,
|
||||
Cf = rigaDip.Cf,
|
||||
DataNascita = rigaDip.DataNascita,
|
||||
Email = rigaDip.Email,
|
||||
Gruppo = rigaDip.Gruppo,
|
||||
Matricola = rigaDip.Matricola,
|
||||
Dominio = rigaDip.Dominio,
|
||||
Utente = rigaDip.Utente
|
||||
};
|
||||
await setupUserData();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NavMan.NavigateTo($"{baseUrl}RegNewDevice");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NavMan.NavigateTo($"{baseUrl}RegNewDevice");
|
||||
}
|
||||
currUser = UState.CurrentUser;
|
||||
|
||||
if (DipOk)
|
||||
dataLoaded = true;
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>4.1.2603.2719</Version>
|
||||
<Version>4.1.2603.2809</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -33,6 +33,8 @@
|
||||
<ProjectReference Include="..\GPW.CORE.Smart8.Shared\GPW.CORE.Smart8.Shared.csproj" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2511.312" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.25" />
|
||||
<PackageReference Include="NLog" Version="6.1.1" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="6.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,20 +6,29 @@ using GPW.CORE.Smart8.Components;
|
||||
using GPW.CORE.Smart8.Data;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using StackExchange.Redis;
|
||||
using System.Globalization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var env = builder.Environment;
|
||||
|
||||
var logger = LogManager.Setup()
|
||||
.LoadConfigurationFromAppSettings()
|
||||
.GetCurrentClassLogger();
|
||||
|
||||
ConfigurationManager configuration = builder.Configuration;
|
||||
logger.Info("GPW.Smart | Program.cs: startup");
|
||||
logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}");
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents()
|
||||
.AddInteractiveWebAssemblyComponents();
|
||||
|
||||
|
||||
// configuration setup
|
||||
ConfigurationManager configuration = builder.Configuration;
|
||||
|
||||
// REDIS setup
|
||||
string connStringRedis = configuration.GetConnectionString("Redis")!;
|
||||
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>GPW - Gestione Presenze Web</i>
|
||||
<h4>Versione: 4.1.2603.2719</h4>
|
||||
<h4>Versione: 4.1.2603.2809</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
4.1.2603.2719
|
||||
4.1.2603.2809
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>4.1.2603.2719</version>
|
||||
<version>4.1.2603.2809</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.Smart.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user