From cc879c073df02c93778f79d1718221a9689bc765 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 25 Jan 2024 17:10:23 +0100 Subject: [PATCH 1/5] Aggiunta display varianti --- MagMan.Core/DTO/MaterialDTO.cs | 38 +++ .../Controllers/TenantController.cs | 258 +++++++++++------- MagMan.Data.Tenant/DbModels/MovMagModel.cs | 9 +- MagMan.Data.Tenant/Services/TenantService.cs | 81 +++++- MagMan.UI/Components/MaterialMan.razor | 26 +- MagMan.UI/Components/MaterialMan.razor.cs | 26 +- MagMan.UI/MagMan.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 10 files changed, 310 insertions(+), 136 deletions(-) diff --git a/MagMan.Core/DTO/MaterialDTO.cs b/MagMan.Core/DTO/MaterialDTO.cs index 5ab8283..170e807 100644 --- a/MagMan.Core/DTO/MaterialDTO.cs +++ b/MagMan.Core/DTO/MaterialDTO.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -35,5 +36,42 @@ namespace MagMan.Core.DTO /// Thikness/Spessore in mm /// public decimal HMm { get; set; } = 0; + + /// + /// Varianti dimensionali disponibili + /// + public int SizeNum { get; set; } = 0; + + /// + /// Quantità totale in giacenza + /// + public int QtyTot { get; set; } = 0; + + /// + /// Codice materiale x QR/Datamatrix + /// + [NotMapped] + public string MatDtmx + { + get => $"MT{MatId:00000000}"; + } + + /// + /// Verifica che sia Beam, quando L == 0 + /// + [NotMapped] + public bool IsBeam + { + get => (LMm == 0 && (HMm > 0 && WMm > 0)); + } + + /// + /// Verifica che sia Wall, quando W/L == 0 + /// + [NotMapped] + public bool IsWall + { + get => (HMm > 0 && (LMm == 0 && WMm == 0)); + } } } diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 2ada339..47a11df 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -277,12 +277,71 @@ namespace MagMan.Data.Tenant.Controllers } } return dbResult; - } /// + } - /// Elenco Materiali gestiti a magazzino Stringa - /// connessione (variabile x cliente) Materiale richiesto, 0 - /// = tutti Se true allora include record child - /// (Items) + /// + /// Elenco Materiali gestiti a magazzino formato DTO + /// + /// Stringa connessione (variabile x cliente) + /// + public List MaterialDtoGetAll(string connString, bool withChild) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (withChild) + { + dbResult = dbCtx + .DbSetMaterials + .Select(x => new MaterialDTO() + { + MatId = x.MatId, + MatCode = x.MatCode, + MatDesc = x.MatDesc, + HMm = x.HMm, + LMm = x.LMm, + WMm = x.WMm, + SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Count, + QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Sum(r => r.QtyAvail) + }) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.HMm) + .ThenBy(x => x.LMm) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetMaterials + .Select(x => new MaterialDTO() + { + MatId = x.MatId, + MatCode = x.MatCode, + MatDesc = x.MatDesc, + HMm = x.HMm, + LMm = x.LMm, + WMm = x.WMm, + SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Count, + QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Sum(r => r.QtyAvail) + }) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.HMm) + .ThenBy(x => x.LMm) + .ToList(); + } + } + return dbResult; + } + + /// + /// Elenco Materiali gestiti a magazzino + /// + /// Stringa connessione (variabile x cliente) + /// Materiale richiesto, 0 = tutti + /// Se true allora include record child (Items) + /// public List MaterialGetFilt(string connString, int matID, bool withChild) { List dbResult = new List(); @@ -525,99 +584,6 @@ namespace MagMan.Data.Tenant.Controllers return done; } - /// - /// Elenco risorse dato progetto e stato - /// - /// Stringa connessione (variabile x cliente) - /// ID progetto - /// true = ultima stima attiva / false = consumi effettivi - /// - public List ResourcesGetByProject(string connString, int projDbId, bool isEstim, bool showAll) - { - List dbResult = new List(); - using (MagManContext dbCtx = new MagManContext(connString)) - { - if (isEstim) - { - dbResult = dbCtx - .DbSetResources - .Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND) - .OrderBy(x => x.ResourceId) - .ToList(); - } - else - { - dbResult = dbCtx - .DbSetResources - .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed) - .OrderBy(x => x.ResourceId) - .ToList(); - } - } - return dbResult; - } - - /// - /// Elenco risorse dato progetto e stato - /// - /// Stringa connessione (variabile x cliente) - /// ID progetto - /// true = ultima stima attiva / false = consumi effettivi - /// - public List ResourcesExpGetByProject(string connString, int projDbId, bool isEstim, bool showAll) - { - List dbResult = new List(); - List rawData = new List(); - using (MagManContext dbCtx = new MagManContext(connString)) - { - if (isEstim) - { - rawData = dbCtx - .DbSetResources - .Include(p => p.RequestNav) - .Include(i => i.ItemNav) - .Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND) - .ToList(); - } - else - { - rawData = dbCtx - .DbSetResources - .Include(p => p.RequestNav) - .Include(i => i.ItemNav) - .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed) - .OrderBy(x => x.ResourceId) - .ToList(); - } - try - { - dbResult = rawData.Select(x => new ResourceExpDTO() - { - ResourceId = x.ResourceId, - RawItemId = x.RawItemId, - Qty = x.Qty, - Note = x.ItemNav.Note, - DtRequest = x.RequestNav.DtRequest, - HMm = x.ItemNav.HMm, - LMm = x.ItemNav.LMm, - WMm = x.ItemNav.WMm, - IsActive = x.RequestNav.IsActive, - IsRemn = x.ItemNav.IsRemn, - MatId = x.ItemNav.MatId, - RequestId = x.RequestId - }) - .OrderByDescending(x => x.DtRequest) - .ThenByDescending(x => x.ResourceId) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Eccezione ResourcesExpGetByProject{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - /// /// Aggiunge/Modifica un record ReqPlan /// @@ -682,11 +648,105 @@ namespace MagMan.Data.Tenant.Controllers return newId; } + /// + /// Elenco risorse dato progetto e stato + /// + /// Stringa connessione (variabile x cliente) + /// ID progetto + /// true = ultima stima attiva / false = consumi effettivi + /// + public List ResourcesExpGetByProject(string connString, int projDbId, bool isEstim, bool showAll) + { + List dbResult = new List(); + List rawData = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (isEstim) + { + rawData = dbCtx + .DbSetResources + .Include(p => p.RequestNav) + .Include(i => i.ItemNav) + .Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND) + .ToList(); + } + else + { + rawData = dbCtx + .DbSetResources + .Include(p => p.RequestNav) + .Include(i => i.ItemNav) + .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed) + .OrderBy(x => x.ResourceId) + .ToList(); + } + try + { + dbResult = rawData.Select(x => new ResourceExpDTO() + { + ResourceId = x.ResourceId, + RawItemId = x.RawItemId, + Qty = x.Qty, + Note = x.ItemNav.Note, + DtRequest = x.RequestNav.DtRequest, + HMm = x.ItemNav.HMm, + LMm = x.ItemNav.LMm, + WMm = x.ItemNav.WMm, + IsActive = x.RequestNav.IsActive, + IsRemn = x.ItemNav.IsRemn, + MatId = x.ItemNav.MatId, + RequestId = x.RequestId + }) + .OrderByDescending(x => x.DtRequest) + .ThenByDescending(x => x.ResourceId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione ResourcesExpGetByProject{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Elenco risorse dato progetto e stato + /// + /// Stringa connessione (variabile x cliente) + /// ID progetto + /// true = ultima stima attiva / false = consumi effettivi + /// + public List ResourcesGetByProject(string connString, int projDbId, bool isEstim, bool showAll) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (isEstim) + { + dbResult = dbCtx + .DbSetResources + .Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND) + .OrderBy(x => x.ResourceId) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetResources + .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed) + .OrderBy(x => x.ResourceId) + .ToList(); + } + } + return dbResult; + } + /// /// Aggiunge/Modifica un elenco di Resource (+ eventuali update giacenze) /// /// Stringa connessione (variabile x cliente) - /// Elenco record da aggiungere/aggiornare> + /// Elenco record da aggiungere/aggiornare + /// > /// Tipo di aggiornamento da registratre /// public int ResourceUpdate(string connString, List recList, Enums.ProjResState resState) diff --git a/MagMan.Data.Tenant/DbModels/MovMagModel.cs b/MagMan.Data.Tenant/DbModels/MovMagModel.cs index 6cdd62e..9033c3a 100644 --- a/MagMan.Data.Tenant/DbModels/MovMagModel.cs +++ b/MagMan.Data.Tenant/DbModels/MovMagModel.cs @@ -29,7 +29,7 @@ namespace MagMan.Data.Tenant.DbModels /// /// Ext ref for Items /// - public int ItemID { get; set; } + public int RawItemId { get; set; } /// /// Qty recorded (delta +/-) @@ -41,11 +41,16 @@ namespace MagMan.Data.Tenant.DbModels /// public string UserId { get; set; } = ""; + /// + /// Note opzionali + /// + public string Note { get; set; } = ""; + /// /// Navigation property to Items /// [ForeignKey("RawItemId")] - public virtual RawItemModel? ITemNav { get; set; } + public virtual RawItemModel? ItemNav { get; set; } } } diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index 944ecb4..d37a19b 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -281,18 +281,21 @@ namespace MagMan.Data.Tenant.Services /// /// /// - public MaterialModel MaterialFromDto(MaterialDTO origItem) + public MaterialModel? MaterialFromDto(MaterialDTO? origItem) { - MaterialModel answ = new MaterialModel() + MaterialModel? answ = null; + if (origItem != null) { - MatId = origItem.MatId, - MatCode = origItem.MatCode, - MatDesc = origItem.MatDesc, - LMm = origItem.LMm, - WMm = origItem.WMm, - HMm = origItem.HMm - }; - + answ = new MaterialModel() + { + MatId = origItem.MatId, + MatCode = origItem.MatCode, + MatDesc = origItem.MatDesc, + LMm = origItem.LMm, + WMm = origItem.WMm, + HMm = origItem.HMm + }; + } return answ; } @@ -354,6 +357,64 @@ namespace MagMan.Data.Tenant.Services return dbResult; } + /// + /// Lista Materiali gestiti a magazzino in formato DTO + /// + /// Key di riferimento + /// Se true allora include record child (Items) + /// + public async Task> MaterialDtoGetAll(int nKey, bool withChild) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + string dType = withChild ? "MaterialsDtoFull" : "MaterialsDto"; + string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.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 + { + dbResult = dbController.MaterialDtoGetAll(cString, withChild); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + // per evitare loopback uso deserialize... + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult != null) + { + dbResult = tempResult; + } + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MaterialDtoGetAll | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during MaterialDtoGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Lista Materiali gestiti a magazzino /// diff --git a/MagMan.UI/Components/MaterialMan.razor b/MagMan.UI/Components/MaterialMan.razor index 4130b17..1cbe42c 100644 --- a/MagMan.UI/Components/MaterialMan.razor +++ b/MagMan.UI/Components/MaterialMan.razor @@ -55,10 +55,13 @@ ID Mat.Code Descr. - W (mm) - H (mm) - @* L (mm) *@ - @* *@ + W (mm) + H (mm) + @if(MaterialId==0) + { + Var. + Qty + } @@ -103,12 +106,15 @@ @($"{item.HMm:N2}") - @* - @($"{item.LMm:N2}") - *@ - @* - - *@ + @if (MaterialId == 0) + { + + @item.SizeNum + + + @item.QtyTot + + } } diff --git a/MagMan.UI/Components/MaterialMan.razor.cs b/MagMan.UI/Components/MaterialMan.razor.cs index fbb97ec..fcd5a6c 100644 --- a/MagMan.UI/Components/MaterialMan.razor.cs +++ b/MagMan.UI/Components/MaterialMan.razor.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this // file to you under the MIT license. using EgwCoreLib.Razor; +using MagMan.Core.DTO; using MagMan.Core.Services; using MagMan.Data.Admin.DbModels; using MagMan.Data.Admin.Services; @@ -47,7 +48,7 @@ namespace MagMan.UI.Components #region Protected Methods - protected string CheckSel(MaterialModel curItem) + protected string CheckSel(MaterialDTO curItem) { string answ = ""; if (CurrItem != null) @@ -71,23 +72,26 @@ namespace MagMan.UI.Components await InvokeAsync(StateHasChanged); } - protected async Task DeleteRecord(MaterialModel selItem) + protected async Task DeleteRecord(MaterialDTO selItem) { if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) return; - await TService.MaterialDelete(KeyNum, selItem); + await TService.MaterialDelete(KeyNum, TService.MaterialFromDto(selItem)); await ReloadData(); } - protected void DoEdit(MaterialModel? selItem) + protected void DoEdit(MaterialDTO? selItem) { - CurrItem = selItem; if (selItem == null) { DoSelect(null); } + else + { + CurrItem = TService.MaterialFromDto(selItem); + } } - protected void DoSelect(MaterialModel? selItem) + protected void DoSelect(MaterialDTO? selItem) { if (selItem != null) { @@ -97,7 +101,7 @@ namespace MagMan.UI.Components { MaterialId = 0; } - E_MaterialSel.InvokeAsync(selItem); + E_MaterialSel.InvokeAsync(TService.MaterialFromDto(selItem)); } protected async Task ForceReload(bool force) @@ -147,9 +151,9 @@ namespace MagMan.UI.Components private string currSearch = ""; private int filtType = 0; - private List? ListRecords = null; + private List? ListRecords = null; - private List? SearchRecords = null; + private List? SearchRecords = null; private bool sortAsc = true; @@ -194,7 +198,7 @@ namespace MagMan.UI.Components isLoading = true; await InvokeAsync(StateHasChanged); ListRecords = null; - SearchRecords = await TService.MaterialGetAll(KeyNum, false); + SearchRecords = await TService.MaterialDtoGetAll(KeyNum, false); // verifico se filtrare x beam/wall if (FiltType > 0) { @@ -299,7 +303,7 @@ namespace MagMan.UI.Components } else { - ListRecords = new List(); + ListRecords = new List(); } } diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index 363261a..9e87ddf 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2516 + 1.0.2401.2517 enable enable true diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 15cca26..13834b2 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.2516

