Files
mapo-core/MP-TAB3/Pages/Logout.razor.cs
T
2024-01-08 12:21:25 +01:00

56 lines
1.7 KiB
C#

using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
using MP.Data.DTO;
using MP.Data.Services;
using Newtonsoft.Json;
namespace MP_TAB3.Pages
{
public partial class Logout
{
#region Protected Properties
[Inject]
protected ILocalStorageService localStorage { get; set; } = null!;
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected TabDataService TDService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
await MsgServ.SetCurrOperDtoLSAsync("");
await MsgServ.IdxMaccSet("");
await MsgServ.LastOpenedPageSet("");
var CurrOprTknLS = await MsgServ.GetCurrOperDtoLSAsync();
var CurrDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
if (!string.IsNullOrEmpty(CurrOprTknLS))
{
var decryptedData = MsgServ.DecryptData(CurrOprTknLS);
if (!string.IsNullOrEmpty(decryptedData))
{
var oprObj = JsonConvert.DeserializeObject<userTknDTO>(decryptedData);
if (oprObj != null)
{
MsgServ.RigaOper = oprObj.currOpr;
}
}
}
await TDService.OperatoreDeleteRedis(MsgServ.MatrOpr, CurrDevGuid);
MsgServ.RigaOper = null;
NavMan.NavigateTo("reg-new-device", true);
}
#endregion Protected Methods
}
}