From 38401093dfe9be2c3b6c093ff2b20a8d32d7c14f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 12 Oct 2024 16:08:01 +0200 Subject: [PATCH] Inizio gestione UserLang corretta --- GPW.CORE.ADM/Components/Compo/GruppiMan.razor | 5 +- .../Components/Compo/LoginDisplay.razor | 30 +-- .../Components/Compo/LoginDisplay.razor.cs | 85 ++++++--- .../Components/Compo/ProgettiMan.razor.cs | 7 +- .../Components/Layout/NavMenu.razor.cs | 8 + .../Components/Pages/ApprovTimbrature.razor | 2 +- GPW.CORE.ADM/Components/Pages/ChLang.razor | 7 - GPW.CORE.ADM/Components/Pages/Clienti.razor | 2 +- .../Components/Pages/GestOrario.razor | 2 +- GPW.CORE.ADM/Components/Pages/Gruppi.razor | 2 +- GPW.CORE.ADM/Components/Pages/Progetti.razor | 2 +- .../Components/Pages/ReviewTimbrature.razor | 2 +- .../Components/Pages/SpostaFasi.razor | 2 +- GPW.CORE.ADM/Components/Pages/Tags.razor | 2 +- GPW.CORE.ADM/GPW.CORE.ADM.csproj | 2 +- .../PublishProfiles/IIS-PROD.pubxml.user | 2 +- GPW.CORE.ADM/appsettings.json | 10 +- GPW.CORE.Data/AppAuthContext.cs | 1 + .../Controllers/AppAuthController.cs | 35 +++- GPW.CORE.Data/DbModels/LingueModel.cs | 26 +++ GPW.CORE.Data/Services/AppAuthService.cs | 173 ++++++++++-------- GPW.CORE.Data/Services/MessageService.cs | 45 ++++- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 25 files changed, 304 insertions(+), 154 deletions(-) delete mode 100644 GPW.CORE.ADM/Components/Pages/ChLang.razor create mode 100644 GPW.CORE.Data/DbModels/LingueModel.cs diff --git a/GPW.CORE.ADM/Components/Compo/GruppiMan.razor b/GPW.CORE.ADM/Components/Compo/GruppiMan.razor index 0f25f75..9e28228 100644 --- a/GPW.CORE.ADM/Components/Compo/GruppiMan.razor +++ b/GPW.CORE.ADM/Components/Compo/GruppiMan.razor @@ -88,7 +88,7 @@ - @@ -103,7 +103,7 @@ @foreach (var item in ListRecords) { -
+ Gruppo
+ @if (SelItem == null) { @@ -163,7 +163,6 @@ } - diff --git a/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor b/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor index 66aa789..1eb3f5c 100644 --- a/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor +++ b/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor @@ -27,20 +27,26 @@ }
- @if (showSearch) - { -
-
- - - +
+ @if (showSearch) + { +
+
+ + + +
+ } +
+
- } - else - { -

-

- } +
diff --git a/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor.cs b/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor.cs index 9c88c81..606b54c 100644 --- a/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor.cs +++ b/GPW.CORE.ADM/Components/Compo/LoginDisplay.razor.cs @@ -29,9 +29,18 @@ namespace GPW.CORE.ADM.Components.Compo [Inject] protected MessageService AppMServ { get; set; } = null!; + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + [Inject] protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!; + [Inject] + protected AppAuthService AuthServ { get; set; } = null!; + + [Inject] + protected AppAuthService AuthService { get; set; } = null!; + [Inject] protected IConfiguration config { get; set; } = null!; @@ -45,12 +54,23 @@ namespace GPW.CORE.ADM.Components.Compo [Inject] protected LicenseService LicServ { get; set; } = null!; + protected List ListLingue + { + get => AuthServ.Lingue; + } + protected string searchVal { get => AppMServ.SearchVal; set => AppMServ.SearchVal = value; } + protected string UserLang + { + get => AppMServ.UserLang; + set => AppMServ.UserLang = value; + } + #endregion Protected Properties #region Protected Methods @@ -130,6 +150,8 @@ namespace GPW.CORE.ADM.Components.Compo AppMServ.RigaDip = null; await Task.Delay(1); await LoadUtente(); + // recupero dati conf lingua... + await ReloadLang(); // verifico attivazione dipendente... await checkUserLicense(); } @@ -144,9 +166,6 @@ namespace GPW.CORE.ADM.Components.Compo await VerifyActiv(); } - [Inject] - protected AppAuthService AuthService { get; set; } = null!; - protected async Task LoadUtente() { var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); @@ -164,7 +183,7 @@ namespace GPW.CORE.ADM.Components.Compo userName = $"{rigaDip.Cognome} {rigaDip.Nome}"; idxDipendente = rigaDip.IdxDipendente; // leggo e salvo in MsgService il menù utente... - var listMenu = await AuthService.MenuUtente(rigaDip.Utente); + var listMenu = await AuthService.MenuUtente(rigaDip.Utente, UserLang); AppMServ.ListMenu = listMenu; } } @@ -182,6 +201,8 @@ namespace GPW.CORE.ADM.Components.Compo AppMServ.EA_HideSearch += AppMServ_EA_HideSearch; AppMServ.EA_ShowSearch += AppMServ_EA_ShowSearch; AppMServ.EA_PageUpdated += AppMServ_EA_PageUpdated; + // leggo lingue... + UserLang = await AppMServ.UserLangGet(); // leggo lista dip ListaDip = await GDataServ.DipendentiGetAll(); numTot = ListaDip.Count(x => x.Attivo == true); @@ -199,27 +220,6 @@ namespace GPW.CORE.ADM.Components.Compo await VerifPresenze(false); } - private void AppMServ_EA_PageUpdated() - { - PageTitle = AppMServ.PageName; - PageIcon = AppMServ.PageIcon; - InvokeAsync(StateHasChanged); - } - - private string PageTitle = ""; - private string PageIcon = ""; - private bool showSearch = false; - - private void AppMServ_EA_ShowSearch() - { - showSearch = true; - } - - private void AppMServ_EA_HideSearch() - { - showSearch = false; - } - protected void resetSearch() { searchVal = ""; @@ -256,6 +256,12 @@ namespace GPW.CORE.ADM.Components.Compo private int numTot = 0; + private string PageIcon = ""; + + private string PageTitle = ""; + + private bool showSearch = false; + private string userName = ""; #endregion Private Fields @@ -271,6 +277,23 @@ namespace GPW.CORE.ADM.Components.Compo #region Private Methods + private void AppMServ_EA_HideSearch() + { + showSearch = false; + } + + private void AppMServ_EA_PageUpdated() + { + PageTitle = AppMServ.PageName; + PageIcon = AppMServ.PageIcon; + InvokeAsync(StateHasChanged); + } + + private void AppMServ_EA_ShowSearch() + { + showSearch = true; + } + private void checkAdmin() { // leggo elenco admin @@ -317,6 +340,11 @@ namespace GPW.CORE.ADM.Components.Compo } } + private async Task ReloadLang() + { + UserLang = await AppMServ.UserLangGet(); + } + /// /// Chiama reset messaggio dopo un periodo di sec richiesto... /// @@ -330,6 +358,13 @@ namespace GPW.CORE.ADM.Components.Compo await InvokeAsync(StateHasChanged); } + private async void SaveLang() + { + await AppMServ.UserLangSet(UserLang); + // vado a pagina reload... + NavMan.NavigateTo("ForceReset", true); + } + private void updateDisplay(TimbratureModel timbData) { string tipo = timbData.Entrata ?? true ? "IN" : "OUT"; diff --git a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs index c1b1f2e..b3dea36 100644 --- a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs +++ b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs @@ -203,9 +203,14 @@ namespace GPW.CORE.ADM.Components.Compo await ReloadData(); } + protected string UserLang + { + get => AppMServ.UserLang; + } + protected string Traduci(string lemma) { - return AuthServ.Traduci(lemma); + return AuthServ.Traduci(lemma, UserLang); } #endregion Protected Methods diff --git a/GPW.CORE.ADM/Components/Layout/NavMenu.razor.cs b/GPW.CORE.ADM/Components/Layout/NavMenu.razor.cs index 2b1c9be..437e94e 100644 --- a/GPW.CORE.ADM/Components/Layout/NavMenu.razor.cs +++ b/GPW.CORE.ADM/Components/Layout/NavMenu.razor.cs @@ -19,6 +19,7 @@ namespace GPW.CORE.ADM.Components.Layout public void Dispose() { AppMServ.EA_MenuUpdated -= AppMServ_EA_MenuUpdated; + AppMServ.EA_LangSel -= AppMServ_EA_LangSel; } #endregion Public Methods @@ -54,9 +55,16 @@ namespace GPW.CORE.ADM.Components.Layout protected override void OnInitialized() { AppMServ.EA_MenuUpdated += AppMServ_EA_MenuUpdated; + AppMServ.EA_LangSel += AppMServ_EA_LangSel; ReloadData(); } + private void AppMServ_EA_LangSel() + { + ReloadData(); + InvokeAsync(StateHasChanged); + } + protected void ToggleCompress() { showText = !showText; diff --git a/GPW.CORE.ADM/Components/Pages/ApprovTimbrature.razor b/GPW.CORE.ADM/Components/Pages/ApprovTimbrature.razor index 480aea9..4b448ee 100644 --- a/GPW.CORE.ADM/Components/Pages/ApprovTimbrature.razor +++ b/GPW.CORE.ADM/Components/Pages/ApprovTimbrature.razor @@ -10,7 +10,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = false; - AppMServ.PageName = AuthServ.Traduci("ApprTimb"); + AppMServ.PageName = AuthServ.Traduci("ApprTimb", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ApprTimbExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/ChLang.razor b/GPW.CORE.ADM/Components/Pages/ChLang.razor deleted file mode 100644 index 735df1f..0000000 --- a/GPW.CORE.ADM/Components/Pages/ChLang.razor +++ /dev/null @@ -1,7 +0,0 @@ -@page "/ChLang" - - - -@code { - -} diff --git a/GPW.CORE.ADM/Components/Pages/Clienti.razor b/GPW.CORE.ADM/Components/Pages/Clienti.razor index 6e9debe..e2aa0cd 100644 --- a/GPW.CORE.ADM/Components/Pages/Clienti.razor +++ b/GPW.CORE.ADM/Components/Pages/Clienti.razor @@ -10,7 +10,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = true; - AppMServ.PageName = AuthServ.Traduci("ManClienti"); + AppMServ.PageName = AuthServ.Traduci("ManClienti", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ManClientiExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/GestOrario.razor b/GPW.CORE.ADM/Components/Pages/GestOrario.razor index d9fc48f..e042432 100644 --- a/GPW.CORE.ADM/Components/Pages/GestOrario.razor +++ b/GPW.CORE.ADM/Components/Pages/GestOrario.razor @@ -9,7 +9,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = false; - AppMServ.PageName = AuthServ.Traduci("ManOrarioTipo"); + AppMServ.PageName = AuthServ.Traduci("ManOrarioTipo", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ManOrarioTipoExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/Gruppi.razor b/GPW.CORE.ADM/Components/Pages/Gruppi.razor index 880137c..73b065a 100644 --- a/GPW.CORE.ADM/Components/Pages/Gruppi.razor +++ b/GPW.CORE.ADM/Components/Pages/Gruppi.razor @@ -9,7 +9,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = false; - AppMServ.PageName = AuthServ.Traduci("ManGruppi"); + AppMServ.PageName = AuthServ.Traduci("ManGruppi", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ManGruppiExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/Progetti.razor b/GPW.CORE.ADM/Components/Pages/Progetti.razor index f32b918..98947de 100644 --- a/GPW.CORE.ADM/Components/Pages/Progetti.razor +++ b/GPW.CORE.ADM/Components/Pages/Progetti.razor @@ -9,7 +9,7 @@ protected override void OnInitialized() { AppMServ.ShowSearch = true; - AppMServ.PageName = AuthServ.Traduci("ManProg"); + AppMServ.PageName = AuthServ.Traduci("ManProg", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ManProgExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/ReviewTimbrature.razor b/GPW.CORE.ADM/Components/Pages/ReviewTimbrature.razor index c2ea7f2..98a97b5 100644 --- a/GPW.CORE.ADM/Components/Pages/ReviewTimbrature.razor +++ b/GPW.CORE.ADM/Components/Pages/ReviewTimbrature.razor @@ -10,7 +10,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = true; - AppMServ.PageName = AuthServ.Traduci("reviewTimb"); + AppMServ.PageName = AuthServ.Traduci("reviewTimb", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("reviewTimbExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/SpostaFasi.razor b/GPW.CORE.ADM/Components/Pages/SpostaFasi.razor index 37af917..6c766f6 100644 --- a/GPW.CORE.ADM/Components/Pages/SpostaFasi.razor +++ b/GPW.CORE.ADM/Components/Pages/SpostaFasi.razor @@ -8,7 +8,7 @@ protected override void OnInitialized() { AppMServ.ShowSearch = true; - AppMServ.PageName = AuthServ.Traduci("SpostaFasi"); + AppMServ.PageName = AuthServ.Traduci("SpostaFasi", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("SpostaFasiExpl"); } } diff --git a/GPW.CORE.ADM/Components/Pages/Tags.razor b/GPW.CORE.ADM/Components/Pages/Tags.razor index 965d1bf..8f23108 100644 --- a/GPW.CORE.ADM/Components/Pages/Tags.razor +++ b/GPW.CORE.ADM/Components/Pages/Tags.razor @@ -11,7 +11,7 @@ { // imposto pagina e info testata AppMServ.ShowSearch = true; - AppMServ.PageName = AuthServ.Traduci("ManTags"); + AppMServ.PageName = AuthServ.Traduci("ManTags", AppMServ.UserLang); AppMServ.PageIcon = AuthServ.Traduci("ManTagsExpl"); } } diff --git a/GPW.CORE.ADM/GPW.CORE.ADM.csproj b/GPW.CORE.ADM/GPW.CORE.ADM.csproj index af2aa1a..0a46cb0 100644 --- a/GPW.CORE.ADM/GPW.CORE.ADM.csproj +++ b/GPW.CORE.ADM/GPW.CORE.ADM.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 4.1.2410.0409 + 4.1.2410.1215 diff --git a/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user b/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user index c687c3f..b0005b4 100644 --- a/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user +++ b/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAw3dMMgC4FUywyOTV2xvCRgAAAAACAAAAAAADZgAAwAAAABAAAADrbAogtj/xpZqylbgs9Hb3AAAAAASAAACgAAAAEAAAAFm1lcdH7oj+NFy4QgZ7q18YAAAAROPsyRR12dhPTKfMEQ5yNCAZJ5K7C4pvFAAAAEFBVTwItjyYP2BlOTsuK1g9myQ8 - True|2024-09-13T17:29:52.0716814Z||;True|2024-09-13T18:38:16.4907845+02:00||;True|2024-09-13T09:22:22.8253732+02:00||;True|2024-09-12T16:07:39.0226825+02:00||;True|2024-09-12T10:58:30.2473031+02:00||;True|2024-09-12T10:03:37.9121520+02:00||;True|2024-09-11T19:18:09.6865317+02:00||;True|2024-09-11T17:21:29.6285775+02:00||;True|2024-09-11T17:06:36.9651346+02:00||;True|2024-09-10T17:58:48.6965236+02:00||;True|2024-09-10T15:56:39.2931971+02:00||;True|2024-09-10T12:27:20.6683309+02:00||;True|2024-09-07T10:37:21.9427027+02:00||;True|2024-09-06T19:01:32.2132061+02:00||;True|2024-09-06T18:20:28.3994458+02:00||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; + True|2024-10-04T08:17:22.7335334Z||;True|2024-09-13T19:29:52.0716814+02:00||;True|2024-09-13T18:38:16.4907845+02:00||;True|2024-09-13T09:22:22.8253732+02:00||;True|2024-09-12T16:07:39.0226825+02:00||;True|2024-09-12T10:58:30.2473031+02:00||;True|2024-09-12T10:03:37.9121520+02:00||;True|2024-09-11T19:18:09.6865317+02:00||;True|2024-09-11T17:21:29.6285775+02:00||;True|2024-09-11T17:06:36.9651346+02:00||;True|2024-09-10T17:58:48.6965236+02:00||;True|2024-09-10T15:56:39.2931971+02:00||;True|2024-09-10T12:27:20.6683309+02:00||;True|2024-09-07T10:37:21.9427027+02:00||;True|2024-09-06T19:01:32.2132061+02:00||;True|2024-09-06T18:20:28.3994458+02:00||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; \ No newline at end of file diff --git a/GPW.CORE.ADM/appsettings.json b/GPW.CORE.ADM/appsettings.json index c14263f..25dfdc2 100644 --- a/GPW.CORE.ADM/appsettings.json +++ b/GPW.CORE.ADM/appsettings.json @@ -56,12 +56,12 @@ "ExternalProviders": { "MailKit": { "SMTP": { - "Address": "smtp-mail.outlook.com", + "Address": "smtp.gmail.com", "Port": "587", - "Account": "steamwarebot@outlook.it", - "Password": "siamoInViaNazionale93!", - "SenderEmail": "steamwarebot@outlook.it", - "SenderName": "Steamware Email BOT" + "Account": "smtp.gmail.com", + "Password": "vpsad24068", + "SenderEmail": "smtp.gmail.com", + "SenderName": "EgalWare Email BOT" } } }, diff --git a/GPW.CORE.Data/AppAuthContext.cs b/GPW.CORE.Data/AppAuthContext.cs index ccfcd2e..b24ba9e 100644 --- a/GPW.CORE.Data/AppAuthContext.cs +++ b/GPW.CORE.Data/AppAuthContext.cs @@ -58,6 +58,7 @@ namespace GPW.CORE.Data #region Public Properties + public virtual DbSet DbSetLingue { get; set; } public virtual DbSet DbSetPermessi { get; set; } = null!; public virtual DbSet DbSetPermessi2Funzione { get; set; } = null!; public virtual DbSet DbSetVocabolario { get; set; } diff --git a/GPW.CORE.Data/Controllers/AppAuthController.cs b/GPW.CORE.Data/Controllers/AppAuthController.cs index 13dbf6a..2f8740d 100644 --- a/GPW.CORE.Data/Controllers/AppAuthController.cs +++ b/GPW.CORE.Data/Controllers/AppAuthController.cs @@ -24,14 +24,28 @@ namespace GPW.CORE.Data.Controllers #region Public Methods - - public void Dispose() { // Clear database context dbCtx.Dispose(); } + /// + /// Elenco lingue ammesse + /// + /// + public List LingueGetAll() + { + List dbResult = new List(); + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + dbResult = localDbCtx + .DbSetLingue + .ToList(); + } + return dbResult; + } + /// /// Elenco completo permessi2funzione /// @@ -89,14 +103,14 @@ namespace GPW.CORE.Data.Controllers public List PermessiGetByFunc(List ListCodFun) { // converto a lower l'elenco... - ListCodFun=ListCodFun.Select(x => x.ToLower()).ToList(); + ListCodFun = ListCodFun.Select(x => x.ToLower()).ToList(); List dbResult = new List(); using (AppAuthContext dbCtx = new AppAuthContext(_configuration)) { var listPer = PermessiGetAll(); var listP2F_all = Permessi2FunzioneGetAll(); //var listP2F = Permessi2FunzioneGetFilt(ListCodFun); - var listP2F= listP2F_all + var listP2F = listP2F_all .Where(x => ListCodFun.Contains(x.CodFunzione.ToLower())) .Distinct() .ToList(); @@ -139,7 +153,7 @@ namespace GPW.CORE.Data.Controllers } /// - /// Elenco Record x gestione Update + /// Vocabolario (completo) /// /// public List VocabolarioGetAll() @@ -158,10 +172,15 @@ namespace GPW.CORE.Data.Controllers #region Private Fields - private static IConfiguration _configuration { get; set; } = null!; - private static AppAuthContext dbCtx { get; set; } = null!; private static Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields + + #region Private Properties + + private static IConfiguration _configuration { get; set; } = null!; + private static AppAuthContext dbCtx { get; set; } = null!; + + #endregion Private Properties } -} +} \ No newline at end of file diff --git a/GPW.CORE.Data/DbModels/LingueModel.cs b/GPW.CORE.Data/DbModels/LingueModel.cs new file mode 100644 index 0000000..078960e --- /dev/null +++ b/GPW.CORE.Data/DbModels/LingueModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GPW.CORE.Data.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("Lingue")] + public partial class LingueModel + { + #region Public Properties + + [Key, MaxLength(3)] + public string Lingua { get; set; } = ""; + [MaxLength(50)] + public string DescrizioneLingua { get; set; } = ""; + + #endregion Public Properties + } +} diff --git a/GPW.CORE.Data/Services/AppAuthService.cs b/GPW.CORE.Data/Services/AppAuthService.cs index 1e8801f..1e56f54 100644 --- a/GPW.CORE.Data/Services/AppAuthService.cs +++ b/GPW.CORE.Data/Services/AppAuthService.cs @@ -23,9 +23,7 @@ namespace GPW.CORE.Data.Services // diritti (cablòato) public const string RoleSuperAdmin = "MoonPro_SuperAdmin"; - public static AppAuthController dbController { get; set; } = null!; - public static GPWController GpwDbController { get; set; } = null!; - public static AppUserController userController { get; set; } = null!; + public List Lingue = new List(); #endregion Public Fields @@ -66,8 +64,15 @@ namespace GPW.CORE.Data.Services #endregion Public Constructors - #region Public Methods + #region Public Properties + public static AppAuthController dbController { get; set; } = null!; + public static GPWController GpwDbController { get; set; } = null!; + public static AppUserController userController { get; set; } = null!; + + #endregion Public Properties + + #region Public Methods public async Task> AnagKeyValList() { @@ -132,6 +137,66 @@ namespace GPW.CORE.Data.Services CheckVoc(); } + /// + /// Menu pagine abilitate dato utente + /// + /// + /// + public async Task> MenuUtente(string UserName, string UserLang) + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyMenuUser}:{UserName}:{UserLang}"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + // verifica preliminare vocabolario + CheckVoc(); + // recupero permessi utente... + List userRightList = await PermessiGetByUser(UserName); + // converto in voce menù + dbResult = userRightList + // solo le vere voci di menù x parametri gruppo/numero + .Where(x => x.Numero > 0 && x.Gruppo < 999) + .OrderBy(g => g.Gruppo) + .ThenBy(n => n.Numero) + .Select(x => new MenuItemDTO + { + Url = x.Url, + Title = Traduci(x.Nome ?? x.Url, UserLang), + Descript = Traduci(x.Descrizione ?? "", UserLang), + Group = x.Gruppo ?? 0, + Num = x.Numero ?? 0 + }) + .ToList(); + // salvo in redis... + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"MenuUtente | {source} | {sw.ElapsedMilliseconds} ms"); + return dbResult; + } + /// /// Elenco permessi dato utente /// @@ -182,67 +247,6 @@ namespace GPW.CORE.Data.Services return dbResult; } - - /// - /// Menu pagine abilitate dato utente - /// - /// - /// - public async Task> MenuUtente(string UserName) - { - string source = "DB"; - List? dbResult = new List(); - string currKey = $"{rKeyMenuUser}:{UserName}"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - // verifica preliminare vocabolario - CheckVoc(); - // recupero permessi utente... - List userRightList = await PermessiGetByUser(UserName); - // converto in voce menù - dbResult = userRightList - // solo le vere voci di menù x parametri gruppo/numero - .Where(x => x.Numero > 0 && x.Gruppo < 999) - .OrderBy(g => g.Gruppo) - .ThenBy(n => n.Numero) - .Select(x => new MenuItemDTO - { - Url = x.Url, - Title = Traduci(x.Nome??x.Url), - Descript = Traduci(x.Descrizione ?? ""), - Group = x.Gruppo ?? 0, - Num = x.Numero ?? 0 - }) - .ToList(); - // salvo in redis... - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - sw.Stop(); - Log.Debug($"MenuUtente | {source} | {sw.ElapsedMilliseconds} ms"); - return dbResult; - } - public string Traduci(string lemma, string lingua = "IT") { string answ = $"__{lemma}__"; @@ -256,7 +260,6 @@ namespace GPW.CORE.Data.Services return answ; } - #endregion Public Methods #region Protected Methods @@ -266,10 +269,31 @@ namespace GPW.CORE.Data.Services if (Vocabolario.Count == 0) { string source = "DB"; - string currKey = $"{redisBaseAddr}:MP:VOCAB"; + string currKey = ""; + string? rawData = ""; Stopwatch sw = new Stopwatch(); sw.Start(); - string? rawData = redisDb.StringGet(currKey); + // lingue + currKey = $"{redisBaseAddr}:MP:LANG"; + rawData = redisDb.StringGet(currKey); + if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + { + var tempResult = JsonConvert.DeserializeObject>(rawData); + Lingue = tempResult ?? new List(); + } + else + { + Lingue = dbController + .LingueGetAll() + .Select(x => x.Lingua) + .ToList(); + rawData = JsonConvert.SerializeObject(Lingue); + redisDb.StringSet(currKey, rawData, UltraLongCache); + } + + // vocabolario + currKey = $"{redisBaseAddr}:MP:VOCAB"; + rawData = redisDb.StringGet(currKey); if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) { source = "REDIS"; @@ -295,18 +319,13 @@ namespace GPW.CORE.Data.Services // gestione key Redis private const string redisBaseAddr = "GPW:ADM"; + private const string rKeyDirittiUser = $"{redisBaseAddr}:DIR_USER"; - private const string rKeyPermUser = $"{redisBaseAddr}:PERM_USER"; - private const string rKeyMenuUser = $"{redisBaseAddr}:MENU_USER"; - - private static IConfiguration _configuration { get; set; } = null!; - + private const string rKeyPermUser = $"{redisBaseAddr}:PERM_USER"; private static JsonSerializerSettings? JSSettings; - private static Logger Log = LogManager.GetCurrentClassLogger(); - private static string Modulo = ""; /// @@ -331,13 +350,13 @@ namespace GPW.CORE.Data.Services private IDatabase redisDb = null!; private Random rnd = new Random(); - private Dictionary Vocabolario = new Dictionary(); #endregion Private Fields #region Private Properties + private static IConfiguration _configuration { get; set; } = null!; private string CodApp { get; set; } = ""; /// @@ -397,4 +416,4 @@ namespace GPW.CORE.Data.Services #endregion Private Methods } -} +} \ No newline at end of file diff --git a/GPW.CORE.Data/Services/MessageService.cs b/GPW.CORE.Data/Services/MessageService.cs index 6b9cf49..b5d8725 100644 --- a/GPW.CORE.Data/Services/MessageService.cs +++ b/GPW.CORE.Data/Services/MessageService.cs @@ -30,6 +30,8 @@ namespace GPW.CORE.Data.Services public event Action EA_HideSearch = null!; + public event Action EA_LangSel = null!; + public event Action EA_MenuUpdated = null!; public event Action EA_PageUpdated = null!; @@ -195,6 +197,22 @@ namespace GPW.CORE.Data.Services public DateTime targetDate { get; set; } = DateTime.Today; + public string UserLang + { + get => userLang; + set + { + if (userLang != value) + { + userLang = value; + if (EA_LangSel != null) + { + EA_LangSel?.Invoke(); + } + } + } + } + public string UserName { get @@ -230,6 +248,24 @@ namespace GPW.CORE.Data.Services await localStore.SetItemAsync($"{gridName}_nRow", newVal); } + /// + /// Lingua richiesta da utente + /// + public async Task UserLangGet() + { + var answ = await localStore.GetItemAsync("UserLang"); + answ = string.IsNullOrEmpty(answ) ? "IT" : answ; + return answ; + } + + /// + /// Salva lingua utente + /// + public async Task UserLangSet(string userLangl) + { + await localStore.SetItemAsync("UserLang", userLang); + } + /// /// Preferenza utente salvata in local storage /// @@ -268,7 +304,6 @@ namespace GPW.CORE.Data.Services #region Protected Properties protected List _listMenu { get; set; } = new List(); - protected ILocalStorageService localStore { get; set; } = null!; protected ISessionStorageService sessionStore { get; set; } = null!; @@ -277,15 +312,19 @@ namespace GPW.CORE.Data.Services #region Private Fields private string _pageIcon = ""; - private string _pageName = ""; - private DipendentiModel? _rigaDip; private string _searchVal = ""; private bool showSearch; #endregion Private Fields + #region Private Properties + + private string userLang { get; set; } = "IT"; + + #endregion Private Properties + #region Private Methods private void ReportPageUpd() diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index ec0e230..81c1aeb 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 4.1.2410.0409

+

Versione: 4.1.2410.1215


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 5c200e4..6897d19 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -4.1.2410.0409 +4.1.2410.1215 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 57f00bb..3049a43 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 4.1.2410.0409 + 4.1.2410.1215 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false