Merge branch 'feature/NugetSdk' into develop

This commit is contained in:
Samuele Locatelli
2024-01-19 11:10:51 +01:00
42 changed files with 1494 additions and 821 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ namespace MagMan.Core.DTO
/// <summary>
/// Item's Thikness
/// </summary>
public decimal TMm { get; set; } = 0;
public decimal HMm { get; set; } = 0;
/// <summary>
/// Note (optional)
+8 -14
View File
@@ -8,27 +8,21 @@ namespace MagMan.Core.DTO
{
public class MaterialDTO
{
/// <summary>
/// Primary Key AUTO, 0 se proviente da EgtBeamWall
/// </summary>
public int MatId { get; set; } = 0;
/// <summary>
/// Codice materiale (esterno)
/// Codice Materiale
/// </summary>
public int MatExtCode { get; set; } = 0;
public string MatCode { get; set; } = "";
/// <summary>
/// Descrizione materiale
/// </summary>
public string MatDesc { get; set; } = "";
#if false
/// <summary>
/// Data approvazione (se non approvato è nel futuro)
/// </summary>
public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100);
/// <summary>
/// Utente approvazione amteriale
/// </summary>
public string ApprovUser { get; set; } = "";
#endif
/// <summary>
/// Lenght/Lunghezza in mm
/// </summary>
@@ -40,6 +34,6 @@ namespace MagMan.Core.DTO
/// <summary>
/// Thikness/Spessore in mm
/// </summary>
public decimal TMm { get; set; } = 0;
public decimal HMm { get; set; } = 0;
}
}
+30 -2
View File
@@ -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
}
}
}
@@ -45,7 +45,7 @@ namespace MagMan.Data.Tenant.Controllers
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="rec2del">Item da eliminare</param>
/// <returns></returns>
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
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <returns></returns>
public List<ItemModel> ItemGetAll(string connString)
public List<RawItemModel> ItemGetAll(string connString)
{
List<ItemModel> dbResult = new List<ItemModel>();
List<RawItemModel> dbResult = new List<RawItemModel>();
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
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="matID">ID del materiale x cui filtrare, 0 = tutti</param>
/// <returns></returns>
public List<ItemModel> ItemGetByMat(string connString, int matID)
public List<RawItemModel> ItemGetByMat(string connString, int matID)
{
List<ItemModel> dbResult = new List<ItemModel>();
List<RawItemModel> dbResult = new List<RawItemModel>();
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
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="rec2upd">Record da aggiungere/aggiornare</param>
/// <returns></returns>
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;
}
+32
View File
@@ -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
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
[Table("AliasList")]
public class AliasModel
{
/// <summary>
/// Famiglia di sinonimi
/// </summary>
public string Family { get; set; } = "";
/// <summary>
/// Codice originale (da trasformare)
/// </summary>
public string ValueOriginal { get; set; } = "";
/// <summary>
/// Codice Alias in cui viene convertito
/// </summary>
public string ValueAlias { get; set; } = "";
}
}
@@ -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
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella dei LOG Macchina (per macchina)
/// </summary>
[Table("LogMachine")]
[Index(nameof(MachineID))]
[Index(nameof(KeyNum))]
public class LogMachineModel
{
[Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int LogDbId { get; set; }
/// <summary>
/// Id macchina (diMagMan)
/// </summary>
public int MachineID { get; set; } = 0;
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
#if false
/// <summary>
/// Codice Allarme
/// </summary>
[Column("AlarmCode")]
public string AlarmCode { get; set; } = "";
/// <summary>
/// Data Evento
/// </summary>
[Column("AlarmDtEvent")]
public DateTime AlarmDatetime { get; set; } = DateTime.Now;
/// <summary>
/// Messaggio Allarme
/// </summary>
[Column("AlarmMessage")]
public string AlarmMessage { get; set; } = "";
/// <summary>
/// Alarm Operation
/// </summary>
[Column("AlarmOperation")]
public int AlarmOperation { get; set; } = 0;
/// <summary>
/// Alarm Type
/// </summary>
[Column("AlarmType")]
public int AlarmType { get; set; } = 0;
/// <summary>
/// Esaecuzione comando corretta
/// </summary>
[Column("CommExecuted")]
public bool CommandExecutedCorrectly { get; set; } = false;
/// <summary>
/// Stato da enum Core
/// </summary>
[Column("CommandState")]
public Core.ConstMachComm.CommandStates CommandState { get; set; } = Core.ConstMachComm.CommandStates.NULL;
/// <summary>
/// Tipo Comando da enum Core
/// </summary>
[Column("CommandType")]
public Core.ConstMachComm.LogCommandTypes CommandType { get; set; } = Core.ConstMachComm.LogCommandTypes.NULL;
/// <summary>
/// Descrizione
/// </summary>
[Column("Description")]
public string Description { get; set; } = "";
/// <summary>
/// New OP State
/// </summary>
[Column("NewOpState")]
public int NewOpState { get; set; } = 0;
#endif
/// <summary>
/// Stato da enum Core
/// </summary>
[Column("ResultType")]
public ResultTypes ResultType { get; set; } = ResultTypes.NULL;
/// <summary>
/// Indirizzo VAR
/// </summary>
[Column("VarAddress")]
public string VarAddress { get; set; } = "";
/// <summary>
/// Valore VAR
/// </summary>
[Column("VarValue")]
public string VarValue { get; set; } = "";
}
}
+43 -21
View File
@@ -11,30 +11,33 @@ namespace MagMan.Data.Tenant.DbModels
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
[Table("Materials")]
[Table("MaterialsList")]
public partial class MaterialModel
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int MatID { get; set; }
/// <summary>
/// Init classe
/// </summary>
public MaterialModel()
{
RawItemList = new HashSet<RawItemModel>();
}
/// <summary>
/// Codice materiale (esterno)
/// Primary Key AUTO
/// </summary>
public int MatExtCode { get; set; } = 0;
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int MatId { get; set; }
/// <summary>
/// Codice Materiale
/// </summary>
public string MatCode { get; set; } = "";
/// <summary>
/// Descrizione materiale
/// </summary>
public string MatDesc { get; set; } = "";
/// <summary>
/// Data approvazione (se non approvato è nel futuro)
/// </summary>
public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100);
/// <summary>
/// Utente approvazione amteriale
/// </summary>
public string ApprovUser { get; set; } = "";
/// <summary>
/// Lenght/Lunghezza in mm
/// </summary>
@@ -44,10 +47,11 @@ namespace MagMan.Data.Tenant.DbModels
/// </summary>
public decimal WMm { get; set; } = 0;
/// <summary>
/// Thikness/Spessore in mm
/// Height (Thikness/Spessore) in mm
/// </summary>
public decimal TMm { get; set; } = 0;
public decimal HMm { get; set; } = 0;
#if false
/// <summary>
/// Lenght/Lunghezza in inch
/// </summary>
@@ -68,10 +72,11 @@ namespace MagMan.Data.Tenant.DbModels
/// Thikness/Spessore in inch
/// </summary>
[NotMapped]
public decimal TIn
public decimal HIn
{
get => Math.Round(TMm / (decimal)25.4, 3);
}
get => Math.Round(HMm / (decimal)25.4, 3);
}
#endif
/// <summary>
/// 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}";
}
/// <summary>
/// Verifica che sia Beam, quando L == 0
/// </summary>
[NotMapped]
public bool IsBeam
{
get => LMm == 0;
}
/// <summary>
/// Verifica che sia Wall, quando W/H == 0
/// </summary>
[NotMapped]
public bool IsWall
{
get => (HMm == 0 && WMm==0);
}
public virtual ICollection<ItemModel>? ItemNav { get; set; }
public virtual ICollection<RawItemModel>? RawItemList { get; set; }
}
}
+2 -2
View File
@@ -44,8 +44,8 @@ namespace MagMan.Data.Tenant.DbModels
/// <summary>
/// Navigation property to Items
/// </summary>
[ForeignKey("ItemID")]
public virtual ItemModel? ITemNav { get; set; }
[ForeignKey("RawItemId")]
public virtual RawItemModel? ITemNav { get; set; }
}
}
+122
View File
@@ -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
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella dei PROJ caricati da EgtBeamWall
/// </summary>
[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
/// <summary>
/// Chiave univoca su DB
/// </summary>
[Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ProjDbId { get; set; }
/// <summary>
/// ID da modello ext
/// </summary>
[Column("Id")]
public int ProjId { get; set; }
/// <summary>
/// Nome file BTL originale
/// </summary>
public string BTLFileName { get; set; } = "";
/// <summary>
/// Tipologia del progetto (Travi, Pareti, ...)
/// </summary>
public BWType PType { get; set; } = BWType.NULL;
/// <summary>
/// Id macchina (diMagMan)
/// </summary>
public int MachineID { get; set; } = 0;
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
/// <summary>
/// Macchina (Costruttore/Modello)
/// </summary>
public string Machine { get; set; } = "";
/// <summary>
/// Descrizione progetto (copiata da BTLFileName inizialmente)
/// </summary>
public string ProjDescription { get; set; } = "";
/// <summary>
/// Data Creazione progetto
/// </summary>
public DateTime DtCreated { get; set; } = DateTime.Now;
/// <summary>
/// Data di schedulazione (prevista)
/// </summary>
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
/// <summary>
/// Data Inizio Produzione
/// </summary>
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
/// <summary>
/// Data ora ultima operazione registrata
/// </summary>
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
/// <summary>
/// ListName del BTL
/// </summary>
public string ListName { get; set; } = "";
/// <summary>
/// Tempo lavorazione previsto (stima) in minuti
/// </summary>
public double ProcTimeEst { get; set; } = 0;
/// <summary>
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
/// </summary>
public double ProcTimeReal { get; set; } = 0;
/// <summary>
/// Record attivo (se false == cancellazione logica)
/// </summary>
public bool IsActive { get; set; } = true;
/// <summary>
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
/// </summary>
public bool IsArchived { get; set; } = false;
#endregion Public Properties
}
}
@@ -12,19 +12,29 @@ namespace MagMan.Data.Tenant.DbModels
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
//[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))]
[Table("ItemsList")]
public partial class ItemModel
[Table("RawItemList")]
public partial class RawItemModel
{
/// <summary>
/// Primary Key AUTO
/// </summary>
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ItemID { get; set; }
public int RawItemId { get; set; }
/// <summary>
/// Ext ref for Material
/// </summary>
public int MatID { get; set; } = 0;
public int MatId { get; set; } = 0;
/// <summary>
/// Qty available on wharehouse
/// </summary>
public int QtyAvail { get; set; } = 0;
/// <summary>
/// Check if is a Remnant
/// </summary>
public bool IsActive { get; set; } = false;
/// <summary>
/// Check if is a Remnant
@@ -35,16 +45,6 @@ namespace MagMan.Data.Tenant.DbModels
/// Location
/// </summary>
public string Location { get; set; } = "";
/// <summary>
/// Qty available on wharehouse
/// </summary>
public int QtyAvail { get; set; } = 0;
/// <summary>
/// DateTime last modification
/// </summary>
public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10);
/// <summary>
/// Item's Lenght
/// </summary>
@@ -56,10 +56,16 @@ namespace MagMan.Data.Tenant.DbModels
public decimal WMm { get; set; } = 0;
/// <summary>
/// Item's Thikness
/// Item's Height (Thikness/Spessore) in mm
/// </summary>
public decimal TMm { get; set; } = 0;
public decimal HMm { get; set; } = 0;
/// <summary>
/// Note (optional)
/// </summary>
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);
}
/// <summary>
/// Note (optional)
/// </summary>
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
/// <summary>
/// Navigation property to Material
/// </summary>
[ForeignKey("MatID")]
[ForeignKey("MatId")]
public virtual MaterialModel MaterialNav { get; set; } = null!;
}
@@ -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
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella esplosione richieste come items
/// </summary>
[Table("RequestDetail")]
public class RequestDetailModel
{
/// <summary>
/// Riferimento Richiesta
/// </summary>
public int RequestId { get; set; } = 0;
/// <summary>
/// Riferimento Item specifico
/// </summary>
public int ItemID { get; set; } = 0;
/// <summary>
/// Quantità necessaria
/// </summary>
public int QtyReq { get; set; } = 0;
/// <summary>
/// Stato richeista
/// </summary>
public RequestStatus ReqState { get; set; } = RequestStatus.None;
}
}
@@ -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
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella dei Piano Richieste associate a Proj
/// </summary>
[Table("RequestPlan")]
public class RequestPlanModel
{
[Key, Column("RequestId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int RequestId { get; set; }
/// <summary>
/// Progetto di riferimento
/// </summary>
public int ProjDbId { get; set; }
/// <summary>
/// Data richiesta
/// </summary>
public DateTime DtRequest{ get; set; }
/// <summary>
/// Record attivo (se false == NON è il piano scelto)
/// </summary>
public bool IsActive { get; set; } = true;
}
}
@@ -42,6 +42,7 @@
<ItemGroup>
<Folder Include="DTO\" />
<Folder Include="Migrations\" />
</ItemGroup>
</Project>
+16 -45
View File
@@ -33,56 +33,26 @@ namespace MagMan.Data.Tenant
connString = currConnString;
}
#if false
public MagManContext(DbContextOptions<MagManContext> 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<ConfigModel> DbSetConfig { get; set; } = null!;
public virtual DbSet<ItemModel> DbSetItems { get; set; } = null!;
public virtual DbSet<RawItemModel> DbSetItems { get; set; } = null!;
public virtual DbSet<MaterialModel> DbSetMaterials { get; set; } = null!;
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
public virtual DbSet<PrintJobQueueModel> DbSetPrintJob { get; set; } = null!;
public virtual DbSet<RawItemModel> DbSetRawItem { get; set; } = null!;
public virtual DbSet<AliasModel> DbSetAlias { get; set; } = null!;
public virtual DbSet<RequestPlanModel> DbSetReqPlan { get; set; } = null!;
public virtual DbSet<RequestDetailModel> DbSetReqDet{ get; set; } = null!;
#if false
public virtual DbSet<AnKeyValModel> DbSetKeyVal { get; set; }
public virtual DbSet<ListValModel> DbSetListVal { get; set; }
public virtual DbSet<OrderModel> DbSetOrders { get; set; }
public virtual DbSet<ParamSendModel> DbSetParamSend { get; set; }
public virtual DbSet<ParamSetModel> DbSetParamSet { get; set; }
public virtual DbSet<PlantDetailModel> DbSetPlant { get; set; }
public virtual DbSet<PlantLogModel> DbSetPlantLog { get; set; }
public virtual DbSet<PlantStatusModel> DbSetPlantStatus { get; set; }
public virtual DbSet<WeekPlanModel> DbSetPlantSupplWeekPlan { get; set; }
public virtual DbSet<SupplierModel> DbSetSupplier { get; set; }
public virtual DbSet<TransporterModel> DbSetTransporter { get; set; }
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
public virtual DbSet<PrintJobQueueModel> 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<ListValModel>().HasKey(c => new { c.TabName, c.FieldName, c.Val });
modelBuilder.Entity<RequestDetailModel>()
.HasKey(c => new { c.RequestId, c.ItemID });
modelBuilder.Entity<PlantStatusModel>().HasKey(c => new { c.PlantId, c.FluxType });
modelBuilder.Entity<ParamSendModel>().HasKey(c => new { c.PlantId, c.ParamUid });
#endif
modelBuilder.Entity<AliasModel>()
.HasKey(c => new { c.Family, c.ValueOriginal});
modelBuilder.Seed();
@@ -1,56 +0,0 @@
// <auto-generated />
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<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(0);
b.Property<string>("Note")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnOrder(3);
b.Property<string>("Val")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(1);
b.Property<string>("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
}
}
}
@@ -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<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ValStd = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
.Annotation("MySql:CharSet", "utf8mb4"),
Note = table.Column<string>(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");
}
}
}
@@ -1,149 +0,0 @@
// <auto-generated />
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<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(0);
b.Property<string>("Note")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnOrder(3);
b.Property<string>("Val")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(1);
b.Property<string>("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<int>("ItemID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtMod")
.HasColumnType("datetime(6)");
b.Property<bool>("IsRemn")
.HasColumnType("tinyint(1)");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("Location")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatID")
.HasColumnType("int");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("QtyAvail")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("ItemID");
b.HasIndex("MatID");
b.ToTable("ItemsList");
});
modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
{
b.Property<int>("MatID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("ApprovDate")
.HasColumnType("datetime(6)");
b.Property<string>("ApprovUser")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatExtCode")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("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
}
}
}
@@ -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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MatExtCode = table.Column<int>(type: "int", nullable: false),
MatDesc = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ApprovDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ApprovUser = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
TMm = table.Column<decimal>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MatID = table.Column<int>(type: "int", nullable: false),
IsRemn = table.Column<bool>(type: "tinyint(1)", nullable: false),
Location = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
QtyAvail = table.Column<int>(type: "int", nullable: false),
DtMod = table.Column<DateTime>(type: "datetime(6)", nullable: false),
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
TMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
Note = table.Column<string>(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");
}
}
}
@@ -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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DtRec = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ItemID = table.Column<int>(type: "int", nullable: false),
QtyRec = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TipoReport = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
KeyParam = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PrtName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DtStart = table.Column<DateTime>(type: "datetime(6)", nullable: false),
DtEnd = table.Column<DateTime>(type: "datetime(6)", nullable: true),
Stato = table.Column<int>(type: "int", nullable: false),
DtLastTry = table.Column<DateTime>(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");
}
}
}
@@ -1,6 +1,6 @@
// <auto-generated />
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<string>("Family")
.HasColumnType("varchar(255)");
b.Property<string>("ValueOriginal")
.HasColumnType("varchar(255)");
b.Property<string>("ValueAlias")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Family", "ValueOriginal");
b.ToTable("AliasList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
{
b.Property<string>("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<int>("ItemID")
b.Property<int>("MatId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtMod")
.HasColumnType("datetime(6)");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatCode")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("MatId");
b.ToTable("MaterialsList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
{
b.Property<int>("RawItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsRemn")
.HasColumnType("tinyint(1)");
@@ -71,7 +119,7 @@ namespace MagMan.Data.Tenant.Migrations
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatID")
b.Property<int>("MatId")
.HasColumnType("int");
b.Property<string>("Note")
@@ -81,139 +129,70 @@ namespace MagMan.Data.Tenant.Migrations
b.Property<int>("QtyAvail")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("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<int>("MatID")
.ValueGeneratedOnAdd()
b.Property<int>("RequestId")
.HasColumnType("int");
b.Property<DateTime>("ApprovDate")
.HasColumnType("datetime(6)");
b.Property<string>("ApprovUser")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatExtCode")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("MatID");
b.ToTable("Materials");
});
modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b =>
{
b.Property<int>("MovID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtRec")
.HasColumnType("datetime(6)");
b.Property<int>("ItemID")
.HasColumnType("int");
b.Property<int>("QtyRec")
b.Property<int>("QtyReq")
.HasColumnType("int");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("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<int>("IdxPrintJob")
b.Property<int>("RequestId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("RequestId");
b.Property<DateTime>("DtRequest")
.HasColumnType("datetime(6)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<int>("ProjDbId")
.HasColumnType("int");
b.Property<DateTime?>("DtEnd")
.HasColumnType("datetime(6)");
b.HasKey("RequestId");
b.Property<DateTime?>("DtLastTry")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtStart")
.HasColumnType("datetime(6)");
b.Property<string>("KeyParam")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("PrtName")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Stato")
.HasColumnType("int");
b.Property<string>("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
}
@@ -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<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ValueOriginal = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ValueAlias = table.Column<string>(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<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ValStd = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
.Annotation("MySql:CharSet", "utf8mb4"),
Note = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MatCode = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
MatDesc = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
HMm = table.Column<decimal>(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<int>(type: "int", nullable: false),
ItemID = table.Column<int>(type: "int", nullable: false),
QtyReq = table.Column<int>(type: "int", nullable: false),
ReqState = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ProjDbId = table.Column<int>(type: "int", nullable: false),
DtRequest = table.Column<DateTime>(type: "datetime(6)", nullable: false),
IsActive = table.Column<bool>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MatId = table.Column<int>(type: "int", nullable: false),
QtyAvail = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
IsRemn = table.Column<bool>(type: "tinyint(1)", nullable: false),
Location = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
HMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
Note = table.Column<string>(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");
}
}
}
@@ -1,6 +1,6 @@
// <auto-generated />
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<string>("Family")
.HasColumnType("varchar(255)");
b.Property<string>("ValueOriginal")
.HasColumnType("varchar(255)");
b.Property<string>("ValueAlias")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Family", "ValueOriginal");
b.ToTable("AliasList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
{
b.Property<string>("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<int>("ItemID")
b.Property<int>("MatId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtMod")
.HasColumnType("datetime(6)");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatCode")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("MatId");
b.ToTable("MaterialsList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
{
b.Property<int>("RawItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsRemn")
.HasColumnType("tinyint(1)");
@@ -69,7 +117,7 @@ namespace MagMan.Data.Tenant.Migrations
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatID")
b.Property<int>("MatId")
.HasColumnType("int");
b.Property<string>("Note")
@@ -79,139 +127,70 @@ namespace MagMan.Data.Tenant.Migrations
b.Property<int>("QtyAvail")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("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<int>("MatID")
.ValueGeneratedOnAdd()
b.Property<int>("RequestId")
.HasColumnType("int");
b.Property<DateTime>("ApprovDate")
.HasColumnType("datetime(6)");
b.Property<string>("ApprovUser")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatExtCode")
.HasColumnType("int");
b.Property<decimal>("TMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("MatID");
b.ToTable("Materials");
});
modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b =>
{
b.Property<int>("MovID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtRec")
.HasColumnType("datetime(6)");
b.Property<int>("ItemID")
.HasColumnType("int");
b.Property<int>("QtyRec")
b.Property<int>("QtyReq")
.HasColumnType("int");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("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<int>("IdxPrintJob")
b.Property<int>("RequestId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("RequestId");
b.Property<DateTime>("DtRequest")
.HasColumnType("datetime(6)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<int>("ProjDbId")
.HasColumnType("int");
b.Property<DateTime?>("DtEnd")
.HasColumnType("datetime(6)");
b.HasKey("RequestId");
b.Property<DateTime?>("DtLastTry")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtStart")
.HasColumnType("datetime(6)");
b.Property<string>("KeyParam")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("PrtName")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Stato")
.HasColumnType("int");
b.Property<string>("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
}
+19 -18
View File
@@ -60,7 +60,7 @@ namespace MagMan.Data.Tenant.Services
/// <param name="nKey">Key di riferimento</param>
/// <param name="rec2del">Item da eliminare</param>
/// <returns></returns>
public async Task<bool> ItemDelete(int nKey, ItemModel rec2del)
public async Task<bool> ItemDelete(int nKey, RawItemModel rec2del)
{
bool fatto = false;
string cString = ConnString(nKey);
@@ -84,15 +84,15 @@ namespace MagMan.Data.Tenant.Services
/// </summary>
/// <param name="origItem"></param>
/// <returns></returns>
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
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <returns></returns>
public async Task<List<ItemModel>> ItemGetAll(int nKey)
public async Task<List<RawItemModel>> ItemGetAll(int nKey)
{
string source = "DB";
string cString = ConnString(nKey);
List<ItemModel>? dbResult = new List<ItemModel>();
List<RawItemModel>? dbResult = new List<RawItemModel>();
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<List<ItemModel>>(rawData);
var tempResult = JsonConvert.DeserializeObject<List<RawItemModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ItemModel>();
dbResult = new List<RawItemModel>();
}
else
{
@@ -138,7 +138,7 @@ namespace MagMan.Data.Tenant.Services
}
if (dbResult == null)
{
dbResult = new List<ItemModel>();
dbResult = new List<RawItemModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -157,11 +157,11 @@ namespace MagMan.Data.Tenant.Services
/// <param name="nKey">Key di riferimento</param>
/// <param name="matID">ID del materiale x cui filtrare, 0 = tutti</param>
/// <returns></returns>
public async Task<List<ItemModel>> ItemGetByMat(int nKey, int matID)
public async Task<List<RawItemModel>> ItemGetByMat(int nKey, int matID)
{
string source = "DB";
string cString = ConnString(nKey);
List<ItemModel>? dbResult = new List<ItemModel>();
List<RawItemModel>? dbResult = new List<RawItemModel>();
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<List<ItemModel>>(rawData);
var tempResult = JsonConvert.DeserializeObject<List<RawItemModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ItemModel>();
dbResult = new List<RawItemModel>();
}
else
{
@@ -189,7 +189,7 @@ namespace MagMan.Data.Tenant.Services
}
if (dbResult == null)
{
dbResult = new List<ItemModel>();
dbResult = new List<RawItemModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -208,7 +208,7 @@ namespace MagMan.Data.Tenant.Services
/// <param name="nKey">Key di riferimento</param>
/// <param name="currItem"></param>
/// <returns></returns>
public async Task<bool> ItemUpdate(int nKey, ItemModel currItem)
public async Task<bool> 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;
-24
View File
@@ -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;
+37
View File
@@ -0,0 +1,37 @@
@if (CurrRecord != null)
{
<div class="row g-1">
<div class="col-md-6">
<div class="input-group">
<div class="form-floating w-25">
<input type="text" class="form-control" @bind="@CurrRecord.MatCode">
<label class="small">Codicee</label>
</div>
<div class="form-floating w-75">
<input type="text" class="form-control" @bind="@CurrRecord.MatDesc">
<label class="small">Descrizione</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="d-flex">
<div class="input-group">
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" Value="@CurrRecord.WMm"></NumInput>
<label class="small">W (mm)</label>
</div>
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" Value="@CurrRecord.HMm"></NumInput>
<label class="small">H (mm)</label>
</div>
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" Value="@CurrRecord.LMm"></NumInput>
<label class="small">L (mm)</label>
</div>
<button class="btn btn-success w-10" @onclick="() => DoSave()"><i class="fa-solid fa-floppy-disk"></i> Save</button>
@* <button class="btn btn-warning w-10" @onclick="() => DoCancel()"><i class="fa-solid fa-ban"></i> Cancel</button> *@
</div>
</div>
</div>
</div>
}
@@ -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<bool> 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
}
}
+102 -3
View File
@@ -1,5 +1,104 @@
<h3>MaterialMan</h3>
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="px-2">
<h3>Materiali</h3>
</div>
<div class="px-2">
<div class="d-flex">
<div class="px-2">
@if (CurrItem == null)
{
<button class="btn btn-success" @onclick="()=>CreateNew()"><i class="fa-solid fa-square-plus"></i> Add New</button>
}
else
{
<button class="btn btn-warning" @onclick="()=> DoEdit(null)"><i class="fa-solid fa-ban"></i> Cancel</button>
}
</div>
<div class="px-2">
<div class="input-group">
<span class="input-group-text" id="basic-addon1">Tipo Mat.</span>
<select class="form-select" @bind="@FiltType">
<option value="0">--- Tutti ---</option>
<option value="1">Beam</option>
<option value="2">Wall</option>
</select>
</div>
</div>
</div>
</div>
</div>
@if (CurrItem != null)
{
<hr />
<MaterialEdit CurrRecord="CurrItem" EC_update="ForceReload"></MaterialEdit>
}
</div>
<div class="card-body p-1">
@if (ListRecords == null)
{
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-info">Nessun record trovato</div>
}
else
{
<table class="table table-striped table-sm text-start">
<thead>
<tr class="">
<th>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(null)"><i class="fa-solid fa-rotate"></i></button>
</th>
<th>ID <Sorter ParamName="MatId" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>Mat.Code <Sorter ParamName="MatCode" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>Descr. <Sorter ParamName="MatDesc" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
@* <th class="text-end"></th> *@
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr class="align-middle @CheckSel(item)">
<td>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
</td>
<td>
@item.MatId
</td>
<td>
@item.MatCode
</td>
<td>
@item.MatDesc
</td>
<td>
@($"{item.WMm:N2}")
</td>
<td>
@($"{item.HMm:N2}")
</td>
<td>
@($"{item.LMm:N2}")
</td>
@* <td class="text-end">
<button class="btn btn-sm btn-danger" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash-can"></i></button>
</td> *@
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer">
<EgwCoreLib.Razor.DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading"></EgwCoreLib.Razor.DataPager>
</div>
</div>
@code {
}
+263
View File
@@ -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<bool>("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<MaterialModel>? ListRecords = null;
private List<MaterialModel>? 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<MaterialModel>();
}
}
private string textCss(bool isActive)
{
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
}
#endregion Private Methods
}
}
+3 -3
View File
@@ -49,10 +49,10 @@ namespace MagMan.UI.Controllers
// GET api/Inventory
[HttpGet]
public async Task<List<ItemModel>> Get()
public async Task<List<RawItemModel>> Get()
{
// se non ho chiave --> vuoto!
List<ItemModel> ListRecords = new List<ItemModel>();
List<RawItemModel> ListRecords = new List<RawItemModel>();
await Task.Delay(100);
return ListRecords;
}
@@ -93,7 +93,7 @@ namespace MagMan.UI.Controllers
if (nKey > 0)
{
// creo oggetti materiale da lista ricevuta
List<ItemModel> matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList();
List<RawItemModel> matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList();
foreach (var item in matList)
{
@@ -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
{
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private MTAdminService _DataService { get; set; } = null!;
public ProjectsController(MTAdminService DataService)
{
_DataService = DataService;
Log.Info("Avviata classe ProjectsController");
}
/// <summary>
/// Controllo status Alive
/// GET: api/Machines/alive
/// </summary>
/// <returns></returns>
[HttpGet("alive")]
public string alive()
{
//Log.Debug("Chiamata alive");
return $"OK";
}
// GET api/Machines/5
[HttpGet]
public async Task<List<MachineModel>> Get()
{
// se non ho chaive --> vuoto!
List<MachineModel> ListRecords = new List<MachineModel>();
await Task.Delay(100);
return ListRecords;
}
/// <summary>
/// Elenco Macchine dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
public async Task<List<MachineModel>> Get(string id, int KeyNum)
{
var ListRecords = await _DataService.MachineGetByToken(id);
return ListRecords;
}
}
}
+3 -3
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.0.2401.1716</Version>
<Version>1.0.2401.1911</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
@@ -36,8 +36,8 @@
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2312.1510" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2312.1510" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2401.1911" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2401.1911" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.23" />
+1 -1
View File
@@ -42,7 +42,7 @@ else
{
@if (currMode == CtMode.Materials)
{
<MaterialMan></MaterialMan>
<MaterialMan CustomerId="@CustomerID" KeyNum="@nKey"></MaterialMan>
}
else if (currMode == CtMode.Items)
{
+9
View File
@@ -135,11 +135,20 @@ Ogni nuovo user dovrà poi essere associato al bucket del cliente tramite un cod
<div style="page-break-after: always; visibility: hidden"></div>
## 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.
<div style="page-break-after: always; visibility: hidden"></div>
## 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
BIN
View File
Binary file not shown.
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MagMan - Wood Warehouse Management System</i>
<h4>Versione: 1.0.2401.1716</h4>
<h4>Versione: 1.0.2401.1911</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2401.1716
1.0.2401.1911
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2401.1716</version>
<version>1.0.2401.1911</version>
<url>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+13 -1
View File
@@ -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
+65 -5
View File
@@ -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
+1 -1
View File
@@ -49,7 +49,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgwProxy.MagMan.0.9.2401-beta.1718\lib\EgwProxy.MagMan.dll</HintPath>
<HintPath>..\packages\EgwProxy.MagMan.0.9.2401-beta.1719\lib\EgwProxy.MagMan.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EgwProxy.MagMan" version="0.9.2401-beta.1718" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="0.9.2401-beta.1719" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="RestSharp" version="110.2.0" targetFramework="net472" />