diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 96be09c7..9808cc32 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -656,20 +656,20 @@ namespace MP.Data.Controllers /// Update record config /// /// - public bool ConfigUpdate(ConfigModel updRec) + public async Task ConfigUpdateAsync(ConfigModel updRec) { bool fatto = false; ConfigModel dbResult = new ConfigModel(); using (var dbCtx = new MoonProContext(options)) { - dbResult = dbCtx + dbResult = await dbCtx .DbSetConfig .Where(x => x.Chiave == updRec.Chiave) - .FirstOrDefault(); + .FirstOrDefaultAsync(); if (dbResult != null) { dbResult.Valore = updRec.Valore; - dbCtx.SaveChanges(); + await dbCtx.SaveChangesAsync(); fatto = true; } } diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 7a2894cb..08d03270 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -631,14 +631,14 @@ namespace MP.SPEC.Data /// Update chiave config /// /// - public bool ConfigUpdate(ConfigModel updRec) + public async Task ConfigUpdateAsync(ConfigModel updRec) { - using var activity = ActivitySource.StartActivity("ConfigUpdate"); + using var activity = ActivitySource.StartActivity("ConfigUpdateAsync"); string source = "DB"; - var updRes = dbController.ConfigUpdate(updRec); + var updRes = await dbController.ConfigUpdateAsync(updRec); activity?.SetTag("data.source", source); activity?.Stop(); - LogTrace($"ConfigUpdate Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"ConfigUpdateAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); return updRes; } diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor index e20b654c..4a655d60 100644 --- a/MP.SPEC/Pages/Articoli.razor +++ b/MP.SPEC/Pages/Articoli.razor @@ -19,10 +19,10 @@
- + - @if (ListAziende != null) { foreach (var item in ListAziende) @@ -32,7 +32,7 @@ } - +
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs index 0d7dbfe8..ce9bd81e 100644 --- a/MP.SPEC/Pages/Articoli.razor.cs +++ b/MP.SPEC/Pages/Articoli.razor.cs @@ -65,13 +65,15 @@ namespace MP.SPEC.Pages if (searchVal != value) { searchVal = value; +#if false var pUpd = Task.Run(async () => - { - ListRecords = null; - await Task.Delay(1); - await ReloadData(); - }); - pUpd.Wait(); + { + ListRecords = null; + await Task.Delay(1); + await ReloadDataAsync(); + }); + pUpd.Wait(); +#endif } } } @@ -117,7 +119,7 @@ namespace MP.SPEC.Pages protected async Task cancel() { currRecord = null; - await ReloadData(); + await ReloadDataAsync(); await Task.Delay(1); } @@ -151,7 +153,7 @@ namespace MP.SPEC.Pages await Task.Delay(1); var done = await MDService.ArticoliDeleteRecord(selRec); currRecord = null; - await ReloadData(); + await ReloadDataAsync(); await Task.Delay(1); } @@ -173,7 +175,7 @@ namespace MP.SPEC.Pages protected override async Task OnParametersSetAsync() { - await ReloadData(); + await ReloadDataAsync(); } protected void ResetData() @@ -185,7 +187,7 @@ namespace MP.SPEC.Pages protected async Task resetSearch() { SearchVal = ""; - await ReloadData(); + await ReloadDataAsync(); } protected async Task resetSel() @@ -209,14 +211,14 @@ namespace MP.SPEC.Pages await Task.Delay(1); var done = await MDService.ArticoliUpdateRecord(selRec); currRecord = null; - await ReloadData(); + await ReloadDataAsync(); await Task.Delay(1); } protected async Task UpdateData() { currRecord = null; - await ReloadData(); + await ReloadDataAsync(); } #endregion Protected Methods @@ -230,6 +232,7 @@ namespace MP.SPEC.Pages private List? ListAziende; private List? ListRecords; private List? ListTipoArt; + private int maxNumRecord = 5000; private List? SearchRecords; #endregion Private Fields @@ -278,24 +281,41 @@ namespace MP.SPEC.Pages if (value != _selAzienda) { _selAzienda = value; +#if false var pUpd = Task.Run(async () => - { - // svuoto cache redis... - ConfigModel updRec = new ConfigModel() - { - Chiave = "AZIENDA", - Valore = value - }; - MDService.ConfigUpdate(updRec); - await MDService.ConfigResetCache(); - // ricarico - await Task.Delay(1); - await ReloadData(); - }); - pUpd.Wait(); + { + // svuoto cache redis... + ConfigModel updRec = new ConfigModel() + { + Chiave = "AZIENDA", + Valore = value + }; + MDService.ConfigUpdate(updRec); + await MDService.ConfigResetCache(); + // ricarico + await Task.Delay(1); + await ReloadDataAsync(); + }); + pUpd.Wait(); +#endif } } } + private async Task ReloadAziendaAsync() + { + isLoading = true; + // svuoto cache redis... + ConfigModel updRec = new ConfigModel() + { + Chiave = "AZIENDA", + Valore = selAzienda + }; + await MDService.ConfigUpdateAsync(updRec); + await MDService.ConfigResetCache(); + // ricarico + await ReloadDataAsync(); + } + private bool ShowCharts { get; set; } = false; @@ -325,16 +345,16 @@ namespace MP.SPEC.Pages ListTipoArt = await MDService.AnagTipoArtLvAsync(); } - private async Task ReloadData() + private async Task ReloadDataAsync() { isLoading = true; - SearchRecords = await MDService.ArticoliGetSearchAsync(100000, selAzienda, SearchVal); + SearchRecords = await MDService.ArticoliGetSearchAsync(maxNumRecord, selAzienda, SearchVal); UpdateTable(); } private void UpdateTable() { - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + ListRecords = SearchRecords?.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList() ?? new(); isLoading = false; }