+

Versione: 1.0.2401.2517


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 1c602b0..da03102 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2516 +1.0.2401.2517 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index c24074a..64fd818 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2516 + 1.0.2401.2517 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false From 7e5605aa7b2bda54e924dad9502cdaa66973f97d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 25 Jan 2024 18:41:39 +0100 Subject: [PATCH 2/5] Aggiunta modello dati MovMag --- .../Controllers/TenantController.cs | 100 +++--- MagMan.Data.Tenant/MagManContext.cs | 2 +- MagMan.Data.Tenant/Services/TenantService.cs | 64 +++- MagMan.UI/Components/ItemMan.razor | 2 +- MagMan.UI/Components/ItemMan.razor.cs | 2 +- MagMan.UI/Components/MaterialMan.razor | 8 +- MagMan.UI/Components/MaterialMan.razor.cs | 2 +- MagMan.UI/Components/MovMag.razor | 87 +++++ MagMan.UI/Components/MovMag.razor.cs | 302 ++++++++++++++++++ MagMan.UI/MagMan.UI.csproj | 2 +- MagMan.UI/Pages/WareHouse.razor | 8 +- MagMan.UI/Pages/WareHouse.razor.cs | 7 + Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 15 files changed, 536 insertions(+), 56 deletions(-) create mode 100644 MagMan.UI/Components/MovMag.razor create mode 100644 MagMan.UI/Components/MovMag.razor.cs diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 47a11df..8503907 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -23,6 +23,30 @@ namespace MagMan.Data.Tenant.Controllers #endregion Public Constructors + + /// + /// Elenco MovMag dato Item + /// + /// Stringa connessione (variabile x cliente) + /// ID dell'item x cui filtrare, 0 = tutti + /// numMax record da leggere, default 1000 + /// + public List MovMagGetFilt(string connString, int rawItemID, int maxRec = 1000) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + dbResult = dbCtx + .DbSetMovMag + .Where(x => rawItemID == 0 || x.RawItemId == rawItemID) + //.Include(c => c.ItemNav) + .OrderByDescending(x => x.DtRec) + .Take(maxRec) + .ToList(); + } + return dbResult; + } + #region Public Methods public async Task DatabaseMigrate(string connString) @@ -244,41 +268,6 @@ namespace MagMan.Data.Tenant.Controllers return done; } - /// - /// Elenco Materiali gestiti a magazzino - /// - /// Stringa connessione (variabile x cliente) - /// - public List MaterialGetAll(string connString, bool withChild) - { - List dbResult = new List(); - using (MagManContext dbCtx = new MagManContext(connString)) - { - if (withChild) - { - dbResult = dbCtx - .DbSetMaterials - .Include(x => x.RawItemList) - .OrderBy(x => x.MatDesc) - .ThenBy(x => x.WMm) - .ThenBy(x => x.HMm) - .ThenBy(x => x.LMm) - .ToList(); - } - else - { - dbResult = dbCtx - .DbSetMaterials - .OrderBy(x => x.MatDesc) - .ThenBy(x => x.WMm) - .ThenBy(x => x.HMm) - .ThenBy(x => x.LMm) - .ToList(); - } - } - return dbResult; - } - /// /// Elenco Materiali gestiti a magazzino formato DTO /// @@ -337,10 +326,45 @@ namespace MagMan.Data.Tenant.Controllers /// /// Elenco Materiali gestiti a magazzino - /// - /// Stringa connessione (variabile x cliente) + /// + /// Stringa connessione (variabile x cliente) + /// + public List MaterialGetAll(string connString, bool withChild) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (withChild) + { + dbResult = dbCtx + .DbSetMaterials + .Include(x => x.RawItemList) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.HMm) + .ThenBy(x => x.LMm) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetMaterials + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.HMm) + .ThenBy(x => x.LMm) + .ToList(); + } + } + return dbResult; + } + + /// + /// Elenco Materiali gestiti a magazzino + /// + /// Stringa connessione (variabile x cliente) /// Materiale richiesto, 0 = tutti - /// Se true allora include record child (Items) + /// Se true allora include record child (Items) /// public List MaterialGetFilt(string connString, int matID, bool withChild) { diff --git a/MagMan.Data.Tenant/MagManContext.cs b/MagMan.Data.Tenant/MagManContext.cs index 0be9330..0819f70 100644 --- a/MagMan.Data.Tenant/MagManContext.cs +++ b/MagMan.Data.Tenant/MagManContext.cs @@ -46,10 +46,10 @@ namespace MagMan.Data.Tenant public virtual DbSet DbSetProjects { get; set; } = null!; public virtual DbSet DbSetReqPlan { get; set; } = null!; public virtual DbSet DbSetResources { get; set; } = null!; + public virtual DbSet DbSetMovMag { get; set; } = null!; #if false - public virtual DbSet DbSetMovMag { get; set; } = null!; public virtual DbSet DbSetPrintJob { get; set; } = null!; #endif diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index d37a19b..a911361 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -13,6 +13,7 @@ using System.Diagnostics; using System.Linq; using System.Runtime; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace MagMan.Data.Tenant.Services @@ -204,10 +205,65 @@ namespace MagMan.Data.Tenant.Services return dbResult; } - /// Update record Item + refresh cache Key di - /// riferimento Item interesato quantità da aggiornare (se <0 è consumo) - public async Task ItemModQty(int nKey, RawItemModel currItem, int deltaQty) + /// + /// Elenco MovMag dato Item + /// + /// Key di riferimento + /// ID dell'item x cui filtrare, 0 = tutti + /// numMax record da leggere, default 1000 + /// + public async Task> MovMagGetFilt(int nKey, int rawItemID, int maxRec = 1000) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + // in cache tengo dati estratti ogni minuto... + string dtKey = DateTime.Now.ToString("yyMMdd:HHmm"); + string currKey = $"{Const.rKeyConfig}:{nKey}:MovMag:{rawItemID}:{dtKey}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.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 + { + dbResult = dbController.MovMagGetFilt(cString, rawItemID, maxRec); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MovMagGetFilt | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during MovMagGetFilt:{Environment.NewLine}{exc}"); + } + return dbResult; + } + + + /// Update record Item + refresh cache Key di + /// riferimento Item interesato quantità da aggiornare (se <0 è consumo) + public async Task ItemModQty(int nKey, RawItemModel currItem, int deltaQty) { bool fatto = false; string cString = ConnString(nKey); diff --git a/MagMan.UI/Components/ItemMan.razor b/MagMan.UI/Components/ItemMan.razor index e2fa44f..d5e11cd 100644 --- a/MagMan.UI/Components/ItemMan.razor +++ b/MagMan.UI/Components/ItemMan.razor @@ -60,7 +60,7 @@ { - @* *@ + diff --git a/MagMan.UI/Components/ItemMan.razor.cs b/MagMan.UI/Components/ItemMan.razor.cs index 5604f4f..7fab80e 100644 --- a/MagMan.UI/Components/ItemMan.razor.cs +++ b/MagMan.UI/Components/ItemMan.razor.cs @@ -220,7 +220,7 @@ namespace MagMan.UI.Components { switch (sortField) { - case "RawItemId": + case "MovId": if (sortAsc) { SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList(); diff --git a/MagMan.UI/Components/MaterialMan.razor b/MagMan.UI/Components/MaterialMan.razor index 1cbe42c..8171358 100644 --- a/MagMan.UI/Components/MaterialMan.razor +++ b/MagMan.UI/Components/MaterialMan.razor @@ -57,10 +57,10 @@ Descr. W (mm) H (mm) - @if(MaterialId==0) - { - Var. - Qty + @if (MaterialId == 0) + { + Var. + Qty } diff --git a/MagMan.UI/Components/MaterialMan.razor.cs b/MagMan.UI/Components/MaterialMan.razor.cs index fcd5a6c..691912d 100644 --- a/MagMan.UI/Components/MaterialMan.razor.cs +++ b/MagMan.UI/Components/MaterialMan.razor.cs @@ -224,7 +224,7 @@ namespace MagMan.UI.Components { switch (sortField) { - case "RawItemId": + case "MovId": if (sortAsc) { SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList(); diff --git a/MagMan.UI/Components/MovMag.razor b/MagMan.UI/Components/MovMag.razor new file mode 100644 index 0000000..1b93ee6 --- /dev/null +++ b/MagMan.UI/Components/MovMag.razor @@ -0,0 +1,87 @@ +
    +
    +
    +
    +

    Movimenti Magazzino

    +
    + @*
    +
    +
    + @if (CurrItem == null) + { + + } + else + { + + } +
    +
    +
    *@ +
    + @* @if (CurrItem != null) + { +
    + + } *@ +
    +
    + @if (ListRecords == null || isLoading) + { + + } + else if (totalCount == 0) + { +
    Nessun record trovato
    + } + else + { + + + + @* *@ + + + + + + + + + @foreach (var item in ListRecords) + { + + @* *@ + + + + + + + } + +
    + + Id Data QtyNote User
    + + + + @item.MovID + + @item.DtRec.ToString("yyyy-MM-dd HH:mm:ss") + + @item.QtyRec + + @item.Note + + @item.UserId +
    + } + +
    + +
    + + diff --git a/MagMan.UI/Components/MovMag.razor.cs b/MagMan.UI/Components/MovMag.razor.cs new file mode 100644 index 0000000..54ab5e3 --- /dev/null +++ b/MagMan.UI/Components/MovMag.razor.cs @@ -0,0 +1,302 @@ +using EgwCoreLib.Razor; +using MagMan.Core.Services; +using MagMan.Data.Tenant.DbModels; +using MagMan.Data.Tenant.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace MagMan.UI.Components +{ + public partial class MovMag + { + + #region Public Properties + + [Parameter] + public int CustomerId { get; set; } = 0; + + + [Parameter] + public int KeyNum { get; set; } = 0; + + [Parameter] + public int RawItemIdSel { get; set; } = 0; + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } = null!; + + [Inject] + protected IConfiguration Configuration { get; set; } = null!; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected int totalCount { get; set; } = 0; + + [Inject] + protected TenantService TService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected string CheckSel(MovMagModel curItem) + { + string answ = ""; + if (CurrItem != null) + { + answ = curItem.MovID == CurrItem.MovID ? "table-info" : ""; + } + else + { + answ = curItem.MovID == MovId ? "table-info" : ""; + } + return answ; + } + + +#if false + protected async Task CreateNew() + { + CurrItem = new RawItemModel() + { + MatId = MaterialSel.MatId, + Location = "nd", + Note = "...", + QtyAvail = 0, + IsActive = true, + IsRemn = false, + HMm = MaterialSel.HMm, + LMm = MaterialSel.LMm, + WMm = MaterialSel.WMm + }; + await InvokeAsync(StateHasChanged); + } + + protected async Task DeleteRecord(RawItemModel selItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) + return; + await TService.ItemDelete(KeyNum, selItem); + await ReloadData(); + } + + protected void DoEdit(RawItemModel? selItem) + { + CurrItem = selItem; + if (selItem == null) + { + DoSelect(null); + } + } + + protected void DoSelect(RawItemModel? selItem) + { + if (selItem != null) + { + RawItemId = selItem.MatId; + } + else + { + RawItemId = 0; + } + E_RawItemSel.InvokeAsync(RawItemId); + } +#endif + + protected async Task ForceReload(bool force) + { + CurrItem = null; + await ReloadData(); + } + + protected override void OnInitialized() + { + currSearch = ""; + AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated; + } + + protected override async Task OnParametersSetAsync() + { + CurrItem = null; + await ReloadData(); + } + + protected void SetNumRec(int newNum) + { + numRecord = newNum; + currPage = 1; + InvokeAsync(ReloadData); + } + + protected void SetPage(int newNum) + { + currPage = newNum; + InvokeAsync(ReloadData); + } + + protected async Task SortRequested(Sorter.SortCallBack e) + { + sortField = e.ParamName; + sortAsc = e.IsAscending; + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private MovMagModel? CurrItem = null; + private string currSearch = ""; + private int filtType = 0; + private List? ListRecords = null; + private int MovId = 0; + private List? SearchRecords = null; + + private bool sortAsc = true; + + private string sortField = ""; + + #endregion Private Fields + + #region Private Properties + + private int currPage { get; set; } = 1; + + private int FiltType + { + get => filtType; + set + { + if (filtType != value) + { + filtType = value; + InvokeAsync(ReloadData); + InvokeAsync(StateHasChanged); + } + } + } + + private bool isLoading { get; set; } = false; + + private int numRecord { get; set; } = 10; + + #endregion Private Properties + + #region Private Methods + + private async void AppMService_EA_SearchUpdated() + { + currSearch = AppMService.SearchVal; + await ReloadData(); + } + + private async Task ReloadData() + { + isLoading = true; + await InvokeAsync(StateHasChanged); + ListRecords = null; + SearchRecords = await TService.MovMagGetFilt(KeyNum, RawItemIdSel, 1000); + // verifico filtro per ricerca + if (!string.IsNullOrEmpty(currSearch)) + { + SearchRecords = SearchRecords.Where(x => x.Note.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList(); + } + totalCount = SearchRecords.Count; + SortTable(); + isLoading = false; + await InvokeAsync(StateHasChanged); + } + + private void SortTable() + { + if (SearchRecords != null) + { + // se ho ordinamento riordino... + if (!string.IsNullOrEmpty(sortField)) + { + switch (sortField) + { + case "MovId": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.RawItemId).ThenByDescending(x => x.Note).ToList(); + } + break; + + case "DtRec": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.DtRec).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.DtRec).ToList(); + } + break; + + case "QtyRec": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.QtyRec).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.QtyRec).ToList(); + } + break; + + case "Note": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.Note).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.Note).ToList(); + } + break; + case "UserId": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.UserId).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.UserId).ToList(); + } + break; + + default: + break; + } + } + + // filtro x display + ListRecords = SearchRecords + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + } + else + { + ListRecords = new List(); + } + } + + private string textCss(bool isActive) + { + return isActive ? "text-dark" : "text-secondary text-decoration-line-through"; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index 9e87ddf..8b8ef5f 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2517 + 1.0.2401.2518 enable enable true diff --git a/MagMan.UI/Pages/WareHouse.razor b/MagMan.UI/Pages/WareHouse.razor index a7760c0..8000cb4 100644 --- a/MagMan.UI/Pages/WareHouse.razor +++ b/MagMan.UI/Pages/WareHouse.razor @@ -8,7 +8,7 @@ } else if (CustomerID == 0) { - + } else { @@ -19,7 +19,11 @@ else @if (MaterialSel != null) {
    - + + @if (RawItemId > 0) + { + + }
    } diff --git a/MagMan.UI/Pages/WareHouse.razor.cs b/MagMan.UI/Pages/WareHouse.razor.cs index e7d7e0d..c1e7fee 100644 --- a/MagMan.UI/Pages/WareHouse.razor.cs +++ b/MagMan.UI/Pages/WareHouse.razor.cs @@ -48,12 +48,19 @@ namespace MagMan.UI.Pages MaterialSel = newMat; } + protected void SaveItem(int selRawItemId) + { + RawItemId = selRawItemId; + } + + #endregion Protected Methods #region Private Fields private int KeyNum = 0; private MaterialModel? MaterialSel = null; + private int RawItemId = 0; #endregion Private Fields diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 13834b2..e764482 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

    Versione: 1.0.2401.2517

    +

    Versione: 1.0.2401.2518


    Note di rilascio:
    • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index da03102..d0f3e55 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2517 +1.0.2401.2518 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 64fd818..212efb1 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2517 + 1.0.2401.2518 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false From 729727610e530495c6d8431f5e6d95b0cb8ba0c3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 25 Jan 2024 18:41:45 +0100 Subject: [PATCH 3/5] Aggiunta migrationx MovMag --- .../20240125174127_AddMovMag.Designer.cs | 348 ++++++++++++++++++ .../Migrations/20240125174127_AddMovMag.cs | 130 +++++++ .../Migrations/MagManContextModelSnapshot.cs | 57 ++- 3 files changed, 532 insertions(+), 3 deletions(-) create mode 100644 MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs create mode 100644 MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs new file mode 100644 index 0000000..6087aa3 --- /dev/null +++ b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs @@ -0,0 +1,348 @@ +// +using System; +using MagMan.Data.Tenant; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MagMan.Data.Tenant.Migrations +{ + [DbContext(typeof(MagManContext))] + [Migration("20240125174127_AddMovMag")] + partial class AddMovMag + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.25") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.AliasModel", b => + { + b.Property("Family") + .HasColumnType("varchar(255)"); + + b.Property("ValueOriginal") + .HasColumnType("varchar(255)"); + + b.Property("ValueAlias") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Family", "ValueOriginal"); + + b.ToTable("AliasList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(0); + + b.Property("Note") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnOrder(3); + + b.Property("Val") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(1); + + b.Property("ValStd") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(2) + .HasComment("Valore di default/riferimento per la variabile"); + + b.HasKey("KeyName"); + + b.ToTable("Config"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => + { + b.Property("MatId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("HMm") + .HasColumnType("decimal(65,30)"); + + b.Property("LMm") + .HasColumnType("decimal(65,30)"); + + b.Property("MatCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MatDesc") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WMm") + .HasColumnType("decimal(65,30)"); + + b.HasKey("MatId"); + + b.ToTable("MaterialsList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b => + { + b.Property("MovID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtRec") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("QtyRec") + .HasColumnType("int"); + + b.Property("RawItemId") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MovID"); + + b.HasIndex("RawItemId"); + + b.ToTable("MovMag"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b => + { + b.Property("ProjDbId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("BTLFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DtCreated") + .HasColumnType("datetime(6)"); + + b.Property("DtLastAction") + .HasColumnType("datetime(6)"); + + b.Property("DtSchedule") + .HasColumnType("datetime(6)"); + + b.Property("DtStartProd") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("KeyNum") + .HasColumnType("int"); + + b.Property("ListName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Machine") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MachineID") + .HasColumnType("int"); + + b.Property("PType") + .HasColumnType("int"); + + b.Property("ProcTimeEst") + .HasColumnType("double"); + + b.Property("ProcTimeReal") + .HasColumnType("double"); + + b.Property("ProjDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjExtDbId") + .HasColumnType("int"); + + b.Property("ProjExtId") + .HasColumnType("int"); + + b.HasKey("ProjDbId"); + + b.HasIndex("IsActive"); + + b.HasIndex("IsArchived"); + + b.HasIndex("KeyNum"); + + b.HasIndex("MachineID"); + + b.HasIndex("ProjExtDbId"); + + b.ToTable("ProjList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => + { + b.Property("RawItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("HMm") + .HasColumnType("decimal(65,30)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsRemn") + .HasColumnType("tinyint(1)"); + + b.Property("LMm") + .HasColumnType("decimal(65,30)"); + + b.Property("Location") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MatId") + .HasColumnType("int"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("QtyAvail") + .HasColumnType("int"); + + b.Property("WMm") + .HasColumnType("decimal(65,30)"); + + b.HasKey("RawItemId"); + + b.HasIndex("MatId"); + + b.ToTable("RawItemList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => + { + b.Property("RequestId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtRequest") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ProjDbId") + .HasColumnType("int"); + + b.Property("ReqState") + .HasColumnType("int"); + + b.HasKey("RequestId"); + + b.ToTable("RequestPlan"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => + { + b.Property("ResourceId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Qty") + .HasColumnType("int"); + + b.Property("RawItemId") + .HasColumnType("int"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.HasKey("ResourceId"); + + b.HasIndex("RawItemId"); + + b.HasIndex("RequestId"); + + b.ToTable("ResourceList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b => + { + b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav") + .WithMany() + .HasForeignKey("RawItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemNav"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => + { + b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") + .WithMany("RawItemList") + .HasForeignKey("MatId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MaterialNav"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => + { + b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav") + .WithMany() + .HasForeignKey("RawItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav") + .WithMany("ResourcesList") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemNav"); + + b.Navigation("RequestNav"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => + { + b.Navigation("RawItemList"); + }); + + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => + { + b.Navigation("ResourcesList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs new file mode 100644 index 0000000..e146473 --- /dev/null +++ b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs @@ -0,0 +1,130 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MagMan.Data.Tenant.Migrations +{ + public partial class AddMovMag : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_ProjList", + table: "ProjList"); + + migrationBuilder.RenameColumn( + name: "ProjExtDbId", + table: "RequestPlan", + newName: "ProjDbId"); + + migrationBuilder.AlterColumn( + name: "ProjExtDbId", + table: "ProjList", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "ProjDbId", + table: "ProjList", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_ProjList", + table: "ProjList", + column: "ProjDbId"); + + migrationBuilder.CreateTable( + name: "MovMag", + columns: table => new + { + MovID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + DtRec = table.Column(type: "datetime(6)", nullable: false), + RawItemId = table.Column(type: "int", nullable: false), + QtyRec = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_MovMag", x => x.MovID); + table.ForeignKey( + name: "FK_MovMag_RawItemList_RawItemId", + column: x => x.RawItemId, + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_ResourceList_RawItemId", + table: "ResourceList", + column: "RawItemId"); + + migrationBuilder.CreateIndex( + name: "IX_MovMag_RawItemId", + table: "MovMag", + column: "RawItemId"); + + migrationBuilder.AddForeignKey( + name: "FK_ResourceList_RawItemList_RawItemId", + table: "ResourceList", + column: "RawItemId", + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ResourceList_RawItemList_RawItemId", + table: "ResourceList"); + + migrationBuilder.DropTable( + name: "MovMag"); + + migrationBuilder.DropIndex( + name: "IX_ResourceList_RawItemId", + table: "ResourceList"); + + migrationBuilder.DropPrimaryKey( + name: "PK_ProjList", + table: "ProjList"); + + migrationBuilder.DropColumn( + name: "ProjDbId", + table: "ProjList"); + + migrationBuilder.RenameColumn( + name: "ProjDbId", + table: "RequestPlan", + newName: "ProjExtDbId"); + + migrationBuilder.AlterColumn( + name: "ProjExtDbId", + table: "ProjList", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_ProjList", + table: "ProjList", + column: "ProjExtDbId"); + } + } +} diff --git a/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs b/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs index ba9d351..4c449bc 100644 --- a/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs +++ b/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs @@ -95,9 +95,39 @@ namespace MagMan.Data.Tenant.Migrations b.ToTable("MaterialsList"); }); + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b => + { + b.Property("MovID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtRec") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("QtyRec") + .HasColumnType("int"); + + b.Property("RawItemId") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MovID"); + + b.HasIndex("RawItemId"); + + b.ToTable("MovMag"); + }); + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b => { - b.Property("ProjExtDbId") + b.Property("ProjDbId") .ValueGeneratedOnAdd() .HasColumnType("int"); @@ -156,7 +186,7 @@ namespace MagMan.Data.Tenant.Migrations b.Property("ProjExtId") .HasColumnType("int"); - b.HasKey("ProjExtDbId"); + b.HasKey("ProjDbId"); b.HasIndex("IsActive"); @@ -225,7 +255,7 @@ namespace MagMan.Data.Tenant.Migrations b.Property("IsActive") .HasColumnType("tinyint(1)"); - b.Property("ProjExtDbId") + b.Property("ProjDbId") .HasColumnType("int"); b.Property("ReqState") @@ -253,11 +283,24 @@ namespace MagMan.Data.Tenant.Migrations b.HasKey("ResourceId"); + b.HasIndex("RawItemId"); + b.HasIndex("RequestId"); b.ToTable("ResourceList"); }); + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b => + { + b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav") + .WithMany() + .HasForeignKey("RawItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemNav"); + }); + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => { b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") @@ -271,12 +314,20 @@ namespace MagMan.Data.Tenant.Migrations modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => { + b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav") + .WithMany() + .HasForeignKey("RawItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav") .WithMany("ResourcesList") .HasForeignKey("RequestId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.Navigation("ItemNav"); + b.Navigation("RequestNav"); }); From f4f2c9bfecb7ca4a097e164e32ffb8809dc98662 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 25 Jan 2024 19:44:20 +0100 Subject: [PATCH 4/5] Fix migrazioni --- .../20240122174314_InitDb.Designer.cs | 297 ------------------ .../Migrations/20240125174127_AddMovMag.cs | 130 -------- ...r.cs => 20240125174457_InitDb.Designer.cs} | 4 +- ...314_InitDb.cs => 20240125174457_InitDb.cs} | 51 ++- 4 files changed, 50 insertions(+), 432 deletions(-) delete mode 100644 MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs delete mode 100644 MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs rename MagMan.Data.Tenant/Migrations/{20240125174127_AddMovMag.Designer.cs => 20240125174457_InitDb.Designer.cs} (99%) rename MagMan.Data.Tenant/Migrations/{20240122174314_InitDb.cs => 20240125174457_InitDb.cs} (84%) diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs deleted file mode 100644 index 5a5a6dc..0000000 --- a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs +++ /dev/null @@ -1,297 +0,0 @@ -// -using System; -using MagMan.Data.Tenant; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - [DbContext(typeof(MagManContext))] - [Migration("20240122174314_InitDb")] - partial class InitDb - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.25") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.AliasModel", b => - { - b.Property("Family") - .HasColumnType("varchar(255)"); - - b.Property("ValueOriginal") - .HasColumnType("varchar(255)"); - - b.Property("ValueAlias") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Family", "ValueOriginal"); - - b.ToTable("AliasList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b => - { - b.Property("KeyName") - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(0); - - b.Property("Note") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("varchar(250)") - .HasColumnOrder(3); - - b.Property("Val") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(1); - - b.Property("ValStd") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(2) - .HasComment("Valore di default/riferimento per la variabile"); - - b.HasKey("KeyName"); - - b.ToTable("Config"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => - { - b.Property("MatId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("HMm") - .HasColumnType("decimal(65,30)"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("MatCode") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatDesc") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("MatId"); - - b.ToTable("MaterialsList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b => - { - b.Property("ProjExtDbId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BTLFileName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DtCreated") - .HasColumnType("datetime(6)"); - - b.Property("DtLastAction") - .HasColumnType("datetime(6)"); - - b.Property("DtSchedule") - .HasColumnType("datetime(6)"); - - b.Property("DtStartProd") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("KeyNum") - .HasColumnType("int"); - - b.Property("ListName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Machine") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MachineID") - .HasColumnType("int"); - - b.Property("PType") - .HasColumnType("int"); - - b.Property("ProcTimeEst") - .HasColumnType("double"); - - b.Property("ProcTimeReal") - .HasColumnType("double"); - - b.Property("ProjDescription") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProjExtDbId") - .HasColumnType("int"); - - b.Property("ProjExtId") - .HasColumnType("int"); - - b.HasKey("ProjExtDbId"); - - b.HasIndex("IsActive"); - - b.HasIndex("IsArchived"); - - b.HasIndex("KeyNum"); - - b.HasIndex("MachineID"); - - b.HasIndex("ProjExtDbId"); - - b.ToTable("ProjList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => - { - b.Property("RawItemId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("HMm") - .HasColumnType("decimal(65,30)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("IsRemn") - .HasColumnType("tinyint(1)"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("Location") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("QtyAvail") - .HasColumnType("int"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("RawItemId"); - - b.HasIndex("MatId"); - - b.ToTable("RawItemList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => - { - b.Property("RequestId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DtRequest") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("ProjExtDbId") - .HasColumnType("int"); - - b.Property("ReqState") - .HasColumnType("int"); - - b.HasKey("RequestId"); - - b.ToTable("RequestPlan"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => - { - b.Property("ResourceId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Qty") - .HasColumnType("int"); - - b.Property("RawItemId") - .HasColumnType("int"); - - b.Property("RequestId") - .HasColumnType("int"); - - b.HasKey("ResourceId"); - - b.HasIndex("RequestId"); - - b.ToTable("ResourceList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => - { - b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") - .WithMany("RawItemList") - .HasForeignKey("MatId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MaterialNav"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => - { - b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav") - .WithMany("ResourcesList") - .HasForeignKey("RequestId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("RequestNav"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => - { - b.Navigation("RawItemList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => - { - b.Navigation("ResourcesList"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs deleted file mode 100644 index e146473..0000000 --- a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - public partial class AddMovMag : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_ProjList", - table: "ProjList"); - - migrationBuilder.RenameColumn( - name: "ProjExtDbId", - table: "RequestPlan", - newName: "ProjDbId"); - - migrationBuilder.AlterColumn( - name: "ProjExtDbId", - table: "ProjList", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddColumn( - name: "ProjDbId", - table: "ProjList", - type: "int", - nullable: false, - defaultValue: 0) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProjList", - table: "ProjList", - column: "ProjDbId"); - - migrationBuilder.CreateTable( - name: "MovMag", - columns: table => new - { - MovID = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DtRec = table.Column(type: "datetime(6)", nullable: false), - RawItemId = table.Column(type: "int", nullable: false), - QtyRec = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Note = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_MovMag", x => x.MovID); - table.ForeignKey( - name: "FK_MovMag_RawItemList_RawItemId", - column: x => x.RawItemId, - principalTable: "RawItemList", - principalColumn: "RawItemId", - onDelete: ReferentialAction.Restrict); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_ResourceList_RawItemId", - table: "ResourceList", - column: "RawItemId"); - - migrationBuilder.CreateIndex( - name: "IX_MovMag_RawItemId", - table: "MovMag", - column: "RawItemId"); - - migrationBuilder.AddForeignKey( - name: "FK_ResourceList_RawItemList_RawItemId", - table: "ResourceList", - column: "RawItemId", - principalTable: "RawItemList", - principalColumn: "RawItemId", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ResourceList_RawItemList_RawItemId", - table: "ResourceList"); - - migrationBuilder.DropTable( - name: "MovMag"); - - migrationBuilder.DropIndex( - name: "IX_ResourceList_RawItemId", - table: "ResourceList"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ProjList", - table: "ProjList"); - - migrationBuilder.DropColumn( - name: "ProjDbId", - table: "ProjList"); - - migrationBuilder.RenameColumn( - name: "ProjDbId", - table: "RequestPlan", - newName: "ProjExtDbId"); - - migrationBuilder.AlterColumn( - name: "ProjExtDbId", - table: "ProjList", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProjList", - table: "ProjList", - column: "ProjExtDbId"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs similarity index 99% rename from MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs rename to MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs index 6087aa3..13dbc34 100644 --- a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs +++ b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace MagMan.Data.Tenant.Migrations { [DbContext(typeof(MagManContext))] - [Migration("20240125174127_AddMovMag")] - partial class AddMovMag + [Migration("20240125174457_InitDb")] + partial class InitDb { protected override void BuildTargetModel(ModelBuilder modelBuilder) { diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs similarity index 84% rename from MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs rename to MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs index 57b8471..f5d00c4 100644 --- a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs +++ b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs @@ -150,6 +150,32 @@ namespace MagMan.Data.Tenant.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "MovMag", + columns: table => new + { + MovID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + DtRec = table.Column(type: "datetime(6)", nullable: false), + RawItemId = table.Column(type: "int", nullable: false), + QtyRec = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_MovMag", x => x.MovID); + table.ForeignKey( + name: "FK_MovMag_RawItemList_RawItemId", + column: x => x.RawItemId, + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "ResourceList", columns: table => new @@ -163,6 +189,12 @@ namespace MagMan.Data.Tenant.Migrations constraints: table => { table.PrimaryKey("PK_ResourceList", x => x.ResourceId); + table.ForeignKey( + name: "FK_ResourceList_RawItemList_RawItemId", + column: x => x.RawItemId, + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ResourceList_RequestPlan_RequestId", column: x => x.RequestId, @@ -172,6 +204,11 @@ namespace MagMan.Data.Tenant.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateIndex( + name: "IX_MovMag_RawItemId", + table: "MovMag", + column: "RawItemId"); + migrationBuilder.CreateIndex( name: "IX_ProjList_IsActive", table: "ProjList", @@ -202,6 +239,11 @@ namespace MagMan.Data.Tenant.Migrations table: "RawItemList", column: "MatId"); + migrationBuilder.CreateIndex( + name: "IX_ResourceList_RawItemId", + table: "ResourceList", + column: "RawItemId"); + migrationBuilder.CreateIndex( name: "IX_ResourceList_RequestId", table: "ResourceList", @@ -217,19 +259,22 @@ namespace MagMan.Data.Tenant.Migrations name: "Config"); migrationBuilder.DropTable( - name: "ProjList"); + name: "MovMag"); migrationBuilder.DropTable( - name: "RawItemList"); + name: "ProjList"); migrationBuilder.DropTable( name: "ResourceList"); migrationBuilder.DropTable( - name: "MaterialsList"); + name: "RawItemList"); migrationBuilder.DropTable( name: "RequestPlan"); + + migrationBuilder.DropTable( + name: "MaterialsList"); } } } From 32999677ea7bb7529809a45a5ccc0ea5c09e56fd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 25 Jan 2024 19:44:28 +0100 Subject: [PATCH 5/5] Aggiunta registrazione tipii comvimento in mag --- MagMan.Core/Services/MessageService.cs | 4 +- .../Controllers/TenantController.cs | 139 +++++-- MagMan.Data.Tenant/Services/TenantService.cs | 354 +++++++++--------- MagMan.UI/Components/ItemEdit.razor.cs | 30 +- MagMan.UI/Components/ItemMan.razor.cs | 2 +- MagMan.UI/Components/LoginDisplay.razor.cs | 23 +- MagMan.UI/Components/MovMag.razor | 61 ++- MagMan.UI/Controllers/InventoryController.cs | 2 +- MagMan.UI/Controllers/ResourcesController.cs | 16 +- MagMan.UI/MagMan.UI.csproj | 2 +- MagMan.UI/Pages/WareHouse.razor | 1 + Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 14 files changed, 379 insertions(+), 261 deletions(-) diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs index 53e12ad..8ce9bbc 100644 --- a/MagMan.Core/Services/MessageService.cs +++ b/MagMan.Core/Services/MessageService.cs @@ -30,7 +30,7 @@ namespace MagMan.Core.Services public event Action EA_PageUpdated = null!; public event Action EA_SearchUpdated = null!; public event Action EA_ShowSearch = null!; - public event Action EA_CustomerSel = null!; + public event Action EA_CustomerSel = null!; #endregion Public Events @@ -57,6 +57,8 @@ namespace MagMan.Core.Services #region Public Properties + public string UserName { get; set; } = "NA"; + public string PageIcon { get => _pageIcon; diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 8503907..873a760 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace MagMan.Data.Tenant.Controllers { @@ -23,30 +24,6 @@ namespace MagMan.Data.Tenant.Controllers #endregion Public Constructors - - /// - /// Elenco MovMag dato Item - /// - /// Stringa connessione (variabile x cliente) - /// ID dell'item x cui filtrare, 0 = tutti - /// numMax record da leggere, default 1000 - /// - public List MovMagGetFilt(string connString, int rawItemID, int maxRec = 1000) - { - List dbResult = new List(); - using (MagManContext dbCtx = new MagManContext(connString)) - { - dbResult = dbCtx - .DbSetMovMag - .Where(x => rawItemID == 0 || x.RawItemId == rawItemID) - //.Include(c => c.ItemNav) - .OrderByDescending(x => x.DtRec) - .Take(maxRec) - .ToList(); - } - return dbResult; - } - #region Public Methods public async Task DatabaseMigrate(string connString) @@ -144,11 +121,15 @@ namespace MagMan.Data.Tenant.Controllers return dbResult; } - /// Aggiunge/Modifica un item in magazzino Stringa connessione (variabile x cliente) Record da aggiornare quantità da - /// aggiornare (se <0 è consumo) - public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty) + /// + /// Aggiunge/Modifica un item in magazzino + /// + /// Stringa connessione (variabile x cliente) + /// Record da aggiornare + /// quantità da aggiornare (se <0 è consumo) + /// User corrente (SE applicabile) + /// + public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty, string userId) { bool done = false; using (MagManContext dbCtx = new MagManContext(connString)) @@ -167,6 +148,16 @@ namespace MagMan.Data.Tenant.Controllers .FirstOrDefault(); if (currData != null) { + MovMagModel recMovMag = new MovMagModel() + { + DtRec = DateTime.Now, + RawItemId = rec2upd.RawItemId, + QtyRec = deltaQty, + UserId = userId, + Note = deltaQty > 0 ? "M01+: Rettifica Inventariale" : "M01-: Rettifica Inventariale" + }; + dbCtx.DbSetMovMag.Add(recMovMag); + currData.QtyAvail += deltaQty; dbCtx.Entry(currData).State = EntityState.Modified; } @@ -186,8 +177,9 @@ namespace MagMan.Data.Tenant.Controllers /// /// Stringa connessione (variabile x cliente) /// Record da aggiungere/aggiornare + /// User corrente (SE applicabile) /// - public bool ItemUpdate(string connString, RawItemModel rec2upd) + public bool ItemUpdate(string connString, RawItemModel rec2upd, string userId) { bool done = false; using (MagManContext dbCtx = new MagManContext(connString)) @@ -206,6 +198,22 @@ namespace MagMan.Data.Tenant.Controllers .FirstOrDefault(); if (currData != null) { + // aggiungo record variazione quantità... + int delta = rec2upd.QtyAvail - currData.QtyAvail; + if (delta != 0) + { + MovMagModel recMovMag = new MovMagModel() + { + DtRec = DateTime.Now, + RawItemId = rec2upd.RawItemId, + QtyRec = delta, + UserId = userId, + Note = delta > 0 ? "M02+: Rettifica Inventariale" : "M02-: Rettifica Inventariale" + }; + dbCtx.DbSetMovMag.Add(recMovMag); + } + + // sistemo record... currData.MatId = rec2upd.MatId; currData.QtyAvail = rec2upd.QtyAvail; currData.IsActive = rec2upd.IsActive; @@ -222,6 +230,17 @@ namespace MagMan.Data.Tenant.Controllers dbCtx .DbSetItems .Add(rec2upd); + dbCtx.SaveChanges(); + + // aggiungo record variazione quantità... + MovMagModel recMovMag = new MovMagModel() + { + DtRec = DateTime.Now, + RawItemId = rec2upd.RawItemId, + QtyRec = rec2upd.QtyAvail, + Note = rec2upd.QtyAvail > 0 ? "M03+: Aggiunta Record" : "M03+: Aggiunta Record" + }; + dbCtx.DbSetMovMag.Add(recMovMag); } dbCtx.SaveChanges(); done = true; @@ -449,6 +468,29 @@ namespace MagMan.Data.Tenant.Controllers return done; } + /// + /// Elenco MovMag dato Item + /// + /// Stringa connessione (variabile x cliente) + /// ID dell'item x cui filtrare, 0 = tutti + /// numMax record da leggere, default 1000 + /// + public List MovMagGetFilt(string connString, int rawItemID, int maxRec = 1000) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + dbResult = dbCtx + .DbSetMovMag + .Where(x => rawItemID == 0 || x.RawItemId == rawItemID) + //.Include(c => c.ItemNav) + .OrderByDescending(x => x.DtRec) + .Take(maxRec) + .ToList(); + } + return dbResult; + } + /// /// Elimina record Project /// @@ -770,10 +812,10 @@ namespace MagMan.Data.Tenant.Controllers /// /// Stringa connessione (variabile x cliente) /// Elenco record da aggiungere/aggiornare - /// > /// Tipo di aggiornamento da registratre + /// User corrente (SE applicabile) /// - public int ResourceUpdate(string connString, List recList, Enums.ProjResState resState) + public int ResourceUpdate(string connString, List recList, Enums.ProjResState resState, string userId) { int numMod = 0; using (MagManContext dbCtx = new MagManContext(connString)) @@ -793,12 +835,45 @@ namespace MagMan.Data.Tenant.Controllers // aggiorno if (currData != null) { + if (resState == Enums.ProjResState.Consumed) + { + // aggiungo record variazione quantità... + int delta = rec2upd.Qty - currData.Qty; + if (delta != 0) + { + MovMagModel recMovMag = new MovMagModel() + { + DtRec = DateTime.Now, + RawItemId = rec2upd.RawItemId, + QtyRec = delta, + UserId = userId, + Note = delta > 0 ? "M04+: Aggiunta Risorsa" : "M04-: Consumo Risorsa" + }; + dbCtx.DbSetMovMag.Add(recMovMag); + } + } + + // aggiorno le risorse currData.Qty = rec2upd.Qty; currData.RawItemId = rec2upd.RawItemId; dbCtx.Entry(currData).State = EntityState.Modified; } else { + if (resState == Enums.ProjResState.Consumed) + { + // aggiungo record variazione quantità... + MovMagModel recMovMag = new MovMagModel() + { + DtRec = DateTime.Now, + RawItemId = rec2upd.RawItemId, + QtyRec = rec2upd.Qty, + UserId = userId, + Note = rec2upd.Qty > 0 ? "M05+: Aggiunta Risorsa" : "M05-: Consumo Risorsa" + }; + dbCtx.DbSetMovMag.Add(recMovMag); + } + // aggiungo record dbCtx .DbSetResources diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index a911361..52d4510 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -206,70 +206,19 @@ namespace MagMan.Data.Tenant.Services } /// - /// Elenco MovMag dato Item + /// Update record Item per quantità + refresh cache /// /// Key di riferimento - /// ID dell'item x cui filtrare, 0 = tutti - /// numMax record da leggere, default 1000 + /// Item interesato + /// User corrente (SE applicabile) /// - public async Task> MovMagGetFilt(int nKey, int rawItemID, int maxRec = 1000) - { - string source = "DB"; - string cString = ConnString(nKey); - List? dbResult = new List(); - try - { - // in cache tengo dati estratti ogni minuto... - string dtKey = DateTime.Now.ToString("yyMMdd:HHmm"); - string currKey = $"{Const.rKeyConfig}:{nKey}:MovMag:{rawItemID}:{dtKey}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.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 - { - dbResult = dbController.MovMagGetFilt(cString, rawItemID, maxRec); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, LongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"MovMagGetFilt | {source} in: {ts.TotalMilliseconds} ms"); - } - catch (Exception exc) - { - Log.Error($"Error during MovMagGetFilt:{Environment.NewLine}{exc}"); - } - return dbResult; - } - - - /// Update record Item + refresh cache Key di - /// riferimento Item interesato quantità da aggiornare (se <0 è consumo) - public async Task ItemModQty(int nKey, RawItemModel currItem, int deltaQty) + public async Task ItemModQty(int nKey, RawItemModel currItem, int deltaQty, string userId) { bool fatto = false; string cString = ConnString(nKey); try { - fatto = dbController.ItemModQty(cString, currItem, deltaQty); + fatto = dbController.ItemModQty(cString, currItem, deltaQty, userId); if (fatto) { await FlushRedisCache(); @@ -287,14 +236,15 @@ namespace MagMan.Data.Tenant.Services /// /// Key di riferimento /// Item interesato + /// User corrente (SE applicabile) /// - public async Task ItemUpdate(int nKey, RawItemModel currItem) + public async Task ItemUpdate(int nKey, RawItemModel currItem, string userId) { bool fatto = false; string cString = ConnString(nKey); try { - fatto = dbController.ItemUpdate(cString, currItem); + fatto = dbController.ItemUpdate(cString, currItem, userId); if (fatto) { await FlushRedisCache(); @@ -332,6 +282,64 @@ namespace MagMan.Data.Tenant.Services return fatto; } + /// + /// Lista Materiali gestiti a magazzino in formato DTO + /// + /// Key di riferimento + /// Se true allora include record child (Items) + /// + public async Task> MaterialDtoGetAll(int nKey, bool withChild) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + string dType = withChild ? "MaterialsDtoFull" : "MaterialsDto"; + string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.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 + { + dbResult = dbController.MaterialDtoGetAll(cString, withChild); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + // per evitare loopback uso deserialize... + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult != null) + { + dbResult = tempResult; + } + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MaterialDtoGetAll | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during MaterialDtoGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Converte il DTO in MaterialModel /// @@ -413,64 +421,6 @@ namespace MagMan.Data.Tenant.Services return dbResult; } - /// - /// Lista Materiali gestiti a magazzino in formato DTO - /// - /// Key di riferimento - /// Se true allora include record child (Items) - /// - public async Task> MaterialDtoGetAll(int nKey, bool withChild) - { - string source = "DB"; - string cString = ConnString(nKey); - List? dbResult = new List(); - try - { - string dType = withChild ? "MaterialsDtoFull" : "MaterialsDto"; - string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.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 - { - dbResult = dbController.MaterialDtoGetAll(cString, withChild); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, LongCache); - // per evitare loopback uso deserialize... - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult != null) - { - dbResult = tempResult; - } - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"MaterialDtoGetAll | {source} in: {ts.TotalMilliseconds} ms"); - } - catch (Exception exc) - { - Log.Error($"Error during MaterialDtoGetAll:{Environment.NewLine}{exc}"); - } - return dbResult; - } - /// /// Lista Materiali gestiti a magazzino /// @@ -555,6 +505,60 @@ namespace MagMan.Data.Tenant.Services return fatto; } + /// + /// Elenco MovMag dato Item + /// + /// Key di riferimento + /// ID dell'item x cui filtrare, 0 = tutti + /// numMax record da leggere, default 1000 + /// + public async Task> MovMagGetFilt(int nKey, int rawItemID, int maxRec = 1000) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + // in cache tengo dati estratti ogni minuto... + string dtKey = DateTime.Now.ToString("yyMMdd:HHmm"); + string currKey = $"{Const.rKeyConfig}:{nKey}:MovMag:{rawItemID}:{dtKey}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.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 + { + dbResult = dbController.MovMagGetFilt(cString, rawItemID, maxRec); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MovMagGetFilt | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during MovMagGetFilt:{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Elimina record Project + refresh cache /// @@ -780,61 +784,6 @@ namespace MagMan.Data.Tenant.Services return answ; } - /// - /// Elenco risorse dato progetto e stato - /// - /// Key di riferimento - /// ID progetto - /// true = ultima stima attiva / false = consumi effettivi - /// true= mostra ANCHE archiviate, false = solo attive - /// - public async Task> ResourcesGetByProject(int nKey, int projDbId, bool isEstim, bool showAll) - { - string source = "DB"; - string cString = ConnString(nKey); - List? dbResult = new List(); - try - { - string tagEst = isEstim ? "EST" : "CON"; - string tagAct = showAll ? "ALL" : "ACT"; - string currKey = $"{Const.rKeyConfig}:{nKey}:ResList:{projDbId}:{tagEst}:{tagAct}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.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 - { - dbResult = dbController.ResourcesGetByProject(cString, projDbId, isEstim, showAll); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, FastCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ResourcesGetByProject | {source} in: {ts.TotalMilliseconds} ms"); - } - catch (Exception exc) - { - Log.Error($"Error during ResourcesGetByProject:{Environment.NewLine}{exc}"); - } - return dbResult; - } - /// /// Elenco risorse dato progetto e stato /// @@ -890,20 +839,77 @@ namespace MagMan.Data.Tenant.Services return dbResult; } + /// + /// Elenco risorse dato progetto e stato + /// + /// Key di riferimento + /// ID progetto + /// true = ultima stima attiva / false = consumi effettivi + /// true= mostra ANCHE archiviate, false = solo attive + /// + public async Task> ResourcesGetByProject(int nKey, int projDbId, bool isEstim, bool showAll) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + string tagEst = isEstim ? "EST" : "CON"; + string tagAct = showAll ? "ALL" : "ACT"; + string currKey = $"{Const.rKeyConfig}:{nKey}:ResList:{projDbId}:{tagEst}:{tagAct}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.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 + { + dbResult = dbController.ResourcesGetByProject(cString, projDbId, isEstim, showAll); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ResourcesGetByProject | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during ResourcesGetByProject:{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Aggiunge/Modifica un record Resource /// /// Key di riferimento - /// Elenco record da aggiungere/aggiornare> + /// Elenco record da aggiungere/aggiornare + /// > /// Tipo di aggiornamento da registratre + /// User corrente (SE applicabile) /// - public async Task ResourceUpdate(int nKey, List recList, Enums.ProjResState resState) + public async Task ResourceUpdate(int nKey, List recList, Enums.ProjResState resState, string userId) { int newId = 0; string cString = ConnString(nKey); try { - newId = dbController.ResourceUpdate(cString, recList, resState); + newId = dbController.ResourceUpdate(cString, recList, resState, userId); if (newId > 0) { await FlushRedisCache(); diff --git a/MagMan.UI/Components/ItemEdit.razor.cs b/MagMan.UI/Components/ItemEdit.razor.cs index 451b3ec..f227cdb 100644 --- a/MagMan.UI/Components/ItemEdit.razor.cs +++ b/MagMan.UI/Components/ItemEdit.razor.cs @@ -1,3 +1,4 @@ +using MagMan.Core.Services; using MagMan.Data.Tenant.DbModels; using MagMan.Data.Tenant.Services; using Microsoft.AspNetCore.Components; @@ -11,15 +12,19 @@ namespace MagMan.UI.Components [Parameter] public RawItemModel? CurrRecord { get; set; } = null; - [Parameter] - public int KeyNum { get; set; } = 0; [Parameter] public EventCallback EC_update { get; set; } + [Parameter] + public int KeyNum { get; set; } = 0; + #endregion Public Properties #region Protected Properties + [Inject] + protected MessageService AppMService { get; set; } = null!; + [Inject] protected TenantService TService { get; set; } = null!; @@ -27,24 +32,35 @@ namespace MagMan.UI.Components #region Protected Methods + protected async Task DoCancel() + { + await EC_update.InvokeAsync(true); + } + protected async Task DoSave() { bool fatto = false; await Task.Delay(1); if (CurrRecord != null) { - fatto = await TService.ItemUpdate(KeyNum, CurrRecord); + fatto = await TService.ItemUpdate(KeyNum, CurrRecord, userName); } if (fatto) { await EC_update.InvokeAsync(true); } } - protected async Task DoCancel() - { - await EC_update.InvokeAsync(true); - } #endregion Protected Methods + + #region Private Properties + + private string userName + { + get => AppMService.UserName; + set => AppMService.UserName = value; + } + + #endregion Private Properties } } \ No newline at end of file diff --git a/MagMan.UI/Components/ItemMan.razor.cs b/MagMan.UI/Components/ItemMan.razor.cs index 7fab80e..1e6236f 100644 --- a/MagMan.UI/Components/ItemMan.razor.cs +++ b/MagMan.UI/Components/ItemMan.razor.cs @@ -98,7 +98,7 @@ namespace MagMan.UI.Components { if (selItem != null) { - RawItemId = selItem.MatId; + RawItemId = selItem.RawItemId; } else { diff --git a/MagMan.UI/Components/LoginDisplay.razor.cs b/MagMan.UI/Components/LoginDisplay.razor.cs index 688b909..3e7fb6b 100644 --- a/MagMan.UI/Components/LoginDisplay.razor.cs +++ b/MagMan.UI/Components/LoginDisplay.razor.cs @@ -1,16 +1,19 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this +// file to you under the MIT license. +using MagMan.Core.Services; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; namespace MagMan.UI.Components { public partial class LoginDisplay { - #region Private Fields + #region Protected Properties - private string userName = ""; + [Inject] + protected MessageService AppMService { get; set; } = null!; - #endregion Private Fields + #endregion Protected Properties #region Protected Methods @@ -26,6 +29,16 @@ namespace MagMan.UI.Components #endregion Protected Methods + #region Private Properties + + private string userName + { + get => AppMService.UserName; + set => AppMService.UserName = value; + } + + #endregion Private Properties + #region Private Methods private async Task forceReload() diff --git a/MagMan.UI/Components/MovMag.razor b/MagMan.UI/Components/MovMag.razor index 1b93ee6..03497ee 100644 --- a/MagMan.UI/Components/MovMag.razor +++ b/MagMan.UI/Components/MovMag.razor @@ -2,27 +2,27 @@
      -

      Movimenti Magazzino

      +
      Movimenti Magazzino
      +
      + @*
      +
      +
      + @if (CurrItem == null) + { + + } + else + { + + } +
      - @*
      -
      -
      - @if (CurrItem == null) - { - - } - else - { - - } -
      -
      *@
      @* @if (CurrItem != null) { -
      - +
      + } *@
      @@ -40,37 +40,36 @@ @* - - *@ + + *@ Id Data Qty - Note - User + Note @foreach (var item in ListRecords) { - @* - - - *@ - - @item.MovID + @* + + + *@ + + @item.MovID @item.DtRec.ToString("yyyy-MM-dd HH:mm:ss") - + @item.QtyRec - - @item.Note - - @item.UserId + @item.Note +
      + @item.UserId +
      } diff --git a/MagMan.UI/Controllers/InventoryController.cs b/MagMan.UI/Controllers/InventoryController.cs index f71323c..54c3f99 100644 --- a/MagMan.UI/Controllers/InventoryController.cs +++ b/MagMan.UI/Controllers/InventoryController.cs @@ -101,7 +101,7 @@ namespace MagMan.UI.Controllers { try { - await TService.ItemUpdate(nKey, item); + await TService.ItemUpdate(nKey, item, $"Key: {nKey}"); fatto = true; } catch (Exception exc) diff --git a/MagMan.UI/Controllers/ResourcesController.cs b/MagMan.UI/Controllers/ResourcesController.cs index 534d3d8..1452fd7 100644 --- a/MagMan.UI/Controllers/ResourcesController.cs +++ b/MagMan.UI/Controllers/ResourcesController.cs @@ -99,13 +99,14 @@ namespace MagMan.UI.Controllers { // recupero ID interno da id esterno... int ProjDbId = 0; + ProjModel? projRec = null; var allProj = await TService.ProjectGetByMachine(nKey, 0); if (allProj != null) { - var pRec = allProj.Find(x => x.ProjExtDbId == projectData.ProjExtDbId); - if (pRec != null) + projRec = allProj.Find(x => x.ProjExtDbId == projectData.ProjExtDbId); + if (projRec != null) { - ProjDbId = pRec.ProjDbId; + ProjDbId = projRec.ProjDbId; } } if (ProjDbId > 0) @@ -127,8 +128,13 @@ namespace MagMan.UI.Controllers listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, reqId)).ToList(); try { - await TService.ResourceUpdate(nKey, listRes, projectData.ReqState); - + string kDesc = $"K{nKey}"; + string prDesc = kDesc; + if (projRec != null) + { + prDesc = $"P: {projRec.ProjExtId}.{projRec.ProjExtDbId} | {projRec.ProjDescription} ({projRec.Machine})"; + } + await TService.ResourceUpdate(nKey, listRes, projectData.ReqState, $"{prDesc} | {kDesc}"); fatto = true; } catch (Exception exc) diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index 8b8ef5f..744bae2 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2518 + 1.0.2401.2519 enable enable true diff --git a/MagMan.UI/Pages/WareHouse.razor b/MagMan.UI/Pages/WareHouse.razor index 8000cb4..ff316c1 100644 --- a/MagMan.UI/Pages/WareHouse.razor +++ b/MagMan.UI/Pages/WareHouse.razor @@ -22,6 +22,7 @@ else @if (RawItemId > 0) { +
      }
      diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index e764482..60c9739 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

      Versione: 1.0.2401.2518

      +

      Versione: 1.0.2401.2519


      Note di rilascio:
      • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index d0f3e55..932a95a 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2518 +1.0.2401.2519 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 212efb1..be04690 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2518 + 1.0.2401.2519 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false