();
+ using (var dbCtx = new MoonProContext(options))
+ {
+ dbResult = await dbCtx
+ .DbSetLinkMenu
+ .Where(x => x.TipoLink == tipoLink)
+ .AsNoTracking()
+ .OrderBy(x => x.Ordine)
+ .ToListAsync();
+ }
+ return dbResult;
+ }
+
///
/// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato)
///
diff --git a/MP.SPEC/Components/Layout/NavMenu.razor.cs b/MP.SPEC/Components/Layout/NavMenu.razor.cs
index 87d2a650..1bc7153e 100644
--- a/MP.SPEC/Components/Layout/NavMenu.razor.cs
+++ b/MP.SPEC/Components/Layout/NavMenu.razor.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.Mvc.RazorPages;
using MP.SPEC.Data;
namespace MP.SPEC.Components.Layout
@@ -62,9 +61,9 @@ namespace MP.SPEC.Components.Layout
return MsgService.HasRole(Ruolo);
}
- protected override void OnInitialized()
+ protected override async Task OnInitializedAsync()
{
- ElencoLink = MDService.ElencoLink();
+ ElencoLink = await MDService.ElencoLinkAsync();
MService.EA_PageUpdated += OnPageUpdate;
}
diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor
index 0922b913..c7f09dfa 100644
--- a/MP.SPEC/Components/ListODL.razor
+++ b/MP.SPEC/Components/ListODL.razor
@@ -11,7 +11,7 @@ else
@if (showKitDetail)
{
-
+
}
@if (currRecord != null && !showStats && isCurrOdl)
{
@@ -109,7 +109,7 @@ else
@record.CodArticolo
@if (CheckIsKit(record.CodArticolo))
{
-
+
}
@record.DescArticolo
diff --git a/MP.SPEC/Components/ListODL.razor.cs b/MP.SPEC/Components/ListODL.razor.cs
index 480caa30..c5791926 100644
--- a/MP.SPEC/Components/ListODL.razor.cs
+++ b/MP.SPEC/Components/ListODL.razor.cs
@@ -191,11 +191,11 @@ namespace MP.SPEC.Components
return answ;
}
- protected void KitToggleDetail(string? selCodArt)
+ protected async Task KitToggleDetailAsync(string? selCodArt)
{
if (!string.IsNullOrEmpty(selCodArt))
{
- ListKitTemplate = MDService.TemplateKitFilt(selCodArt, "");
+ ListKitTemplate = await MDService.TemplateKitFiltAsync(selCodArt, "");
}
else
{
diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor
index 109b0421..ac739a63 100644
--- a/MP.SPEC/Components/ListPODL.razor
+++ b/MP.SPEC/Components/ListPODL.razor
@@ -16,7 +16,7 @@ else
@if (showKitDetail)
{
-
+
}
@@ -143,7 +143,7 @@ else
@record.CodArticolo
@if (CheckIsKit(record.CodArticolo))
{
-
+
}
@record.DescArticolo
diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs
index e6ac8080..4b75606b 100644
--- a/MP.SPEC/Components/ListPODL.razor.cs
+++ b/MP.SPEC/Components/ListPODL.razor.cs
@@ -151,11 +151,11 @@ namespace MP.SPEC.Components
await RecordEdit.InvokeAsync(selRec);
}
- protected void KitToggleDetail(PODLExpModel? recSel)
+ protected async Task KitToggleDetailAsync(PODLExpModel? recSel)
{
if (recSel != null)
{
- ListKitTemplate = MDService.TemplateKitFilt(recSel.CodArticolo, "");
+ ListKitTemplate = await MDService.TemplateKitFiltAsync(recSel.CodArticolo, "");
ListPOdlKit = MDService.POdlListByKitParent(recSel.IdxPromessa);
}
else
diff --git a/MP.SPEC/Components/ProdKit/KitVerify.razor b/MP.SPEC/Components/ProdKit/KitVerify.razor
index 96e5f8ba..6ead57b4 100644
--- a/MP.SPEC/Components/ProdKit/KitVerify.razor
+++ b/MP.SPEC/Components/ProdKit/KitVerify.razor
@@ -16,7 +16,7 @@
{
@if (doShowDetail)
{
-
+
}
@@ -33,7 +33,7 @@
{
|
-
+
|
@record.CodArtParent |
@record.ChildFound / @numRecWsm |
diff --git a/MP.SPEC/Components/ProdKit/KitVerify.razor.cs b/MP.SPEC/Components/ProdKit/KitVerify.razor.cs
index 13868a07..96c13bc6 100644
--- a/MP.SPEC/Components/ProdKit/KitVerify.razor.cs
+++ b/MP.SPEC/Components/ProdKit/KitVerify.razor.cs
@@ -41,17 +41,17 @@ namespace MP.SPEC.Components.ProdKit
#region Protected Methods
- protected void KitToggleDetail(TksScoreModel? currRec)
+ protected async Task KitToggleDetailAsync(TksScoreModel? currRec)
{
CodArtParent = currRec != null ? currRec.CodArtParent : "";
if (!string.IsNullOrEmpty(CodArtParent))
{
- ListKitTemplate = MDService.TemplateKitFilt(CodArtParent, "");
+ ListKitTemplate = await MDService.TemplateKitFiltAsync(CodArtParent, "");
totalKitCount = ListKitTemplate.Count;
ListRecKitPODL = PodlRecords
- .Where(x => !string.IsNullOrEmpty(x.KeyRichiesta)
+ .Where(x => !string.IsNullOrEmpty(x.KeyRichiesta)
&& x.KeyRichiesta.StartsWith("KIT")
- && x.CodArticolo==CodArtParent)
+ && x.CodArticolo == CodArtParent)
.ToList();
}
else
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index eb470669..13acb697 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -838,14 +838,14 @@ namespace MP.SPEC.Data
/// Elenco link validi
///
///
- public List ElencoLink()
+ public async Task> ElencoLinkAsync()
{
- using var activity = ActivitySource.StartActivity("ElencoLink");
+ using var activity = ActivitySource.StartActivity("ElencoLinkAsync");
string source = "DB";
- var linkList = dbController.ElencoLink();
+ var linkList = await dbController.ElencoLinkAsync();
activity?.SetTag("data.source", source);
activity?.Stop();
- LogTrace($"ElencoLink | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
+ LogTrace($"ElencoLinkAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return linkList;
}
@@ -2773,14 +2773,14 @@ namespace MP.SPEC.Data
///
///
///
- public List TemplateKitFilt(string codParent, string codChild)
+ public async Task> TemplateKitFiltAsync(string codParent, string codChild)
{
- using var activity = ActivitySource.StartActivity("TemplateKitFilt");
+ using var activity = ActivitySource.StartActivity("TemplateKitFiltAsync");
string source = "DB";
List? result = new List();
// cerco in redis...
string currKey = $"{Utils.redisKitTempl}:{codParent}:{codChild}";
- RedisValue rawData = redisDb.StringGet(currKey);
+ RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject>($"{rawData}");
@@ -2791,7 +2791,7 @@ namespace MP.SPEC.Data
result = dbController.TemplateKitFilt(codParent, codChild);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache));
+ await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache));
}
if (result == null)
{
@@ -2800,7 +2800,7 @@ namespace MP.SPEC.Data
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
activity?.Stop();
- LogTrace($"TemplateKitFilt | {source} | {activity?.Duration.TotalMilliseconds}ms");
+ LogTrace($"TemplateKitFiltAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
diff --git a/MP.SPEC/Pages/Index.razor.cs b/MP.SPEC/Pages/Index.razor.cs
index 0dad9401..5fbbf699 100644
--- a/MP.SPEC/Pages/Index.razor.cs
+++ b/MP.SPEC/Pages/Index.razor.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
-using MP.AppAuth.Models;
using MP.Data.DbModels;
using MP.SPEC.Data;
@@ -38,7 +37,7 @@ namespace MP.SPEC.Pages
protected override async Task OnInitializedAsync()
{
// recupero elenco link
- ElencoLink = MDService.ElencoLink();
+ ElencoLink = await MDService.ElencoLinkAsync();
currAzienda = await MDService.ConfigTryGetAsync("AZIENDA");
await Task.Delay(1);
}
diff --git a/MP.SPEC/Pages/KIT.razor b/MP.SPEC/Pages/KIT.razor
index 2596ab1e..8b46229c 100644
--- a/MP.SPEC/Pages/KIT.razor
+++ b/MP.SPEC/Pages/KIT.razor
@@ -29,12 +29,12 @@
}
-
+
-
+
diff --git a/MP.SPEC/Pages/KIT.razor.cs b/MP.SPEC/Pages/KIT.razor.cs
index b40dece1..30eb1275 100644
--- a/MP.SPEC/Pages/KIT.razor.cs
+++ b/MP.SPEC/Pages/KIT.razor.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
using MP.Data.DbModels;
using MP.SPEC.Data;
@@ -56,9 +55,6 @@ namespace MP.SPEC.Pages
if (sCodChild != value)
{
sCodChild = value;
- currPage = 1;
- ListRecords = null;
- ReloadData();
}
}
}
@@ -75,9 +71,6 @@ namespace MP.SPEC.Pages
if (sCodParent != value)
{
sCodParent = value;
- currPage = 1;
- ListRecords = null;
- ReloadData();
}
}
}
@@ -142,8 +135,7 @@ namespace MP.SPEC.Pages
protected async Task DoCancel()
{
EditRecord = null;
- ReloadData();
- await Task.Delay(1);
+ await ResetDataAsync();
}
protected async Task DoClone(TemplateKitModel selRec)
@@ -170,11 +162,9 @@ namespace MP.SPEC.Pages
if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione riga KIT: sei sicuro di voler procedere?"))
return;
- await Task.Delay(1);
var done = await MDService.TemplateKitDelete(selRec);
EditRecord = null;
- ReloadData();
- await Task.Delay(1);
+ await ResetDataAsync();
}
///
@@ -203,8 +193,7 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
var done = await MDService.TemplateKitUpsert(selRec, CodAzienda);
EditRecord = null;
- ReloadData();
- await Task.Delay(1);
+ await ResetDataAsync();
}
protected override void OnInitialized()
@@ -237,15 +226,15 @@ namespace MP.SPEC.Pages
}
}
- protected override void OnParametersSet()
+ protected override Task OnParametersSetAsync()
{
- ReloadData();
+ return ReloadDataAsync();
}
- protected void ResetChild()
+ protected async Task ResetChild()
{
SearchChild = "";
- ReloadData();
+ await ReloadDataAsync();
}
protected void ResetData()
@@ -253,10 +242,10 @@ namespace MP.SPEC.Pages
EditRecord = null;
}
- protected void ResetParent()
+ protected async Task ResetParent()
{
SearchParent = "";
- ReloadData();
+ await ReloadDataAsync();
}
protected void ResetSel()
@@ -280,10 +269,10 @@ namespace MP.SPEC.Pages
numRecord = newNum;
}
- protected void UpdateData()
+ protected async Task UpdateData()
{
EditRecord = null;
- ReloadData();
+ await ReloadDataAsync();
}
#endregion Protected Methods
@@ -305,6 +294,7 @@ namespace MP.SPEC.Pages
private bool enabKitCount = false;
private bool enabKitSearch = false;
+
private List? ListRecords;
private int minChar = 2;
@@ -329,7 +319,7 @@ namespace MP.SPEC.Pages
if (_currPage != value)
{
_currPage = value;
- ReloadData();
+ UpdateTable();
}
}
}
@@ -344,7 +334,7 @@ namespace MP.SPEC.Pages
if (_numRecord != value)
{
_numRecord = value;
- ReloadData();
+ UpdateTable();
}
}
}
@@ -357,18 +347,25 @@ namespace MP.SPEC.Pages
#region Private Methods
- private void ReloadData()
+ ///
+ /// reeload dati + paginazione
+ ///
+ ///
+ private async Task ReloadDataAsync()
{
isLoading = true;
- SearchRecords = MDService.TemplateKitFilt(SearchParent, SearchChild);
+ SearchRecords = await MDService.TemplateKitFiltAsync(SearchParent, SearchChild);
totalCount = SearchRecords.Count;
// conto i kit = distinct...
kitCount = SearchRecords.GroupBy(x => x.CodArtParent).Count();
- ListRecords = SearchRecords
- .Skip(numRecord * (currPage - 1))
- .Take(numRecord)
- .ToList();
- isLoading = false;
+ UpdateTable();
+ }
+
+ private Task ResetDataAsync()
+ {
+ currPage = 1;
+ ListRecords = null;
+ return ReloadDataAsync();
}
///
@@ -392,6 +389,18 @@ namespace MP.SPEC.Pages
}
}
+ ///
+ /// Paginazione dati
+ ///
+ private void UpdateTable()
+ {
+ ListRecords = SearchRecords?
+ .Skip(numRecord * (currPage - 1))
+ .Take(numRecord)
+ .ToList() ?? new();
+ isLoading = false;
+ }
+
#endregion Private Methods
}
}
\ No newline at end of file