diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs index dc81144..cfbedaa 100644 --- a/MagMan.Core/Services/MessageService.cs +++ b/MagMan.Core/Services/MessageService.cs @@ -31,29 +31,11 @@ namespace MagMan.Core.Services public event Action EA_SearchUpdated = null!; public event Action EA_ShowSearch = null!; public event Action EA_CustomerSel = null!; + public event Action EA_KeySel = null!; + public event Action EA_ShowCustomers = null!; #endregion Public Events -#if false - public SelectData DetailFilter - { - get => _detailFilter; - set - { - if (_detailFilter != value) - { - _detailFilter = value; - - if (EA_FilterUpdated != null) - { - EA_FilterUpdated?.Invoke(); - } - } - } - } - - public SelectOrderData Order_Filter { get; set; } = SelectOrderData.Init(5, 30); -#endif #region Public Properties @@ -114,7 +96,23 @@ namespace MagMan.Core.Services } } } - } + } + + public int KeyNum + { + get => _keyNum; + set + { + if (_keyNum != value) + { + _keyNum = value; + if (EA_KeySel != null) + { + EA_KeySel?.Invoke(); + } + } + } + } public string SelOrderCode { get; set; } = ""; public string SelPlantId { get; set; } = "0"; @@ -145,6 +143,23 @@ namespace MagMan.Core.Services } } + public bool ShowCustomers + { + get => _showCustomers; + set + { + if (_showCustomers != value) + { + _showCustomers = value; + if (EA_ShowCustomers != null) + { + EA_ShowCustomers?.Invoke(value); + } + + } + } + } + /// /// Cliente selezionato (da browser data cache) /// @@ -157,9 +172,27 @@ namespace MagMan.Core.Services /// /// Imposta Cliente selezionato (browser data cache) /// - public async Task ClientIdSet(int machSel) + public async Task ClientIdSet(int newVal) { - await localStore.SetItemAsync("ClientID", machSel); + await localStore.SetItemAsync("ClientID", newVal); + } + + + /// + /// KeyNum da cliente selezionato (da browser data cache) + /// + public async Task KeyNumGet() + { + var answ = await localStore.GetItemAsync("KeyNum"); + return answ; + } + + /// + /// Imposta KeyNum da cliente selezionato (browser data cache) + /// + public async Task KeyNumSet(int newVal) + { + await localStore.SetItemAsync("KeyNum", newVal); } #endregion Public Properties @@ -503,7 +536,9 @@ namespace MagMan.Core.Services private string _pageName = ""; private string _searchVal = ""; private int _customerID = -1; + private int _keyNum = -1; private bool _showSearch = false; + private bool _showCustomers = true; private Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields diff --git a/MagMan.Data.Tenant/DbAdmin.cs b/MagMan.Data.Tenant/DbAdmin.cs index a53900e..98d8a09 100644 --- a/MagMan.Data.Tenant/DbAdmin.cs +++ b/MagMan.Data.Tenant/DbAdmin.cs @@ -24,10 +24,10 @@ namespace MagMan.Data.Tenant #region Public Methods - public static async Task migrateDbMain() + public static async Task migrateDbMain(string connString) { bool answ = false; - using (MagManContext dbCtx = new MagManContext()) + using (MagManContext dbCtx = new MagManContext(connString)) { await dbCtx.Database.MigrateAsync(); answ = true; diff --git a/MagMan.Data.Tenant/DbConfig.cs b/MagMan.Data.Tenant/DbConfig.cs index 7e64a17..16ac909 100644 --- a/MagMan.Data.Tenant/DbConfig.cs +++ b/MagMan.Data.Tenant/DbConfig.cs @@ -36,10 +36,10 @@ namespace MagMan.Data.Tenant return $"server={server};port=3306;database={dbName};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None"; } - public static bool ExecMigrationMain() + public static bool ExecMigrationMain(string connString) { // esecuzione migrazione - var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain()); + var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain(connString)); migrateTask.Wait(); return migrateTask.Result; } diff --git a/MagMan.Data.Tenant/MagManContext.cs b/MagMan.Data.Tenant/MagManContext.cs index 0819f70..18e2122 100644 --- a/MagMan.Data.Tenant/MagManContext.cs +++ b/MagMan.Data.Tenant/MagManContext.cs @@ -71,7 +71,9 @@ namespace MagMan.Data.Tenant if (!optionsBuilder.IsConfigured) { #if DEBUG - connString = "Server=localhost;port=3306;database=MagMan_000470;uid=MagMan_DbUser;pwd=viad@nte16!;sslmode=None;"; +#if false + connString = "Server=localhost;port=3306;database=MagMan_000470;uid=MagMan_DbUser;pwd=viad@nte16!;sslmode=None;"; +#endif #endif var serverVersion = ServerVersion.AutoDetect(connString); optionsBuilder.UseMySql(connString, serverVersion); @@ -92,7 +94,7 @@ namespace MagMan.Data.Tenant }); modelBuilder.Entity() - .HasKey(c => new { c.Family, c.ValueOriginal}); + .HasKey(c => new { c.Family, c.ValueOriginal }); modelBuilder.Seed(); diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index 875a0f5..777beef 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -1077,7 +1077,7 @@ namespace MagMan.Data.Tenant.Services // verifico eventuale creazione/migrazione... DbConfig.InitDb(DbServerAddr, nKey); // verifico se serve applicazione migrazioni - DbConfig.ExecMigrationMain(); + DbConfig.ExecMigrationMain(answ); // aggiungo a LUT ConnStringLUT.Add(nKey, answ); } diff --git a/MagMan.UI/Components/CmpSelCliente.razor b/MagMan.UI/Components/CmpSelCliente.razor index 0bf9d7f..02f5666 100644 --- a/MagMan.UI/Components/CmpSelCliente.razor +++ b/MagMan.UI/Components/CmpSelCliente.razor @@ -4,10 +4,22 @@ @if (CustomersList != null) { - @foreach (var item in CustomersList) - { - - } + + + @foreach (var item in CustomersList) + { + + } + + + + + @foreach (var item in CustomersList) + { + + } + + } diff --git a/MagMan.UI/Components/CmpSelCliente.razor.cs b/MagMan.UI/Components/CmpSelCliente.razor.cs index cacbeca..3917ff2 100644 --- a/MagMan.UI/Components/CmpSelCliente.razor.cs +++ b/MagMan.UI/Components/CmpSelCliente.razor.cs @@ -2,6 +2,7 @@ using MagMan.Core.Services; using MagMan.Data.Admin.DbModels; using MagMan.Data.Admin.Services; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; namespace MagMan.UI.Components { @@ -21,12 +22,26 @@ namespace MagMan.UI.Components { customerID = value; InvokeAsync(() => AppMService.ClientIdSet(value)); + // gestione KeyNum + if (CustomersList != null) + { + var currRec = CustomersList.Find(x => x.CustomerID == customerID); + if (currRec != null) + { + int mKeyNum = currRec.MainKey; + InvokeAsync(() => AppMService.KeyNumSet(mKeyNum)); + AppMService.KeyNum = mKeyNum; + } + } AppMService.CustomerID = value; InvokeAsync(StateHasChanged); } } } + + + [Inject] protected MTAdminService MTService { get; set; } = null!; @@ -49,11 +64,30 @@ namespace MagMan.UI.Components protected async Task ReloadData() { - CustomersList = await MTService.CustomerGetAll(); + await GetClaimsData(); + var rawList = await MTService.CustomerGetAll(); + // se ho un plantId valido --> altrimenti non abilitato + if (ClaimCustomerId == 0) + { + CustomersList = rawList; + } + else if (ClaimCustomerId > 0) + { + CustomersList = rawList.Where(x => x.CustomerID == ClaimCustomerId).ToList(); + } + else + { + CustomersList = new List(); + } } #endregion Protected Methods + /// + /// Valore CustomerID filtrato da claim + /// + protected int ClaimCustomerId = -1; + #region Private Fields private int customerID = -1; @@ -61,5 +95,32 @@ namespace MagMan.UI.Components private List? CustomersList = null; #endregion Private Fields + + [Inject] + protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!; + + /// + /// Recupero Claims dell'utente... + /// + /// https://docs.microsoft.com/it-it/aspnet/core/blazor/security/?view=aspnetcore-6.0 + /// + /// + private async Task GetClaimsData() + { + // recupero auth + var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + var user = authState.User; + // se autenticato --> controllo i claims + if (user.Identity!=null && user.Identity.IsAuthenticated) + { + // cerco il claim PlantId... + var custClaim = user.FindFirst(c => c.Type == "CustomerID")?.Value; + int.TryParse(custClaim, out ClaimCustomerId); + } + else + { + ClaimCustomerId = -1; + } + } } } \ No newline at end of file diff --git a/MagMan.UI/Components/CmpTop.razor b/MagMan.UI/Components/CmpTop.razor index 323c2ef..3399bcf 100644 --- a/MagMan.UI/Components/CmpTop.razor +++ b/MagMan.UI/Components/CmpTop.razor @@ -12,12 +12,11 @@ } -
- - - - - -
+ @if (ShowCustomers) + { +
+ +
+ } diff --git a/MagMan.UI/Components/CmpTop.razor.cs b/MagMan.UI/Components/CmpTop.razor.cs index 34d5c9a..8e8b4bc 100644 --- a/MagMan.UI/Components/CmpTop.razor.cs +++ b/MagMan.UI/Components/CmpTop.razor.cs @@ -53,6 +53,8 @@ namespace MagMan.UI.Components private bool ShowSearch { get; set; } = false; + [CascadingParameter(Name = "ShowCustomers")] + private bool ShowCustomers { get; set; } = true; #endregion Private Properties } diff --git a/MagMan.UI/Components/CustomerMan.razor.cs b/MagMan.UI/Components/CustomerMan.razor.cs index 85b49fe..1ba0d2b 100644 --- a/MagMan.UI/Components/CustomerMan.razor.cs +++ b/MagMan.UI/Components/CustomerMan.razor.cs @@ -48,12 +48,13 @@ namespace MagMan.UI.Components dbOk = Data.Admin.DbConfig.CheckCustDb(currRec.MainKey); } // se ok --> migration... - if (dbOk || true) + if (dbOk) { string dbServerAddr = Configuration["DbConfig:Server"]; - Data.Tenant.DbConfig.InitDb(dbServerAddr, currRec.MainKey); + //Data.Tenant.DbConfig.InitDb(dbServerAddr, currRec.MainKey); + string connStr = Data.Tenant.DbConfig.CustomerConnString(dbServerAddr, currRec.MainKey); // verifico se serve applicazione migrazioni - Data.Tenant.DbConfig.ExecMigrationMain(); + Data.Tenant.DbConfig.ExecMigrationMain(connStr); } // aggiorno comunque status DB... currRec.HasDb = dbOk; diff --git a/MagMan.UI/Components/MigrationManager.razor b/MagMan.UI/Components/MigrationManager.razor deleted file mode 100644 index cc4a530..0000000 --- a/MagMan.UI/Components/MigrationManager.razor +++ /dev/null @@ -1,89 +0,0 @@ -@* @using MagMan.Data -@using MagMan.UI.Data -@using MagMan.UI.Components *@ - -@* @inject GWMSDataService DataService *@ -@inject MessageService AppMService -@inject IJSRuntime JSRuntime - -@if (!DbAllOk) -{ -
-
-

