Merge branch 'feature/NugetSdk' into develop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -35,5 +36,42 @@ namespace MagMan.Core.DTO
|
||||
/// Thikness/Spessore in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Varianti dimensionali disponibili
|
||||
/// </summary>
|
||||
public int SizeNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Quantità totale in giacenza
|
||||
/// </summary>
|
||||
public int QtyTot { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice materiale x QR/Datamatrix
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public string MatDtmx
|
||||
{
|
||||
get => $"MT{MatId:00000000}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Beam, quando L == 0
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool IsBeam
|
||||
{
|
||||
get => (LMm == 0 && (HMm > 0 && WMm > 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Wall, quando W/L == 0
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool IsWall
|
||||
{
|
||||
get => (HMm > 0 && (LMm == 0 && WMm == 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace MagMan.Core.Services
|
||||
public event Action EA_PageUpdated = null!;
|
||||
public event Action EA_SearchUpdated = null!;
|
||||
public event Action EA_ShowSearch = null!;
|
||||
public event Action EA_CustomerSel = null!;
|
||||
public event Action EA_CustomerSel = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace MagMan.Core.Services
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string UserName { get; set; } = "NA";
|
||||
|
||||
public string PageIcon
|
||||
{
|
||||
get => _pageIcon;
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace MagMan.Data.Tenant.Controllers
|
||||
{
|
||||
@@ -120,11 +121,15 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary> Aggiunge/Modifica un item in magazzino </summary> <param
|
||||
/// name="connString">Stringa connessione (variabile x cliente)</param> <param
|
||||
/// name="rec2upd">Record da aggiornare</param> <param name="deltaQty">quantità da
|
||||
/// aggiornare (se <0 è consumo)</param> <returns></returns>
|
||||
public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty)
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un item in magazzino
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="rec2upd">Record da aggiornare</param>
|
||||
/// <param name="deltaQty">quantità da aggiornare (se <0 è consumo)</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty, string userId)
|
||||
{
|
||||
bool done = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
@@ -143,6 +148,16 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = deltaQty,
|
||||
UserId = userId,
|
||||
Note = deltaQty > 0 ? "M01+: Rettifica Inventariale" : "M01-: Rettifica Inventariale"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
|
||||
currData.QtyAvail += deltaQty;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
@@ -162,8 +177,9 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="rec2upd">Record da aggiungere/aggiornare</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public bool ItemUpdate(string connString, RawItemModel rec2upd)
|
||||
public bool ItemUpdate(string connString, RawItemModel rec2upd, string userId)
|
||||
{
|
||||
bool done = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
@@ -182,6 +198,22 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
int delta = rec2upd.QtyAvail - currData.QtyAvail;
|
||||
if (delta != 0)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = delta,
|
||||
UserId = userId,
|
||||
Note = delta > 0 ? "M02+: Rettifica Inventariale" : "M02-: Rettifica Inventariale"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
|
||||
// sistemo record...
|
||||
currData.MatId = rec2upd.MatId;
|
||||
currData.QtyAvail = rec2upd.QtyAvail;
|
||||
currData.IsActive = rec2upd.IsActive;
|
||||
@@ -198,6 +230,17 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
dbCtx
|
||||
.DbSetItems
|
||||
.Add(rec2upd);
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// aggiungo record variazione quantità...
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = rec2upd.QtyAvail,
|
||||
Note = rec2upd.QtyAvail > 0 ? "M03+: Aggiunta Record" : "M03+: Aggiunta Record"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
@@ -244,6 +287,62 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Materiali gestiti a magazzino formato DTO
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <returns></returns>
|
||||
public List<MaterialDTO> MaterialDtoGetAll(string connString, bool withChild)
|
||||
{
|
||||
List<MaterialDTO> dbResult = new List<MaterialDTO>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
if (withChild)
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMaterials
|
||||
.Select(x => new MaterialDTO()
|
||||
{
|
||||
MatId = x.MatId,
|
||||
MatCode = x.MatCode,
|
||||
MatDesc = x.MatDesc,
|
||||
HMm = x.HMm,
|
||||
LMm = x.LMm,
|
||||
WMm = x.WMm,
|
||||
SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Count,
|
||||
QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Sum(r => r.QtyAvail)
|
||||
})
|
||||
.OrderBy(x => x.MatDesc)
|
||||
.ThenBy(x => x.WMm)
|
||||
.ThenBy(x => x.HMm)
|
||||
.ThenBy(x => x.LMm)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMaterials
|
||||
.Select(x => new MaterialDTO()
|
||||
{
|
||||
MatId = x.MatId,
|
||||
MatCode = x.MatCode,
|
||||
MatDesc = x.MatDesc,
|
||||
HMm = x.HMm,
|
||||
LMm = x.LMm,
|
||||
WMm = x.WMm,
|
||||
SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Count,
|
||||
QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Sum(r => r.QtyAvail)
|
||||
})
|
||||
.OrderBy(x => x.MatDesc)
|
||||
.ThenBy(x => x.WMm)
|
||||
.ThenBy(x => x.HMm)
|
||||
.ThenBy(x => x.LMm)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Materiali gestiti a magazzino
|
||||
/// </summary>
|
||||
@@ -277,12 +376,15 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
} /// <summary>
|
||||
}
|
||||
|
||||
/// Elenco Materiali gestiti a magazzino </summary> <param name="connString">Stringa
|
||||
/// connessione (variabile x cliente)</param> <param name="projDbId">Materiale richiesto, 0
|
||||
/// = tutti</param> <param name="withChild">Se true allora include record child
|
||||
/// (Items)</param> <returns></returns>
|
||||
/// <summary>
|
||||
/// Elenco Materiali gestiti a magazzino
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="projDbId">Materiale richiesto, 0 = tutti</param>
|
||||
/// <param name="withChild">Se true allora include record child (Items)</param>
|
||||
/// <returns></returns>
|
||||
public List<MaterialModel> MaterialGetFilt(string connString, int matID, bool withChild)
|
||||
{
|
||||
List<MaterialModel> dbResult = new List<MaterialModel>();
|
||||
@@ -366,6 +468,29 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco MovMag dato Item
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="rawItemID">ID dell'item x cui filtrare, 0 = tutti</param>
|
||||
/// <param name="maxRec">numMax record da leggere, default 1000</param>
|
||||
/// <returns></returns>
|
||||
public List<MovMagModel> MovMagGetFilt(string connString, int rawItemID, int maxRec = 1000)
|
||||
{
|
||||
List<MovMagModel> dbResult = new List<MovMagModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMovMag
|
||||
.Where(x => rawItemID == 0 || x.RawItemId == rawItemID)
|
||||
//.Include(c => c.ItemNav)
|
||||
.OrderByDescending(x => x.DtRec)
|
||||
.Take(maxRec)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record Project
|
||||
/// </summary>
|
||||
@@ -525,99 +650,6 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <returns></returns>
|
||||
public List<ResourceModel> ResourcesGetByProject(string connString, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
List<ResourceModel> dbResult = new List<ResourceModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
if (isEstim)
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetResources
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetResources
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <returns></returns>
|
||||
public List<ResourceExpDTO> ResourcesExpGetByProject(string connString, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
List<ResourceExpDTO> dbResult = new List<ResourceExpDTO>();
|
||||
List<ResourceModel> rawData = new List<ResourceModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
if (isEstim)
|
||||
{
|
||||
rawData = dbCtx
|
||||
.DbSetResources
|
||||
.Include(p => p.RequestNav)
|
||||
.Include(i => i.ItemNav)
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData = dbCtx
|
||||
.DbSetResources
|
||||
.Include(p => p.RequestNav)
|
||||
.Include(i => i.ItemNav)
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
try
|
||||
{
|
||||
dbResult = rawData.Select(x => new ResourceExpDTO()
|
||||
{
|
||||
ResourceId = x.ResourceId,
|
||||
RawItemId = x.RawItemId,
|
||||
Qty = x.Qty,
|
||||
Note = x.ItemNav.Note,
|
||||
DtRequest = x.RequestNav.DtRequest,
|
||||
HMm = x.ItemNav.HMm,
|
||||
LMm = x.ItemNav.LMm,
|
||||
WMm = x.ItemNav.WMm,
|
||||
IsActive = x.RequestNav.IsActive,
|
||||
IsRemn = x.ItemNav.IsRemn,
|
||||
MatId = x.ItemNav.MatId,
|
||||
RequestId = x.RequestId
|
||||
})
|
||||
.OrderByDescending(x => x.DtRequest)
|
||||
.ThenByDescending(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione ResourcesExpGetByProject{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un record ReqPlan
|
||||
/// </summary>
|
||||
@@ -682,14 +714,108 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return newId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <returns></returns>
|
||||
public List<ResourceExpDTO> ResourcesExpGetByProject(string connString, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
List<ResourceExpDTO> dbResult = new List<ResourceExpDTO>();
|
||||
List<ResourceModel> rawData = new List<ResourceModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
if (isEstim)
|
||||
{
|
||||
rawData = dbCtx
|
||||
.DbSetResources
|
||||
.Include(p => p.RequestNav)
|
||||
.Include(i => i.ItemNav)
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData = dbCtx
|
||||
.DbSetResources
|
||||
.Include(p => p.RequestNav)
|
||||
.Include(i => i.ItemNav)
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
try
|
||||
{
|
||||
dbResult = rawData.Select(x => new ResourceExpDTO()
|
||||
{
|
||||
ResourceId = x.ResourceId,
|
||||
RawItemId = x.RawItemId,
|
||||
Qty = x.Qty,
|
||||
Note = x.ItemNav.Note,
|
||||
DtRequest = x.RequestNav.DtRequest,
|
||||
HMm = x.ItemNav.HMm,
|
||||
LMm = x.ItemNav.LMm,
|
||||
WMm = x.ItemNav.WMm,
|
||||
IsActive = x.RequestNav.IsActive,
|
||||
IsRemn = x.ItemNav.IsRemn,
|
||||
MatId = x.ItemNav.MatId,
|
||||
RequestId = x.RequestId
|
||||
})
|
||||
.OrderByDescending(x => x.DtRequest)
|
||||
.ThenByDescending(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione ResourcesExpGetByProject{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <returns></returns>
|
||||
public List<ResourceModel> ResourcesGetByProject(string connString, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
List<ResourceModel> dbResult = new List<ResourceModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
if (isEstim)
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetResources
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && (x.RequestNav.IsActive || showAll) && x.RequestNav.ReqState > Enums.ProjResState.ND)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetResources
|
||||
.Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Enums.ProjResState.Consumed)
|
||||
.OrderBy(x => x.ResourceId)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un elenco di Resource (+ eventuali update giacenze)
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>>
|
||||
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>
|
||||
/// <param name="resState">Tipo di aggiornamento da registratre</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public int ResourceUpdate(string connString, List<ResourceModel> recList, Enums.ProjResState resState)
|
||||
public int ResourceUpdate(string connString, List<ResourceModel> recList, Enums.ProjResState resState, string userId)
|
||||
{
|
||||
int numMod = 0;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
@@ -709,12 +835,45 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
// aggiorno
|
||||
if (currData != null)
|
||||
{
|
||||
if (resState == Enums.ProjResState.Consumed)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
int delta = rec2upd.Qty - currData.Qty;
|
||||
if (delta != 0)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = delta,
|
||||
UserId = userId,
|
||||
Note = delta > 0 ? "M04+: Aggiunta Risorsa" : "M04-: Consumo Risorsa"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
}
|
||||
|
||||
// aggiorno le risorse
|
||||
currData.Qty = rec2upd.Qty;
|
||||
currData.RawItemId = rec2upd.RawItemId;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resState == Enums.ProjResState.Consumed)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = rec2upd.Qty,
|
||||
UserId = userId,
|
||||
Note = rec2upd.Qty > 0 ? "M05+: Aggiunta Risorsa" : "M05-: Consumo Risorsa"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
|
||||
// aggiungo record
|
||||
dbCtx
|
||||
.DbSetResources
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
/// <summary>
|
||||
/// Ext ref for Items
|
||||
/// </summary>
|
||||
public int ItemID { get; set; }
|
||||
public int RawItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Qty recorded (delta +/-)
|
||||
@@ -41,11 +41,16 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
/// </summary>
|
||||
public string UserId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Note opzionali
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property to Items
|
||||
/// </summary>
|
||||
[ForeignKey("RawItemId")]
|
||||
public virtual RawItemModel? ITemNav { get; set; }
|
||||
public virtual RawItemModel? ItemNav { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace MagMan.Data.Tenant
|
||||
public virtual DbSet<ProjModel> DbSetProjects { get; set; } = null!;
|
||||
public virtual DbSet<RequestPlanModel> DbSetReqPlan { get; set; } = null!;
|
||||
public virtual DbSet<ResourceModel> DbSetResources { get; set; } = null!;
|
||||
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
|
||||
|
||||
|
||||
#if false
|
||||
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
|
||||
public virtual DbSet<PrintJobQueueModel> DbSetPrintJob { get; set; } = null!;
|
||||
#endif
|
||||
|
||||
|
||||
+55
-4
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
[Migration("20240122174314_InitDb")]
|
||||
[Migration("20240125174457_InitDb")]
|
||||
partial class InitDb
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -97,9 +97,39 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.Property<int>("MovID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRec")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyRec")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MovID");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.ToTable("MovMag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjExtDbId")
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -158,7 +188,7 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<int>("ProjExtId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ProjExtDbId");
|
||||
b.HasKey("ProjDbId");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
@@ -227,7 +257,7 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
@@ -255,11 +285,24 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
|
||||
@@ -273,12 +316,20 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
|
||||
b.Navigation("RequestNav");
|
||||
});
|
||||
|
||||
+48
-3
@@ -150,6 +150,32 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
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),
|
||||
RawItemId = 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"),
|
||||
Note = 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_RawItemList_RawItemId",
|
||||
column: x => x.RawItemId,
|
||||
principalTable: "RawItemList",
|
||||
principalColumn: "RawItemId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ResourceList",
|
||||
columns: table => new
|
||||
@@ -163,6 +189,12 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ResourceList", x => x.ResourceId);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResourceList_RawItemList_RawItemId",
|
||||
column: x => x.RawItemId,
|
||||
principalTable: "RawItemList",
|
||||
principalColumn: "RawItemId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResourceList_RequestPlan_RequestId",
|
||||
column: x => x.RequestId,
|
||||
@@ -172,6 +204,11 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MovMag_RawItemId",
|
||||
table: "MovMag",
|
||||
column: "RawItemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_IsActive",
|
||||
table: "ProjList",
|
||||
@@ -202,6 +239,11 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
table: "RawItemList",
|
||||
column: "MatId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResourceList_RawItemId",
|
||||
table: "ResourceList",
|
||||
column: "RawItemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResourceList_RequestId",
|
||||
table: "ResourceList",
|
||||
@@ -217,19 +259,22 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
name: "Config");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjList");
|
||||
name: "MovMag");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RawItemList");
|
||||
name: "ProjList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ResourceList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MaterialsList");
|
||||
name: "RawItemList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestPlan");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MaterialsList");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,9 +95,39 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.Property<int>("MovID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRec")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyRec")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MovID");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.ToTable("MovMag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjExtDbId")
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -156,7 +186,7 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<int>("ProjExtId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ProjExtDbId");
|
||||
b.HasKey("ProjDbId");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
@@ -225,7 +255,7 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
@@ -253,11 +283,24 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
|
||||
@@ -271,12 +314,20 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
|
||||
b.Navigation("RequestNav");
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
@@ -204,16 +205,20 @@ namespace MagMan.Data.Tenant.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary> Update record Item + refresh cache </summary> <param name="nKey">Key di
|
||||
/// riferimento</param> <param name="currItem">Item interesato</param> <param
|
||||
/// name="deltaQty">quantità da aggiornare (se <0 è consumo)</param> <returns></returns>
|
||||
public async Task<bool> ItemModQty(int nKey, RawItemModel currItem, int deltaQty)
|
||||
/// <summary>
|
||||
/// Update record Item per quantità + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="currItem">Item interesato</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemModQty(int nKey, RawItemModel currItem, int deltaQty, string userId)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
fatto = dbController.ItemModQty(cString, currItem, deltaQty);
|
||||
fatto = dbController.ItemModQty(cString, currItem, deltaQty, userId);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
@@ -231,14 +236,15 @@ namespace MagMan.Data.Tenant.Services
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="currItem">Item interesato</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemUpdate(int nKey, RawItemModel currItem)
|
||||
public async Task<bool> ItemUpdate(int nKey, RawItemModel currItem, string userId)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
fatto = dbController.ItemUpdate(cString, currItem);
|
||||
fatto = dbController.ItemUpdate(cString, currItem, userId);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
@@ -276,23 +282,84 @@ namespace MagMan.Data.Tenant.Services
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Materiali gestiti a magazzino in formato DTO
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="withChild">Se true allora include record child (Items)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MaterialDTO>> MaterialDtoGetAll(int nKey, bool withChild)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<MaterialDTO>? dbResult = new List<MaterialDTO>();
|
||||
try
|
||||
{
|
||||
string dType = withChild ? "MaterialsDtoFull" : "MaterialsDto";
|
||||
string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<MaterialDTO>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.MaterialDtoGetAll(cString, withChild);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
// per evitare loopback uso deserialize...
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
if (tempResult != null)
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<MaterialDTO>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"MaterialDtoGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during MaterialDtoGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converte il DTO in MaterialModel
|
||||
/// </summary>
|
||||
/// <param name="origItem"></param>
|
||||
/// <returns></returns>
|
||||
public MaterialModel MaterialFromDto(MaterialDTO origItem)
|
||||
public MaterialModel? MaterialFromDto(MaterialDTO? origItem)
|
||||
{
|
||||
MaterialModel answ = new MaterialModel()
|
||||
MaterialModel? answ = null;
|
||||
if (origItem != null)
|
||||
{
|
||||
MatId = origItem.MatId,
|
||||
MatCode = origItem.MatCode,
|
||||
MatDesc = origItem.MatDesc,
|
||||
LMm = origItem.LMm,
|
||||
WMm = origItem.WMm,
|
||||
HMm = origItem.HMm
|
||||
};
|
||||
|
||||
answ = new MaterialModel()
|
||||
{
|
||||
MatId = origItem.MatId,
|
||||
MatCode = origItem.MatCode,
|
||||
MatDesc = origItem.MatDesc,
|
||||
LMm = origItem.LMm,
|
||||
WMm = origItem.WMm,
|
||||
HMm = origItem.HMm
|
||||
};
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -438,6 +505,60 @@ namespace MagMan.Data.Tenant.Services
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco MovMag dato Item
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="rawItemID">ID dell'item x cui filtrare, 0 = tutti</param>
|
||||
/// <param name="maxRec">numMax record da leggere, default 1000</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MovMagModel>> MovMagGetFilt(int nKey, int rawItemID, int maxRec = 1000)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<MovMagModel>? dbResult = new List<MovMagModel>();
|
||||
try
|
||||
{
|
||||
// in cache tengo dati estratti ogni minuto...
|
||||
string dtKey = DateTime.Now.ToString("yyMMdd:HHmm");
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:MovMag:{rawItemID}:{dtKey}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MovMagModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<MovMagModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.MovMagGetFilt(cString, rawItemID, maxRec);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<MovMagModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"MovMagGetFilt | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during MovMagGetFilt:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record Project + refresh cache
|
||||
/// </summary>
|
||||
@@ -663,61 +784,6 @@ namespace MagMan.Data.Tenant.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <param name="showAll">true= mostra ANCHE archiviate, false = solo attive</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ResourceModel>> ResourcesGetByProject(int nKey, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<ResourceModel>? dbResult = new List<ResourceModel>();
|
||||
try
|
||||
{
|
||||
string tagEst = isEstim ? "EST" : "CON";
|
||||
string tagAct = showAll ? "ALL" : "ACT";
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:ResList:{projDbId}:{tagEst}:{tagAct}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<ResourceModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<ResourceModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.ResourcesGetByProject(cString, projDbId, isEstim, showAll);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<ResourceModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ResourcesGetByProject | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ResourcesGetByProject:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
@@ -773,20 +839,77 @@ namespace MagMan.Data.Tenant.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse dato progetto e stato
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="projDbId">ID progetto</param>
|
||||
/// <param name="isEstim">true = ultima stima attiva / false = consumi effettivi</param>
|
||||
/// <param name="showAll">true= mostra ANCHE archiviate, false = solo attive</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ResourceModel>> ResourcesGetByProject(int nKey, int projDbId, bool isEstim, bool showAll)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<ResourceModel>? dbResult = new List<ResourceModel>();
|
||||
try
|
||||
{
|
||||
string tagEst = isEstim ? "EST" : "CON";
|
||||
string tagAct = showAll ? "ALL" : "ACT";
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:ResList:{projDbId}:{tagEst}:{tagAct}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<ResourceModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<ResourceModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.ResourcesGetByProject(cString, projDbId, isEstim, showAll);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<ResourceModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ResourcesGetByProject | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ResourcesGetByProject:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un record Resource
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>>
|
||||
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>
|
||||
/// >
|
||||
/// <param name="resState">Tipo di aggiornamento da registratre</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> ResourceUpdate(int nKey, List<ResourceModel> recList, Enums.ProjResState resState)
|
||||
public async Task<int> ResourceUpdate(int nKey, List<ResourceModel> recList, Enums.ProjResState resState, string userId)
|
||||
{
|
||||
int newId = 0;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
newId = dbController.ResourceUpdate(cString, recList, resState);
|
||||
newId = dbController.ResourceUpdate(cString, recList, resState, userId);
|
||||
if (newId > 0)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -11,15 +12,19 @@ namespace MagMan.UI.Components
|
||||
[Parameter]
|
||||
public RawItemModel? CurrRecord { get; set; } = null;
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
[Parameter]
|
||||
public EventCallback<bool> EC_update { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TenantService TService { get; set; } = null!;
|
||||
|
||||
@@ -27,24 +32,35 @@ namespace MagMan.UI.Components
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
await EC_update.InvokeAsync(true);
|
||||
}
|
||||
|
||||
protected async Task DoSave()
|
||||
{
|
||||
bool fatto = false;
|
||||
await Task.Delay(1);
|
||||
if (CurrRecord != null)
|
||||
{
|
||||
fatto = await TService.ItemUpdate(KeyNum, CurrRecord);
|
||||
fatto = await TService.ItemUpdate(KeyNum, CurrRecord, userName);
|
||||
}
|
||||
if (fatto)
|
||||
{
|
||||
await EC_update.InvokeAsync(true);
|
||||
}
|
||||
}
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
await EC_update.InvokeAsync(true);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string userName
|
||||
{
|
||||
get => AppMService.UserName;
|
||||
set => AppMService.UserName = value;
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@
|
||||
{
|
||||
<tr class="align-middle @CheckSel(item)">
|
||||
<td>
|
||||
@* <button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button> *@
|
||||
<button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
|
||||
</td>
|
||||
<td class="text-end fs-5">
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
RawItemId = selItem.MatId;
|
||||
RawItemId = selItem.RawItemId;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -220,7 +220,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
switch (sortField)
|
||||
{
|
||||
case "RawItemId":
|
||||
case "MovId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList();
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
|
||||
// file to you under the MIT license.
|
||||
using MagMan.Core.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
{
|
||||
public partial class LoginDisplay
|
||||
{
|
||||
#region Private Fields
|
||||
#region Protected Properties
|
||||
|
||||
private string userName = "";
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
#endregion Private Fields
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -26,6 +29,16 @@ namespace MagMan.UI.Components
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string userName
|
||||
{
|
||||
get => AppMService.UserName;
|
||||
set => AppMService.UserName = value;
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task forceReload()
|
||||
|
||||
@@ -55,10 +55,13 @@
|
||||
<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 class="text-end">W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th class="text-end">H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
@* <th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th> *@
|
||||
@* <th class="text-end"></th> *@
|
||||
<th class="text-end"><Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> W (mm)</th>
|
||||
<th class="text-end"><Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> H (mm)</th>
|
||||
@if (MaterialId == 0)
|
||||
{
|
||||
<th class="text-end"><Sorter ParamName="SizeNum" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Var.</th>
|
||||
<th class="text-end"><Sorter ParamName="QtyTot" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Qty</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -103,12 +106,15 @@
|
||||
<td class="text-end">
|
||||
@($"{item.HMm:N2}")
|
||||
</td>
|
||||
@* <td class="text-end">
|
||||
@($"{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> *@
|
||||
@if (MaterialId == 0)
|
||||
{
|
||||
<td class="text-end">
|
||||
@item.SizeNum
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@item.QtyTot
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
|
||||
// file to you under the MIT license.
|
||||
using EgwCoreLib.Razor;
|
||||
using MagMan.Core.DTO;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
@@ -47,7 +48,7 @@ namespace MagMan.UI.Components
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string CheckSel(MaterialModel curItem)
|
||||
protected string CheckSel(MaterialDTO curItem)
|
||||
{
|
||||
string answ = "";
|
||||
if (CurrItem != null)
|
||||
@@ -71,23 +72,26 @@ namespace MagMan.UI.Components
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected async Task DeleteRecord(MaterialModel selItem)
|
||||
protected async Task DeleteRecord(MaterialDTO selItem)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
|
||||
return;
|
||||
await TService.MaterialDelete(KeyNum, selItem);
|
||||
await TService.MaterialDelete(KeyNum, TService.MaterialFromDto(selItem));
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void DoEdit(MaterialModel? selItem)
|
||||
protected void DoEdit(MaterialDTO? selItem)
|
||||
{
|
||||
CurrItem = selItem;
|
||||
if (selItem == null)
|
||||
{
|
||||
DoSelect(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrItem = TService.MaterialFromDto(selItem);
|
||||
}
|
||||
}
|
||||
protected void DoSelect(MaterialModel? selItem)
|
||||
protected void DoSelect(MaterialDTO? selItem)
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
@@ -97,7 +101,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
MaterialId = 0;
|
||||
}
|
||||
E_MaterialSel.InvokeAsync(selItem);
|
||||
E_MaterialSel.InvokeAsync(TService.MaterialFromDto(selItem));
|
||||
}
|
||||
|
||||
protected async Task ForceReload(bool force)
|
||||
@@ -147,9 +151,9 @@ namespace MagMan.UI.Components
|
||||
|
||||
private string currSearch = "";
|
||||
private int filtType = 0;
|
||||
private List<MaterialModel>? ListRecords = null;
|
||||
private List<MaterialDTO>? ListRecords = null;
|
||||
|
||||
private List<MaterialModel>? SearchRecords = null;
|
||||
private List<MaterialDTO>? SearchRecords = null;
|
||||
|
||||
private bool sortAsc = true;
|
||||
|
||||
@@ -194,7 +198,7 @@ namespace MagMan.UI.Components
|
||||
isLoading = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
ListRecords = null;
|
||||
SearchRecords = await TService.MaterialGetAll(KeyNum, false);
|
||||
SearchRecords = await TService.MaterialDtoGetAll(KeyNum, false);
|
||||
// verifico se filtrare x beam/wall
|
||||
if (FiltType > 0)
|
||||
{
|
||||
@@ -220,7 +224,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
switch (sortField)
|
||||
{
|
||||
case "RawItemId":
|
||||
case "MovId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList();
|
||||
@@ -299,7 +303,7 @@ namespace MagMan.UI.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
ListRecords = new List<MaterialModel>();
|
||||
ListRecords = new List<MaterialDTO>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-2">
|
||||
<h5>Movimenti Magazzino</h5>
|
||||
</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>
|
||||
</div> *@
|
||||
</div>
|
||||
@* @if (CurrItem != null)
|
||||
{
|
||||
<hr />
|
||||
<ItemEdit CurrRecord="CurrItem" EC_update="ForceReload"></ItemEdit>
|
||||
} *@
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@if (ListRecords == null || isLoading)
|
||||
{
|
||||
<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="RawItemId" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Data <Sorter ParamName="Location" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th class="text-end"><Sorter ParamName="QtyRec" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Qty</th>
|
||||
<th class="text-end"><Sorter ParamName="Note" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Note</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<tr class="align-middle @CheckSel(item)">
|
||||
@* <td>
|
||||
<button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
|
||||
</td> *@
|
||||
<td>
|
||||
<small>@item.MovID</small>
|
||||
</td>
|
||||
<td>
|
||||
@item.DtRec.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
</td>
|
||||
<td class="text-end fs-5">
|
||||
<b>@item.QtyRec</b>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@item.Note
|
||||
<div class="small">
|
||||
@item.UserId
|
||||
</div>
|
||||
</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>
|
||||
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
using EgwCoreLib.Razor;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
{
|
||||
public partial class MovMag
|
||||
{
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int CustomerId { get; set; } = 0;
|
||||
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public int RawItemIdSel { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
protected TenantService TService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string CheckSel(MovMagModel curItem)
|
||||
{
|
||||
string answ = "";
|
||||
if (CurrItem != null)
|
||||
{
|
||||
answ = curItem.MovID == CurrItem.MovID ? "table-info" : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = curItem.MovID == MovId ? "table-info" : "";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
#if false
|
||||
protected async Task CreateNew()
|
||||
{
|
||||
CurrItem = new RawItemModel()
|
||||
{
|
||||
MatId = MaterialSel.MatId,
|
||||
Location = "nd",
|
||||
Note = "...",
|
||||
QtyAvail = 0,
|
||||
IsActive = true,
|
||||
IsRemn = false,
|
||||
HMm = MaterialSel.HMm,
|
||||
LMm = MaterialSel.LMm,
|
||||
WMm = MaterialSel.WMm
|
||||
};
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected async Task DeleteRecord(RawItemModel selItem)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
|
||||
return;
|
||||
await TService.ItemDelete(KeyNum, selItem);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void DoEdit(RawItemModel? selItem)
|
||||
{
|
||||
CurrItem = selItem;
|
||||
if (selItem == null)
|
||||
{
|
||||
DoSelect(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DoSelect(RawItemModel? selItem)
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
RawItemId = selItem.MatId;
|
||||
}
|
||||
else
|
||||
{
|
||||
RawItemId = 0;
|
||||
}
|
||||
E_RawItemSel.InvokeAsync(RawItemId);
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task ForceReload(bool force)
|
||||
{
|
||||
CurrItem = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
currSearch = "";
|
||||
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
CurrItem = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void SetNumRec(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
currPage = 1;
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected void SetPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected async Task SortRequested(Sorter.SortCallBack e)
|
||||
{
|
||||
sortField = e.ParamName;
|
||||
sortAsc = e.IsAscending;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private MovMagModel? CurrItem = null;
|
||||
private string currSearch = "";
|
||||
private int filtType = 0;
|
||||
private List<MovMagModel>? ListRecords = null;
|
||||
private int MovId = 0;
|
||||
private List<MovMagModel>? SearchRecords = null;
|
||||
|
||||
private bool sortAsc = true;
|
||||
|
||||
private string sortField = "";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private int FiltType
|
||||
{
|
||||
get => filtType;
|
||||
set
|
||||
{
|
||||
if (filtType != value)
|
||||
{
|
||||
filtType = value;
|
||||
InvokeAsync(ReloadData);
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async void AppMService_EA_SearchUpdated()
|
||||
{
|
||||
currSearch = AppMService.SearchVal;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
ListRecords = null;
|
||||
SearchRecords = await TService.MovMagGetFilt(KeyNum, RawItemIdSel, 1000);
|
||||
// verifico filtro per ricerca
|
||||
if (!string.IsNullOrEmpty(currSearch))
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => x.Note.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
SortTable();
|
||||
isLoading = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void SortTable()
|
||||
{
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
// se ho ordinamento riordino...
|
||||
if (!string.IsNullOrEmpty(sortField))
|
||||
{
|
||||
switch (sortField)
|
||||
{
|
||||
case "MovId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.RawItemId).ThenByDescending(x => x.Note).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "DtRec":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.DtRec).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.DtRec).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "QtyRec":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.QtyRec).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.QtyRec).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "Note":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.Note).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.Note).ToList();
|
||||
}
|
||||
break;
|
||||
case "UserId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.UserId).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.UserId).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// filtro x display
|
||||
ListRecords = SearchRecords
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ListRecords = new List<MovMagModel>();
|
||||
}
|
||||
}
|
||||
|
||||
private string textCss(bool isActive)
|
||||
{
|
||||
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace MagMan.UI.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
await TService.ItemUpdate(nKey, item);
|
||||
await TService.ItemUpdate(nKey, item, $"Key: {nKey}");
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -99,13 +99,14 @@ namespace MagMan.UI.Controllers
|
||||
{
|
||||
// recupero ID interno da id esterno...
|
||||
int ProjDbId = 0;
|
||||
ProjModel? projRec = null;
|
||||
var allProj = await TService.ProjectGetByMachine(nKey, 0);
|
||||
if (allProj != null)
|
||||
{
|
||||
var pRec = allProj.Find(x => x.ProjExtDbId == projectData.ProjExtDbId);
|
||||
if (pRec != null)
|
||||
projRec = allProj.Find(x => x.ProjExtDbId == projectData.ProjExtDbId);
|
||||
if (projRec != null)
|
||||
{
|
||||
ProjDbId = pRec.ProjDbId;
|
||||
ProjDbId = projRec.ProjDbId;
|
||||
}
|
||||
}
|
||||
if (ProjDbId > 0)
|
||||
@@ -127,8 +128,13 @@ namespace MagMan.UI.Controllers
|
||||
listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, reqId)).ToList();
|
||||
try
|
||||
{
|
||||
await TService.ResourceUpdate(nKey, listRes, projectData.ReqState);
|
||||
|
||||
string kDesc = $"K{nKey}";
|
||||
string prDesc = kDesc;
|
||||
if (projRec != null)
|
||||
{
|
||||
prDesc = $"P: {projRec.ProjExtId}.{projRec.ProjExtDbId} | {projRec.ProjDescription} ({projRec.Machine})";
|
||||
}
|
||||
await TService.ResourceUpdate(nKey, listRes, projectData.ReqState, $"{prDesc} | {kDesc}");
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.2401.2516</Version>
|
||||
<Version>1.0.2401.2519</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
}
|
||||
else if (CustomerID == 0)
|
||||
{
|
||||
<CmpCustomerUndef></CmpCustomerUndef>
|
||||
<CmpCustomerUndef></CmpCustomerUndef>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -19,7 +19,12 @@ else
|
||||
@if (MaterialSel != null)
|
||||
{
|
||||
<div class="col-6">
|
||||
<ItemMan CustomerId="@CustomerID" KeyNum="@nKey" MaterialSel="@MaterialSel"></ItemMan>
|
||||
<ItemMan CustomerId="@CustomerID" KeyNum="@nKey" MaterialSel="@MaterialSel" E_RawItemSel="SaveItem"></ItemMan>
|
||||
@if (RawItemId > 0)
|
||||
{
|
||||
<br />
|
||||
<MovMag CustomerId="@CustomerID" KeyNum="@nKey" RawItemIdSel="@RawItemId"></MovMag>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -48,12 +48,19 @@ namespace MagMan.UI.Pages
|
||||
MaterialSel = newMat;
|
||||
}
|
||||
|
||||
protected void SaveItem(int selRawItemId)
|
||||
{
|
||||
RawItemId = selRawItemId;
|
||||
}
|
||||
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private int KeyNum = 0;
|
||||
private MaterialModel? MaterialSel = null;
|
||||
private int RawItemId = 0;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MagMan - Wood Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2401.2516</h4>
|
||||
<h4>Versione: 1.0.2401.2519</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2401.2516
|
||||
1.0.2401.2519
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2401.2516</version>
|
||||
<version>1.0.2401.2519</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>
|
||||
|
||||
Reference in New Issue
Block a user