From 66469b9df79188a123c0273d52a72bafefe48dbc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 1 Aug 2022 12:43:42 +0200 Subject: [PATCH] Inizio pagina PODL/ODL correnti --- MP.Data/Controllers/MpSpecController.cs | 9 ++++ MP.SPEC/Data/MpDataService.cs | 65 ++++++++++++++++++++++- MP.SPEC/Pages/ODL.razor | 42 +++++++++++++-- MP.SPEC/Pages/ODL.razor.cs | 69 +++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 MP.SPEC/Pages/ODL.razor.cs diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 929c3344..1c0f822f 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -79,6 +79,15 @@ namespace MP.Data.Controllers return ListValuesFilt("AnagArticoli", "Tipo"); } + /// + /// Elenco valori ammessi x Stati commessa (es Yacht Baglietto) + /// + /// + public List AnagStatiComm() + { + return ListValuesFilt("PODL", "StatoComm"); + } + /// /// Elenco valori link (x home e navMenu laterale) diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 70069dad..10cb7fff 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -69,9 +69,38 @@ namespace MP.SPEC.Data public async Task> AnagTipoArtLV() { - return await Task.FromResult(dbController.AnagTipoArtLV()); + int maxAgeConfig = 5; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + RedisValue rawData = await redisDb.StringGetAsync(redisTipoArt); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagTipoArtLV Read from REDIS: {ts.TotalMilliseconds}ms"); + } + else + { + result = await Task.FromResult(dbController.AnagTipoArtLV()); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(redisTipoArt, rawData, TimeSpan.FromMinutes(maxAgeConfig)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagTipoArtLV Read from DB: {ts.TotalMilliseconds}ms"); + } + if (result == null) + { + result = new List(); + } + return result; } + + /// /// Eliminazione record selezionato /// @@ -202,6 +231,38 @@ namespace MP.SPEC.Data return result; } + public async Task> AnagStatiComm() + { + int maxAgeConfig = 5; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + RedisValue rawData = await redisDb.StringGetAsync(redisStatoCom); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagStatiComm Read from REDIS: {ts.TotalMilliseconds}ms"); + } + else + { + result = await Task.FromResult(dbController.AnagStatiComm()); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(redisStatoCom, rawData, TimeSpan.FromMinutes(maxAgeConfig)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms"); + } + if (result == null) + { + result = new List(); + } + return result; + } + /// /// Reset dati cache config /// @@ -330,6 +391,8 @@ namespace MP.SPEC.Data private int fastRefreshMs = 1000; private string redisConfKey = "MP:MON:Cache:Config"; + private string redisTipoArt = "MP:MON:Cache:TipoArt"; + private string redisStatoCom = "MP:MON:Cache:StatoCom"; /// /// Oggetto per connessione a REDIS diff --git a/MP.SPEC/Pages/ODL.razor b/MP.SPEC/Pages/ODL.razor index 71321c43..57978dd3 100644 --- a/MP.SPEC/Pages/ODL.razor +++ b/MP.SPEC/Pages/ODL.razor @@ -1,7 +1,43 @@ @page "/ODL" -

ODL

-@code { -} +
+
+
+
+

Ordini Di Lavoro

+
+
+
+
+ ODL Programmati / In Corso +
+ + +
+
+
+ +
+
+
+
+
+
+
+ @**@ +
+ + diff --git a/MP.SPEC/Pages/ODL.razor.cs b/MP.SPEC/Pages/ODL.razor.cs new file mode 100644 index 00000000..1e203e99 --- /dev/null +++ b/MP.SPEC/Pages/ODL.razor.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using MP.SPEC; +using MP.SPEC.Shared; +using MP.SPEC.Components; +using MP.SPEC.Data; + +namespace MP.SPEC.Pages +{ + public partial class ODL + { + + private List? ListStati; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected MpDataService MDService { get; set; } + + [Inject] + protected MessageService MessageService { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + + private bool isLoading { get; set; } = false; + + protected override async Task OnInitializedAsync() + { + await reloadData(); + } + + + private async Task reloadData() + { + isLoading = true; + ListStati = await MDService.AnagStatiComm(); + isLoading = false; + } + + private bool showCurrent { get; set; } = false; + + private async Task toggleCurrent() + { + showCurrent = !showCurrent; + await Task.Delay(1); + } + + private string textToggle + { + get => showCurrent ? "In Corso" : "Programmati"; + } + + private string selStato { get; set; } = "*"; + } +} \ No newline at end of file