DB Init

-
- @if (!DbUserOk) - { -
- -
- } - else if (!DbIdentity) - { -
- -
- } -
-} - -@code { - - [Parameter] - public EventCallback evRefresh { get; set; } - [Parameter] - public EventCallback evProcessing { get; set; } - - protected async Task initDb() - { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler effettuare inizializzazione/migrazione DB?")) - return; - - reportProcess(); - await MagMan.Data.Tenant.DbAdmin.migrateDbMain(); - await ReloadData(); - reportChange(); - } - - protected async Task initIdent() - { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler effettuare inizializzazione/migrazione servizi Identity?")) - return; - - reportProcess(); - await MagMan.Data.Admin.DbAdmin.MigrateDbIdentity(); - await ReloadData(); - reportChange(); - } - - protected bool DbUserOk { get; set; } = false; - protected bool DbIdentity { get; set; } = false; - protected bool DbAllOk { get; set; } = false; - - protected override async Task OnInitializedAsync() - { - await ReloadData(); - } - - protected async Task ReloadData() - { - var resultIden = await Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME); - DbIdentity = (resultIden.Status == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy); - DbAllOk = (DbIdentity); - } - - private void reportChange() - { - evRefresh.InvokeAsync(1); - } - - private void reportProcess() - { - evProcessing.InvokeAsync(1); - } - -} \ No newline at end of file diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index 51f13c5..dc557d2 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2402.0209 + 1.0.2402.0211 enable enable true diff --git a/MagMan.UI/Pages/AdminArea.razor.cs b/MagMan.UI/Pages/AdminArea.razor.cs index 4719bde..43d653d 100644 --- a/MagMan.UI/Pages/AdminArea.razor.cs +++ b/MagMan.UI/Pages/AdminArea.razor.cs @@ -37,8 +37,9 @@ namespace MagMan.UI.Pages protected override void OnInitialized() { AppMService.ShowSearch = false; + AppMService.ShowCustomers = false; AppMService.PageName = "Admin Area"; - AppMService.PageIcon = "fa-solid fa-house pr-2"; + AppMService.PageIcon = "fa-solid fa-building pr-2"; AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; CustomerID = AppMService.CustomerID; } diff --git a/MagMan.UI/Pages/Index.razor.cs b/MagMan.UI/Pages/Index.razor.cs index 02abac1..cad1168 100644 --- a/MagMan.UI/Pages/Index.razor.cs +++ b/MagMan.UI/Pages/Index.razor.cs @@ -5,10 +5,23 @@ namespace MagMan.UI.Pages { public partial class Index { + #region Protected Properties - [Inject] protected MessageService AppMService { get; set; } = null!; + #endregion Protected Properties + + #region Protected Methods + + protected override void OnInitialized() + { + AppMService.ShowSearch = false; + AppMService.ShowCustomers = false; + AppMService.PageName = "Home"; + AppMService.PageIcon = "fa-solid fa-home pr-2"; + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/MagMan.UI/Pages/ProjectsStatus.razor.cs b/MagMan.UI/Pages/ProjectsStatus.razor.cs index 165c495..9f1d5d9 100644 --- a/MagMan.UI/Pages/ProjectsStatus.razor.cs +++ b/MagMan.UI/Pages/ProjectsStatus.razor.cs @@ -33,6 +33,7 @@ namespace MagMan.UI.Pages protected override async Task OnInitializedAsync() { AppMService.ShowSearch = true; + AppMService.ShowCustomers = true; AppMService.PageName = "Progetti"; AppMService.PageIcon = "fa-solid fa-chart-gantt pr-2"; AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; diff --git a/MagMan.UI/Pages/WareHouse.razor.cs b/MagMan.UI/Pages/WareHouse.razor.cs index 62c7c91..b37818f 100644 --- a/MagMan.UI/Pages/WareHouse.razor.cs +++ b/MagMan.UI/Pages/WareHouse.razor.cs @@ -16,6 +16,7 @@ namespace MagMan.UI.Pages public void Dispose() { AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel; + AppMService.EA_KeySel -= AppMService_EA_KeySel; } #endregion Public Methods @@ -46,10 +47,13 @@ namespace MagMan.UI.Pages protected override async Task OnInitializedAsync() { AppMService.ShowSearch = true; + AppMService.ShowCustomers = true; AppMService.PageName = "Magazzino"; AppMService.PageIcon = "fa-solid fa-warehouse pr-2"; AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; + AppMService.EA_KeySel += AppMService_EA_KeySel; CustomerID = AppMService.CustomerID; + nKey = AppMService.KeyNum; // rileggo dati await ReloadData(); } @@ -69,7 +73,9 @@ namespace MagMan.UI.Pages #region Private Fields private int KeyNum = 0; + private MaterialModel? MaterialSel = null; + private RawItemModel? RawItemSel = null; #endregion Private Fields @@ -77,6 +83,7 @@ namespace MagMan.UI.Pages #region Private Properties private int CustomerID { get; set; } = 0; + private bool isLoading { get; set; } = false; #endregion Private Properties @@ -86,15 +93,21 @@ namespace MagMan.UI.Pages private async void AppMService_EA_CustomerSel() { CustomerID = AppMService.CustomerID; - await Task.Delay(10); - await ReloadData(); + //await Task.Delay(1); + await InvokeAsync(StateHasChanged); + } + + private async void AppMService_EA_KeySel() + { + nKey = AppMService.KeyNum; + //await Task.Delay(1); await InvokeAsync(StateHasChanged); } private async Task ReloadData() { isLoading = true; - nKey = await MTService.MainKeyByCustomer(CustomerID); + await Task.Delay(50); isLoading = false; } diff --git a/MagMan.UI/Shared/MainLayout.razor b/MagMan.UI/Shared/MainLayout.razor index 7605263..08bccea 100644 --- a/MagMan.UI/Shared/MainLayout.razor +++ b/MagMan.UI/Shared/MainLayout.razor @@ -9,9 +9,11 @@
+
+
@*
*@
diff --git a/MagMan.UI/Shared/MainLayout.razor.cs b/MagMan.UI/Shared/MainLayout.razor.cs index a719d54..851ce66 100644 --- a/MagMan.UI/Shared/MainLayout.razor.cs +++ b/MagMan.UI/Shared/MainLayout.razor.cs @@ -9,8 +9,8 @@ namespace MagMan.UI.Shared public void Dispose() { - MessageService.EA_ShowSearch -= OnShowSearch; - MessageService.EA_ShowSearch -= OnHideSearch; + AppMService.EA_ShowSearch -= OnShowSearch; + AppMService.EA_ShowSearch -= OnHideSearch; } public void OnHideSearch() @@ -36,7 +36,7 @@ namespace MagMan.UI.Shared #region Protected Properties [Inject] - protected MessageService MessageService { get; set; } = null!; + protected MessageService AppMService { get; set; } = null!; protected bool navLarge { get; set; } = true; protected string sideClass { get; set; } = "sidebar"; @@ -47,8 +47,14 @@ namespace MagMan.UI.Shared protected override void OnInitialized() { - MessageService.EA_ShowSearch += OnShowSearch; - MessageService.EA_HideSearch += OnHideSearch; + AppMService.EA_ShowSearch += OnShowSearch; + AppMService.EA_HideSearch += OnHideSearch; + AppMService.EA_ShowCustomers += AppMService_EA_ShowCustomers; + } + + private void AppMService_EA_ShowCustomers(bool obj) + { + ShowCustomers = obj; } protected void UpdateNavDisplay() @@ -63,6 +69,8 @@ namespace MagMan.UI.Shared private bool ShowSearch { get; set; } = false; + private bool ShowCustomers { get; set; } = false; + #endregion Private Properties } } \ No newline at end of file diff --git a/MagMan.UI/appsettings.json b/MagMan.UI/appsettings.json index 90ed442..444c604 100644 --- a/MagMan.UI/appsettings.json +++ b/MagMan.UI/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "Redis": "localhost:6379", + "Redis": "localhost:6379,DefaultDatabase=14,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", "UserIdentityDbContextConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;", "AuthConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;", "DefaultConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;", diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 69c886e..6896d8b 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2402.0209

+

Versione: 1.0.2402.0211


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 1bb5555..a4df64e 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2402.0209 +1.0.2402.0211 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 01d8a45..a2acb18 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2402.0209 + 1.0.2402.0211 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false