diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index 0ae6198e..d4bfc95f 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -198,5 +198,6 @@ namespace MP.Core } #endregion Public Methods + } } \ No newline at end of file diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 1e3a8bf4..6ccddc81 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -56,19 +56,60 @@ namespace MP.Data.Controllers public AnagCountersModel AnagCountersGetNext(string cntType) { AnagCountersModel answ = new AnagCountersModel(); - using (var dbCtx = new MoonProContext(_configuration)) + bool outTable = true; + if (outTable) { - var pCntType = new SqlParameter("@CntType", cntType); - - var dbResult = dbCtx - .DbSetAnagCount - .FromSqlRaw("EXEC dbo.stp_getNextNumb @CntType", pCntType) - .AsNoTracking() - .AsEnumerable() - .FirstOrDefault(); - if (dbResult != null) + using (var dbCtx = new MoonProContext(_configuration)) { - answ = dbResult; + var pCntType = new SqlParameter("@CntType", cntType); + var pLastNum = new SqlParameter + { + ParameterName = "@LastNum", + SqlDbType = SqlDbType.Int, + Direction = ParameterDirection.Output + }; + + var dbResult = dbCtx + .DbSetAnagCount + .FromSqlRaw("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT", pCntType, pLastNum) + .AsNoTracking() + .AsEnumerable() + .FirstOrDefault(); + if (dbResult != null) + { + answ = dbResult; + } + } + } + else + { + // se si volessero impiegare parametri OUTPUT (qui ne mancherebbe 1 nella stored x CntCode...) + using (var dbCtx = new MoonProContext(_configuration)) + { + var pCntType = new SqlParameter("@CntType", cntType); + var pLastNum = new SqlParameter + { + ParameterName = "@LastNum", + SqlDbType = SqlDbType.Int, + Direction = ParameterDirection.Output + }; + var pCntCode = new SqlParameter + { + ParameterName = "@CntCode", + SqlDbType = SqlDbType.NVarChar, + Direction = ParameterDirection.Output + }; + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT, @CntCode OUTPUT", pCntType, pLastNum, pCntCode); + if (dbResult != 0) + { + answ.CntType = cntType; + answ.CntCode = $"{pCntCode.Value}"; + int lNum = 0; + int.TryParse($"{pLastNum.Value}", out lNum); + answ.LastNum = lNum; + } } } return answ; @@ -433,10 +474,10 @@ namespace MP.Data.Controllers using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx - .DbSetConfig - .AsNoTracking() - .OrderBy(x => x.Chiave) - .ToList(); + .DbSetConfig + .AsNoTracking() + .OrderBy(x => x.Chiave) + .ToList(); } return dbResult; } @@ -452,9 +493,9 @@ namespace MP.Data.Controllers using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx - .DbSetConfig - .Where(x => x.Chiave == updRec.Chiave) - .FirstOrDefault(); + .DbSetConfig + .Where(x => x.Chiave == updRec.Chiave) + .FirstOrDefault(); if (dbResult != null) { dbResult.Valore = updRec.Valore; @@ -2090,17 +2131,40 @@ namespace MP.Data.Controllers /// Esegue upsert record /// /// - public bool TemplateKitUpsert(TemplateKitModel editRec) + /// + public bool TemplateKitUpsert(TemplateKitModel editRec, string codAzienda) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) { + // verifico preliminarmente articolo... + var recArt = dbCtx + .DbSetArticoli + .FirstOrDefault(x => x.CodArticolo == editRec.CodArtParent); + // se mancasse... + if (recArt == null) + { + // aggiungo! + AnagArticoliModel newRecArt = new AnagArticoliModel() + { + CodArticolo = editRec.CodArtParent, + Tipo = "KIT", + DescArticolo = $"Articolo KIT - {DateTime.Now:yyyy-MM-dd HH:mm:ss}", + Disegno = "", + Azienda = codAzienda + }; + dbCtx + .DbSetArticoli + .Add(newRecArt); + } + + // proseguo col KIT var actRec = dbCtx .DbSetTempKit .Where(x => x.CodArtParent == editRec.CodArtParent && x.CodArtChild == editRec.CodArtChild) .FirstOrDefault(); - // se ci fosse aggiorno... + // se NON ci fosse aggiungo... if (actRec == null) { dbCtx diff --git a/MP.SPEC/Components/CmpTop.razor b/MP.SPEC/Components/CmpTop.razor index 7d7009c8..1dfde2a0 100644 --- a/MP.SPEC/Components/CmpTop.razor +++ b/MP.SPEC/Components/CmpTop.razor @@ -8,11 +8,14 @@
@userName
+
+ @PageName +
- +
diff --git a/MP.SPEC/Components/CmpTop.razor.cs b/MP.SPEC/Components/CmpTop.razor.cs index 74cd7038..c7d26602 100644 --- a/MP.SPEC/Components/CmpTop.razor.cs +++ b/MP.SPEC/Components/CmpTop.razor.cs @@ -1,39 +1,51 @@ using Amazon.Runtime.Internal.Endpoints.StandardLibrary; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.JSInterop; using MP.AppAuth.Services; using MP.SPEC.Data; +using MP.SPEC.Extensions; using System; namespace MP.SPEC.Components { - public partial class CmpTop + public partial class CmpTop : IDisposable { #region Public Methods - public async Task flushCache() + public void Dispose() { - await Task.Delay(1); - await MDService.FlushRedisCache(); - await Task.Delay(1); - await ForceReload(); - // rimando a pagina corrente - NavManager.NavigateTo(NavManager.Uri, true); + MService.EA_PageUpdated -= OnPageUpdate; + NavManager.LocationChanged -= NavManager_LocationChanged; + } + + public void OnPageUpdate() + { + PageName = MService.PageName; + PageIcon = MService.PageIcon; + InvokeAsync(() => + { + StateHasChanged(); + }); } #endregion Public Methods #region Protected Properties + [Inject] + protected AppAuthService AAService { get; set; } = null!; + + [Inject] + protected AuthenticationStateProvider AuthStateProv { get; set; } = null!; + [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; [Inject] protected MpDataService MDService { get; set; } = null!; - [Inject] - protected AuthenticationStateProvider AuthStateProv { get; set; } = null!; [Inject] protected MsgServiceSpec MService { get; set; } = null!; @@ -41,15 +53,30 @@ namespace MP.SPEC.Components #region Protected Methods + protected async Task FlushCache() + { + await MDService.FlushRedisCache(); + await ForceReload(); + // rimando a pagina corrente + NavManager.NavigateTo(NavManager.Uri, true); + } + protected override async Task OnInitializedAsync() { await ForceReload(); + MService.EA_PageUpdated += OnPageUpdate; + NavManager.LocationChanged += NavManager_LocationChanged; + SetPageData(); } #endregion Protected Methods #region Private Fields + private string PageIcon = ""; + + private string PageName = ""; + private string userName = ""; #endregion Private Fields @@ -58,11 +85,6 @@ namespace MP.SPEC.Components [Inject] private NavigationManager NavManager { get; set; } = null!; - [Inject] - private MsgServiceSpec MsgServ { get; set; } = null!; - [Inject] - protected AppAuthService AAService { get; set; } = null!; - #endregion Private Properties @@ -79,13 +101,13 @@ namespace MP.SPEC.Components var userData = userName.Split(@"\"); if (userData.Length > 1) { - MsgServ.DomainName = userData[0]; - MsgServ.UserName = userData[1]; + MService.DomainName = userData[0]; + MService.UserName = userData[1]; // recupero diritti e salvo... - var UserRightList = await AAService.DirittiGetByUser(MsgServ.UserName); + var UserRightList = await AAService.DirittiGetByUser(MService.UserName); if (UserRightList != null) { - MsgServ.UserRight = UserRightList.Select(x => x.Funzione).ToList(); + MService.UserRight = UserRightList.Select(x => x.Funzione).ToList(); } } } @@ -95,10 +117,34 @@ namespace MP.SPEC.Components } } - private async void MService_EA_ShowSearch() + private void NavManager_LocationChanged(object? sender, Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs e) { - await Task.Delay(1); - await InvokeAsync(() => StateHasChanged()); + SetPageData(); + } + + private void SetPageData() + { + // update testo pagina da URI + string pageUri = NavManager.Page().ToLower(); + // se home/index/vuoto... home! + if (string.IsNullOrEmpty(pageUri) || pageUri == "index" || pageUri == "home") + { + MService.PageIcon = "fa-solid fa-house"; + MService.PageName = "Home"; + } + else + { + // verifica pagina x permessi + if (MService.ElencoLink != null) + { + var recLink = MService.ElencoLink.FirstOrDefault(x => x.NavigateUrl.ToLower() == pageUri); + if (recLink != null) + { + MService.PageIcon = recLink.Icona; + MService.PageName = recLink.Testo; + } + } + } } #endregion Private Methods diff --git a/MP.SPEC/Components/Reparti/ListReparti.razor.cs b/MP.SPEC/Components/Reparti/ListReparti.razor.cs index 0b85388b..f95b835b 100644 --- a/MP.SPEC/Components/Reparti/ListReparti.razor.cs +++ b/MP.SPEC/Components/Reparti/ListReparti.razor.cs @@ -25,29 +25,23 @@ namespace MP.SPEC.Components.Reparti #region Protected Properties - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - [Inject] - protected MpDataService MDService { get; set; } = null!; - [Inject] - protected MsgServiceSpec MsgService { get; set; } = null!; - - #endregion Protected Properties - protected bool IsSuperAdmin { get => HasRole(AppAuthService.RoleSuperAdmin); } - #region Protected Methods + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; - protected override void OnInitialized() - { - SelRecord = null; - EditRec = null; - numRecord = 10; - } + [Inject] + protected MpDataService MDService { get; set; } = null!; + + [Inject] + protected MsgServiceSpec MsgService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods /// /// Verifica ruolo utente @@ -58,6 +52,14 @@ namespace MP.SPEC.Components.Reparti { return MsgService.HasRole(Ruolo); } + + protected override void OnInitialized() + { + SelRecord = null; + EditRec = null; + numRecord = 10; + } + protected override void OnParametersSet() { isLoading = true; diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 9519e703..c5926387 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -2350,11 +2350,12 @@ namespace MP.SPEC.Data /// Esegue salvataggio record + svuotamento cache /// /// - public async Task TemplateKitUpsert(TemplateKitModel currRecord) + /// + public async Task TemplateKitUpsert(TemplateKitModel currRecord, string codAzienda) { bool fatto = false; // salvo - fatto = dbController.TemplateKitUpsert(currRecord); + fatto = dbController.TemplateKitUpsert(currRecord, codAzienda); // svuoto cache RedisValue pattern = $"{Utils.redisKitTempl}:*"; await ExecFlushRedisPatternAsync(pattern); diff --git a/MP.SPEC/Data/MsgServiceSpec.cs b/MP.SPEC/Data/MsgServiceSpec.cs index 559804e1..a6658de8 100644 --- a/MP.SPEC/Data/MsgServiceSpec.cs +++ b/MP.SPEC/Data/MsgServiceSpec.cs @@ -1,4 +1,5 @@ -using MP.AppAuth.Models; +using Microsoft.AspNetCore.Components; +using MP.AppAuth.Models; namespace MP.SPEC.Data { @@ -8,6 +9,8 @@ namespace MP.SPEC.Data public event Action EA_BroadCastMsg = null!; + public event Action EA_PageUpdated = null!; + #endregion Public Events #region Public Properties @@ -17,6 +20,11 @@ namespace MP.SPEC.Data /// public string DomainName { get; set; } = ""; + /// + /// Elenco link utente + /// + public List? ElencoLink { get; set; } = null; + public string newBCMsg { get => _newBCMsg; @@ -30,6 +38,32 @@ namespace MP.SPEC.Data } } + public string PageIcon + { + get => _pageIcon; + set + { + if (_pageIcon != value) + { + _pageIcon = value; + ReportPageUpd(); + } + } + } + + public string PageName + { + get => _pageName; + set + { + if (_pageName != value) + { + _pageName = value; + ReportPageUpd(); + } + } + } + /// /// Username utente /// @@ -40,6 +74,10 @@ namespace MP.SPEC.Data /// public List UserRight { get; set; } = new List(); + #endregion Public Properties + + #region Public Methods + /// /// Verifica ruolo utente /// @@ -57,7 +95,36 @@ namespace MP.SPEC.Data return answ; } - #endregion Public Properties + /// + /// Segnala cambio pagina + /// + /// + public void ReportPageUpd() + { + if (EA_PageUpdated != null) + { + EA_PageUpdated?.Invoke(); + } + } + + /// + /// Imposta i dati della pagina corrente dato l'url + /// + /// + public void SetPage(string pageUrl) + { + if (ElencoLink != null) + { + var recLink = ElencoLink.FirstOrDefault(x => x.NavigateUrl == pageUrl); + if (recLink != null) + { + _pageIcon = recLink.Icona; + PageName = recLink.Testo; + } + } + } + + #endregion Public Methods #region Protected Methods @@ -71,6 +138,13 @@ namespace MP.SPEC.Data #endregion Protected Methods + #region Private Fields + + private string _pageIcon = ""; + private string _pageName = ""; + + #endregion Private Fields + #region Private Properties private string _newBCMsg { get; set; } = ""; diff --git a/MP.SPEC/Extensions/NavigationManagerExtension.cs b/MP.SPEC/Extensions/NavigationManagerExtension.cs new file mode 100644 index 00000000..9383180a --- /dev/null +++ b/MP.SPEC/Extensions/NavigationManagerExtension.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.WebUtilities; + +namespace MP.SPEC.Extensions +{ + public static class NavigationManagerExtension + { + #region Public Methods + + /// + /// Estensione metodo NavigationManager x recupero querystring + /// + /// https://code-maze.com/query-strings-blazor-webassembly/ + /// + /// + /// + /// + /// + public static T ExtractQueryStringByKey(this NavigationManager navManager, string key) + { + var uri = navManager.ToAbsoluteUri(navManager.Uri); + QueryHelpers.ParseQuery(uri.Query) + .TryGetValue(key, out var queryValue); + + if (typeof(T).Equals(typeof(int))) + { + int.TryParse(queryValue, out int result); + return (T)(object)result; + } + + if (typeof(T).Equals(typeof(string))) + return (T)(object)queryValue.ToString(); + + return default; + } + + /// + /// Recupero base page + /// + /// https://stackoverflow.com/questions/50102726/navigationmanager-get-current-url-in-a-blazor-component + /// + /// + /// + public static string Page(this NavigationManager navigation) + { + return navigation.Uri.Substring(navigation.BaseUri.Length); + } + + #endregion Public Methods + } +} diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index c0036644..85b6abb4 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2504.1617 + 6.16.2505.714 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/GroupMacOprMan.razor.cs b/MP.SPEC/Pages/GroupMacOprMan.razor.cs index b1ccebeb..68566d90 100644 --- a/MP.SPEC/Pages/GroupMacOprMan.razor.cs +++ b/MP.SPEC/Pages/GroupMacOprMan.razor.cs @@ -2,6 +2,7 @@ using DnsClient.Protocol; using Microsoft.AspNetCore.Components; using MP.Core.DTO; using MP.Data.DbModels; +using MP.Data.Services; using MP.SPEC.Data; namespace MP.SPEC.Pages diff --git a/MP.SPEC/Pages/Index.razor b/MP.SPEC/Pages/Index.razor index eebb6da4..67cd4745 100644 --- a/MP.SPEC/Pages/Index.razor +++ b/MP.SPEC/Pages/Index.razor @@ -1,4 +1,5 @@ @page "/" +@page "/Home" @page "/Index" Index diff --git a/MP.SPEC/Pages/KIT.razor b/MP.SPEC/Pages/KIT.razor index 22887a4a..068ddba4 100644 --- a/MP.SPEC/Pages/KIT.razor +++ b/MP.SPEC/Pages/KIT.razor @@ -5,9 +5,18 @@
-
- KIT - Definizione KIT multiprodotto per singolo ciclo | @kitCount Kit disp. +
+
+ KIT +
+
+
+ Definizione KIT multiprodotto per singolo ciclo +
+
+ Azienda: @CodAzienda | @kitCount Kit disp. +
+
@@ -188,4 +197,4 @@ }
-
\ No newline at end of file + diff --git a/MP.SPEC/Pages/KIT.razor.cs b/MP.SPEC/Pages/KIT.razor.cs index 59b4c8e9..bbd982d5 100644 --- a/MP.SPEC/Pages/KIT.razor.cs +++ b/MP.SPEC/Pages/KIT.razor.cs @@ -174,13 +174,15 @@ namespace MP.SPEC.Pages await Task.Delay(1); } + protected string CodAzienda = "***"; + protected async Task DoUpdate(TemplateKitModel selRec) { if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?")) return; await Task.Delay(1); - var done = await MDService.TemplateKitUpsert(selRec); + var done = await MDService.TemplateKitUpsert(selRec, CodAzienda); EditRecord = null; ReloadData(); await Task.Delay(1); @@ -194,6 +196,11 @@ namespace MP.SPEC.Pages { int.TryParse(rawVal, out minChar); } + rawVal = MDService.ConfigTryGet("AZIENDA"); + if (!string.IsNullOrEmpty(rawVal)) + { + CodAzienda = rawVal; + } rawVal = MDService.ConfigTryGet("SPEC_Kit_enabCount"); if (!string.IsNullOrEmpty(rawVal)) { diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index bb81bb2b..4b65a8d0 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2504.1617

+

Versione: 6.16.2505.714


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 02219081..a906f32d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2504.1617 +6.16.2505.714 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 2bd31486..ef315968 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2504.1617 + 6.16.2505.714 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 diff --git a/MP.SPEC/Shared/NavMenu.razor b/MP.SPEC/Shared/NavMenu.razor index e089c51b..1a7a6bb1 100644 --- a/MP.SPEC/Shared/NavMenu.razor +++ b/MP.SPEC/Shared/NavMenu.razor @@ -21,7 +21,7 @@