Files
Samuele E. Locatelli 50d65eebaa MP.DATA, riorganizzazioni varie:
- renaming classi gestione DbModels in
- spostamento anagrafica flussi da auth a generale
2025-03-08 10:40:09 +01:00

261 lines
6.2 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DbModels;
using MP.Data.Services;
using NLog;
namespace MP_TAB3.Pages
{
public partial class User : IDisposable
{
#region Public Properties
public string currIpv4 { get; set; } = "";
public int Height { get; set; } = 0;
public int Width { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public void Dispose()
{
//GC.Collect();
}
#endregion Public Methods
#region Public Classes
public class WindowDimension
{
#region Public Properties
public int Height { get; set; }
public int Width { get; set; }
#endregion Public Properties
}
#endregion Public Classes
#region Protected Properties
protected string _defCardMode { get; set; } = "";
protected string _langIns { get; set; } = "EN";
protected string _tcModIns { get; set; } = "";
protected string btnFullStyle
{
get
{
string answ = "";
if (defCardModeIns == "full")
{
answ = "btn-primary";
}
else
{
answ = "btn-outline-secondary";
}
return answ;
}
}
protected string btnMcStyle
{
get
{
string answ = "";
if (tcModIns == "mc")
{
answ = "btn-primary";
}
else
{
answ = "btn-outline-secondary";
}
return answ;
}
}
protected string btnMsStyle
{
get
{
string answ = "";
if (tcModIns == "ms")
{
answ = "btn-primary";
}
else
{
answ = "btn-outline-secondary";
}
return answ;
}
}
protected string btnShrinkStyle
{
get
{
string answ = "";
if (defCardModeIns == "shrink")
{
answ = "btn-primary";
}
else
{
answ = "btn-outline-secondary";
}
return answ;
}
}
protected string defCardModeIns
{
get => _defCardMode;
set
{
if (_defCardMode != value)
{
_defCardMode = value;
MsgServ.UserPrefSet("DefCardMode", value);
}
}
}
protected int dtScadLogin { get; set; } = 0;
protected string langIns
{
get => _langIns;
set
{
if (_langIns != value)
{
_langIns = value;
MsgServ.UserPrefSet("Lang", value);
}
}
}
protected string mainSize
{
get
{
string answ = "col-12";
if (Width > 1021)
{
answ = "col-6";
}
return answ;
}
}
[Inject]
protected SharedMemService MStor { get; set; } = null!;
protected string tcModIns
{
get => _tcModIns;
set
{
if (_tcModIns != value)
{
_tcModIns = value;
MsgServ.UserPrefSet("TcMode", value);
}
}
}
#endregion Protected Properties
#region Protected Methods
protected async Task getWDim()
{
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
Height = dimension.Height;
Width = dimension.Width;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
//await Task.Delay(500);
if (firstRender)
{
await getWDim();
StateHasChanged();
Log.Debug($"Dimensioni schermo: {Width}x{Height}");
}
}
protected override async Task OnInitializedAsync()
{
tcModIns = MsgServ.UserPrefSetup("TcMode", "ms");
langIns = MsgServ.UserPrefSetup("Lang", "IT");
defCardModeIns = MsgServ.UserPrefSetup("DefCardMode", "full");
dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin");
await Task.Delay(1);
if (string.IsNullOrEmpty(currIpv4))
{
// ricalcolo e salvo...
if (httpContextAccessor.HttpContext != null)
{
var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
// provo a recuperare ipV4...
currIpv4 = EgwCoreLib.Razor.Data.IpUtils.getLocalIpv4(remoteIp);
}
}
}
protected async Task setDefCardMode(string defCardMode)
{
await Task.Delay(1);
defCardModeIns = defCardMode;
}
protected async Task setLang(string lang)
{
await Task.Delay(1);
langIns = lang;
}
protected async Task setTcMode(string tcMode)
{
await Task.Delay(1);
tcModIns = tcMode;
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private int MatrOpr
{
get => MsgServ.MatrOpr;
}
[Inject]
private MessageService MsgServ { get; set; } = null!;
private string UserName
{
get => MsgServ.CognomeNome;
}
#endregion Private Properties
}
}