165 lines
4.6 KiB
C#
165 lines
4.6 KiB
C#
using global::Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.Conf;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.Data.Services;
|
|
using NLog;
|
|
using System.Runtime.ExceptionServices;
|
|
|
|
namespace MP_TAB_SERV.Pages
|
|
{
|
|
public partial class StatusMap
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected bool _showCard = false;
|
|
|
|
protected int maxCol = 6;
|
|
|
|
protected string showArt = "";
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IConfiguration config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected StatusData MDataService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime{ get; set; } = null!;
|
|
|
|
protected bool ShowCard
|
|
{
|
|
get => _showCard;
|
|
set
|
|
{
|
|
_showCard = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Recupera da conf eventuale setup tag dell'IOB indicato
|
|
/// </summary>
|
|
/// <param name="codIob"></param>
|
|
/// <returns></returns>
|
|
protected List<TagData>? getIobTag(string codIob)
|
|
{
|
|
List<TagData>? answ = null;
|
|
if (MDataService.currTagConf != null)
|
|
{
|
|
// cerco x chiave IOB...
|
|
if (MDataService.currTagConf.ContainsKey(codIob))
|
|
{
|
|
answ = MDataService.currTagConf[codIob];
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera da redis (in una chiamata soltanto) tutti i valori richiesti e compone un
|
|
/// dizionario x ottimizzare visualizzazione
|
|
/// </summary>
|
|
/// <param name="codIob"></param>
|
|
/// <returns></returns>
|
|
protected Dictionary<string, string> getTagVal(string codIob)
|
|
{
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
// recupero conf tags...
|
|
var currTags = getIobTag(codIob);
|
|
if (currTags != null && currTags.Count > 0)
|
|
{
|
|
// FIXME TODO !!!! FARE !!!! - da verificare
|
|
answ = currTags.ToDictionary(x => x.TagLocation, x => MDataService.getTagConf(x.TagLocation));
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
await getWDim();
|
|
}
|
|
if (ListMSE != null)
|
|
{
|
|
// salvo in LocalStorage...
|
|
await MServ.SaveMse(ListMSE);
|
|
}
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
ListMSE = null;
|
|
SetupConf();
|
|
ListMSE = await MDataService.MseGetAll();
|
|
}
|
|
|
|
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
|
{
|
|
ListMSE = newList;
|
|
await InvokeAsync(StateHasChanged);
|
|
//Log.Trace("StatusMap | RefreshData");
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private static System.Timers.Timer slowTimer = new System.Timers.Timer(300000);
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private List<MappaStatoExpl>? ListMSE { get; set; } = null;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void SetupConf()
|
|
{
|
|
// sistemo i parametri opzionali...
|
|
TabDServ.ConfigGetVal("MON_maxCol", ref maxCol);
|
|
TabDServ.ConfigGetVal("sART", ref showArt);
|
|
Log.Info($"setupConf | Effettuato setup parametri | MaxCol: {maxCol}");
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
protected int Width { get; set; } = 0;
|
|
protected int Height { get; set; } = 0;
|
|
|
|
public class WindowDimension
|
|
{
|
|
#region Public Properties
|
|
|
|
public int Height { get; set; }
|
|
public int Width { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
protected async Task getWDim()
|
|
{
|
|
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
|
|
Height = dimension.Height;
|
|
Width = dimension.Width;
|
|
}
|
|
}
|
|
} |