From b9e9a4d556ea89c2f08f65dc06717c87fc3f226f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 14 Nov 2023 11:51:10 +0100 Subject: [PATCH] Update gestione rilettura prod + inizio fix redis x user --- MP-TAB-SERV/Components/CmpTop.razor.cs | 144 +++++++++++++------------ MP-TAB-SERV/Components/OdlMan.razor | 2 +- MP-TAB-SERV/Components/OdlMan.razor.cs | 12 ++- MP-TAB-SERV/MP-TAB-SERV.csproj | 2 +- MP-TAB-SERV/Resources/ChangeLog.html | 2 +- MP-TAB-SERV/Resources/VersNum.txt | 2 +- MP-TAB-SERV/Resources/manifest.xml | 2 +- MP.Data/Controllers/MpTabController.cs | 15 ++- MP.Data/Services/TabDataService.cs | 5 +- 9 files changed, 100 insertions(+), 86 deletions(-) diff --git a/MP-TAB-SERV/Components/CmpTop.razor.cs b/MP-TAB-SERV/Components/CmpTop.razor.cs index 796476d5..2c8c859d 100644 --- a/MP-TAB-SERV/Components/CmpTop.razor.cs +++ b/MP-TAB-SERV/Components/CmpTop.razor.cs @@ -1,34 +1,32 @@ -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_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; -using MP.Data; using MP.Data.DatabaseModels; -using MP.Data.DTO; using MP.Data.Services; -using Newtonsoft.Json; using NLog; -using EgwCoreLib.Razor; -using MP_TAB_SERV.Pages; -using NLog.Fluent; using System.Diagnostics; namespace MP_TAB_SERV.Components { public partial class CmpTop { + #region Public Properties + + [Parameter] + public List CurrMenuItems { get; set; } = new List(); + + #endregion Public Properties + + #region Protected Fields + + protected string ResetClass = "btn-primary"; + + #endregion Protected Fields + + #region Protected Properties + + protected string CurrOprTknLS { get; set; } = null!; + + protected string CurrOprTknRedis { get; set; } = null!; + [Inject] protected ListSelectDataSrv MDataService { get; set; } = null!; @@ -44,11 +42,56 @@ namespace MP_TAB_SERV.Components [Inject] protected TabDataService TDService { get; set; } = null!; - [Parameter] - public List CurrMenuItems { get; set; } = new List(); + #endregion Protected Properties + #region Protected Methods - protected string ResetClass = "btn-primary"; + protected async Task ForceReload() + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + Log.Info("Start ForceReload"); + ResetClass = "btn-warning"; + await InvokeAsync(StateHasChanged); + // reset cache varie + await MsgServ.ClearLocalStor(); + await MsgServ.ClearSessionStor(); + await MDataService.FlushCache(); + // reload MStor + await ReloadMemStor(); + // calcolo tempo esecuzione + sw.Stop(); + int delta = 500 - (int)sw.ElapsedMilliseconds; + delta = delta > 0 ? delta : 50; + await Task.Delay(delta); + ResetClass = "btn-primary"; + // await InvokeAsync(StateHasChanged); + Log.Info($"ForceReload completed in {sw.ElapsedMilliseconds}ms"); + // ricarica pagina! + NavMan.NavigateTo("/", true); + } + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + CurrOprTknLS = await MsgServ.getCurrOperDtoAsync(); + var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS); + CurrOprTknRedis = await TDService.OperatoreGetRedis(MsgServ.MatrOpr); + if (CurrOprTknRedis == "") + { + if (!NavMan.Uri.Contains("reg-new-device")) + { + NavMan.NavigateTo("reg-new-device", true); + } + } + else if (CurrOprTknRedis != "") + { + if (!NavMan.Uri.Contains("status-map")) + { + NavMan.NavigateTo("status-map", true); + } + } + } protected async Task ReloadMemStor() { @@ -87,53 +130,12 @@ namespace MP_TAB_SERV.Components TDService.SetupConfig(); } - protected async Task ForceReload() - { - Stopwatch sw = new Stopwatch(); - sw.Start(); - Log.Info("Start ForceReload"); - ResetClass = "btn-warning"; - await InvokeAsync(StateHasChanged); - // reset cache varie - await MsgServ.ClearLocalStor(); - await MsgServ.ClearSessionStor(); - await MDataService.FlushCache(); - // reload MStor - await ReloadMemStor(); - // calcolo tempo esecuzione - sw.Stop(); - int delta = 500 - (int)sw.ElapsedMilliseconds; - delta = delta > 0 ? delta : 50; - await Task.Delay(delta); - ResetClass = "btn-primary"; - // await InvokeAsync(StateHasChanged); - Log.Info($"ForceReload completed in {sw.ElapsedMilliseconds}ms"); - // ricarica pagina! - NavMan.NavigateTo("/", true); - } + #endregion Protected Methods - protected override async Task OnInitializedAsync() - { - await Task.Delay(1); - CurrOprTknLS = await MsgServ.getCurrOperDtoAsync(); - var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS); - CurrOprTknRedis = await TDService.OperatoreGetRedis(MsgServ.MatrOpr); - if (CurrOprTknRedis == "") - { - if (!NavMan.Uri.Contains("regnewdevice")) - { - NavMan.NavigateTo("regnewdevice", true); - } - } - else if (CurrOprTknRedis != "") - { - if (!NavMan.Uri.Contains("status-map")) - { - NavMan.NavigateTo("status-map", true); - } - } - } - protected string CurrOprTknLS { get; set; } = null!; - protected string CurrOprTknRedis { get; set; } = null!; + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/OdlMan.razor b/MP-TAB-SERV/Components/OdlMan.razor index eb43683b..68db7337 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor +++ b/MP-TAB-SERV/Components/OdlMan.razor @@ -255,7 +255,7 @@ } else { - if (odlOk) + if (odlOk && showChkCloseOdlVal) {
diff --git a/MP-TAB-SERV/Components/OdlMan.razor.cs b/MP-TAB-SERV/Components/OdlMan.razor.cs index ee193877..ca176060 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor.cs +++ b/MP-TAB-SERV/Components/OdlMan.razor.cs @@ -641,6 +641,7 @@ namespace MP_TAB_SERV.Components { //baseLang = SMServ.GetConf("baseLang"); numDayOdl = SMServ.GetConfInt("numDaySelOdl"); + forceCloseOdl = SMServ.GetConfBool("chkCloseOdl"); confRett = SMServ.GetConfBool("confRett"); enableSplitODL = SMServ.GetConfBool("enableSplitODL"); modoConfProd = SMServ.GetConfInt("modoConfProd"); @@ -648,8 +649,9 @@ namespace MP_TAB_SERV.Components enableAnnullaSetup = SMServ.GetConfBool("enableAnnullaSetup"); enableSchedaTecnica = SMServ.GetConfBool("enableSchedaTecnica"); enableFixSetup = SMServ.GetConfBool("OptEnableFixSetup"); - showSplitOdlOnTav = SMServ.GetConfBool("showSplitOdlOnTav"); + showChkCloseOdlVal = SMServ.GetConfBool("showChkCloseOdlVal"); showReopenOdlTav = SMServ.GetConfBool("showReopenOdlTav"); + showSplitOdlOnTav = SMServ.GetConfBool("showSplitOdlOnTav"); gPeriodReopenOdlTav = SMServ.GetConfInt("gPeriodReopenOdlTav"); string rawEmailDest = SMServ.GetConf("_adminEmail"); emailAdmDest = rawEmailDest.Split(',').ToList(); @@ -960,6 +962,7 @@ namespace MP_TAB_SERV.Components private bool showOdlDetail = false; private bool showReopenOdlTav = false; + private bool showChkCloseOdlVal = false; private bool showSplitOdlOnTav = false; @@ -1548,8 +1551,11 @@ namespace MP_TAB_SERV.Components Log.Trace($"found {ListODL.Count} rec"); if (forceReload) { - var rawData = await TabDServ.PezziProdMacchina(IdxMaccSel); - prodMacchina = rawData.FirstOrDefault() ?? new PzProdModel(); + if (!isMulti || (isMulti && IdxMaccSel.IndexOf("#") > 0)) + { + var rawData = await TabDServ.PezziProdMacchina(IdxMaccSel); + prodMacchina = rawData.FirstOrDefault() ?? new PzProdModel(); + } } } // imposto tcRichAttr in base allo stato... diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 07368b64..654471b0 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2311.1319 + 6.16.2311.1411 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 11570614..6e880a19 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2311.1319

+

Versione: 6.16.2311.1411


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 1d647080..56646032 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2311.1319 +6.16.2311.1411 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 8e83637d..b9d9e968 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2311.1319 + 6.16.2311.1411 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index af3a4a36..1af0eb73 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1275,11 +1275,16 @@ namespace MP.Data.Controllers using (var dbCtx = new MoonProContext(_configuration)) { var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); - dbResult = dbCtx - .DbSetPzProd - .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina) - .AsNoTracking() - .ToList(); + try + { + dbResult = dbCtx + .DbSetPzProd + .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina) + .AsNoTracking() + .ToList(); + } + catch + { } } return dbResult; } diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index f13db5d4..88882db5 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -293,7 +293,7 @@ namespace MP.Data.Services sw.Start(); string answ = ""; // cerco in redis... - string currKey = $"{redisBaseKey}:CurrOpr:{matrOpr}"; + string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); if (rawData.HasValue) { @@ -322,7 +322,7 @@ namespace MP.Data.Services sw.Start(); string answ = ""; // cerco in redis... - string currKey = $"{redisBaseKey}:CurrOpr:{matrOpr}"; + string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}"; //RedisValue rawData = await redisDb.StringGetAsync(currKey); // serializzo e salvo... //rawData = JsonConvert.SerializeObject(currOpr); @@ -3000,6 +3000,7 @@ namespace MP.Data.Services private string DataSource = ""; private string redisBaseKey = "MP:TAB:Cache"; + private string redisUserDataKey = "MP:TAB:Users"; #endregion Private Fields