132 lines
3.4 KiB
C#
132 lines
3.4 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Stats.Data;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Stats.Pages
|
|
{
|
|
public partial class UserLog : ComponentBase, IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
private MP.Data.DatabaseModels.AzioniUL[] ActionsList;
|
|
private MP.Data.DatabaseModels.UserActionLog currRecord = null;
|
|
|
|
private MP.Data.DatabaseModels.UserActionLog[] ListRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private SelectData currFilter { get; set; } = new SelectData();
|
|
private int numRecord { get; set; } = 10;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
protected MessageService MessageService { get; set; }
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; }
|
|
|
|
[Inject]
|
|
protected MpStatsService StatService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task reloadData()
|
|
{
|
|
ActionsList = await StatService.ActionsGetAll();
|
|
ListRecords = await StatService.StatUserLogGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, numRecord, MessageService.SearchVal);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task DoFilter(SelectData newFilter)
|
|
{
|
|
currFilter = newFilter;
|
|
await reloadData();
|
|
}
|
|
|
|
protected async Task ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
await reloadData();
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MessageService.ShowSearch = true;
|
|
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
|
await reloadData();
|
|
}
|
|
|
|
protected void ResetData()
|
|
{
|
|
StatService.rollBackEdit(currRecord);
|
|
currRecord = null;
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currRecord = null;
|
|
await reloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(int IdxLog)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.IdxLog == IdxLog) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public MP.Data.DatabaseModels.AzioniUL decodeAction(string azione)
|
|
{
|
|
// cerco
|
|
MP.Data.DatabaseModels.AzioniUL data = ActionsList
|
|
.Where(x => x.Azione == azione)
|
|
.FirstOrDefault();
|
|
data = data != null ? data : new MP.Data.DatabaseModels.AzioniUL() { Azione = "ND", Class = "", Descrizione = "ND" };
|
|
return data;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
|
}
|
|
|
|
public void OnSeachUpdated()
|
|
{
|
|
InvokeAsync(() =>
|
|
{
|
|
UpdateData();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |