Aggiunta registrazione tipii comvimento in mag
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -23,30 +24,6 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<bool> DatabaseMigrate(string connString)
|
||||
@@ -144,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))
|
||||
@@ -167,6 +148,16 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = deltaQty,
|
||||
UserId = userId,
|
||||
Note = deltaQty > 0 ? "M01+: Rettifica Inventariale" : "M01-: Rettifica Inventariale"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
|
||||
currData.QtyAvail += deltaQty;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
@@ -186,8 +177,9 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
/// </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))
|
||||
@@ -206,6 +198,22 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
int delta = rec2upd.QtyAvail - currData.QtyAvail;
|
||||
if (delta != 0)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = delta,
|
||||
UserId = userId,
|
||||
Note = delta > 0 ? "M02+: Rettifica Inventariale" : "M02-: Rettifica Inventariale"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
|
||||
// sistemo record...
|
||||
currData.MatId = rec2upd.MatId;
|
||||
currData.QtyAvail = rec2upd.QtyAvail;
|
||||
currData.IsActive = rec2upd.IsActive;
|
||||
@@ -222,6 +230,17 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
dbCtx
|
||||
.DbSetItems
|
||||
.Add(rec2upd);
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// aggiungo record variazione quantità...
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = rec2upd.QtyAvail,
|
||||
Note = rec2upd.QtyAvail > 0 ? "M03+: Aggiunta Record" : "M03+: Aggiunta Record"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
@@ -449,6 +468,29 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -770,10 +812,10 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</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))
|
||||
@@ -793,12 +835,45 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
// aggiorno
|
||||
if (currData != null)
|
||||
{
|
||||
if (resState == Enums.ProjResState.Consumed)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
int delta = rec2upd.Qty - currData.Qty;
|
||||
if (delta != 0)
|
||||
{
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = delta,
|
||||
UserId = userId,
|
||||
Note = delta > 0 ? "M04+: Aggiunta Risorsa" : "M04-: Consumo Risorsa"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
}
|
||||
|
||||
// aggiorno le risorse
|
||||
currData.Qty = rec2upd.Qty;
|
||||
currData.RawItemId = rec2upd.RawItemId;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resState == Enums.ProjResState.Consumed)
|
||||
{
|
||||
// aggiungo record variazione quantità...
|
||||
MovMagModel recMovMag = new MovMagModel()
|
||||
{
|
||||
DtRec = DateTime.Now,
|
||||
RawItemId = rec2upd.RawItemId,
|
||||
QtyRec = rec2upd.Qty,
|
||||
UserId = userId,
|
||||
Note = rec2upd.Qty > 0 ? "M05+: Aggiunta Risorsa" : "M05-: Consumo Risorsa"
|
||||
};
|
||||
dbCtx.DbSetMovMag.Add(recMovMag);
|
||||
}
|
||||
|
||||
// aggiungo record
|
||||
dbCtx
|
||||
.DbSetResources
|
||||
|
||||
@@ -206,70 +206,19 @@ namespace MagMan.Data.Tenant.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco MovMag dato Item
|
||||
/// Update record Item per quantità + refresh cache
|
||||
/// </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>
|
||||
/// <param name="currItem">Item interesato</param>
|
||||
/// <param name="userId">User corrente (SE applicabile)</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> 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)
|
||||
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();
|
||||
@@ -287,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();
|
||||
@@ -332,6 +282,64 @@ 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>
|
||||
@@ -413,64 +421,6 @@ namespace MagMan.Data.Tenant.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// Lista Materiali gestiti a magazzino
|
||||
/// </summary>
|
||||
@@ -555,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>
|
||||
@@ -780,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>
|
||||
@@ -890,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
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
RawItemId = selItem.MatId;
|
||||
RawItemId = selItem.RawItemId;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-2">
|
||||
<h3>Movimenti Magazzino</h3>
|
||||
<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 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>
|
||||
<hr />
|
||||
<ItemEdit CurrRecord="CurrItem" EC_update="ForceReload"></ItemEdit>
|
||||
} *@
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@@ -40,37 +40,36 @@
|
||||
<thead>
|
||||
<tr class="">
|
||||
@* <th>
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(null)"><i class="fa-solid fa-rotate"></i></button>
|
||||
</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>Note <Sorter ParamName="Note" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th class="text-end"><Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> User</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 class="text-end fs-5">
|
||||
<b>@item.MovID</b>
|
||||
@* <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>
|
||||
<td class="text-end fs-5">
|
||||
<b>@item.QtyRec</b>
|
||||
</td>
|
||||
<td>
|
||||
@item.Note
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@item.UserId
|
||||
@item.Note
|
||||
<div class="small">
|
||||
@item.UserId
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@@ -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.2518</Version>
|
||||
<Version>1.0.2401.2519</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
|
||||
@@ -22,6 +22,7 @@ else
|
||||
<ItemMan CustomerId="@CustomerID" KeyNum="@nKey" MaterialSel="@MaterialSel" E_RawItemSel="SaveItem"></ItemMan>
|
||||
@if (RawItemId > 0)
|
||||
{
|
||||
<br />
|
||||
<MovMag CustomerId="@CustomerID" KeyNum="@nKey" RawItemIdSel="@RawItemId"></MovMag>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MagMan - Wood Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2401.2518</h4>
|
||||
<h4>Versione: 1.0.2401.2519</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2401.2518
|
||||
1.0.2401.2519
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2401.2518</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