105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
using Blazored.SessionStorage;
|
|
using Blazored.LocalStorage;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DTO;
|
|
using MP.INVE.Data;
|
|
using MP.Core.DTO;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class CmpTop
|
|
{
|
|
#region Public Methods
|
|
|
|
public async Task flushCache()
|
|
{
|
|
await Task.Delay(1);
|
|
await Task.Delay(1);
|
|
await MIDataService.FlushRedisCache();
|
|
// rimando a pagina corrente
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
public async Task LogOut()
|
|
{
|
|
await MsgService.clearLocalStorageAsync();
|
|
// rimando a pagina login
|
|
NavManager.NavigateTo("OperatoreLogin", true);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MiDataService MIDataService { get; set; } = null!;
|
|
[Inject]
|
|
protected MessageService MsgService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
//&& !(answ.dtExp < DateTime.Now)
|
|
|
|
protected async Task getId()
|
|
{
|
|
#if false
|
|
OperatoreDTO answ = new OperatoreDTO();
|
|
answ = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
|
#endif
|
|
OperatoreDTO answ = await MsgService.getCurrOperDtoAsync();
|
|
if (!NavManager.Uri.Contains("Jumper?"))
|
|
{
|
|
if (answ.MatrOpr != 0)
|
|
{
|
|
userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})";
|
|
if (NavManager.Uri.Contains("OperatoreLogin"))
|
|
{
|
|
NavManager.NavigateTo("ElencoMagazzini", true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
userName = "0";
|
|
if (!NavManager.Uri.Contains("OperatoreLogin"))
|
|
{
|
|
NavManager.NavigateTo("OperatoreLogin", true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await getId();
|
|
}
|
|
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string userName = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private ISessionStorageService sessionStorage { get; set; } = null!;
|
|
|
|
#if false
|
|
[Inject]
|
|
private ILocalStorageService localStorage { get; set; } = null!;
|
|
#endif
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |