cbd4a90d01
- Correzione MSE i MSEModel x naming - fix e test vari su app CORE (IOC/SPEC/TAB3/MON)
183 lines
4.7 KiB
C#
183 lines
4.7 KiB
C#
using global::Microsoft.AspNetCore.Components;
|
|
using MP.Core.DTO;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
using NLog;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class ParamsMan : ComponentBase, IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public MappaStatoExplModel? RecMSE { get; set; } = null;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
if (aTimer != null)
|
|
{
|
|
aTimer.Elapsed -= ElapsedTimer;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
protected List<ObjItemDTO> ListRecord { get; set; } = new List<ObjItemDTO>();
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
protected string reqVal { get; set; } = "";
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task DoCancel()
|
|
{
|
|
reqVal = "";
|
|
currItem = null;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task DoSave()
|
|
{
|
|
if (currItem != null)
|
|
{
|
|
// invio richiesta e salvo...
|
|
updateParameter(currItem.uid, reqVal);
|
|
currItem = null;
|
|
}
|
|
await ReloadData();
|
|
}
|
|
|
|
protected void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await ReloadData();
|
|
await InvokeAsync(() => StateHasChanged());
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
|
|
protected async Task ForceReload()
|
|
{
|
|
currItem = null;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected bool isSelected(string uid)
|
|
{
|
|
bool answ = false;
|
|
if (currItem != null)
|
|
{
|
|
answ = uid == currItem.uid;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
setupConf();
|
|
StartTimer();
|
|
currItem = null;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (RecMSE != null && !RecMSE.MostlyEquals(lastRecMSE))
|
|
{
|
|
IdxMaccSel = RecMSE.IdxMacchina;
|
|
lastRecMSE = RecMSE;
|
|
await ReloadData();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected string selectedCss(string uid)
|
|
{
|
|
string answ = "";
|
|
if (currItem != null)
|
|
{
|
|
answ = uid == currItem.uid ? "table-info" : "";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void SelRecord(ObjItemDTO newRec)
|
|
{
|
|
reqVal = newRec.value;
|
|
currItem = newRec;
|
|
}
|
|
|
|
protected void StartTimer()
|
|
{
|
|
if (aTimer != null)
|
|
{
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
aTimer = new System.Timers.Timer(dtTimerTabParam);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
protected void updateParameter(string uid, string reqValue)
|
|
{
|
|
Log.Info($"updateParameter | idxMacchina: {IdxMaccSel} | uid: {uid} | reqValue: {reqValue}");
|
|
TabDServ.MachineParamUpdate(IdxMaccSel, uid, reqValue);
|
|
Log.Info($"updateParameter | idxMacchina: {IdxMaccSel} | uid: {uid} | done!");
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
private System.Timers.Timer aTimer = null!;
|
|
private int dtTimerTabParam = 5000;
|
|
private bool isProcessing = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private ObjItemDTO? currItem { get; set; } = null;
|
|
private string IdxMaccSel { get; set; } = "";
|
|
private MappaStatoExplModel? lastRecMSE { get; set; } = null;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isProcessing = true;
|
|
ListRecord = TabDServ.MachineParamList(IdxMaccSel);
|
|
await Task.Delay(1);
|
|
isProcessing = false;
|
|
}
|
|
|
|
private void setupConf()
|
|
{
|
|
TabDServ.ConfigGetVal("dtTimerTabParam", ref dtTimerTabParam);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |