Code reorg-cleanup

This commit is contained in:
Samuele Locatelli
2026-02-26 18:35:53 +01:00
parent 8757528de3
commit 003f8792c4
2 changed files with 109 additions and 82 deletions
+83 -57
View File
@@ -10,12 +10,7 @@ namespace GWMS.UI.Components
{
public partial class OrderAdminEditor
{
private List<SupplierModel> suppList;
private List<TransporterModel> transpList;
protected OrderModel _currItem = new OrderModel();
protected int _supplierId { get; set; } = 0;
#region Public Properties
[Parameter]
public OrderModel currItem
@@ -30,10 +25,9 @@ namespace GWMS.UI.Components
}
}
private bool editAll { get; set; } = false;
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
@@ -53,28 +47,83 @@ namespace GWMS.UI.Components
}
}
#endregion Public Properties
#region Protected Fields
protected OrderModel _currItem = new OrderModel();
#endregion Protected Fields
#region Protected Properties
protected int _supplierId { get; set; } = 0;
[Inject]
protected MessageService MServ { get; set; } = null;
private async Task saveUpdate()
protected string rawCode
{
if (_currItem != null)
get
{
using var activity = StartTracing("SaveUpdate");
await DataService.OrderUpdate(_currItem);
activity?.SetTag("order.code", _currItem.OrderCode);
activity?.SetTag("order.operator", MServ.UserName);
activity?.SetTag("order.quantity_req", _currItem.OrderQty);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Order null!");
string answ = "";
if (_currItem != null)
{
answ = _currItem.OrderCode;
}
return answ;
}
}
#endregion Protected Properties
#region Protected Methods
// Blazor: get query parm from the URL
protected string GetQueryParm(string parmName)
{
var uriBuilder = new UriBuilder(NavManager.Uri);
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
return q[parmName] ?? "";
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
await JSRuntime.InvokeVoidAsync("displayQr", "qrCodeImg", rawCode);
}
protected async Task ReloadAllData()
{
suppList = await DataService.SuppliersGetAll();
transpList = await DataService.TransportersGetAll();
// vedere anche https://www.mikesdotnetting.com/article/340/working-with-query-strings-in-blazor
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
var currMode = GetQueryParm("currMode");
if (!string.IsNullOrEmpty(currMode))
{
editAll = currMode.Equals("debug");
}
}
#endregion Protected Methods
#region Private Fields
private List<SupplierModel> suppList;
private List<TransporterModel> transpList;
#endregion Private Fields
#region Private Properties
private bool editAll { get; set; } = false;
#endregion Private Properties
#region Private Methods
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
@@ -100,46 +149,23 @@ namespace GWMS.UI.Components
}
}
protected override async Task OnInitializedAsync()
private async Task saveUpdate()
{
await ReloadAllData();
await JSRuntime.InvokeVoidAsync("displayQr", "qrCodeImg", rawCode);
}
protected string rawCode
{
get
if (_currItem != null)
{
string answ = "";
if (_currItem != null)
{
answ = _currItem.OrderCode;
}
return answ;
using var activity = StartTracing("SaveUpdate");
await DataService.OrderUpdate(_currItem);
activity?.SetTag("order.code", _currItem.OrderCode);
activity?.SetTag("order.operator", MServ.UserName);
activity?.SetTag("order.quantity_req", _currItem.OrderQty);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Order null!");
}
}
protected async Task ReloadAllData()
{
suppList = await DataService.SuppliersGetAll();
transpList = await DataService.TransportersGetAll();
// vedere anche https://www.mikesdotnetting.com/article/340/working-with-query-strings-in-blazor
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
var currMode = GetQueryParm("currMode");
if (!string.IsNullOrEmpty(currMode))
{
editAll = currMode.Equals("debug");
}
}
// Blazor: get query parm from the URL
protected string GetQueryParm(string parmName)
{
var uriBuilder = new UriBuilder(NavManager.Uri);
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
return q[parmName] ?? "";
}
#endregion Private Methods
}
}
+26 -25
View File
@@ -984,7 +984,7 @@ namespace GWMS.UI.Data
string cacheKey = mHash("PLANTS:ListDTO");
#if false
Stopwatch sw = new Stopwatch();
sw.Start();
sw.Start();
#endif
string source = "DB";
rawData = await redisDb.StringGetAsync(cacheKey);
@@ -1003,7 +1003,7 @@ namespace GWMS.UI.Data
}
#if false
sw.Stop();
Log.Info($"PlantDtoGetAll | {source} | {sw.ElapsedMilliseconds} ms");
Log.Info($"PlantDtoGetAll | {source} | {sw.ElapsedMilliseconds} ms");
#endif
// elimino veto!
await ExecFlushRedisPattern(cacheVetoKey);
@@ -1184,7 +1184,7 @@ namespace GWMS.UI.Data
string cacheKey = mHash("PLANTS:ListModel");
#if false
Stopwatch sw = new Stopwatch();
sw.Start();
sw.Start();
#endif
string rawData;
rawData = await redisDb.StringGetAsync(cacheKey);
@@ -1209,7 +1209,7 @@ namespace GWMS.UI.Data
}
#if false
sw.Stop();
Log.Debug($"PlantsList | {source} | {sw.ElapsedMilliseconds} ms");
Log.Debug($"PlantsList | {source} | {sw.ElapsedMilliseconds} ms");
#endif
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
@@ -1892,6 +1892,11 @@ namespace GWMS.UI.Data
#region Private Fields
/// <summary>
/// Oggetto per collezione dati Activity (span in Uptrace)
/// </summary>
private static readonly ActivitySource ActivitySource = new ActivitySource("GWMS.Data");
private static IConfiguration _configuration;
private static ILogger<GWMSDataService> _logger;
@@ -1943,29 +1948,10 @@ namespace GWMS.UI.Data
/// </summary>
private Random rnd = new Random();
#endregion Private Fields
/// <summary>
/// Oggetto per collezione dati Activity (span in Uptrace)
/// </summary>
private static readonly ActivitySource ActivitySource = new ActivitySource("GWMS.Data");
/// <summary>
/// Helper trace messaggio log (SE abilitato)
/// </summary>
/// <param name="traceMsg"></param>
private void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null)
{
if (!traceEnabled)
return;
reqLevel ??= NLog.LogLevel.Debug;
// Loggo!
Log.Log(reqLevel, traceMsg);
}
private bool traceEnabled = false;
#endregion Private Fields
#region Private Properties
private string CodApp { get; set; } = "";
@@ -2058,6 +2044,21 @@ namespace GWMS.UI.Data
return mHash($"SavedTask:{idxMacchina}");
}
/// <summary>
/// Helper trace messaggio log (SE abilitato)
/// </summary>
/// <param name="traceMsg"></param>
private void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null)
{
if (!traceEnabled)
return;
reqLevel ??= NLog.LogLevel.Debug;
// Loggo!
Log.Log(reqLevel, traceMsg);
}
/// <summary>
/// Recupera PlantDTO e aggiorno valori attuali (se presente...)
/// ATTENZIONE: i dati sono sempre ricevuti PER SINGOLO PlantId!!!