Merge branch 'Release/Spec_KitMan_01'

This commit is contained in:
Samuele Locatelli
2025-05-07 15:04:18 +02:00
20 changed files with 341 additions and 75 deletions
+1
View File
@@ -198,5 +198,6 @@ namespace MP.Core
}
#endregion Public Methods
}
}
+84 -20
View File
@@ -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
/// </summary>
/// <param name="editRec"></param>
public bool TemplateKitUpsert(TemplateKitModel editRec)
/// <param name="codAzienda"></param>
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
+4 -1
View File
@@ -8,11 +8,14 @@
<div class="px-2">
<i class="fas fa-user-alt"></i> <b>@userName</b>
</div>
<div class="px-2 fs-4">
<span class="@PageIcon px-2" aria-hidden="true"></span><span>@PageName</span>
</div>
<div class="px-2">
<AskCloseOdl></AskCloseOdl>
</div>
<div class="pe-2">
<button class="btn btn-primary" @onclick="() => flushCache()" title="Forza Refresh Dati correnti"> Force Reload </button>
<button class="btn btn-primary" @onclick="() => FlushCache()" title="Forza Refresh Dati correnti"> Force Reload </button>
</div>
</div>
+68 -22
View File
@@ -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
+19 -17
View File
@@ -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
/// <summary>
/// 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;
+3 -2
View File
@@ -2350,11 +2350,12 @@ namespace MP.SPEC.Data
/// Esegue salvataggio record + svuotamento cache
/// </summary>
/// <param name="currRecord"></param>
public async Task<bool> TemplateKitUpsert(TemplateKitModel currRecord)
/// <param name="codAzienda"></param>
public async Task<bool> 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);
+76 -2
View File
@@ -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
/// </summary>
public string DomainName { get; set; } = "";
/// <summary>
/// Elenco link utente
/// </summary>
public List<MP.Data.DbModels.LinkMenuModel>? 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();
}
}
}
/// <summary>
/// Username utente
/// </summary>
@@ -40,6 +74,10 @@ namespace MP.SPEC.Data
/// </summary>
public List<string> UserRight { get; set; } = new List<string>();
#endregion Public Properties
#region Public Methods
/// <summary>
/// Verifica ruolo utente
/// </summary>
@@ -57,7 +95,36 @@ namespace MP.SPEC.Data
return answ;
}
#endregion Public Properties
/// <summary>
/// Segnala cambio pagina
/// </summary>
/// <returns></returns>
public void ReportPageUpd()
{
if (EA_PageUpdated != null)
{
EA_PageUpdated?.Invoke();
}
}
/// <summary>
/// Imposta i dati della pagina corrente dato l'url
/// </summary>
/// <param name="pageUrl"></param>
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; } = "";
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.WebUtilities;
namespace MP.SPEC.Extensions
{
public static class NavigationManagerExtension
{
#region Public Methods
/// <summary>
/// Estensione metodo NavigationManager x recupero querystring
///
/// https://code-maze.com/query-strings-blazor-webassembly/
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="navManager"></param>
/// <param name="key"></param>
/// <returns></returns>
public static T ExtractQueryStringByKey<T>(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;
}
/// <summary>
/// Recupero base page
///
/// https://stackoverflow.com/questions/50102726/navigationmanager-get-current-url-in-a-blazor-component
/// </summary>
/// <param name="navigation"></param>
/// <returns></returns>
public static string Page(this NavigationManager navigation)
{
return navigation.Uri.Substring(navigation.BaseUri.Length);
}
#endregion Public Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2504.1617</Version>
<Version>6.16.2505.714</Version>
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+1
View File
@@ -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
+1
View File
@@ -1,4 +1,5 @@
@page "/"
@page "/Home"
@page "/Index"
<PageTitle>Index</PageTitle>
+13 -4
View File
@@ -5,9 +5,18 @@
<div class="d-flex justify-content-between">
<div class="px-0">
<div class="d-flex justify-content-between">
<div class="px-2">
<span class="fs-3 mb-0">KIT</span>
<small class="small">Definizione KIT multiprodotto per singolo ciclo | <b>@kitCount</b> Kit disp.</small>
<div class="d-flex">
<div class="px-2">
<span class="fs-3 mb-0 fw-bold">KIT</span>
</div>
<div class="px-2">
<div class="small">
Definizione KIT multiprodotto per singolo ciclo
</div>
<div class="small">
Azienda: <b>@CodAzienda</b> | <b>@kitCount</b> Kit disp.
</div>
</div>
</div>
</div>
</div>
@@ -188,4 +197,4 @@
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetNumPage" totalCount="totalCount" showLoading="isLoading" />
}
</div>
</div>
</div>
+8 -1
View File
@@ -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<bool>("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))
{
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2504.1617</h4>
<h4>Versione: 6.16.2505.714</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2504.1617
6.16.2505.714
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2504.1617</version>
<version>6.16.2505.714</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -21,7 +21,7 @@
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column">
<div class="nav-item px-2 col-12">
<NavLink class="nav-link px-2" href="" Match="NavLinkMatch.All">
<NavLink class="nav-link px-2" href="Home" Match="NavLinkMatch.All">
<div class="col-2">
<span class="fa-solid fa-house px-2" aria-hidden="true"></span>
</div>
+5 -1
View File
@@ -10,7 +10,11 @@ namespace MP.SPEC.Shared
[Parameter]
public EventCallback<bool> EC_compressUpdated { get; set; }
public List<MP.Data.DbModels.LinkMenuModel>? ElencoLink { get; set; }
public List<MP.Data.DbModels.LinkMenuModel>? ElencoLink
{
get => MsgService.ElencoLink;
set => MsgService.ElencoLink = value;
}
#endregion Public Properties
+1
View File
@@ -13,6 +13,7 @@
"MP.Data": "Server=localhost\\SQLEXPRESS;Database=MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Flux": "Server=localhost\\SQLEXPRESS;Database=MoonPro_FluxData; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Land": "Server=localhost\\SQLEXPRESS;Database=MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Land.Auth": "Server=SQL2016DEV;Database=MoonPro_Anagrafica; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Inve": "Server=localhost\\SQLEXPRESS;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"Redis": "localhost:6379,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
"RedisAdmin": "localhost:6379,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
+1
View File
@@ -53,6 +53,7 @@
"MP.Flux": "Server=SQL2016DEV;Database=MoonPro_FluxData; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Inve": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Land": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"MP.Land.Auth": "Server=SQL2016DEV;Database=MoonPro_Anagrafica; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"Redis": "localhost:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
"RedisAdmin": "localhost:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
"mdbConnString": "mongodb://W2019-MONGODB:27017"