208 lines
6.3 KiB
C#
208 lines
6.3 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.INVE.Data;
|
|
using MP.Data.DatabaseModels;
|
|
using Blazored.LocalStorage;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class InveSessionList : IDisposable
|
|
{
|
|
|
|
public void Dispose()
|
|
{
|
|
elencoSessioni = null;
|
|
elencoMagazzini = null;
|
|
elencoOperatori = null;
|
|
SearchRecords = null;
|
|
GC.Collect();
|
|
}
|
|
private int magazzino { get; set; } = 0;
|
|
private string desc { get; set; } = "";
|
|
private bool reqNew
|
|
{
|
|
get => currParams.reqNew;
|
|
set => currParams.reqNew = value;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => currParams.TotCount;
|
|
set => currParams.TotCount = value;
|
|
}
|
|
private int numRecord
|
|
{
|
|
get => currParams.NumRec;
|
|
set
|
|
{
|
|
currParams.NumRec = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private int currPage
|
|
{
|
|
get => currParams.CurrPage;
|
|
set
|
|
{
|
|
currParams.CurrPage = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private string idOperatore
|
|
{
|
|
get => currParams.idOperatore;
|
|
set => currParams.idOperatore = value;
|
|
}
|
|
private string authKey
|
|
{
|
|
get => currParams.authKey;
|
|
set => currParams.authKey = value;
|
|
}
|
|
private bool inCorso
|
|
{
|
|
get => currParams.inCorso;
|
|
set => currParams.inCorso = value;
|
|
}
|
|
|
|
|
|
private void closeNew()
|
|
{
|
|
reqNew = false;
|
|
elencoOperatori = new List<AnagOperatoriModel>();
|
|
elencoMagazzini = new List<AnagMagModel>();
|
|
}
|
|
|
|
private DateTime dtStart { get; set; } = DateTime.Now.AddMonths(-1);
|
|
private DateTime dtEnd { get; set; } = DateTime.Now;
|
|
|
|
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
|
|
|
|
|
|
protected string rawCode
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = $"{BaseUrlTab}IdSessione={currIdSess}&MatrOpr={idOperatore}&UserAuthKey={authKey}";
|
|
return answ;
|
|
}
|
|
}
|
|
protected async Task popola()
|
|
{
|
|
await Task.Delay(1);
|
|
if (reqNew)
|
|
{
|
|
elencoOperatori = MIDataservice.ElencoOperatori();
|
|
elencoMagazzini = MIDataservice.ElencoMagazzini();
|
|
}
|
|
}
|
|
|
|
protected async Task getCurrSess(int idSess)
|
|
{
|
|
currIdSess = idSess;
|
|
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}");
|
|
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode);
|
|
}
|
|
|
|
private async Task insertNewSession()
|
|
{
|
|
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler creare una nuova sessione per il magazzino selezionato?");
|
|
|
|
if (alert)
|
|
{
|
|
InventorySessionModel newSess = new InventorySessionModel()
|
|
{
|
|
UserCrea = idOperatore,
|
|
Description = desc,
|
|
DtStart = DateTime.Parse(DateTime.Now.ToString("yyyy/MM/dd HH:mm")),
|
|
DtEnd = null,
|
|
Transferred = false,
|
|
MagID = magazzino
|
|
};
|
|
|
|
await MIDataservice.InsertNewSessione(newSess);
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
await reloadData();
|
|
}
|
|
else
|
|
{
|
|
closeNew();
|
|
}
|
|
}
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData();
|
|
await popola();
|
|
}
|
|
|
|
private async Task deleteSession(InventorySessionModel session)
|
|
{
|
|
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler creare una nuova sessione per il magazzino selezionato?");
|
|
if (alert)
|
|
{
|
|
await MIDataservice.deleteSessione(session);
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
await reloadData();
|
|
}
|
|
}
|
|
private async Task reloadData()
|
|
{
|
|
elencoSessioni = null;
|
|
isLoading = true;
|
|
if (inCorso)
|
|
{
|
|
SearchRecords = MIDataservice.InventSessCurrList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = MIDataservice.InventSessHistList(dtStart, dtEnd);
|
|
}
|
|
totalCount = SearchRecords.Count;
|
|
elencoSessioni = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
[Parameter]
|
|
public SelectInveSessionParams currParams { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public bool isLoading { get; set; }
|
|
|
|
|
|
[Parameter]
|
|
public int currIdSess { get; set; }
|
|
|
|
[Inject]
|
|
private MiDataService MIDataservice { get; set; } = null!;
|
|
[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!;
|
|
|
|
private List<InventorySessionModel>? elencoSessioni;
|
|
private List<InventorySessionModel>? SearchRecords;
|
|
private List<AnagOperatoriModel>? elencoOperatori;
|
|
private List<AnagMagModel>? elencoMagazzini;
|
|
}
|
|
} |