From b5ed1571064aafb6d9bfc5c8eb695d3dc6ba4e6e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Nov 2022 18:30:06 +0100 Subject: [PATCH] PODL: - Fix ordinamento su DB --- MP.Data/Controllers/MpSpecController.cs | 4 +- MP.Data/Utils.cs | 65 ++++++++++++++++++++++++- MP.SPEC/Components/ListPODL.razor.cs | 24 +-------- MP.SPEC/Data/MpDataService.cs | 37 +++++++++----- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/PODL.razor.cs | 13 ++--- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 9 files changed, 102 insertions(+), 49 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 968f40e1..d9dc302b 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1064,7 +1064,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task PODLUpdateRecord(PODLExpModel editRec) + public async Task PODLUpdateRecord(PODLModel editRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) @@ -1092,7 +1092,7 @@ namespace MP.Data.Controllers { dbCtx .DbSetPODL - .Add(currRec); + .Add(editRec); } await dbCtx.SaveChangesAsync(); fatto = true; diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index f7f548cd..c52fc80b 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -1,5 +1,6 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; using MP.Data.DTO; using System; using System.Collections.Generic; @@ -13,7 +14,7 @@ namespace MP.Data public class Utils { #region Public Properties - + public static string redKeyArtUsed { @@ -109,6 +110,68 @@ namespace MP.Data return answ; } + public class POdlExt + { + /// + /// Clona un POdleExt a POdl + /// + /// + /// + public static PODLModel convertToPOdl(PODLExpModel selRec) + { + // creo record duplicato... + PODLModel newRec = new PODLModel() + { + Attivabile = selRec.Attivabile, + CodArticolo = selRec.CodArticolo, + CodCli = selRec.CodCli, + CodGruppo = selRec.CodGruppo, + DueDate = selRec.DueDate, + IdxMacchina = selRec.IdxMacchina, + IdxOdl = selRec.IdxOdl, + IdxPromessa = 0, + InsertDate = selRec.InsertDate, + KeyBCode = selRec.KeyBCode, + KeyRichiesta = selRec.KeyRichiesta, + Note = selRec.Note, + NumPezzi = selRec.NumPezzi, + Priorita = selRec.Priorita, + PzPallet = selRec.PzPallet, + Tcassegnato = selRec.Tcassegnato + }; + return newRec; + } + /// + /// Clona un POdleExt + /// + /// + /// + public static PODLExpModel clone(PODLExpModel selRec) + { + // creo record duplicato... + PODLExpModel newRec = new PODLExpModel() + { + Attivabile = selRec.Attivabile, + CodArticolo = selRec.CodArticolo, + CodCli = selRec.CodCli, + CodGruppo = selRec.CodGruppo, + DueDate = selRec.DueDate, + IdxMacchina = selRec.IdxMacchina, + IdxOdl = selRec.IdxOdl, + IdxPromessa = 0, + InsertDate = selRec.InsertDate, + KeyBCode = selRec.KeyBCode, + KeyRichiesta = selRec.KeyRichiesta, + Note = $"DUPLICATED - {selRec.Note}", + NumPezzi = selRec.NumPezzi, + Priorita = selRec.Priorita, + PzPallet = selRec.PzPallet, + Tcassegnato = selRec.Tcassegnato + }; + return newRec; + } + } + #endregion Public Methods } } \ No newline at end of file diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index 73730092..5ee60510 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; +using MP.Data; using MP.Data.DatabaseModels; using MP.SPEC.Data; using MP.SPEC.Services; @@ -76,28 +77,7 @@ namespace MP.SPEC.Components protected async Task cloneRecord(PODLExpModel selRec) { - // creo record duplicato... - PODLExpModel newRec = new PODLExpModel() - { - Attivabile = selRec.Attivabile, - CodArticolo = selRec.CodArticolo, - CodCli = selRec.CodCli, - CodGruppo = selRec.CodGruppo, - DueDate = selRec.DueDate, - IdxMacchina = selRec.IdxMacchina, - IdxOdl = selRec.IdxOdl, - IdxPromessa = 0, - InsertDate = selRec.InsertDate, - KeyBCode = selRec.KeyBCode, - KeyRichiesta = selRec.KeyRichiesta, - Note = $"DUPLICATED - {selRec.Note}", - NumPezzi = selRec.NumPezzi, - Priorita = selRec.Priorita, - PzPallet = selRec.PzPallet, - Tcassegnato = selRec.Tcassegnato - }; - currRecord = selRec; - await RecordSel.InvokeAsync(newRec); + await RecordSel.InvokeAsync(Utils.POdlExt.clone(selRec)); } /// diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index a8a89dc6..e9357190 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -708,7 +708,7 @@ namespace MP.SPEC.Data Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - string currKey = $"{redisPOdlList}:{lanciato}:{keyRichPart}:{idxMacchina}:{codGruppo}"; + string currKey = $"{redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}"; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) @@ -1064,7 +1064,12 @@ namespace MP.SPEC.Data /// public async Task PODLDeleteRecord(PODLExpModel currRec) { - return await dbController.PODLDeleteRecord(currRec); + var dbResult = await dbController.PODLDeleteRecord(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; } /// @@ -1074,7 +1079,12 @@ namespace MP.SPEC.Data /// public async Task POdlDoSetup(PODLExpModel currRec) { - return await dbController.PODL_startSetup(currRec, 0, 1, 1, ""); + var dbResult = await dbController.PODL_startSetup(currRec, 0, 1, 1, ""); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; } /// @@ -1082,13 +1092,13 @@ namespace MP.SPEC.Data /// /// /// - public async Task POdlUpdateRecord(PODLExpModel currRec) + public async Task POdlUpdateRecord(PODLModel currRec) { var dbResult = await dbController.PODLUpdateRecord(currRec); // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisPOdlList}:*"); + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); bool answ = await ExecFlushRedisPattern(pattern); - + await Task.Delay(1); return dbResult; } @@ -1243,13 +1253,16 @@ namespace MP.SPEC.Data private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList"; - private const string redisOdlCurrByMac = redisBaseAddr + "SPEC:Cache:OdlByMac"; - private const string redisOdlList = redisBaseAddr + "SPEC:Cache:OdlList"; - private const string redisPOdlByOdl = redisBaseAddr + "SPEC:Cache:POdlByOdl"; - private const string redisPOdlByPOdl = redisBaseAddr + "SPEC:Cache:POdlByPOdl"; - private const string redisPOdlList = redisBaseAddr + "SPEC:Cache:POdlList"; - private const string redisPOdlListNOOdl = redisBaseAddr + "SPEC:Cache:POdlListNOOdl"; + private const string redisXdlData = redisBaseAddr + "SPEC:Cache:XDL"; + + private const string redisOdlCurrByMac = redisXdlData + ":OdlByMac"; + private const string redisOdlList = redisXdlData + ":OdlList"; + + private const string redisPOdlByOdl = redisXdlData + ":POdlByOdl"; + private const string redisPOdlByPOdl = redisXdlData + ":POdlByPOdl"; + private const string redisPOdlList = redisXdlData + ":POdlList"; + private const string redisPOdlListNOOdl = redisXdlData + ":POdlListNOOdl"; private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt"; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index fe0bf660..061dadf4 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2211.2817 + 6.16.2211.2818 diff --git a/MP.SPEC/Pages/PODL.razor.cs b/MP.SPEC/Pages/PODL.razor.cs index 6f1b20e6..92b1d249 100644 --- a/MP.SPEC/Pages/PODL.razor.cs +++ b/MP.SPEC/Pages/PODL.razor.cs @@ -182,14 +182,11 @@ namespace MP.SPEC.Pages if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?")) return; await Task.Delay(1); - var done = await MDService.POdlUpdateRecord(selRec); - await callSyncDb(selRec); + var clonedRec = MP.Data.Utils.POdlExt.convertToPOdl(selRec); + var done = await MDService.POdlUpdateRecord(clonedRec); + await callSyncDb(clonedRec); currRecord = null; - await reloadData(); - // forzo update parametri - await Task.Delay(1); - currFase = "*"; - await Task.Delay(1); + NavManager.NavigateTo(NavManager.Uri, true); } protected void UpdateTotCount(int newTotCount) @@ -359,7 +356,7 @@ namespace MP.SPEC.Pages /// /// /// - private async Task callSyncDb(PODLExpModel selRec) + private async Task callSyncDb(PODLModel selRec) { // chiamo aggiunta task SyncDb... string idxMacc = selRec.IdxMacchina; diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 999d97cd..6835ff4b 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2211.2817

+

Versione: 6.16.2211.2818


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 2ecd71f2..80b0949d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2211.2817 +6.16.2211.2818 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 2ef22785..12a66a71 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2211.2817 + 6.16.2211.2818 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false