diff --git a/MagMan.Core/DTO/ItemDTO.cs b/MagMan.Core/DTO/ItemDTO.cs index 5516f1f..0fcdf5b 100644 --- a/MagMan.Core/DTO/ItemDTO.cs +++ b/MagMan.Core/DTO/ItemDTO.cs @@ -42,7 +42,7 @@ namespace MagMan.Core.DTO /// /// Item's Thikness /// - public decimal TMm { get; set; } = 0; + public decimal HMm { get; set; } = 0; /// /// Note (optional) diff --git a/MagMan.Core/DTO/MaterialDTO.cs b/MagMan.Core/DTO/MaterialDTO.cs index 1c98963..a6fddc3 100644 --- a/MagMan.Core/DTO/MaterialDTO.cs +++ b/MagMan.Core/DTO/MaterialDTO.cs @@ -8,27 +8,21 @@ namespace MagMan.Core.DTO { public class MaterialDTO { + /// + /// Primary Key AUTO, 0 se proviente da EgtBeamWall + /// + public int MatId { get; set; } = 0; /// - /// Codice materiale (esterno) + /// Codice Materiale /// - public int MatExtCode { get; set; } = 0; + public string MatCode { get; set; } = ""; + /// /// Descrizione materiale /// public string MatDesc { get; set; } = ""; -#if false - /// - /// Data approvazione (se non approvato è nel futuro) - /// - public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100); - /// - /// Utente approvazione amteriale - /// - public string ApprovUser { get; set; } = ""; -#endif - /// /// Lenght/Lunghezza in mm /// @@ -40,6 +34,6 @@ namespace MagMan.Core.DTO /// /// Thikness/Spessore in mm /// - public decimal TMm { get; set; } = 0; + public decimal HMm { get; set; } = 0; } } diff --git a/MagMan.Core/Enums.cs b/MagMan.Core/Enums.cs index 573e11e..6b76686 100644 --- a/MagMan.Core/Enums.cs +++ b/MagMan.Core/Enums.cs @@ -1,7 +1,18 @@ -namespace MagMan.Core +using StackExchange.Redis; + +namespace MagMan.Core { public class Enums { + #region Public Enums + + public enum BWType + { + NULL = 0, + BEAM = 1, + WALL = 2 + } + public enum ItemState { None, @@ -10,5 +21,22 @@ Request, } + + public enum RequestStatus + { + None = 0, + Estimated, + Confirmed, + Reserved + } + + public enum ResultTypes + { + NULL = 0, + EXECUTED = 1, + RESULT = 2 + } + + #endregion Public Enums } -} +} \ No newline at end of file diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 0fc6cc2..1826f8f 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -45,7 +45,7 @@ namespace MagMan.Data.Tenant.Controllers /// Stringa connessione (variabile x cliente) /// Item da eliminare /// - public bool ItemDelete(string connString, ItemModel rec2del) + public bool ItemDelete(string connString, RawItemModel rec2del) { bool done = false; using (MagManContext dbCtx = new MagManContext(connString)) @@ -54,7 +54,7 @@ namespace MagMan.Data.Tenant.Controllers { var currData = dbCtx .DbSetItems - .Where(x => x.ItemID == rec2del.ItemID) + .Where(x => x.RawItemId == rec2del.RawItemId) .FirstOrDefault(); if (currData != null) { @@ -78,16 +78,16 @@ namespace MagMan.Data.Tenant.Controllers /// /// Stringa connessione (variabile x cliente) /// - public List ItemGetAll(string connString) + public List ItemGetAll(string connString) { - List dbResult = new List(); + List dbResult = new List(); using (MagManContext dbCtx = new MagManContext(connString)) { dbResult = dbCtx .DbSetItems //.Where(x => CustomerId == 0 || x.CustomerID == CustomerId) .Include(c => c.MaterialNav) - .OrderBy(x => x.MatID) + .OrderBy(x => x.MatId) .ToList(); } return dbResult; @@ -99,18 +99,18 @@ namespace MagMan.Data.Tenant.Controllers /// Stringa connessione (variabile x cliente) /// ID del materiale x cui filtrare, 0 = tutti /// - public List ItemGetByMat(string connString, int matID) + public List ItemGetByMat(string connString, int matID) { - List dbResult = new List(); + List dbResult = new List(); using (MagManContext dbCtx = new MagManContext(connString)) { dbResult = dbCtx .DbSetItems - .Where(x => matID == 0 || x.MatID == matID) + .Where(x => matID == 0 || x.MatId == matID) .Include(c => c.MaterialNav) - //.OrderBy(x => x.MatID) + //.OrderBy(x => x.MatId) .OrderBy(x => x.WMm) - .ThenBy(x => x.TMm) + .ThenBy(x => x.HMm) .ThenBy(x => x.LMm) .ToList(); } @@ -123,28 +123,34 @@ namespace MagMan.Data.Tenant.Controllers /// Stringa connessione (variabile x cliente) /// Record da aggiungere/aggiornare /// - public bool ItemUpdate(string connString, ItemModel rec2upd) + public bool ItemUpdate(string connString, RawItemModel rec2upd) { bool done = false; using (MagManContext dbCtx = new MagManContext(connString)) { try { + /* + * Verifica se esistesse: deve essere valido TUTTO + * - stesso materiale + * - stesse dimensioni + * */ var currData = dbCtx .DbSetItems - .Where(x => x.ItemID == rec2upd.ItemID) + .Where(x => (x.RawItemId == rec2upd.RawItemId) || + (x.MatId == rec2upd.MatId && (x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm))) .FirstOrDefault(); if (currData != null) { - currData.MatID = rec2upd.MatID; + currData.MatId = rec2upd.MatId; + currData.QtyAvail = rec2upd.QtyAvail; + currData.IsActive = rec2upd.IsActive; currData.IsRemn = rec2upd.IsRemn; currData.Location = rec2upd.Location; - currData.QtyAvail = rec2upd.QtyAvail; - currData.Note = rec2upd.Note; currData.LMm = rec2upd.LMm; - currData.TMm = rec2upd.TMm; + currData.HMm = rec2upd.HMm; currData.WMm = rec2upd.WMm; - currData.DtMod = rec2upd.DtMod; + currData.Note = rec2upd.Note; dbCtx.Entry(currData).State = EntityState.Modified; } else @@ -179,7 +185,7 @@ namespace MagMan.Data.Tenant.Controllers { var currData = dbCtx .DbSetMaterials - .Where(x => x.MatID == rec2del.MatID) + .Where(x => x.MatId == rec2del.MatId) .FirstOrDefault(); if (currData != null) { @@ -212,10 +218,10 @@ namespace MagMan.Data.Tenant.Controllers { dbResult = dbCtx .DbSetMaterials - .Include(x => x.ItemNav) + .Include(x => x.RawItemList) .OrderBy(x => x.MatDesc) .ThenBy(x => x.WMm) - .ThenBy(x => x.TMm) + .ThenBy(x => x.HMm) .ThenBy(x => x.LMm) .ToList(); } @@ -225,7 +231,7 @@ namespace MagMan.Data.Tenant.Controllers .DbSetMaterials .OrderBy(x => x.MatDesc) .ThenBy(x => x.WMm) - .ThenBy(x => x.TMm) + .ThenBy(x => x.HMm) .ThenBy(x => x.LMm) .ToList(); } @@ -247,11 +253,11 @@ namespace MagMan.Data.Tenant.Controllers { dbResult = dbCtx .DbSetMaterials - .Where(x => matID == 0 || x.MatID == matID) - .Include(x => x.ItemNav) + .Where(x => matID == 0 || x.MatId == matID) + .Include(x => x.RawItemList) .OrderBy(x => x.MatDesc) .ThenBy(x => x.WMm) - .ThenBy(x => x.TMm) + .ThenBy(x => x.HMm) .ThenBy(x => x.LMm) .ToList(); } @@ -259,10 +265,10 @@ namespace MagMan.Data.Tenant.Controllers { dbResult = dbCtx .DbSetMaterials - .Where(x => matID == 0 || x.MatID == matID) + .Where(x => matID == 0 || x.MatId == matID) .OrderBy(x => x.MatDesc) .ThenBy(x => x.WMm) - .ThenBy(x => x.TMm) + .ThenBy(x => x.HMm) .ThenBy(x => x.LMm) .ToList(); } @@ -283,18 +289,24 @@ namespace MagMan.Data.Tenant.Controllers { try { + /* + * Ricerca equal: corrisponde se + * - MatID identico + * - se Uguali + NonNulli [MatCode oppure MatDescript] + uguali [W/H/L]... + */ var currData = dbCtx .DbSetMaterials - .Where(x => x.MatID == rec2upd.MatID || x.MatExtCode == rec2upd.MatExtCode) + .Where(x => (rec2upd.MatId > 0 && x.MatId == rec2upd.MatId) || + ((x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm) && + ((!string.IsNullOrEmpty(rec2upd.MatCode) && x.MatCode == rec2upd.MatCode) || (!string.IsNullOrEmpty(rec2upd.MatDesc) && x.MatDesc == rec2upd.MatDesc)) + )) .FirstOrDefault(); if (currData != null) { - currData.MatExtCode = rec2upd.MatExtCode; + currData.MatCode = rec2upd.MatCode; currData.MatDesc = rec2upd.MatDesc; - currData.ApprovDate = rec2upd.ApprovDate; - currData.ApprovUser = rec2upd.ApprovUser; currData.LMm = rec2upd.LMm; - currData.TMm = rec2upd.TMm; + currData.HMm = rec2upd.HMm; currData.WMm = rec2upd.WMm; dbCtx.Entry(currData).State = EntityState.Modified; } diff --git a/MagMan.Data.Tenant/DbModels/AliasModel.cs b/MagMan.Data.Tenant/DbModels/AliasModel.cs new file mode 100644 index 0000000..1d0b6fc --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/AliasModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("AliasList")] + public class AliasModel + { + /// + /// Famiglia di sinonimi + /// + public string Family { get; set; } = ""; + + /// + /// Codice originale (da trasformare) + /// + public string ValueOriginal { get; set; } = ""; + + /// + /// Codice Alias in cui viene convertito + /// + public string ValueAlias { get; set; } = ""; + } +} diff --git a/MagMan.Data.Tenant/DbModels/LogMachineModel.cs b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs new file mode 100644 index 0000000..15e65fc --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei LOG Macchina (per macchina) + /// + [Table("LogMachine")] + [Index(nameof(MachineID))] + [Index(nameof(KeyNum))] + public class LogMachineModel + { + [Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int LogDbId { get; set; } + + /// + /// Id macchina (diMagMan) + /// + public int MachineID { get; set; } = 0; + + /// + /// Key di riferimento per il progetto + /// + public int KeyNum { get; set; } = 0; + +#if false + /// + /// Codice Allarme + /// + [Column("AlarmCode")] + public string AlarmCode { get; set; } = ""; + + /// + /// Data Evento + /// + [Column("AlarmDtEvent")] + public DateTime AlarmDatetime { get; set; } = DateTime.Now; + + /// + /// Messaggio Allarme + /// + [Column("AlarmMessage")] + public string AlarmMessage { get; set; } = ""; + + /// + /// Alarm Operation + /// + [Column("AlarmOperation")] + public int AlarmOperation { get; set; } = 0; + + /// + /// Alarm Type + /// + [Column("AlarmType")] + public int AlarmType { get; set; } = 0; + + /// + /// Esaecuzione comando corretta + /// + [Column("CommExecuted")] + public bool CommandExecutedCorrectly { get; set; } = false; + + /// + /// Stato da enum Core + /// + [Column("CommandState")] + public Core.ConstMachComm.CommandStates CommandState { get; set; } = Core.ConstMachComm.CommandStates.NULL; + + /// + /// Tipo Comando da enum Core + /// + [Column("CommandType")] + public Core.ConstMachComm.LogCommandTypes CommandType { get; set; } = Core.ConstMachComm.LogCommandTypes.NULL; + + /// + /// Descrizione + /// + [Column("Description")] + public string Description { get; set; } = ""; + + + + /// + /// New OP State + /// + [Column("NewOpState")] + public int NewOpState { get; set; } = 0; +#endif + + /// + /// Stato da enum Core + /// + [Column("ResultType")] + public ResultTypes ResultType { get; set; } = ResultTypes.NULL; + + /// + /// Indirizzo VAR + /// + [Column("VarAddress")] + public string VarAddress { get; set; } = ""; + + /// + /// Valore VAR + /// + [Column("VarValue")] + public string VarValue { get; set; } = ""; + + + } +} diff --git a/MagMan.Data.Tenant/DbModels/MaterialModel.cs b/MagMan.Data.Tenant/DbModels/MaterialModel.cs index 8b1cf3d..a0da42a 100644 --- a/MagMan.Data.Tenant/DbModels/MaterialModel.cs +++ b/MagMan.Data.Tenant/DbModels/MaterialModel.cs @@ -11,30 +11,33 @@ namespace MagMan.Data.Tenant.DbModels // // This is here so CodeMaid doesn't reorganize this document // - [Table("Materials")] + [Table("MaterialsList")] public partial class MaterialModel { - [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int MatID { get; set; } + /// + /// Init classe + /// + public MaterialModel() + { + RawItemList = new HashSet(); + } /// - /// Codice materiale (esterno) + /// Primary Key AUTO /// - public int MatExtCode { get; set; } = 0; + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int MatId { get; set; } + + /// + /// Codice Materiale + /// + public string MatCode { get; set; } = ""; + /// /// Descrizione materiale /// public string MatDesc { get; set; } = ""; - /// - /// Data approvazione (se non approvato è nel futuro) - /// - public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100); - /// - /// Utente approvazione amteriale - /// - public string ApprovUser { get; set; } = ""; - /// /// Lenght/Lunghezza in mm /// @@ -44,10 +47,11 @@ namespace MagMan.Data.Tenant.DbModels /// public decimal WMm { get; set; } = 0; /// - /// Thikness/Spessore in mm + /// Height (Thikness/Spessore) in mm /// - public decimal TMm { get; set; } = 0; + public decimal HMm { get; set; } = 0; +#if false /// /// Lenght/Lunghezza in inch /// @@ -68,10 +72,11 @@ namespace MagMan.Data.Tenant.DbModels /// Thikness/Spessore in inch /// [NotMapped] - public decimal TIn + public decimal HIn { - get => Math.Round(TMm / (decimal)25.4, 3); - } + get => Math.Round(HMm / (decimal)25.4, 3); + } +#endif /// /// Codice materiale x QR/Datamatrix @@ -79,10 +84,27 @@ namespace MagMan.Data.Tenant.DbModels [NotMapped] public string MatDtmx { - get => $"MT{MatExtCode:00000000}"; + get => $"MT{MatId:00000000}"; } + /// + /// Verifica che sia Beam, quando L == 0 + /// + [NotMapped] + public bool IsBeam + { + get => LMm == 0; + } + + /// + /// Verifica che sia Wall, quando W/H == 0 + /// + [NotMapped] + public bool IsWall + { + get => (HMm == 0 && WMm==0); + } - public virtual ICollection? ItemNav { get; set; } + public virtual ICollection? RawItemList { get; set; } } } diff --git a/MagMan.Data.Tenant/DbModels/MovMagModel.cs b/MagMan.Data.Tenant/DbModels/MovMagModel.cs index 32aac01..6cdd62e 100644 --- a/MagMan.Data.Tenant/DbModels/MovMagModel.cs +++ b/MagMan.Data.Tenant/DbModels/MovMagModel.cs @@ -44,8 +44,8 @@ namespace MagMan.Data.Tenant.DbModels /// /// Navigation property to Items /// - [ForeignKey("ItemID")] - public virtual ItemModel? ITemNav { get; set; } + [ForeignKey("RawItemId")] + public virtual RawItemModel? ITemNav { get; set; } } } diff --git a/MagMan.Data.Tenant/DbModels/ProjModel.cs b/MagMan.Data.Tenant/DbModels/ProjModel.cs new file mode 100644 index 0000000..551fe40 --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/ProjModel.cs @@ -0,0 +1,122 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei PROJ caricati da EgtBeamWall + /// + [Table("ProjList")] + [Index(nameof(MachineID))] + [Index(nameof(KeyNum))] + [Index(nameof(DtCreated))] + [Index(nameof(DtStartProd))] + [Index(nameof(DtLastAction))] + [Index(nameof(ProjId))] + [Index(nameof(IsActive))] + [Index(nameof(IsArchived))] + public class ProjModel + { + #region Public Properties + + /// + /// Chiave univoca su DB + /// + [Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProjDbId { get; set; } + + /// + /// ID da modello ext + /// + [Column("Id")] + public int ProjId { get; set; } + + /// + /// Nome file BTL originale + /// + public string BTLFileName { get; set; } = ""; + + /// + /// Tipologia del progetto (Travi, Pareti, ...) + /// + public BWType PType { get; set; } = BWType.NULL; + + /// + /// Id macchina (diMagMan) + /// + public int MachineID { get; set; } = 0; + + /// + /// Key di riferimento per il progetto + /// + public int KeyNum { get; set; } = 0; + + /// + /// Macchina (Costruttore/Modello) + /// + public string Machine { get; set; } = ""; + + /// + /// Descrizione progetto (copiata da BTLFileName inizialmente) + /// + public string ProjDescription { get; set; } = ""; + + /// + /// Data Creazione progetto + /// + public DateTime DtCreated { get; set; } = DateTime.Now; + + /// + /// Data di schedulazione (prevista) + /// + public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3); + + /// + /// Data Inizio Produzione + /// + public DateTime DtStartProd { get; set; } = DateTime.MinValue; + + /// + /// Data ora ultima operazione registrata + /// + public DateTime DtLastAction { get; set; } = DateTime.MinValue; + + /// + /// ListName del BTL + /// + public string ListName { get; set; } = ""; + + /// + /// Tempo lavorazione previsto (stima) in minuti + /// + public double ProcTimeEst { get; set; } = 0; + + /// + /// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato) + /// + public double ProcTimeReal { get; set; } = 0; + + /// + /// Record attivo (se false == cancellazione logica) + /// + public bool IsActive { get; set; } = true; + + /// + /// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso + /// + public bool IsArchived { get; set; } = false; + + #endregion Public Properties + } +} diff --git a/MagMan.Data.Tenant/DbModels/ItemModel.cs b/MagMan.Data.Tenant/DbModels/RawItemModel.cs similarity index 76% rename from MagMan.Data.Tenant/DbModels/ItemModel.cs rename to MagMan.Data.Tenant/DbModels/RawItemModel.cs index e4a8eac..40644dd 100644 --- a/MagMan.Data.Tenant/DbModels/ItemModel.cs +++ b/MagMan.Data.Tenant/DbModels/RawItemModel.cs @@ -12,19 +12,29 @@ namespace MagMan.Data.Tenant.DbModels // This is here so CodeMaid doesn't reorganize this document // //[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))] - [Table("ItemsList")] - public partial class ItemModel + [Table("RawItemList")] + public partial class RawItemModel { /// /// Primary Key AUTO /// [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int ItemID { get; set; } + public int RawItemId { get; set; } /// /// Ext ref for Material /// - public int MatID { get; set; } = 0; + public int MatId { get; set; } = 0; + + /// + /// Qty available on wharehouse + /// + public int QtyAvail { get; set; } = 0; + + /// + /// Check if is a Remnant + /// + public bool IsActive { get; set; } = false; /// /// Check if is a Remnant @@ -35,16 +45,6 @@ namespace MagMan.Data.Tenant.DbModels /// Location /// public string Location { get; set; } = ""; - /// - /// Qty available on wharehouse - /// - public int QtyAvail { get; set; } = 0; - - /// - /// DateTime last modification - /// - public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10); - /// /// Item's Lenght /// @@ -56,10 +56,16 @@ namespace MagMan.Data.Tenant.DbModels public decimal WMm { get; set; } = 0; /// - /// Item's Thikness + /// Item's Height (Thikness/Spessore) in mm /// - public decimal TMm { get; set; } = 0; + public decimal HMm { get; set; } = 0; + /// + /// Note (optional) + /// + public string Note { get; set; } = ""; + +#if false [NotMapped] public decimal LIn { @@ -71,22 +77,18 @@ namespace MagMan.Data.Tenant.DbModels get => Math.Round(WMm / (decimal)25.4, 3); } [NotMapped] - public decimal TIn + public decimal HIn { - get => Math.Round(TMm / (decimal)25.4, 3); - } + get => Math.Round(HMm / (decimal)25.4, 3); + } - /// - /// Note (optional) - /// - public string Note { get; set; } = ""; - [NotMapped] public decimal Area { get => LMm * WMm; } +#endif [NotMapped] @@ -94,10 +96,10 @@ namespace MagMan.Data.Tenant.DbModels { get { - string answ = $"MT99999999-{LMm * 1000:00000000}"; + string answ = $"MT99999999W{WMm * 10:000000}H{HMm * 10:000000}L{LMm * 10:000000}"; if (MaterialNav != null) { - answ = $"MT{MaterialNav.MatExtCode:00000000}-{LMm * 1000:00000000}"; + answ = $"MT{MaterialNav.MatId:00000000}W{WMm * 10:000000}H{HMm * 10:000000}L{LMm * 10:000000}"; } return answ; } @@ -106,7 +108,7 @@ namespace MagMan.Data.Tenant.DbModels /// /// Navigation property to Material /// - [ForeignKey("MatID")] + [ForeignKey("MatId")] public virtual MaterialModel MaterialNav { get; set; } = null!; } diff --git a/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs b/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs new file mode 100644 index 0000000..fadaf41 --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella esplosione richieste come items + /// + [Table("RequestDetail")] + public class RequestDetailModel + { + /// + /// Riferimento Richiesta + /// + public int RequestId { get; set; } = 0; + + /// + /// Riferimento Item specifico + /// + public int ItemID { get; set; } = 0; + + /// + /// Quantità necessaria + /// + public int QtyReq { get; set; } = 0; + + /// + /// Stato richeista + /// + public RequestStatus ReqState { get; set; } = RequestStatus.None; + } +} diff --git a/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs new file mode 100644 index 0000000..b1b2d93 --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei Piano Richieste associate a Proj + /// + [Table("RequestPlan")] + public class RequestPlanModel + { + [Key, Column("RequestId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int RequestId { get; set; } + + /// + /// Progetto di riferimento + /// + public int ProjDbId { get; set; } + + /// + /// Data richiesta + /// + public DateTime DtRequest{ get; set; } + + + /// + /// Record attivo (se false == NON è il piano scelto) + /// + public bool IsActive { get; set; } = true; + } +} diff --git a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj index cd5d5f6..1986e8e 100644 --- a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj +++ b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj @@ -42,6 +42,7 @@ + diff --git a/MagMan.Data.Tenant/MagManContext.cs b/MagMan.Data.Tenant/MagManContext.cs index d4ed53c..02e8cdd 100644 --- a/MagMan.Data.Tenant/MagManContext.cs +++ b/MagMan.Data.Tenant/MagManContext.cs @@ -33,56 +33,26 @@ namespace MagMan.Data.Tenant connString = currConnString; } -#if false - public MagManContext(DbContextOptions options) : base(options) - { - try - { - // se non ci fosse... crea o migra! - Database.Migrate(); - } - catch (Exception exc) - { - Log.Error(exc, "Exception during context initialization 02"); - } - } -#endif - #endregion Public Constructors #region Public Properties public virtual DbSet DbSetConfig { get; set; } = null!; - public virtual DbSet DbSetItems { get; set; } = null!; + public virtual DbSet DbSetItems { get; set; } = null!; public virtual DbSet DbSetMaterials { get; set; } = null!; - public virtual DbSet DbSetMovMag { get; set; } = null!; - public virtual DbSet DbSetPrintJob { get; set; } = null!; + public virtual DbSet DbSetRawItem { get; set; } = null!; + public virtual DbSet DbSetAlias { get; set; } = null!; + public virtual DbSet DbSetReqPlan { get; set; } = null!; + public virtual DbSet DbSetReqDet{ get; set; } = null!; + #if false - public virtual DbSet DbSetKeyVal { get; set; } - - public virtual DbSet DbSetListVal { get; set; } - - public virtual DbSet DbSetOrders { get; set; } - - public virtual DbSet DbSetParamSend { get; set; } - - public virtual DbSet DbSetParamSet { get; set; } - - public virtual DbSet DbSetPlant { get; set; } - - public virtual DbSet DbSetPlantLog { get; set; } - - public virtual DbSet DbSetPlantStatus { get; set; } - - public virtual DbSet DbSetPlantSupplWeekPlan { get; set; } - - public virtual DbSet DbSetSupplier { get; set; } - - public virtual DbSet DbSetTransporter { get; set; } + public virtual DbSet DbSetMovMag { get; set; } = null!; + public virtual DbSet DbSetPrintJob { get; set; } = null!; #endif + private string connString = ""; #endregion Public Properties @@ -99,6 +69,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;"; +#endif var serverVersion = ServerVersion.AutoDetect(connString); optionsBuilder.UseMySql(connString, serverVersion); } @@ -117,13 +90,11 @@ namespace MagMan.Data.Tenant .HasComment("Valore di default/riferimento per la variabile"); }); -#if false - modelBuilder.Entity().HasKey(c => new { c.TabName, c.FieldName, c.Val }); + modelBuilder.Entity() + .HasKey(c => new { c.RequestId, c.ItemID }); - modelBuilder.Entity().HasKey(c => new { c.PlantId, c.FluxType }); - - modelBuilder.Entity().HasKey(c => new { c.PlantId, c.ParamUid }); -#endif + modelBuilder.Entity() + .HasKey(c => new { c.Family, c.ValueOriginal}); modelBuilder.Seed(); diff --git a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs b/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs deleted file mode 100644 index 9171131..0000000 --- a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -using MagMan.Data; -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("20231222163946_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.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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs b/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs deleted file mode 100644 index 0a7e484..0000000 --- a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - public partial class InitDb : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Config", - columns: table => new - { - KeyName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Val = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ValStd = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile") - .Annotation("MySql:CharSet", "utf8mb4"), - Note = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Config", x => x.KeyName); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Config"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs b/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs deleted file mode 100644 index f1aa296..0000000 --- a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -using System; -using MagMan.Data; -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("20231222180319_AddMagBaseObj")] - partial class AddMagBaseObj - { - 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.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.DbModels.ItemModel", b => - { - b.Property("ItemID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DtMod") - .HasColumnType("datetime(6)"); - - 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("TMm") - .HasColumnType("decimal(65,30)"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("ItemID"); - - b.HasIndex("MatID"); - - b.ToTable("ItemsList"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => - { - b.Property("MatID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApprovDate") - .HasColumnType("datetime(6)"); - - b.Property("ApprovUser") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("MatDesc") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatExtCode") - .HasColumnType("int"); - - b.Property("TMm") - .HasColumnType("decimal(65,30)"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("MatID"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b => - { - b.HasOne("MagMan.Data.DbModels.MaterialModel", "MaterialNav") - .WithMany("ItemNav") - .HasForeignKey("MatID") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MaterialNav"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => - { - b.Navigation("ItemNav"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs b/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs deleted file mode 100644 index b141d32..0000000 --- a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - public partial class AddMagBaseObj : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Materials", - columns: table => new - { - MatID = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - MatExtCode = table.Column(type: "int", nullable: false), - MatDesc = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApprovDate = table.Column(type: "datetime(6)", nullable: false), - ApprovUser = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - LMm = table.Column(type: "decimal(65,30)", nullable: false), - WMm = table.Column(type: "decimal(65,30)", nullable: false), - TMm = table.Column(type: "decimal(65,30)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Materials", x => x.MatID); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ItemsList", - columns: table => new - { - ItemID = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - MatID = table.Column(type: "int", nullable: false), - IsRemn = table.Column(type: "tinyint(1)", nullable: false), - Location = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - QtyAvail = table.Column(type: "int", nullable: false), - DtMod = table.Column(type: "datetime(6)", nullable: false), - LMm = table.Column(type: "decimal(65,30)", nullable: false), - WMm = table.Column(type: "decimal(65,30)", nullable: false), - TMm = table.Column(type: "decimal(65,30)", nullable: false), - Note = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_ItemsList", x => x.ItemID); - table.ForeignKey( - name: "FK_ItemsList_Materials_MatID", - column: x => x.MatID, - principalTable: "Materials", - principalColumn: "MatID", - onDelete: ReferentialAction.Restrict); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_ItemsList_MatID", - table: "ItemsList", - column: "MatID"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ItemsList"); - - migrationBuilder.DropTable( - name: "Materials"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs b/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs deleted file mode 100644 index 2ce7017..0000000 --- a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - public partial class AddMagBaseObj01 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - 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), - ItemID = table.Column(type: "int", nullable: false), - QtyRec = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_MovMag", x => x.MovID); - table.ForeignKey( - name: "FK_MovMag_ItemsList_ItemID", - column: x => x.ItemID, - principalTable: "ItemsList", - principalColumn: "ItemID", - onDelete: ReferentialAction.Restrict); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "PrintJobQueue", - columns: table => new - { - IdxPrintJob = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - TipoReport = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - KeyParam = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PrtName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DtStart = table.Column(type: "datetime(6)", nullable: false), - DtEnd = table.Column(type: "datetime(6)", nullable: true), - Stato = table.Column(type: "int", nullable: false), - DtLastTry = table.Column(type: "datetime(6)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PrintJobQueue", x => x.IdxPrintJob); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_MovMag_ItemID", - table: "MovMag", - column: "ItemID"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "MovMag"); - - migrationBuilder.DropTable( - name: "PrintJobQueue"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs b/MagMan.Data.Tenant/Migrations/20240118161646_InitDb.Designer.cs similarity index 55% rename from MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs rename to MagMan.Data.Tenant/Migrations/20240118161646_InitDb.Designer.cs index bc5a906..f6c513d 100644 --- a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs +++ b/MagMan.Data.Tenant/Migrations/20240118161646_InitDb.Designer.cs @@ -1,6 +1,6 @@ // using System; -using MagMan.Data; +using MagMan.Data.Tenant; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace MagMan.Data.Tenant.Migrations { [DbContext(typeof(MagManContext))] - [Migration("20231222180523_AddMagBaseObj01")] - partial class AddMagBaseObj01 + [Migration("20240118161646_InitDb")] + partial class InitDb { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -21,7 +21,24 @@ namespace MagMan.Data.Tenant.Migrations .HasAnnotation("ProductVersion", "6.0.25") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("MagMan.Data.DbModels.ConfigModel", b => + 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) @@ -52,14 +69,45 @@ namespace MagMan.Data.Tenant.Migrations b.ToTable("Config"); }); - modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => { - b.Property("ItemID") + b.Property("MatId") .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("DtMod") - .HasColumnType("datetime(6)"); + 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.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)"); @@ -71,7 +119,7 @@ namespace MagMan.Data.Tenant.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("MatID") + b.Property("MatId") .HasColumnType("int"); b.Property("Note") @@ -81,139 +129,70 @@ namespace MagMan.Data.Tenant.Migrations b.Property("QtyAvail") .HasColumnType("int"); - b.Property("TMm") - .HasColumnType("decimal(65,30)"); - b.Property("WMm") .HasColumnType("decimal(65,30)"); - b.HasKey("ItemID"); + b.HasKey("RawItemId"); - b.HasIndex("MatID"); + b.HasIndex("MatId"); - b.ToTable("ItemsList"); + b.ToTable("RawItemList"); }); - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestDetailModel", b => { - b.Property("MatID") - .ValueGeneratedOnAdd() + b.Property("RequestId") .HasColumnType("int"); - b.Property("ApprovDate") - .HasColumnType("datetime(6)"); - - b.Property("ApprovUser") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("MatDesc") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatExtCode") - .HasColumnType("int"); - - b.Property("TMm") - .HasColumnType("decimal(65,30)"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("MatID"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b => - { - b.Property("MovID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DtRec") - .HasColumnType("datetime(6)"); - b.Property("ItemID") .HasColumnType("int"); - b.Property("QtyRec") + b.Property("QtyReq") .HasColumnType("int"); - b.Property("UserId") - .IsRequired() - .HasColumnType("longtext"); + b.Property("ReqState") + .HasColumnType("int"); - b.HasKey("MovID"); + b.HasKey("RequestId", "ItemID"); - b.HasIndex("ItemID"); - - b.ToTable("MovMag"); + b.ToTable("RequestDetail"); }); - modelBuilder.Entity("MagMan.Data.DbModels.PrintJobQueueModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => { - b.Property("IdxPrintJob") + b.Property("RequestId") .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("RequestId"); + + b.Property("DtRequest") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ProjDbId") .HasColumnType("int"); - b.Property("DtEnd") - .HasColumnType("datetime(6)"); + b.HasKey("RequestId"); - b.Property("DtLastTry") - .HasColumnType("datetime(6)"); - - b.Property("DtStart") - .HasColumnType("datetime(6)"); - - b.Property("KeyParam") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PrtName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stato") - .HasColumnType("int"); - - b.Property("TipoReport") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("IdxPrintJob"); - - b.ToTable("PrintJobQueue"); + b.ToTable("RequestPlan"); }); - modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => { - b.HasOne("MagMan.Data.DbModels.MaterialModel", "MaterialNav") - .WithMany("ItemNav") - .HasForeignKey("MatID") + b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") + .WithMany("RawItemList") + .HasForeignKey("MatId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("MaterialNav"); }); - modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => { - b.HasOne("MagMan.Data.DbModels.ItemModel", "ITemNav") - .WithMany() - .HasForeignKey("ItemID") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ITemNav"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => - { - b.Navigation("ItemNav"); + b.Navigation("RawItemList"); }); #pragma warning restore 612, 618 } diff --git a/MagMan.Data.Tenant/Migrations/20240118161646_InitDb.cs b/MagMan.Data.Tenant/Migrations/20240118161646_InitDb.cs new file mode 100644 index 0000000..2760326 --- /dev/null +++ b/MagMan.Data.Tenant/Migrations/20240118161646_InitDb.cs @@ -0,0 +1,160 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MagMan.Data.Tenant.Migrations +{ + public partial class InitDb : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AliasList", + columns: table => new + { + Family = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueOriginal = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueAlias = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AliasList", x => new { x.Family, x.ValueOriginal }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Config", + columns: table => new + { + KeyName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Val = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ValStd = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile") + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_Config", x => x.KeyName); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "MaterialsList", + columns: table => new + { + MatId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + MatCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MatDesc = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + LMm = table.Column(type: "decimal(65,30)", nullable: false), + WMm = table.Column(type: "decimal(65,30)", nullable: false), + HMm = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MaterialsList", x => x.MatId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "RequestDetail", + columns: table => new + { + RequestId = table.Column(type: "int", nullable: false), + ItemID = table.Column(type: "int", nullable: false), + QtyReq = table.Column(type: "int", nullable: false), + ReqState = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestDetail", x => new { x.RequestId, x.ItemID }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "RequestPlan", + columns: table => new + { + RequestId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ProjDbId = table.Column(type: "int", nullable: false), + DtRequest = table.Column(type: "datetime(6)", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestPlan", x => x.RequestId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "RawItemList", + columns: table => new + { + RawItemId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + MatId = table.Column(type: "int", nullable: false), + QtyAvail = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + IsRemn = table.Column(type: "tinyint(1)", nullable: false), + Location = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + LMm = table.Column(type: "decimal(65,30)", nullable: false), + WMm = table.Column(type: "decimal(65,30)", nullable: false), + HMm = table.Column(type: "decimal(65,30)", nullable: false), + Note = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_RawItemList", x => x.RawItemId); + table.ForeignKey( + name: "FK_RawItemList_MaterialsList_MatId", + column: x => x.MatId, + principalTable: "MaterialsList", + principalColumn: "MatId", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_RawItemList_MatId", + table: "RawItemList", + column: "MatId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AliasList"); + + migrationBuilder.DropTable( + name: "Config"); + + migrationBuilder.DropTable( + name: "RawItemList"); + + migrationBuilder.DropTable( + name: "RequestDetail"); + + migrationBuilder.DropTable( + name: "RequestPlan"); + + migrationBuilder.DropTable( + name: "MaterialsList"); + } + } +} diff --git a/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs b/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs index 9092b6a..fea0ff6 100644 --- a/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs +++ b/MagMan.Data.Tenant/Migrations/MagManContextModelSnapshot.cs @@ -1,6 +1,6 @@ // using System; -using MagMan.Data; +using MagMan.Data.Tenant; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -19,7 +19,24 @@ namespace MagMan.Data.Tenant.Migrations .HasAnnotation("ProductVersion", "6.0.25") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("MagMan.Data.DbModels.ConfigModel", b => + 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) @@ -50,14 +67,45 @@ namespace MagMan.Data.Tenant.Migrations b.ToTable("Config"); }); - modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => { - b.Property("ItemID") + b.Property("MatId") .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("DtMod") - .HasColumnType("datetime(6)"); + 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.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)"); @@ -69,7 +117,7 @@ namespace MagMan.Data.Tenant.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("MatID") + b.Property("MatId") .HasColumnType("int"); b.Property("Note") @@ -79,139 +127,70 @@ namespace MagMan.Data.Tenant.Migrations b.Property("QtyAvail") .HasColumnType("int"); - b.Property("TMm") - .HasColumnType("decimal(65,30)"); - b.Property("WMm") .HasColumnType("decimal(65,30)"); - b.HasKey("ItemID"); + b.HasKey("RawItemId"); - b.HasIndex("MatID"); + b.HasIndex("MatId"); - b.ToTable("ItemsList"); + b.ToTable("RawItemList"); }); - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestDetailModel", b => { - b.Property("MatID") - .ValueGeneratedOnAdd() + b.Property("RequestId") .HasColumnType("int"); - b.Property("ApprovDate") - .HasColumnType("datetime(6)"); - - b.Property("ApprovUser") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("MatDesc") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatExtCode") - .HasColumnType("int"); - - b.Property("TMm") - .HasColumnType("decimal(65,30)"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("MatID"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b => - { - b.Property("MovID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DtRec") - .HasColumnType("datetime(6)"); - b.Property("ItemID") .HasColumnType("int"); - b.Property("QtyRec") + b.Property("QtyReq") .HasColumnType("int"); - b.Property("UserId") - .IsRequired() - .HasColumnType("longtext"); + b.Property("ReqState") + .HasColumnType("int"); - b.HasKey("MovID"); + b.HasKey("RequestId", "ItemID"); - b.HasIndex("ItemID"); - - b.ToTable("MovMag"); + b.ToTable("RequestDetail"); }); - modelBuilder.Entity("MagMan.Data.DbModels.PrintJobQueueModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => { - b.Property("IdxPrintJob") + b.Property("RequestId") .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("RequestId"); + + b.Property("DtRequest") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ProjDbId") .HasColumnType("int"); - b.Property("DtEnd") - .HasColumnType("datetime(6)"); + b.HasKey("RequestId"); - b.Property("DtLastTry") - .HasColumnType("datetime(6)"); - - b.Property("DtStart") - .HasColumnType("datetime(6)"); - - b.Property("KeyParam") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PrtName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stato") - .HasColumnType("int"); - - b.Property("TipoReport") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("IdxPrintJob"); - - b.ToTable("PrintJobQueue"); + b.ToTable("RequestPlan"); }); - modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => { - b.HasOne("MagMan.Data.DbModels.MaterialModel", "MaterialNav") - .WithMany("ItemNav") - .HasForeignKey("MatID") + b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") + .WithMany("RawItemList") + .HasForeignKey("MatId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("MaterialNav"); }); - modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b => + modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => { - b.HasOne("MagMan.Data.DbModels.ItemModel", "ITemNav") - .WithMany() - .HasForeignKey("ItemID") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ITemNav"); - }); - - modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b => - { - b.Navigation("ItemNav"); + b.Navigation("RawItemList"); }); #pragma warning restore 612, 618 } diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index cc0d40e..a223559 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -60,7 +60,7 @@ namespace MagMan.Data.Tenant.Services /// Key di riferimento /// Item da eliminare /// - public async Task ItemDelete(int nKey, ItemModel rec2del) + public async Task ItemDelete(int nKey, RawItemModel rec2del) { bool fatto = false; string cString = ConnString(nKey); @@ -84,15 +84,15 @@ namespace MagMan.Data.Tenant.Services /// /// /// - public ItemModel ItemFromDto(ItemDTO origItem) + public RawItemModel ItemFromDto(ItemDTO origItem) { - ItemModel answ = new ItemModel() + RawItemModel answ = new RawItemModel() { - MatID = origItem.MatID, + MatId = origItem.MatID, Note = origItem.Note, LMm = origItem.LMm, WMm = origItem.WMm, - TMm = origItem.TMm, + HMm = origItem.HMm, IsRemn = origItem.IsRemn, Location = origItem.Location, QtyAvail = origItem.QtyAvail @@ -106,11 +106,11 @@ namespace MagMan.Data.Tenant.Services /// /// Key di riferimento /// - public async Task> ItemGetAll(int nKey) + public async Task> ItemGetAll(int nKey) { string source = "DB"; string cString = ConnString(nKey); - List? dbResult = new List(); + List? dbResult = new List(); try { string currKey = $"{Const.rKeyConfig}:ItemList:{nKey}"; @@ -120,10 +120,10 @@ namespace MagMan.Data.Tenant.Services if (!string.IsNullOrEmpty(rawData)) { source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); + var tempResult = JsonConvert.DeserializeObject>(rawData); if (tempResult == null) { - dbResult = new List(); + dbResult = new List(); } else { @@ -138,7 +138,7 @@ namespace MagMan.Data.Tenant.Services } if (dbResult == null) { - dbResult = new List(); + dbResult = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; @@ -157,11 +157,11 @@ namespace MagMan.Data.Tenant.Services /// Key di riferimento /// ID del materiale x cui filtrare, 0 = tutti /// - public async Task> ItemGetByMat(int nKey, int matID) + public async Task> ItemGetByMat(int nKey, int matID) { string source = "DB"; string cString = ConnString(nKey); - List? dbResult = new List(); + List? dbResult = new List(); try { string currKey = $"{Const.rKeyConfig}:{nKey}:{matID}:ItemList"; @@ -171,10 +171,10 @@ namespace MagMan.Data.Tenant.Services if (!string.IsNullOrEmpty(rawData)) { source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); + var tempResult = JsonConvert.DeserializeObject>(rawData); if (tempResult == null) { - dbResult = new List(); + dbResult = new List(); } else { @@ -189,7 +189,7 @@ namespace MagMan.Data.Tenant.Services } if (dbResult == null) { - dbResult = new List(); + dbResult = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; @@ -208,7 +208,7 @@ namespace MagMan.Data.Tenant.Services /// Key di riferimento /// /// - public async Task ItemUpdate(int nKey, ItemModel currItem) + public async Task ItemUpdate(int nKey, RawItemModel currItem) { bool fatto = false; string cString = ConnString(nKey); @@ -261,11 +261,12 @@ namespace MagMan.Data.Tenant.Services { MaterialModel answ = new MaterialModel() { - MatExtCode = origItem.MatExtCode, + MatId = origItem.MatId, + MatCode = origItem.MatCode, MatDesc = origItem.MatDesc, LMm = origItem.LMm, WMm = origItem.WMm, - TMm = origItem.TMm + HMm = origItem.HMm }; return answ; diff --git a/MagMan.UI/Components/MachineMan.razor.cs b/MagMan.UI/Components/MachineMan.razor.cs index cec0547..fd84ba2 100644 --- a/MagMan.UI/Components/MachineMan.razor.cs +++ b/MagMan.UI/Components/MachineMan.razor.cs @@ -101,30 +101,6 @@ namespace MagMan.UI.Components #endregion Protected Methods -#if false - protected async Task CreateDb(MachineModel currRec) - { - await Task.Delay(1); - bool dbOk = Data.Admin.DbConfig.CheckCustDb(currRec.MainKey); - if (!dbOk) - { - dbOk = Data.Admin.DbConfig.CheckCustDb(currRec.MainKey); - } - // se ok --> migration... - if (dbOk || true) - { - string dbServerAddr = Configuration["DbConfig:Server"]; - Data.Tenant.DbConfig.InitDb(dbServerAddr, currRec.MainKey); - // verifico se serve applicazione migrazioni - Data.Tenant.DbConfig.ExecMigrationMain(); - } - // aggiorno comunque status DB... - currRec.HasDb = dbOk; - await MTService.MachineUpdate(currRec); - await ReloadData(); - } -#endif - #region Private Fields private MachineModel? CurrItem = null; diff --git a/MagMan.UI/Components/MaterialEdit.razor b/MagMan.UI/Components/MaterialEdit.razor new file mode 100644 index 0000000..98ebd06 --- /dev/null +++ b/MagMan.UI/Components/MaterialEdit.razor @@ -0,0 +1,37 @@ +@if (CurrRecord != null) +{ +
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+ + @* *@ +
+
+
+
+} diff --git a/MagMan.UI/Components/MaterialEdit.razor.cs b/MagMan.UI/Components/MaterialEdit.razor.cs new file mode 100644 index 0000000..4e2f325 --- /dev/null +++ b/MagMan.UI/Components/MaterialEdit.razor.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +using MagMan.Data.Admin.DbModels; +using MagMan.Data.Admin.Services; +using MagMan.Data.Tenant.DbModels; +using MagMan.Data.Tenant.Services; +using Microsoft.AspNetCore.Components; + +namespace MagMan.UI.Components +{ + public partial class MaterialEdit + { + #region Public Properties + + [Parameter] + public MaterialModel? CurrRecord { get; set; } = null; + + [Parameter] + public int KeyNum { get; set; } = 0; + [Parameter] + public EventCallback EC_update { get; set; } + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected TenantService TService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task DoSave() + { + bool fatto = false; + await Task.Delay(1); + if (CurrRecord != null) + { + fatto = await TService.MaterialUpdate(KeyNum, CurrRecord); + } + if (fatto) + { + await EC_update.InvokeAsync(true); + } + } + protected async Task DoCancel() + { + await EC_update.InvokeAsync(true); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MagMan.UI/Components/MaterialMan.razor b/MagMan.UI/Components/MaterialMan.razor index 73aec93..87b767f 100644 --- a/MagMan.UI/Components/MaterialMan.razor +++ b/MagMan.UI/Components/MaterialMan.razor @@ -1,5 +1,104 @@ -

MaterialMan

+
+
+
+
+

Materiali

+
+
+
+
+ @if (CurrItem == null) + { + + } + else + { + + } +
+
+
+ Tipo Mat. + +
+
+
+
+
+ @if (CurrItem != null) + { +
+ + } +
+
+ @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { + + + + + + + + + + + @* *@ + + + + @foreach (var item in ListRecords) + { + + + + + + + + + @* *@ + + } + +
+ + ID Mat.Code Descr. W (mm) H (mm) L (mm)
+ + + @item.MatId + + @item.MatCode + + @item.MatDesc + + @($"{item.WMm:N2}") + + @($"{item.HMm:N2}") + + @($"{item.LMm:N2}") + + +
+ } + +
+ +
-@code { -} diff --git a/MagMan.UI/Components/MaterialMan.razor.cs b/MagMan.UI/Components/MaterialMan.razor.cs new file mode 100644 index 0000000..12dd2b8 --- /dev/null +++ b/MagMan.UI/Components/MaterialMan.razor.cs @@ -0,0 +1,263 @@ +// 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.Data.Admin.DbModels; +using MagMan.Data.Admin.Services; +using MagMan.Data.Tenant.DbModels; +using MagMan.Data.Tenant.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MimeKit.Text; + +namespace MagMan.UI.Components +{ + public partial class MaterialMan + { + #region Public Properties + + [Parameter] + public int CustomerId { get; set; } = 0; + + [Parameter] + public int KeyNum { get; set; } = 0; + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IConfiguration Configuration { get; set; } = null!; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected TenantService TService { get; set; } = null!; + + protected int totalCount { get; set; } = 0; + + #endregion Protected Properties + + #region Protected Methods + + protected string CheckSel(MaterialModel curItem) + { + string answ = ""; + if (CurrItem != null) + { + answ = curItem.MatId == CurrItem.MatId? "table-info" : ""; + } + return answ; + } + + protected async Task CreateNew() + { + CurrItem = new MaterialModel() + { + MatCode = "Mat_unique_code", + MatDesc = "Material Description" + }; + await InvokeAsync(StateHasChanged); + } + + protected async Task DeleteRecord(MaterialModel selItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) + return; + await TService.MaterialDelete(KeyNum, selItem); + await ReloadData(); + } + + protected void DoEdit(MaterialModel? selItem) + { + CurrItem = selItem; + } + + protected async Task ForceReload(bool force) + { + CurrItem = null; + await ReloadData(); + } + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + protected void SetNumRec(int newNum) + { + numRecord = newNum; + currPage = 1; + } + + protected void SetPage(int newNum) + { + currPage = newNum; + } + + protected async Task SortRequested(Sorter.SortCallBack e) + { + sortField = e.ParamName; + sortAsc = e.IsAscending; + await ReloadData(); + } + + #endregion Protected Methods + + + #region Private Fields + + private MaterialModel? CurrItem = null; + + private List? ListRecords = null; + + private List? SearchRecords = null; + + private bool sortAsc = true; + + private string sortField = ""; + + #endregion Private Fields + + #region Private Properties + + private int currPage { get; set; } = 1; + + private bool isLoading { get; set; } = false; + + private int numRecord { get; set; } = 10; + + #endregion Private Properties + + #region Private Methods + + private async Task ReloadData() + { + isLoading = true; + ListRecords = null; + SearchRecords = await TService.MaterialGetAll(KeyNum, false); + // verifico se filtrare x beam/wall + if (FiltType> 0) + { + SearchRecords = SearchRecords.Where(x => (x.IsBeam && FiltType == 1) || (x.IsWall && FiltType == 2)).ToList(); + } + totalCount = SearchRecords.Count; + SortTable(); + isLoading = false; + } + + private int filtType = 0; + private int FiltType + { + get => filtType; + set + { + if (filtType != value) + { + filtType = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private void SortTable() + { + if (SearchRecords != null) + { + // se ho ordinamento riordino... + if (!string.IsNullOrEmpty(sortField)) + { + switch (sortField) + { + case "MatId": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatId).ThenByDescending(x => x.MatCode).ToList(); + } + break; + + case "MatCode": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatCode).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatCode).ToList(); + } + break; + + case "MatDesc": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatDesc).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatDesc).ToList(); + } + break; + + case "W": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.WMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.WMm).ToList(); + } + break; + + case "H": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.HMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.HMm).ToList(); + } + break; + + case "L": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.LMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.LMm).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/Controllers/InventoryController.cs b/MagMan.UI/Controllers/InventoryController.cs index a2f1b9b..0fa8fc4 100644 --- a/MagMan.UI/Controllers/InventoryController.cs +++ b/MagMan.UI/Controllers/InventoryController.cs @@ -49,10 +49,10 @@ namespace MagMan.UI.Controllers // GET api/Inventory [HttpGet] - public async Task> Get() + public async Task> Get() { // se non ho chiave --> vuoto! - List ListRecords = new List(); + List ListRecords = new List(); await Task.Delay(100); return ListRecords; } @@ -93,7 +93,7 @@ namespace MagMan.UI.Controllers if (nKey > 0) { // creo oggetti materiale da lista ricevuta - List matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList(); + List matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList(); foreach (var item in matList) { diff --git a/MagMan.UI/Controllers/ProjectsController.cs b/MagMan.UI/Controllers/ProjectsController.cs new file mode 100644 index 0000000..1ef0461 --- /dev/null +++ b/MagMan.UI/Controllers/ProjectsController.cs @@ -0,0 +1,59 @@ +using MagMan.Data.Admin.DbModels; +using MagMan.Data.Admin.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using NLog; + +namespace MagMan.UI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ProjectsController : ControllerBase + { + /// + /// Classe per logging + /// + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + private MTAdminService _DataService { get; set; } = null!; + public ProjectsController(MTAdminService DataService) + { + _DataService = DataService; + Log.Info("Avviata classe ProjectsController"); + } + + /// + /// Controllo status Alive + /// GET: api/Machines/alive + /// + /// + [HttpGet("alive")] + public string alive() + { + //Log.Debug("Chiamata alive"); + return $"OK"; + } + + // GET api/Machines/5 + [HttpGet] + public async Task> Get() + { + // se non ho chaive --> vuoto! + List ListRecords = new List(); + await Task.Delay(100); + return ListRecords; + } + + /// + /// Elenco Macchine dato RestToken + /// + /// Rest Token cliente + /// + // GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7 + [HttpGet("{id}")] + public async Task> Get(string id, int KeyNum) + { + var ListRecords = await _DataService.MachineGetByToken(id); + return ListRecords; + } + } +} diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index ba0d30e..963cf73 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.1716 + 1.0.2401.1911 enable enable true @@ -36,8 +36,8 @@ - - + + diff --git a/MagMan.UI/Pages/WareHouse.razor b/MagMan.UI/Pages/WareHouse.razor index b3a219d..9990900 100644 --- a/MagMan.UI/Pages/WareHouse.razor +++ b/MagMan.UI/Pages/WareHouse.razor @@ -42,7 +42,7 @@ else { @if (currMode == CtMode.Materials) { - + } else if (currMode == CtMode.Items) { diff --git a/README.md b/README.md index ecd1248..eaa78d9 100644 --- a/README.md +++ b/README.md @@ -135,11 +135,20 @@ Ogni nuovo user dovrà poi essere associato al bucket del cliente tramite un cod
+## Gestione Sync DB + +E' stato implementato un nuovo set di tabelle sul DB (locale) di EgtBeamWall per gestire materiali e grezzi non tramite file ma tramite DB e così gettare la base per la gestione del sync locale/cloud. + +Nello stesso tempo, il sito web, oltre a proporre pagine utente, implementa web API rest che, tramite apposita libreria di comuncazione SDK (messa sul repo nuget aziendale) permette di comuncare, sincronizzare e gestire i dati. + +
+ ## Revisione documento Version | Date | Editor | Note :--: |----------|----- | ----: + 0.5 | 2024.01.18 | S.E. Locatelli | Prime note sync DB online/locale 0.3 | 2024.01.10 | S.E. Locatelli | Revisione modalità multi-tenant 0.2 | 2024.01.05 | S.E. Locatelli | update ruoli e workflow 0.1 | 2023.12.28 | S.E. Locatelli | Prima revisione documento diff --git a/README.pdf b/README.pdf index 7f550ac..660cfaf 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/REST/Insomnia.json b/REST/Insomnia.json index 8659c16..1cc79cc 100644 --- a/REST/Insomnia.json +++ b/REST/Insomnia.json @@ -1 +1 @@ -{"_type":"export","__export_format":4,"__export_date":"2024-01-16T09:55:45.993Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_e5d99b16b8074d22a4c757238507f8cb","parentId":"fld_17b061b4822f4287adf3b29e6d1e13fc","modified":1705344596823,"created":1705344578185,"url":"{{ _.base_url }}api/Keys/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_17b061b4822f4287adf3b29e6d1e13fc","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344102561,"created":1705344102561,"name":"Keys","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1705344102561,"_type":"request_group"},{"_id":"wrk_c74e89202b3242d7b5fe3f0adafc5788","parentId":null,"modified":1705344078935,"created":1705344078935,"name":"MagMan","description":"","scope":"collection","_type":"workspace"},{"_id":"req_8fb7cf9e71574607926f465fd7da2a4f","parentId":"fld_17b061b4822f4287adf3b29e6d1e13fc","modified":1705390261799,"created":1705344105246,"url":"{{ _.base_url }}api/Keys/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_b4a2e8329a714354ad218c370c0afe4c","parentId":"fld_a10cb3e547ef4fc78701ee8608cb42d7","modified":1705344622933,"created":1705344619321,"url":"{{ _.base_url }}api/Machines/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_a10cb3e547ef4fc78701ee8608cb42d7","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344619317,"created":1705344619317,"name":"Machines","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1703730703257.5,"_type":"request_group"},{"_id":"req_e68ae849e98d4466897d162591fd1e48","parentId":"fld_a10cb3e547ef4fc78701ee8608cb42d7","modified":1705390282006,"created":1705344619318,"url":"{{ _.base_url }}api/Machines/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_7400252471a846b294a48f3e54e1cf4d","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705389755064,"created":1705389750317,"url":"{{ _.base_url }}api/Materials/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705389750309,"created":1705389750309,"name":"Materials","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1702924003605.75,"_type":"request_group"},{"_id":"req_8ec97a93730c4792a2b74f8fed8a1382","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705390293213,"created":1705389750311,"url":"{{ _.base_url }}api/Materials/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_a4b9c4039f79478aa84ad49a4de24bf9","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705398813245,"created":1705396599073,"url":"{{ _.base_url }}api/Materials/upsertMat/{{ _.rest_token }}","name":"saveMat","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"MatList\":[\n\t\t{\n\t\t\t\"MatExtCode\": 1,\n\t\t\t\"MatDesc\": \"Multistrato Lamellare 400x600x15000\",\n\t\t\t\"WMm\": 400.00,\n\t\t\t\"TMm\": 600.00,\n\t\t\t\"LMm\": 15000.00\n\t\t},\n\t\t{\n\t\t\t\"MatExtCode\": 2,\n\t\t\t\"MatDesc\": \"Multistrato Lamellare 400x600x12000\",\n\t\t\t\"WMm\": 400.00,\n\t\t\t\"TMm\": 600.00,\n\t\t\t\"LMm\": 12000.00\n\t\t}\n\t]\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1703730709735,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344145753,"created":1705344078941,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1705344078941,"_type":"environment"},{"_id":"jar_4a9cc3783617386c58190e600d8c899f60f2c3d4","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344078947,"created":1705344078947,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"env_41343eb0570c45b0a766124f5b175889","parentId":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","modified":1705390247321,"created":1705344148114,"name":"Prod","data":{"base_url":"https://magman.egalware.com/","rest_token":"91f4fec6-7e9c-4130-9df2-702d729ccdd3"},"dataPropertyOrder":{"&":["base_url","rest_token"]},"color":null,"isPrivate":false,"metaSortKey":1705344148114,"_type":"environment"},{"_id":"env_422a91f164bf4be2a41c4b1c3e1d5d97","parentId":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","modified":1705390242714,"created":1705344154153,"name":"Dev","data":{"base_url":"https://localhost:7207/","rest_token":"91f4fec6-7e9c-4130-9df2-702d729ccdd3"},"dataPropertyOrder":{"&":["base_url","rest_token"]},"color":null,"isPrivate":false,"metaSortKey":1705344148164,"_type":"environment"}]} \ No newline at end of file +{"_type":"export","__export_format":4,"__export_date":"2024-01-18T18:23:31.094Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_e5d99b16b8074d22a4c757238507f8cb","parentId":"fld_17b061b4822f4287adf3b29e6d1e13fc","modified":1705344596823,"created":1705344578185,"url":"{{ _.base_url }}api/Keys/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_17b061b4822f4287adf3b29e6d1e13fc","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344102561,"created":1705344102561,"name":"Keys","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1705344102561,"_type":"request_group"},{"_id":"wrk_c74e89202b3242d7b5fe3f0adafc5788","parentId":null,"modified":1705344078935,"created":1705344078935,"name":"MagMan","description":"","scope":"collection","_type":"workspace"},{"_id":"req_8fb7cf9e71574607926f465fd7da2a4f","parentId":"fld_17b061b4822f4287adf3b29e6d1e13fc","modified":1705390261799,"created":1705344105246,"url":"{{ _.base_url }}api/Keys/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_b4a2e8329a714354ad218c370c0afe4c","parentId":"fld_a10cb3e547ef4fc78701ee8608cb42d7","modified":1705344622933,"created":1705344619321,"url":"{{ _.base_url }}api/Machines/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_a10cb3e547ef4fc78701ee8608cb42d7","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344619317,"created":1705344619317,"name":"Machines","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1703730703257.5,"_type":"request_group"},{"_id":"req_e68ae849e98d4466897d162591fd1e48","parentId":"fld_a10cb3e547ef4fc78701ee8608cb42d7","modified":1705560976134,"created":1705344619318,"url":"{{ _.base_url }}api/Machines/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_7400252471a846b294a48f3e54e1cf4d","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705389755064,"created":1705389750317,"url":"{{ _.base_url }}api/Materials/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705389750309,"created":1705389750309,"name":"Materials","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1702924003605.75,"_type":"request_group"},{"_id":"req_8ec97a93730c4792a2b74f8fed8a1382","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705390293213,"created":1705389750311,"url":"{{ _.base_url }}api/Materials/{{ _.rest_token }}","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_a4b9c4039f79478aa84ad49a4de24bf9","parentId":"fld_edf6b9b5b5ba44b9a44df8b1482e33e2","modified":1705601001499,"created":1705396599073,"url":"{{ _.base_url }}api/Materials/upsert/{{ _.rest_token }}","name":"upsert","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"MatList\":[\n\t\t{\n\t\t\t\"MatCode\": \"GL24h_200x200\",\n\t\t\t\"MatDesc\": \"GL24h Multistrato Lamellare 200x200\",\n\t\t\t\"WMm\": 200.00,\n\t\t\t\"HMm\": 200.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"GL24h_200x360\",\n\t\t\t\"MatDesc\": \"GL24h Multistrato Lamellare 200x360\",\n\t\t\t\"WMm\": 200.00,\n\t\t\t\"HMm\": 360.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"GL24h_200x600\",\n\t\t\t\"MatDesc\": \"GL24h Multistrato Lamellare 200x600\",\n\t\t\t\"WMm\": 200.00,\n\t\t\t\"HMm\": 600.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"Douglas_Fir_200x254\",\n\t\t\t\"MatDesc\": \"Douglas Fir 200x254\",\n\t\t\t\"WMm\": 200.00,\n\t\t\t\"HMm\": 254.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"Douglas_Fir_150x254\",\n\t\t\t\"MatDesc\": \"Douglas Fir 150x254\",\n\t\t\t\"WMm\": 150.00,\n\t\t\t\"HMm\": 254.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"GL24h_120x200\",\n\t\t\t\"MatDesc\": \"GL24h Multistrato Lamellare 120x200\",\n\t\t\t\"WMm\": 120.00,\n\t\t\t\"HMm\": 200.00,\n\t\t\t\"LMm\": 0.00\n\t\t},\n\t\t{\n\t\t\t\"MatCode\": \"GL24h_120x120\",\n\t\t\t\"MatDesc\": \"GL24h Multistrato Lamellare 120x120\",\n\t\t\t\"WMm\": 120.00,\n\t\t\t\"HMm\": 120.00,\n\t\t\t\"LMm\": 0.00\n\t\t}\n\t]\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1703730709735,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_5f8f856baf9040e6a0791f0f18ccd788","parentId":"fld_5b7bda87c436418a970d26bfac50881d","modified":1705423646724,"created":1705403456196,"url":"{{ _.base_url }}api/Inventory/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_5b7bda87c436418a970d26bfac50881d","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705560664441,"created":1705403456188,"name":"Inventory","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1702898794241.6328,"_type":"request_group"},{"_id":"req_39f7a887bac24769983cb429c9b76e46","parentId":"fld_5b7bda87c436418a970d26bfac50881d","modified":1705423981119,"created":1705403456191,"url":"{{ _.base_url }}api/Inventory/{{ _.rest_token }}?MatId=0","name":"Inventory (all MatId=0)","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_b9a061e3fff64e8599c6119b1e728335","parentId":"fld_5b7bda87c436418a970d26bfac50881d","modified":1705423987538,"created":1705403501179,"url":"{{ _.base_url }}api/Inventory/{{ _.rest_token }}?MatId=1","name":"Inventory (MatId =1)","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1704537408676.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_53d77da66ad1464aa5e401f0a89d9bdc","parentId":"fld_5b7bda87c436418a970d26bfac50881d","modified":1705501490742,"created":1705501487038,"url":"{{ _.base_url }}api/Inventory/{{ _.rest_token }}?MatId=2","name":"Inventory (MatId =2)","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1704134059205.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_2a13be6f5dfe4f18ab732716a8325ceb","parentId":"fld_5b7bda87c436418a970d26bfac50881d","modified":1705601392389,"created":1705403456204,"url":"{{ _.base_url }}api/Inventory/upsert/{{ _.rest_token }}","name":"upsert","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"ItemList\":[\n\t\t{\n\t\t\t\"MatID\": 6,\n\t\t\t\"IsRemn\": false,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 99,\n\t\t\t\"LMm\": 13000,\n\t\t\t\"WMm\": 200,\n\t\t\t\"HMm\": 200,\n\t\t\t\"Note\": \"GL24h 120x200\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 5,\n\t\t\t\"IsRemn\": false,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 50,\n\t\t\t\"LMm\": 12000,\n\t\t\t\"WMm\": 150,\n\t\t\t\"HMm\": 254,\n\t\t\t\"Note\": \"Douglas Fir 150x254\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 4,\n\t\t\t\"IsRemn\": true,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 50,\n\t\t\t\"LMm\": 6000,\n\t\t\t\"WMm\": 400,\n\t\t\t\"HMm\": 600,\n\t\t\t\"Note\": \"Douglas Fir 200x254\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 7,\n\t\t\t\"IsRemn\": true,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 99,\n\t\t\t\"LMm\": 12500,\n\t\t\t\"WMm\": 120,\n\t\t\t\"HMm\": 120,\n\t\t\t\"Note\": \"GL24h 120x200\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 3,\n\t\t\t\"IsRemn\": true,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 40,\n\t\t\t\"LMm\": 12000,\n\t\t\t\"WMm\": 200,\n\t\t\t\"HMm\": 600,\n\t\t\t\"Note\": \"GL24h 200x600\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 2,\n\t\t\t\"IsRemn\": true,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 40,\n\t\t\t\"LMm\": 12000,\n\t\t\t\"WMm\": 200,\n\t\t\t\"HMm\": 360,\n\t\t\t\"Note\": \"GL24h 200x360\"\n\t\t},\n\t\t{\n\t\t\t\"MatID\": 1,\n\t\t\t\"IsRemn\": true,\n\t\t\t\"Location\": \"Magazzino\",\n\t\t\t\"QtyAvail\": 40,\n\t\t\t\"LMm\": 12000,\n\t\t\t\"WMm\": 200,\n\t\t\t\"HMm\": 200,\n\t\t\t\"Note\": \"GL24h 200x200\"\n\t\t}\n\t]\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1703730709735,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_59cc5f9de65c44a1b718cdcd2f4172c3","parentId":"fld_8710de12f61d475c8cb781a10d5fdb56","modified":1705560903091,"created":1705560651070,"url":"{{ _.base_url }}api/Projects/alive","name":"Alive","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107718,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_8710de12f61d475c8cb781a10d5fdb56","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705560662161,"created":1705560651066,"name":"Project","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1702873584877.5156,"_type":"request_group"},{"_id":"req_5a8e82339432475bbe91915101f0ea63","parentId":"fld_8710de12f61d475c8cb781a10d5fdb56","modified":1705561108272,"created":1705560651068,"url":"{{ _.base_url }}api/Projects/{{ _.rest_token }}?KeyNum=470","name":"Get","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1705344107618,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_db5af405f8f148c68e965f2f48ff23ad","parentId":"fld_8710de12f61d475c8cb781a10d5fdb56","modified":1705560651073,"created":1705560651073,"url":"{{ _.base_url }}api/Materials/upsert/{{ _.rest_token }}","name":"upsert","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"MatList\":[\n\t\t{\n\t\t\t\"MatExtCode\": 1,\n\t\t\t\"MatDesc\": \"Multistrato Lamellare 400x600x15000\",\n\t\t\t\"WMm\": 400.00,\n\t\t\t\"TMm\": 600.00,\n\t\t\t\"LMm\": 15000.00\n\t\t},\n\t\t{\n\t\t\t\"MatExtCode\": 2,\n\t\t\t\"MatDesc\": \"Multistrato Lamellare 400x600x12000\",\n\t\t\t\"WMm\": 400.00,\n\t\t\t\"TMm\": 600.00,\n\t\t\t\"LMm\": 12000.00\n\t\t}\n\t]\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1703730709735,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344145753,"created":1705344078941,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1705344078941,"_type":"environment"},{"_id":"jar_4a9cc3783617386c58190e600d8c899f60f2c3d4","parentId":"wrk_c74e89202b3242d7b5fe3f0adafc5788","modified":1705344078947,"created":1705344078947,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"env_41343eb0570c45b0a766124f5b175889","parentId":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","modified":1705515978571,"created":1705344148114,"name":"Prod","data":{"base_url":"https://magman.egalware.com/","rest_token":"22fa4426-6670-41ad-ac2b-d7b5c3dfe849"},"dataPropertyOrder":{"&":["base_url","rest_token"]},"color":null,"isPrivate":false,"metaSortKey":1705344148114,"_type":"environment"},{"_id":"env_422a91f164bf4be2a41c4b1c3e1d5d97","parentId":"env_4a9cc3783617386c58190e600d8c899f60f2c3d4","modified":1705390242714,"created":1705344154153,"name":"Dev","data":{"base_url":"https://localhost:7207/","rest_token":"91f4fec6-7e9c-4130-9df2-702d729ccdd3"},"dataPropertyOrder":{"&":["base_url","rest_token"]},"color":null,"isPrivate":false,"metaSortKey":1705344148164,"_type":"environment"}]} \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 3f26b06..5205fbd 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.1716

+

Versione: 1.0.2401.1911


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 36050d5..07a28f9 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.1716 +1.0.2401.1911 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 2a460bb..c10d440 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.1716 + 1.0.2401.1911 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false diff --git a/TestWinFormVB/Form1.Designer.vb b/TestWinFormVB/Form1.Designer.vb index c872beb..1aa10ea 100644 --- a/TestWinFormVB/Form1.Designer.vb +++ b/TestWinFormVB/Form1.Designer.vb @@ -26,6 +26,7 @@ Partial Class Form1 Me.lblServTest = New System.Windows.Forms.Label() Me.Button2 = New System.Windows.Forms.Button() Me.txtOut = New System.Windows.Forms.TextBox() + Me.Button3 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 @@ -62,14 +63,24 @@ Partial Class Form1 Me.txtOut.Location = New System.Drawing.Point(103, 53) Me.txtOut.Multiline = True Me.txtOut.Name = "txtOut" - Me.txtOut.Size = New System.Drawing.Size(685, 184) + Me.txtOut.Size = New System.Drawing.Size(685, 392) Me.txtOut.TabIndex = 3 ' + 'Button3 + ' + Me.Button3.Location = New System.Drawing.Point(12, 97) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(75, 23) + Me.Button3.TabIndex = 4 + Me.Button3.Text = "Get Invent." + Me.Button3.UseVisualStyleBackColor = True + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.txtOut) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.lblServTest) @@ -85,4 +96,5 @@ Partial Class Form1 Friend WithEvents lblServTest As Label Friend WithEvents Button2 As Button Friend WithEvents txtOut As TextBox + Friend WithEvents Button3 As Button End Class diff --git a/TestWinFormVB/Form1.vb b/TestWinFormVB/Form1.vb index d63ade4..f28d002 100644 --- a/TestWinFormVB/Form1.vb +++ b/TestWinFormVB/Form1.vb @@ -3,13 +3,29 @@ Imports Microsoft.SqlServer Public Class Form1 + + +#If DEBUG Then + + ' token di auth Private restToken As String = "91f4fec6-7e9c-4130-9df2-702d729ccdd3" + ' Indirizzo server (DEBUG) + Private servAddr As String = "localhost:7207" + +#Else + + ' token di auth + Private restToken As String = "22fa4426-6670-41ad-ac2b-d7b5c3dfe849" + ' Indirizzo server (DEBUG) + Private servAddr As String = "magman.egalware.com" + +#End If Private commLib As DataSyncro Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' esegue test comunicazione server (ping, alive) - commLib = New DataSyncro(restToken) + commLib = New DataSyncro(servAddr, restToken) Dim servOk As Boolean servOk = commLib.CheckRemote() Dim esito As String = "" @@ -24,7 +40,7 @@ Public Class Form1 Private Async Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ' recupera e mostra dati elenco materiali - commLib = New DataSyncro(restToken) + commLib = New DataSyncro(servAddr, restToken) Dim result As String = "" @@ -32,13 +48,57 @@ Public Class Form1 If matList IsNot Nothing Then For Each item In matList - result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" - result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" + result += $"Mat ID: {item.MatID}{Environment.NewLine}" result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" result += $"descript: {item.MatDesc}{Environment.NewLine}" result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" - 'result += $"Items count: {item.ItemList.Count}" + If item.ItemNav IsNot Nothing Then + 'result += $"Items count: {item.ItemList.Count}" + result += $"{Environment.NewLine}" + End If + Next + End If + + txtOut.Text = result + + End Sub + + Private Async Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click + ' recupera e mostra dati elenco materiali + commLib = New DataSyncro(servAddr, restToken) + + Dim result As String = "" + Dim sepShort As String = "----" + + Dim matList = Await commLib.GetInventario(0) + + If matList IsNot Nothing Then + + For Each item In matList + result += $"Mat ID: {item.MatID}{Environment.NewLine}" + result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" + result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" + result += $"descript: {item.MatDesc}{Environment.NewLine}" + result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" + If item.ItemNav IsNot Nothing Then + result += $"Items count: {item.ItemNav.Count}" + + If item.ItemNav.Count > 0 Then + result += "Inventario:" + + For Each itemInv In item.ItemNav + result += $"{sepShort}{Environment.NewLine}" + result += $"ID: {itemInv.ItemID}{Environment.NewLine}" + result += $"Location: {itemInv.Location}{Environment.NewLine}" + result += $"Descript: {itemInv.Note}{Environment.NewLine}" + result += $"Giacenza: {itemInv.QtyAvail}{Environment.NewLine}" + result += $"Dimensions W x T x L: {itemInv.WMm:N3} x {itemInv.TMm:N3} x {itemInv.LMm:N3}{Environment.NewLine}" + result += $"Dtmx Code: {itemInv.ItemDtmx}{Environment.NewLine}" + Next + End If + End If + result += $"{Environment.NewLine}" Next End If diff --git a/TestWinFormVB/TestWinFormVB.vbproj b/TestWinFormVB/TestWinFormVB.vbproj index 8e1fca0..152fead 100644 --- a/TestWinFormVB/TestWinFormVB.vbproj +++ b/TestWinFormVB/TestWinFormVB.vbproj @@ -49,7 +49,7 @@ - ..\packages\EgwProxy.MagMan.0.9.2401-beta.1718\lib\EgwProxy.MagMan.dll + ..\packages\EgwProxy.MagMan.0.9.2401-beta.1719\lib\EgwProxy.MagMan.dll ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/TestWinFormVB/packages.config b/TestWinFormVB/packages.config index bded6e6..7d159d3 100644 --- a/TestWinFormVB/packages.config +++ b/TestWinFormVB/packages.config @@ -1,6 +1,6 @@  - +