Files
mapo-core/MP.INVE/Pages/Session.razor.cs
T
zaccaria.majid a242302fd0 Aggiunta cache metodi:
- elenco operatori
- elenco sessioni in corso
2022-11-17 11:13:41 +01:00

118 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.INVE;
using MP.INVE.Shared;
using MP.INVE.Components;
using MP.Data.DatabaseModels;
using MP.INVE.Data;
using MP.Data.DTO;
using Blazored.LocalStorage;
namespace MP.INVE.Pages
{
public partial class Session
{
[Inject]
private MiDataService MIDataservice { get; set; } = null!;
private List<InventorySessionModel>? elencoSessioni;
protected override async Task OnInitializedAsync()
{
//await FilterChanged.InvokeAsync(actFilter);
await getId();
await Task.Delay(1);
await reloadData();
}
#if false
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
}
}
#endif
private bool inCorso { get; set; } = true;
protected async Task toggle()
{
inCorso = !inCorso;
await reloadData();
}
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
private int idOperatore { get; set; } = 0;
private int currIdSess { get; set; } = 0;
private string authKey { get; set; } = "";
private DateTime dtStart { get; set; } = DateTime.Now.AddMonths(-1);
private DateTime dtEnd { get; set; } = DateTime.Now;
protected string rawCode
{
get
{
string answ = "";
answ = $"{BaseUrlTab}IdSessione={currIdSess}&MatrOpr={idOperatore}&UserAuthKey={authKey}";
return answ;
}
}
private bool isLoading { get; set; } = false;
private async Task reloadData()
{
await Task.Delay(1);
isLoading = true;
if (inCorso)
{
elencoSessioni = MIDataservice.InventSessCurrList(dtStart, null);
}
else
{
elencoSessioni = MIDataservice.InventSessCurrList(dtStart, dtEnd);
}
isLoading = false;
}
protected async Task getCurrSess(int idSess)
{
currIdSess = idSess;
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}");
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode);
}
[Inject]
private IConfiguration Configuration { get; set; } = null!;
[Inject]
protected ILocalStorageService localStorage { get; set; } = null!;
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected async Task getId()
{
OperatoreDTO local = new OperatoreDTO();
local = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
if(local != null)
{
idOperatore = local.MatrOpr;
authKey = local.hashAuthKey;
}
}
}
}