Continuo code cleanup metodi STATS
This commit is contained in:
@@ -54,63 +54,57 @@ namespace MP.Data.Controllers
|
||||
/// Stacca un nuovo counter x il tipo richiesto
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AnagCountersModel AnagCountersGetNext(string cntType)
|
||||
public async Task<AnagCountersModel> AnagCountersGetNextAsync(string cntType)
|
||||
{
|
||||
AnagCountersModel answ = new AnagCountersModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
bool outTable = true;
|
||||
if (outTable)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
|
||||
var dbResult = dbCtx
|
||||
var dbResult = await dbCtx
|
||||
.DbSetAnagCount
|
||||
.FromSqlRaw("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT", pCntType, pLastNum)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (dbResult != null)
|
||||
{
|
||||
answ = dbResult;
|
||||
}
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
answ = dbResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// se si volessero impiegare parametri OUTPUT (qui ne mancherebbe 1 nella stored x CntCode...)
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var pCntCode = new SqlParameter
|
||||
{
|
||||
ParameterName = "@CntCode",
|
||||
SqlDbType = SqlDbType.NVarChar,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT, @CntCode OUTPUT", pCntType, pLastNum, pCntCode);
|
||||
if (dbResult != 0)
|
||||
{
|
||||
answ.CntType = cntType;
|
||||
answ.CntCode = $"{pCntCode.Value}";
|
||||
int lNum = 0;
|
||||
int.TryParse($"{pLastNum.Value}", out lNum);
|
||||
answ.LastNum = lNum;
|
||||
}
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var pCntCode = new SqlParameter
|
||||
{
|
||||
ParameterName = "@CntCode",
|
||||
SqlDbType = SqlDbType.NVarChar,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT, @CntCode OUTPUT", pCntType, pLastNum, pCntCode);
|
||||
if (dbResult != 0)
|
||||
{
|
||||
answ.CntType = cntType;
|
||||
answ.CntCode = $"{pCntCode.Value}";
|
||||
int lNum = 0;
|
||||
int.TryParse($"{pLastNum.Value}", out lNum);
|
||||
answ.LastNum = lNum;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
@@ -782,25 +776,13 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="editRec">record dossier da modificare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DossiersInsert(DossierModel newRec)
|
||||
public async Task<bool> DossiersInsertAsync(DossierModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DossiersInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -832,21 +814,17 @@ namespace MP.Data.Controllers
|
||||
/// <param name="idxMacchina">macchina</param>
|
||||
/// <param name="dtMin">Data min x selezione</param>
|
||||
/// <param name="dtMax">Data MAX x selezione</param>
|
||||
public bool DossiersTakeParamsSnapshotLast(string idxMacchina, DateTime dtMin, DateTime dtMax)
|
||||
public async Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDtMin = new SqlParameter("@DtMin", dtMin);
|
||||
var pDtMax = new SqlParameter("@DtMax", dtMax);
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDtMin = new SqlParameter("@DtMin", dtMin);
|
||||
var pDtMax = new SqlParameter("@DtMax", dtMax);
|
||||
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC stp_FL_TakeSnapshotLast @IdxMacchina,@DtMin,@DtMax", pIdxMacchina, pDtMin, pDtMax);
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_FL_TakeSnapshotLast @IdxMacchina,@DtMin,@DtMax", pIdxMacchina, pDtMin, pDtMax);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -854,37 +832,25 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="editRec">record dossier da modificare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DossiersUpdateValore(DossierModel editRec)
|
||||
public async Task<bool> DossiersUpdateValoreAsync(DossierModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == editRec.IdxDossier)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Valore = editRec.Valore;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var currRec = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Add(editRec);
|
||||
}
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DossiersUpdateRecord{Environment.NewLine}{exc}");
|
||||
}
|
||||
.Where(x => x.IdxDossier == editRec.IdxDossier)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Valore = editRec.Valore;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
return fatto;
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -920,25 +886,14 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="newRec"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsert(EventListModel newRec)
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = dbCtx
|
||||
.DbSetEvList
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante EvListInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var currRec = await dbCtx
|
||||
.DbSetEvList
|
||||
.AddAsync(newRec);
|
||||
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -952,10 +907,10 @@ namespace MP.Data.Controllers
|
||||
/// <returns>
|
||||
/// Restitusice list dei record statistiche raccolti (da integrare a quelli rpesenti in Redis...)
|
||||
/// </returns>
|
||||
public async Task<List<StatDedupDTO>> FluxLogDataRedux(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem)
|
||||
public async Task<List<StatDedupDTO>> FluxLogDataReduxAsync(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem)
|
||||
{
|
||||
List<StatDedupDTO> procStats = new List<StatDedupDTO>();
|
||||
Log.Info($"Inizio FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
Log.Info($"Inizio FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
TimeSpan step = TimeSpan.FromHours(1);
|
||||
switch (intReq)
|
||||
{
|
||||
@@ -982,7 +937,7 @@ namespace MP.Data.Controllers
|
||||
// processo 1:1 ogni flusso
|
||||
foreach (var item in fluxList)
|
||||
{
|
||||
Log.Info($"FluxLogDataRedux | Flux: {item}");
|
||||
Log.Info($"FluxLogDataReduxAsync | Flux: {item}");
|
||||
int numRecProc = 0;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -1058,9 +1013,9 @@ namespace MP.Data.Controllers
|
||||
// parametri x periodo (base)
|
||||
var pDtStart = new SqlParameter("@DtStart", slot.Inizio);
|
||||
var pDtEnd = new SqlParameter("@DtEnd", slot.Fine);
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC man.stp_ReduceFluxLog @IdxMacchina, @CodFlux, @DtStart, @DtEnd, @OnlyTest", pIdxMacchina, pCodFlux, pDtStart, pDtEnd, pOnlyTest);
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC man.stp_ReduceFluxLog @IdxMacchina, @CodFlux, @DtStart, @DtEnd, @OnlyTest", pIdxMacchina, pCodFlux, pDtStart, pDtEnd, pOnlyTest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1083,7 +1038,7 @@ namespace MP.Data.Controllers
|
||||
};
|
||||
procStats.Add(currStat);
|
||||
}
|
||||
Log.Info($"FINE FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
Log.Info($"FINE FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
return procStats;
|
||||
}
|
||||
|
||||
@@ -1914,73 +1869,63 @@ namespace MP.Data.Controllers
|
||||
/// <param name="confRett">Conferma con rettifica (ev 121) x pezzi lasciati in macchina</param>
|
||||
/// <param name="modoConfProd">Modo conferma produzione (0=periodo, 1=giorno, 2=turno)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ODLClose(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd)
|
||||
public async Task<bool> ODLCloseAsync(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd)
|
||||
{
|
||||
bool fatto = false;
|
||||
await Task.Delay(1);
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
DateTime adesso = DateTime.Now;
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
|
||||
|
||||
// se richiesto confermo produzione
|
||||
if (confPezzi)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var MatrApp = new SqlParameter("@MatrApp", idxMacchina);
|
||||
|
||||
// FARE FIXME TODO !!! da valutare casi setup/autoconferma...
|
||||
#if false
|
||||
// controllo se HO pezzi da confermare...
|
||||
var statoProd = StatoProdMacchina(idxMacchina);
|
||||
if (statoProd.pezziNonConfermati < 1)
|
||||
{ }
|
||||
#endif
|
||||
/* ----------------------------------
|
||||
* CONFERMA PEZZI
|
||||
*
|
||||
* condizioni da verificare:
|
||||
* - gestione rettifica (ev121) / pezzi da LASCIARE in macchina
|
||||
* - conferma a zero pezzi (setup) oppure con i pezzi fatti e non ancora confermati
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
|
||||
// se richiesto confermo produzione
|
||||
if (confPezzi)
|
||||
{
|
||||
var MatrApp = new SqlParameter("@MatrApp", idxMacchina);
|
||||
// recupero i dati dei pezzi da confermare... con DbSetPzProd + exec
|
||||
// stp_PzProd_getByMacchina 'SIMUL_01'
|
||||
|
||||
/* ----------------------------------
|
||||
* CONFERMA PEZZI
|
||||
*
|
||||
* condizioni da verificare:
|
||||
* - gestione rettifica (ev121) / pezzi da LASCIARE in macchina
|
||||
* - conferma a zero pezzi (setup) oppure con i pezzi fatti e non ancora confermati
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
// stp_ConfermaProduzCompletaFull
|
||||
/*
|
||||
* @idxMacchina NVARCHAR(50),
|
||||
@MatrApp INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@pezziConf INT,
|
||||
@pezziLasciati INT, -- pezzi lasciati = evento 121 (-) pre conferma e (+) dopo --> da lasciare in macchina post conferma
|
||||
@pezziScar INT = 0, -- pezzi scartati (registrati da 2016.11.20) DA INDICARE COME VALORE > 0!!! sennò faccio ABS...
|
||||
@TipoConf INT = 0, -- Tipo intervallo conferma: 0 = periodo intero, 1 = per giorni, 2 = per turni
|
||||
@DataOraApp DATETIME = NULL, -- di norma GETDATE() nel programma - serve per ricalcolo
|
||||
@TestConferma BIT = 1 -- TestConferma : 1 = verifica conf. duplicata e inserisci in ElencoConfermeProd, 0 = nessuna verifica e inserimento ( per ricalcolo )
|
||||
*/
|
||||
}
|
||||
|
||||
// recupero i dati dei pezzi da confermare... con DbSetPzProd + exec
|
||||
// stp_PzProd_getByMacchina 'SIMUL_01'
|
||||
|
||||
// stp_ConfermaProduzCompletaFull
|
||||
/*
|
||||
* @idxMacchina NVARCHAR(50),
|
||||
@MatrApp INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@pezziConf INT,
|
||||
@pezziLasciati INT, -- pezzi lasciati = evento 121 (-) pre conferma e (+) dopo --> da lasciare in macchina post conferma
|
||||
@pezziScar INT = 0, -- pezzi scartati (registrati da 2016.11.20) DA INDICARE COME VALORE > 0!!! sennò faccio ABS...
|
||||
@TipoConf INT = 0, -- Tipo intervallo conferma: 0 = periodo intero, 1 = per giorni, 2 = per turni
|
||||
@DataOraApp DATETIME = NULL, -- di norma GETDATE() nel programma - serve per ricalcolo
|
||||
@TestConferma BIT = 1 -- TestConferma : 1 = verifica conf. duplicata e inserisci in ElencoConfermeProd, 0 = nessuna verifica e inserimento ( per ricalcolo )
|
||||
*/
|
||||
}
|
||||
|
||||
// ora chiudo ODL con stored SENZA ritorno...
|
||||
try
|
||||
{
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ODLClose{Environment.NewLine}{exc}");
|
||||
}
|
||||
// ora chiudo ODL con stored SENZA ritorno...
|
||||
try
|
||||
{
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina);
|
||||
fatto = dbResult != 0;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ODLCloseAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
@@ -2003,6 +1948,7 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco TUTTI GLI ODL
|
||||
/// </summary>
|
||||
@@ -2025,27 +1971,26 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche ODL calcolate (da stored stp_STAT_ODL)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<StatODLModel>> OdlStart(int IdxOdl)
|
||||
public async Task<List<StatODLModel>> OdlGetStatAsync(int IdxOdl)
|
||||
{
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetStatOdl
|
||||
.FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
dbResult = await dbCtx
|
||||
.DbSetStatOdl
|
||||
.FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
@@ -2128,27 +2073,15 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="idxPODL"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PODLModel> PODL_getByKey(int idxPODL)
|
||||
public async Task<PODLModel> PODL_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
PODLModel dbResult = new PODLModel();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante PODL_getByKey{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.FirstOrDefaultAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2355,45 +2288,34 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="currRec"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> PODLUpdateRecord(PODLModel editRec)
|
||||
public async Task<bool> PODLUpdateRecordAsync(PODLModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.CodGruppo = editRec.CodGruppo;
|
||||
currRec.CodArticolo = editRec.CodArticolo;
|
||||
currRec.IdxMacchina = editRec.IdxMacchina;
|
||||
currRec.KeyBCode = editRec.KeyBCode;
|
||||
currRec.KeyRichiesta = editRec.KeyRichiesta;
|
||||
currRec.NumPezzi = editRec.NumPezzi;
|
||||
currRec.Tcassegnato = editRec.Tcassegnato;
|
||||
currRec.Attivabile = editRec.Attivabile;
|
||||
currRec.Note = editRec.Note;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Add(editRec);
|
||||
}
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante PODLUpdateRecord{Environment.NewLine}{exc}");
|
||||
}
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.CodGruppo = editRec.CodGruppo;
|
||||
currRec.CodArticolo = editRec.CodArticolo;
|
||||
currRec.IdxMacchina = editRec.IdxMacchina;
|
||||
currRec.KeyBCode = editRec.KeyBCode;
|
||||
currRec.KeyRichiesta = editRec.KeyRichiesta;
|
||||
currRec.NumPezzi = editRec.NumPezzi;
|
||||
currRec.Tcassegnato = editRec.Tcassegnato;
|
||||
currRec.Attivabile = editRec.Attivabile;
|
||||
currRec.Note = editRec.Note;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
return fatto;
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetPODL
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2440,26 +2362,21 @@ namespace MP.Data.Controllers
|
||||
/// Elimina record
|
||||
/// </summary>
|
||||
/// <param name="rec2del"></param>
|
||||
public bool TemplateKitDelete(TemplateKitModel rec2del)
|
||||
public async Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
.FirstOrDefaultAsync();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
.FirstOrDefault();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetTempKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
dbCtx
|
||||
.DbSetTempKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return fatto;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user