From 20b92a2c71b37cd68fdf0805badf91dbeeae0351 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 26 Oct 2023 15:27:32 +0200 Subject: [PATCH] Fix traduzione scheda tecnica --- .../Components/TechSheet_ST_ObjView.razor | 13 +-- .../Components/TechSheet_ST_ObjView.razor.cs | 94 ++++++++++--------- 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-TAB-SERV/Shared/MainLayout.razor.cs | 4 + MP.Data/Controllers/MpTabController.cs | 84 ++++++++++------- MP.Data/Services/SharedMemService.cs | 48 ++++++++++ MP.Data/Services/TabDataService.cs | 30 ++++++ 10 files changed, 192 insertions(+), 89 deletions(-) diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor index f9d796a1..ee9e55fd 100644 --- a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor @@ -1,6 +1,6 @@ 
- @CurrRec.Label + @(Traduci(CurrRec.Label))
@if (CurrRec.ShowMissingData && enableForceParamSchedaTecnica) @@ -14,15 +14,16 @@ } } - (@CurrRec.ValueRead) @CurrRec.Value + @if (!string.IsNullOrEmpty(CurrRec.ValueRead)) + { + (@CurrRec.ValueRead)  + } + @CurrRec.Value - @if (showError) + @if (CurrRec.ShowMissingData) { - } - @if (showChecked) - { } diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs index d65b35a2..a0c20621 100644 --- a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs @@ -1,56 +1,15 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; using global::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 System.ComponentModel.DataAnnotations; namespace MP_TAB_SERV.Components { public partial class TechSheet_ST_ObjView { + #region Public Properties + [Parameter] public ST_ActRow CurrRec { get; set; } = null!; - [Inject] - protected SharedMemService SMServ { get; set; } = null!; - - protected override void OnParametersSet() - { - enableForceParamSchedaTecnica = SMServ.GetConfBool("enableForceParamSchedaTecnica"); - hasDeroga = false; -#if false - try - { - var currDeroga = DataLayerObj.getDerogaSt(idxST); - answ = (currDeroga != null); - if (answ) - { - answ = (currDeroga.CanForce && currDeroga.Num == dataNum && currDeroga.CodGruppo == dataGroup && currDeroga.CodTipo == dataType && currDeroga.Oggetto == dataOggetto); - } - } - catch - { } -#endif - } - - private bool enableForceParamSchedaTecnica = false; public string dataCss { @@ -82,11 +41,54 @@ namespace MP_TAB_SERV.Components } } + #endregion Public Properties + #region Public Methods + + public string Traduci(string lemma) + { + return SMServ.Traduci($"{baseLang}_{lemma}"); + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnParametersSet() + { + enableForceParamSchedaTecnica = SMServ.GetConfBool("enableForceParamSchedaTecnica"); + baseLang = SMServ.GetConf("baseLang"); + hasDeroga = false; +#if false + try + { + var currDeroga = DataLayerObj.getDerogaSt(idxST); + answ = (currDeroga != null); + if (answ) + { + answ = (currDeroga.CanForce && currDeroga.Num == dataNum && currDeroga.CodGruppo == dataGroup && currDeroga.CodTipo == dataType && currDeroga.Oggetto == dataOggetto); + } + } + catch + { } +#endif + } + + #endregion Protected Methods + + #region Private Fields + + private string baseLang = "IT"; + private bool enableForceParamSchedaTecnica = false; private bool hasDeroga = false; - private bool showError = false; - private bool showChecked = false; - + #endregion Private Fields } } \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 8557a415..3892bde8 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.2310.2612 + 6.16.2310.2615 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index ef182c56..fc02882c 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.2612

+

Versione: 6.16.2310.2615


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 767b41ea..5875c55f 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.2612 +6.16.2310.2615 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index d2f0d8d0..82b2e04d 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.2612 + 6.16.2310.2615 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-TAB-SERV/Shared/MainLayout.razor.cs b/MP-TAB-SERV/Shared/MainLayout.razor.cs index 4b25ea1a..f7ada6bd 100644 --- a/MP-TAB-SERV/Shared/MainLayout.razor.cs +++ b/MP-TAB-SERV/Shared/MainLayout.razor.cs @@ -126,6 +126,10 @@ namespace MP_TAB_SERV.Shared // MDataService.MacchineByMatrOper(0); MStor.DictMacchine = allMach.ToDictionary(x => // x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}"); + // fix vocabolario + var allVoc = TDataService.VocabolarioGetAll(); + MStor.SetVocab(allVoc); + // resetto il tabDServ await TDataService.FlushCache(); // ricarica la config... diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 6224c891..5751af8a 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -746,39 +746,6 @@ namespace MP.Data.Controllers return dbResult; } - /// - /// Restituisce elenco gruppi Scheda tecnica - /// - /// - public List ST_AnagGruppiList() - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetStAnagGruppi - .OrderBy(x => x.OrdVisual) - .AsNoTracking() - .ToList(); - } - return dbResult; - } - - public bool ST_CheckCleanByOdl(int idxOdl) - { - bool fatto = false; - using (var dbCtx = new MoonProContext(_configuration)) - { - var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); - - var result = dbCtx - .Database - .ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl); - fatto = result != 0; - } - return fatto; - } - /// /// Registra controllo /// @@ -1053,6 +1020,39 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Restituisce elenco gruppi Scheda tecnica + /// + /// + public List ST_AnagGruppiList() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetStAnagGruppi + .OrderBy(x => x.OrdVisual) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + public bool ST_CheckCleanByOdl(int idxOdl) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl); + fatto = result != 0; + } + return fatto; + } + /// /// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL /// @@ -1230,6 +1230,24 @@ namespace MP.Data.Controllers return answ; } + /// + /// Elenco Vocabolario (completo) + /// + /// + public List VocabolarioGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetVocabolario + .AsNoTracking() + .OrderBy(x => x.Lemma) + .ToList(); + } + return dbResult; + } + /// /// Elenco causali scarto /// diff --git a/MP.Data/Services/SharedMemService.cs b/MP.Data/Services/SharedMemService.cs index b0cece8a..4797d009 100644 --- a/MP.Data/Services/SharedMemService.cs +++ b/MP.Data/Services/SharedMemService.cs @@ -45,6 +45,11 @@ namespace MP.Data.Services /// public Dictionary DictStati { get; set; } = new Dictionary(); + /// + /// Dizionario globale (key: lingua_lemma, lowercase) + /// + public Dictionary DictVocab { get; set; } = new Dictionary(); + /// /// Lista completa eventi /// @@ -60,6 +65,11 @@ namespace MP.Data.Services /// public List ListStati { get; set; } = new List(); + /// + /// Lista completa stati + /// + public List ListVocab { get; set; } = new List(); + public bool MenuOk { get => AllMenuData.Count > 0; @@ -81,6 +91,7 @@ namespace MP.Data.Services DictConfig = new Dictionary(); DictEventi = new Dictionary(); DictStati = new Dictionary(); + DictVocab = new Dictionary(); Log.Info("SharedMemService | Cache resetted!"); } @@ -224,12 +235,49 @@ namespace MP.Data.Services Log.Info("SharedMemService | SetupMenu executed!"); } + /// + /// Effettua setup vocabolario + /// + /// + public void SetVocab(List allVoc) + { + ListVocab = allVoc ?? new List(); + // salvo dizionario + DictVocab = ListVocab.ToDictionary(x => $"{x.Lingua}_{x.Lemma.ToUpper()}", x => x.Traduzione); + Log.Info("SharedMemService | SetVocab executed!"); + } + + public string Traduci(string lingua, string lemma) + { + return Traduci($"{lingua}_{lemma}".ToUpper()); + } + + /// + /// Traduzione diretta vocabolario + /// + /// Formato {lingua}_{lemma}, lowercase + /// + public string Traduci(string lingua_lemma) + { + string answ = $"[{lingua_lemma}]"; + if (DictVocab.ContainsKey(lingua_lemma)) + { + answ = DictVocab[lingua_lemma]; + } + return answ; + } + #endregion Public Methods #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); + /// + /// Oggetto vocabolario x uso continuo traduzione + /// + private List ObjVocabolario = new List(); + #endregion Private Fields #region Private Properties diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index b1619644..0fe7075e 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -1078,6 +1078,36 @@ namespace MP.Data.Services return result; } + public List VocabolarioGetAll() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:Vocab"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.VocabolarioGetAll(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } /// /// Aggiunta record RegistroScarti