Update controller x usare scoped service x input in modalità connectionFactory x process input
This commit is contained in:
@@ -17,6 +17,10 @@ namespace MP.Data.Controllers
|
||||
public MpInveController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpInveController");
|
||||
}
|
||||
|
||||
@@ -84,6 +88,7 @@ namespace MP.Data.Controllers
|
||||
|
||||
#endregion gestione articoli
|
||||
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#region gestione config
|
||||
|
||||
/// <summary>
|
||||
@@ -93,7 +98,7 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -350,7 +355,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagOperatoriModel> ElencoOperatori()
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -372,7 +377,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -644,7 +649,7 @@ namespace MP.Data.Controllers
|
||||
InventorySessionModel dbResult = new InventorySessionModel();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.InveSessID == sessID)
|
||||
|
||||
@@ -13,13 +13,17 @@ using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
public class MpIocController /*: IDisposable*/
|
||||
public class MpIocController
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MpIocController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpIocController");
|
||||
}
|
||||
|
||||
@@ -39,7 +43,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmLogInsertAsync(DateTime dtRif, string machineId, string memAddress, int memIndex, int statusVal, string valDecoded)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var DtRif = new SqlParameter("@DtRif", dtRif);
|
||||
var MachineId = new SqlParameter("@MachineId", machineId);
|
||||
@@ -59,7 +63,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagStatiModel>> AnagStatiGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetAnagStati
|
||||
@@ -77,7 +81,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetLastByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var dbResult = await dbCtx
|
||||
@@ -103,7 +107,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AutoStartOdlAsync(int idxOdl, int MatrOpr, string idxMacchina, decimal tCRich, int pzPallet, string note, bool startNewOdl, int qtyRich, string keyRich)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxOdl = new SqlParameter("@idxOdl ", idxOdl);
|
||||
var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
|
||||
@@ -134,7 +138,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
|
||||
{
|
||||
await using var dbCtx = new MoonProContext(_configuration);
|
||||
await using var dbCtx = new MoonProContext(options);
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
@@ -165,7 +169,7 @@ namespace MP.Data.Controllers
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
// ✅ prima chiamata SYNC
|
||||
// ✅ prima chiamata ASYNC
|
||||
rigaTrans = (await dbCtx.DbSetSMES
|
||||
.FromSqlRaw(sql, pIdxMacchina, pIdxTipo)
|
||||
.AsNoTracking()
|
||||
@@ -220,7 +224,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ConfermaProdMacchinaAsync(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", DateTime.Now);
|
||||
@@ -263,7 +267,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ConfermaProdMacchinaFullAsync(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzLasciati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", DateTime.Now);
|
||||
@@ -322,7 +326,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
@@ -339,7 +343,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
bool fatto = false;
|
||||
var dbResult = dbCtx
|
||||
@@ -361,7 +365,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<DatiMacchineModel>> DatiMacchineGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetDatiMacchine
|
||||
@@ -384,7 +388,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DDB_InsStatoBatchAsync(string idxMacchina, DateTime inizioStato, int idxStato, string codArt, string value, int matrOpr, string pallet)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var InizioStato = new SqlParameter("@InizioStato", inizioStato);
|
||||
@@ -407,7 +411,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<DecNumArticoliModel>> DecNumArtGetFiltAsync(string codArt = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var query = dbCtx.DbSetDecNumArt
|
||||
.AsNoTracking()
|
||||
@@ -421,13 +425,6 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if false
|
||||
public void Dispose()
|
||||
{
|
||||
_configuration = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Stored x recuperare ultimi dossier macchina
|
||||
/// </summary>
|
||||
@@ -455,7 +452,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbCtx.DbSetEvList.Add(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
@@ -470,7 +467,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv)
|
||||
{
|
||||
// eseguo in transazione...
|
||||
await using var dbCtx = new MoonProContext(_configuration);
|
||||
await using var dbCtx = new MoonProContext(options);
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
@@ -608,7 +605,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> KeepAliveUpsertAsync(string IdxMacc, DateTime OraServer, DateTime OraMacc)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var currRec = await dbCtx
|
||||
.DbSetKeepAlive
|
||||
@@ -641,7 +638,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetLinkMenu
|
||||
@@ -661,7 +658,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<ListValuesModel>> ListValuesFiltAsync(string tabName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var query = dbCtx
|
||||
.DbSetListValues
|
||||
@@ -685,7 +682,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<Macchine2SlaveModel>> Macchine2SlaveAsync()
|
||||
{
|
||||
List<Macchine2SlaveModel> dbResult = new List<Macchine2SlaveModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetM2S
|
||||
@@ -703,7 +700,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MacchineModel>> MacchineGetAllAsync()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -715,7 +712,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<MacchineModel?> MacchineGetByIdxAsync(string IdxMacchina)
|
||||
{
|
||||
MacchineModel dbResult = null;
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -732,7 +729,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
@@ -766,7 +763,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> MacchineUpsertAsync(MacchineModel entity)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = await dbCtx
|
||||
@@ -794,7 +791,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MicroStatoMacchinaModel>> MicroStatoMacchinaGetByIdxMaccAsync(string IdxMacc)
|
||||
{
|
||||
List<MicroStatoMacchinaModel> dbResult = new List<MicroStatoMacchinaModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -812,7 +809,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> MicroStatoMacchinaUpsertAsync(MicroStatoMacchinaModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var actRec = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -845,7 +842,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
@@ -865,7 +862,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlAutoDayGenAsync(string idxMacchina, DateTime dataInizio, DateTime dataFine, string codArticolo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataInizio = new SqlParameter("@DataInizio", dataInizio);
|
||||
@@ -887,7 +884,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlAutoDayGenFullAsync(string idxMacchina, DateTime dataInizio, DateTime dataFine, string codArticolo, int? pzPODL, int? pzPallet, string? keyRichiesta, int? tcAssegnato, string? codGruppo, bool flgCreaPODL, bool flgCheckTC)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataInizio = new SqlParameter("@DataInizio", dataInizio);
|
||||
@@ -916,7 +913,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<ODLExpModel> OdlCurrByMaccAsync(string idxMacchina)
|
||||
{
|
||||
ODLExpModel answ = new();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
// attenzione: se la stored resituisce una tabella, il primo elemento va recuperato in RAM!!!
|
||||
@@ -939,7 +936,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var idxMaccParam = new SqlParameter("@IdxMacchina", idxMacchina ?? "");
|
||||
var numDayPrevParam = new SqlParameter("@NumDayPrev", numDayPrev);
|
||||
@@ -961,7 +958,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlFixMachineSlaveAsync(string idxMacchina, int numDayPrev, int doInsert)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var NumDayPrev = new SqlParameter("@NumDayPrev", numDayPrev);
|
||||
@@ -980,7 +977,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<ODLExpModel> OdlLastByMaccAsync(string idxMacchina)
|
||||
{
|
||||
ODLExpModel answ = new();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
// attenzione: se la stored resituisce una tabella, il primo elemento va recuperato in RAM!!!
|
||||
@@ -1004,7 +1001,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<ODLExpModel>> OdlListByMaccPeriodoAsync(string idxMacchina, DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataFrom = new SqlParameter("@dataFrom", dtStart);
|
||||
@@ -1026,7 +1023,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<PzProdModel> PezziProdMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
PzProdModel dbResult = new PzProdModel();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
dbResult = (await dbCtx
|
||||
@@ -1049,7 +1046,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<PODLExpModel>> POdlGetByMaccArtAsync(string idxMacchina, string codArticolo, string codGruppo, bool onlyFree)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", codArticolo);
|
||||
@@ -1072,7 +1069,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RecalcMseAsync(string idxMacchina, int maxAgeSec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var rigaProd = await StatoProdMacchinaAsync(idxMacchina, DateTime.Now);
|
||||
var MaxAgeSec = new SqlParameter("@maxAgeSec ", maxAgeSec);
|
||||
@@ -1096,7 +1093,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegControlliInsertAsync(string idxMacchina, int matrOpr, bool esitoOk, string note, DateTime dataOra)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
|
||||
@@ -1117,7 +1114,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegDichiarInsertAsync(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var TagCode = new SqlParameter("@TagCode", newRec.TagCode);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", newRec.IdxMacchina);
|
||||
@@ -1139,7 +1136,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegDichiarUpdateAsync(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var Original_IdxDich = new SqlParameter("@Original_IdxDich", newRec.IdxDich);
|
||||
var DtRec = new SqlParameter("@DtRec", newRec.DtRec);
|
||||
@@ -1160,7 +1157,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegScartiInsertAsync(RegistroScartiModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", newRec.IdxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra", newRec.DataOra);
|
||||
@@ -1187,7 +1184,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> RemRebootLogAddAndCleanAsync(RemoteRebootLogModel newRec, bool doClean, int num2keep)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
// 1. Transazione minima: SOLO INSERT + COMMIT
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
@@ -1230,7 +1227,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemRebootLogAddAsync(RemoteRebootLogModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -1245,7 +1242,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -1261,7 +1258,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetLastAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var dbResult = await dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_getLast")
|
||||
@@ -1276,7 +1273,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemRebootLogKeepLastAsync(int num2keep)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var pNum2Keep = new SqlParameter("@num2keep", num2keep);
|
||||
// La SP gestisce già la logica di soglia (1.5x), ma la specifico x sicurezza
|
||||
@@ -1294,7 +1291,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SignalLogInsertAsync(SignalLogModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var currRec = dbCtx
|
||||
.DbSetSignalLog
|
||||
@@ -1310,7 +1307,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneStatiModel>> SMES_getHwTransitionsAsync(string idxMacchina, int idxTipo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -1330,7 +1327,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneStatiModel>> SMES_getUserForcedAsync(string idxMacchina, int idxTipo)
|
||||
{
|
||||
await using var dbCtx = new MoonProContext(_configuration);
|
||||
await using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -1350,7 +1347,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneIngressiModel> StateMachineIngressi(int idxFam)
|
||||
{
|
||||
List<TransizioneIngressiModel> dbResult = new List<TransizioneIngressiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
dbResult = dbCtx
|
||||
@@ -1369,7 +1366,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneIngressiModel>> StateMachineIngressiAsync(int idxFam)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
var dbResult = await dbCtx
|
||||
@@ -1389,7 +1386,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<StatoProdModel> StatoProdMacchinaAsync(string idxMacchina, DateTime dtReq)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", dtReq);
|
||||
@@ -1409,7 +1406,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetMSFD
|
||||
@@ -1427,7 +1424,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<VMSFDModel?> VMSFDGetByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var dbResult = (await dbCtx
|
||||
@@ -1447,7 +1444,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetMultiByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(_configuration);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
|
||||
@@ -1465,9 +1462,16 @@ namespace MP.Data.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#if false
|
||||
public void Dispose()
|
||||
{
|
||||
_configuration = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZXing;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
@@ -24,6 +19,10 @@ namespace MP.Data.Controllers
|
||||
public MpLandController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviato MpLandController");
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ namespace MP.Data.Controllers
|
||||
// leggo per DB principale
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.All")))
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
@@ -113,7 +112,7 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception exc)
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AllDbInfo:{Environment.NewLine}{exc}");
|
||||
}
|
||||
@@ -127,7 +126,7 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -150,7 +149,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagOperatoriModel> ElencoOperatori()
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -169,7 +168,7 @@ namespace MP.Data.Controllers
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
using (MoonProContext localDbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
@@ -185,7 +184,7 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetAll()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -203,7 +202,7 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetLast()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -221,7 +220,7 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetLastNoMacc()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -262,8 +261,8 @@ namespace MP.Data.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace MP.Data.Controllers
|
||||
public MpMonController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpMonController");
|
||||
}
|
||||
|
||||
@@ -33,7 +38,7 @@ namespace MP.Data.Controllers
|
||||
public List<DbModels.StatsAnagArticoli> ArticoliGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<DbModels.StatsAnagArticoli> dbResult = new List<DbModels.StatsAnagArticoli>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetStatArticoli
|
||||
@@ -53,7 +58,7 @@ namespace MP.Data.Controllers
|
||||
public List<DbModels.ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<DbModels.ConfigModel> dbResult = new List<DbModels.ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -75,7 +80,7 @@ namespace MP.Data.Controllers
|
||||
public List<DbModels.MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<DbModels.MacchineModel> dbResult = new List<DbModels.MacchineModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -96,7 +101,7 @@ namespace MP.Data.Controllers
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
@@ -140,7 +145,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<DbModels.MappaStatoExplModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
@@ -161,7 +166,7 @@ namespace MP.Data.Controllers
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -183,8 +188,8 @@ namespace MP.Data.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ namespace MP.Data.Controllers
|
||||
public MpSpecController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpSpecController");
|
||||
}
|
||||
|
||||
@@ -36,7 +40,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagCountersModel> AnagCounters()
|
||||
{
|
||||
List<AnagCountersModel> dbResult = new List<AnagCountersModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagCount
|
||||
@@ -56,7 +60,7 @@ namespace MP.Data.Controllers
|
||||
bool outTable = true;
|
||||
if (outTable)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
@@ -81,7 +85,7 @@ namespace MP.Data.Controllers
|
||||
else
|
||||
{
|
||||
// se si volessero impiegare parametri OUTPUT (qui ne mancherebbe 1 nella stored x CntCode...)
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
@@ -121,7 +125,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelEventiBCodeModel> AnagEventiGeneral(string TableName = "EvList", string FieldName = "Common")
|
||||
{
|
||||
List<vSelEventiBCodeModel> dbResult = new List<vSelEventiBCodeModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
@@ -142,7 +146,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelEventiBCodeModel> AnagEventiGetByMacc(string IdxMac)
|
||||
{
|
||||
List<vSelEventiBCodeModel> dbResult = new List<vSelEventiBCodeModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacch = new SqlParameter("@idxMacchina", IdxMac);
|
||||
|
||||
@@ -172,7 +176,7 @@ namespace MP.Data.Controllers
|
||||
public bool AnagGruppiDelete(AnagGruppiModel updRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetAnagGruppi
|
||||
@@ -206,7 +210,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagGruppiModel> AnagGruppiGetAll()
|
||||
{
|
||||
List<AnagGruppiModel> dbResult = new List<AnagGruppiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagGruppi
|
||||
@@ -225,7 +229,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagGruppiModel> AnagGruppiGetTipo(string tipoGruppo)
|
||||
{
|
||||
List<AnagGruppiModel> dbResult = new List<AnagGruppiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagGruppi
|
||||
@@ -253,7 +257,7 @@ namespace MP.Data.Controllers
|
||||
public List<RepartiDTO> AnagGruppiRepartoDTO()
|
||||
{
|
||||
List<RepartiDTO> dbResult = new List<RepartiDTO>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
// in primis recupero i reparti...
|
||||
var listReparti = AnagGruppiGetTipo("REPARTO");
|
||||
@@ -292,7 +296,7 @@ namespace MP.Data.Controllers
|
||||
public bool AnagGruppiUpsert(AnagGruppiModel updRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetAnagGruppi
|
||||
@@ -323,7 +327,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagKeyValueModel> AnagKeyValGetAll()
|
||||
{
|
||||
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAKV
|
||||
@@ -379,7 +383,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> ArticoliDeleteRecord(AnagArticoliModel currRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -411,7 +415,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagArticoliModel> ArticoliGetByTipo(string tipo, string azienda = "*")
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -432,7 +436,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagArticoliModel> ArticoliGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -455,7 +459,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagArticoliModel> ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "")
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -475,7 +479,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagArticoliModel> ArticoliGetUsed()
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -494,7 +498,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -534,7 +538,7 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -553,7 +557,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new ConfigModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -576,7 +580,7 @@ namespace MP.Data.Controllers
|
||||
public List<DatiMacchineModel> DatiMacchineGetAll()
|
||||
{
|
||||
List<DatiMacchineModel> dbResult = new List<DatiMacchineModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetDatiMacchine
|
||||
@@ -776,7 +780,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagOperatoriModel> ElencoOperatori()
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -796,7 +800,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> EvListInsert(EventListModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1048,7 +1052,7 @@ namespace MP.Data.Controllers
|
||||
public bool Grp2MaccDelete(Gruppi2MaccModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetGrp2Macc
|
||||
@@ -1072,7 +1076,7 @@ namespace MP.Data.Controllers
|
||||
public bool Grp2MaccInsert(Gruppi2MaccModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetGrp2Macc
|
||||
@@ -1097,7 +1101,7 @@ namespace MP.Data.Controllers
|
||||
public bool Grp2OperDelete(Gruppi2OperModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetGrp2Oper
|
||||
@@ -1121,7 +1125,7 @@ namespace MP.Data.Controllers
|
||||
public bool Grp2OperInsert(Gruppi2OperModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var dbRec = dbCtx
|
||||
.DbSetGrp2Oper
|
||||
@@ -1145,7 +1149,7 @@ namespace MP.Data.Controllers
|
||||
public bool IstKitDelete(IstanzeKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInstKit
|
||||
@@ -1173,7 +1177,7 @@ namespace MP.Data.Controllers
|
||||
public List<IstanzeKitModel> IstKitFilt(string keyKit, string keyExtOrd)
|
||||
{
|
||||
List<IstanzeKitModel> dbResult = new List<IstanzeKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetInstKit
|
||||
@@ -1192,7 +1196,7 @@ namespace MP.Data.Controllers
|
||||
public bool IstKitInsertByWKS(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
@@ -1212,7 +1216,7 @@ namespace MP.Data.Controllers
|
||||
public bool IstKitUpsert(IstanzeKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInstKit
|
||||
@@ -1274,7 +1278,7 @@ namespace MP.Data.Controllers
|
||||
public List<LinkMenuModel> ListLinkAll()
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetLinkMenu
|
||||
@@ -1293,7 +1297,7 @@ namespace MP.Data.Controllers
|
||||
public List<LinkMenuModel> ListLinkFilt(string tipoLink)
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetLinkMenu
|
||||
@@ -1319,7 +1323,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLExpModel> ListODLFilt(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var InCorso = new SqlParameter("@InCorso", inCorso);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
@@ -1347,7 +1351,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODL_ByCodArt(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
@@ -1370,7 +1374,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODL_ByKitParent(int IdxPodlParent)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
@@ -1394,7 +1398,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODL_KitFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
@@ -1423,7 +1427,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
@@ -1450,7 +1454,7 @@ namespace MP.Data.Controllers
|
||||
public List<ListValuesModel> ListValuesFilt(string tabName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetListValues
|
||||
@@ -1472,7 +1476,7 @@ namespace MP.Data.Controllers
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
@@ -1522,7 +1526,7 @@ namespace MP.Data.Controllers
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
@@ -1577,27 +1581,6 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella MappaStatoExplModel
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<MappaStatoExplModel> MseGetAll(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetMSE
|
||||
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Aggiornamento record Microstato macchina
|
||||
/// </summary>
|
||||
@@ -1606,7 +1589,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> MicroStatoMacchinaUpsert(MicroStatoMacchinaModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -1633,6 +1616,26 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella MappaStatoExplModel
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<MappaStatoExplModel> MseGetAll(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetMSE
|
||||
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL dato batch selezionato
|
||||
/// </summary>
|
||||
@@ -1667,7 +1670,7 @@ namespace MP.Data.Controllers
|
||||
public ODLExpModel OdlByKey(int IdxOdl)
|
||||
{
|
||||
ODLExpModel dbResult = new ODLExpModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1701,7 +1704,7 @@ namespace MP.Data.Controllers
|
||||
await Task.Delay(1);
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
// preparo i parametri
|
||||
@@ -1776,7 +1779,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<ODLModel> OdlGetByKey(int idxOdl)
|
||||
{
|
||||
ODLModel dbResult = new ODLModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetODL
|
||||
@@ -1792,7 +1795,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLModel> OdlGetCurrent()
|
||||
{
|
||||
List<ODLModel> dbResult = new List<ODLModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetODL
|
||||
@@ -1809,7 +1812,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLModel> OdlListAll()
|
||||
{
|
||||
List<ODLModel> dbResult = new List<ODLModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1835,7 +1838,7 @@ namespace MP.Data.Controllers
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
@@ -1859,7 +1862,7 @@ namespace MP.Data.Controllers
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
@@ -1923,7 +1926,7 @@ namespace MP.Data.Controllers
|
||||
public PzProdModel PezziProdMacchina(string idxMacchina)
|
||||
{
|
||||
PzProdModel dbResult = new PzProdModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
dbResult = dbCtx
|
||||
@@ -1943,7 +1946,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<PODLModel> PODL_getByKey(int idxPODL)
|
||||
{
|
||||
PODLModel dbResult = new PODLModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1971,7 +1974,7 @@ namespace MP.Data.Controllers
|
||||
public PODLModel PODL_getByOdl(int idxODL)
|
||||
{
|
||||
PODLModel dbResult = new PODLModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2021,7 +2024,7 @@ namespace MP.Data.Controllers
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2066,7 +2069,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> PODL_updateRecipe(int idxPODL, string recipeName)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2118,7 +2121,7 @@ namespace MP.Data.Controllers
|
||||
InsertDate = currRec.InsertDate
|
||||
};
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2147,7 +2150,7 @@ namespace MP.Data.Controllers
|
||||
public bool PodlIstKitDelete(int IdxPODL)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
@@ -2167,7 +2170,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> PODLUpdateRecord(PODLModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2213,7 +2216,7 @@ namespace MP.Data.Controllers
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2238,7 +2241,7 @@ namespace MP.Data.Controllers
|
||||
public StatoMacchineModel StatoMacchina(string idxMacchina)
|
||||
{
|
||||
StatoMacchineModel dbResult = new StatoMacchineModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetStatoMacc
|
||||
@@ -2256,7 +2259,7 @@ namespace MP.Data.Controllers
|
||||
public bool TemplateKitDelete(TemplateKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetTempKit
|
||||
@@ -2284,7 +2287,7 @@ namespace MP.Data.Controllers
|
||||
public List<TemplateKitModel> TemplateKitFilt(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTempKit
|
||||
@@ -2303,7 +2306,7 @@ namespace MP.Data.Controllers
|
||||
public bool TemplateKitUpsert(TemplateKitModel editRec, string codAzienda)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
// verifico preliminarmente articolo...
|
||||
var recArt = dbCtx
|
||||
@@ -2363,7 +2366,7 @@ namespace MP.Data.Controllers
|
||||
List<TksScoreModel> dbResult = new List<TksScoreModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
var pMaxRes = new SqlParameter("@maxResult", MaxResult);
|
||||
@@ -2385,7 +2388,7 @@ namespace MP.Data.Controllers
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
@@ -2403,7 +2406,7 @@ namespace MP.Data.Controllers
|
||||
public bool WipKitDelete(WipSetupKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
@@ -2429,7 +2432,7 @@ namespace MP.Data.Controllers
|
||||
public bool WipKitDeleteGroup(string KeyFilt)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
@@ -2456,7 +2459,7 @@ namespace MP.Data.Controllers
|
||||
public bool WipKitDeleteOlder(DateTime dateLimit)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
@@ -2486,7 +2489,7 @@ namespace MP.Data.Controllers
|
||||
// solo se filtro valido...
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetWipKit
|
||||
@@ -2505,7 +2508,7 @@ namespace MP.Data.Controllers
|
||||
public bool WipKitUpsert(WipSetupKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
@@ -2538,8 +2541,8 @@ namespace MP.Data.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace MP.Data.Controllers
|
||||
public MpTabController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviato MpTabController");
|
||||
}
|
||||
|
||||
@@ -40,7 +44,7 @@ namespace MP.Data.Controllers
|
||||
public bool AlarmLogInsert(DateTime dtRif, string machineId, string memAddress, int memIndex, int statusVal, string valDecoded)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var DtRif = new SqlParameter("@DtRif", dtRif);
|
||||
var MachineId = new SqlParameter("@MachineId", machineId);
|
||||
@@ -68,7 +72,7 @@ namespace MP.Data.Controllers
|
||||
public List<AlarmLogModel> AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti)
|
||||
{
|
||||
List<AlarmLogModel> dbResult = new List<AlarmLogModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DtFrom = new SqlParameter("@dtFrom", dtFrom);
|
||||
@@ -94,7 +98,7 @@ namespace MP.Data.Controllers
|
||||
public bool AlarmLogSetAck(int alarmLogId, DateTime dtAck, string userAck)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var AlarmLogId = new SqlParameter("@MachineId", alarmLogId);
|
||||
var DtAck = new SqlParameter("@DtRif", dtAck);
|
||||
@@ -117,7 +121,7 @@ namespace MP.Data.Controllers
|
||||
public bool AlarmLogSetNotify(int alarmLogId, DateTime dtNotify)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var AlarmLogId = new SqlParameter("@MachineId", alarmLogId);
|
||||
var DtNotify = new SqlParameter("@DtNotify", dtNotify);
|
||||
@@ -137,7 +141,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagEventiModel> AnagEventiGetAll()
|
||||
{
|
||||
List<AnagEventiModel> dbResult = new List<AnagEventiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagEventi
|
||||
@@ -154,7 +158,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelEventiBCodeModel> AnagEventiGetByMacc(string IdxMac)
|
||||
{
|
||||
List<vSelEventiBCodeModel> dbResult = new List<vSelEventiBCodeModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacch = new SqlParameter("@idxMacchina", IdxMac);
|
||||
|
||||
@@ -175,7 +179,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagStatiModel> AnagStatiGetAll()
|
||||
{
|
||||
List<AnagStatiModel> dbResult = new List<AnagStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagStati
|
||||
@@ -192,7 +196,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagTagsModel> AnagTagsOrd()
|
||||
{
|
||||
List<AnagTagsModel> dbResult = new List<AnagTagsModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagTags
|
||||
@@ -214,7 +218,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagArticoliModel> ArticoliGetByTipo(string tipo, string azienda = "*")
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -319,7 +323,7 @@ namespace MP.Data.Controllers
|
||||
public List<CommentiModel> CommentiGetLastByMacc(string idxMacchina, int numDays)
|
||||
{
|
||||
List<CommentiModel> dbResult = new List<CommentiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var NumDays = new SqlParameter("@NumDays", numDays);
|
||||
@@ -351,7 +355,7 @@ namespace MP.Data.Controllers
|
||||
try
|
||||
{
|
||||
var rigaProd = StatoProdMacchina(idxMacchina, DateTime.Now);
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
|
||||
var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
|
||||
@@ -398,7 +402,7 @@ namespace MP.Data.Controllers
|
||||
try
|
||||
{
|
||||
var rigaProd = StatoProdMacchina(idxMacchina, DateTime.Now);
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
|
||||
var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
|
||||
@@ -433,7 +437,7 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -457,7 +461,7 @@ namespace MP.Data.Controllers
|
||||
public bool DDB_DoRecalc(string idxMacchina, DateTime inizio, int idxStatoStart, int nStepEventi, int nRecCheck, bool checkOnly)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var Inizio = new SqlParameter("@inizio", inizio);
|
||||
@@ -485,7 +489,7 @@ namespace MP.Data.Controllers
|
||||
public DiarioDiBordoModel DDB_getNext(string idxMacchina, DateTime inizioStato)
|
||||
{
|
||||
DiarioDiBordoModel dbResult = new DiarioDiBordoModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataRif = new SqlParameter("@dataRif", inizioStato);
|
||||
@@ -514,7 +518,7 @@ namespace MP.Data.Controllers
|
||||
public bool DDB_InsStatoBatch(string idxMacchina, DateTime inizioStato, int idxStato, string codArt, string value, int matrOpr, string pallet)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var InizioStato = new SqlParameter("@InizioStato", inizioStato);
|
||||
@@ -549,7 +553,7 @@ namespace MP.Data.Controllers
|
||||
public List<ElencoConfermeProdModel> ElencoConfProdFilt(string idxMacchina, DateTime dataFrom, DateTime dataTo)
|
||||
{
|
||||
List<ElencoConfermeProdModel> dbResult = new List<ElencoConfermeProdModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetElConfProd
|
||||
@@ -595,7 +599,7 @@ namespace MP.Data.Controllers
|
||||
public List<AnagOperatoriModel> ElencoOperatori()
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -617,7 +621,7 @@ namespace MP.Data.Controllers
|
||||
public bool EvListDelete(string idxMacchina, DateTime dtEvento, int idxTipo)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var InizioStato = new SqlParameter("@InizioStato", dtEvento);
|
||||
@@ -651,7 +655,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<EventListModel>> EvListGetLastBySearch(string idxMacchina, DateTime dtLimit, int idxTipo, int maxRec)
|
||||
{
|
||||
List<EventListModel> dbResult = new List<EventListModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetEvList
|
||||
@@ -673,7 +677,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> EvListInsert(EventListModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -701,7 +705,7 @@ namespace MP.Data.Controllers
|
||||
public List<FermiNonQualModel> FermiNonQualificatiFilt(string idxMacchina, int gg, double durataMin)
|
||||
{
|
||||
List<FermiNonQualModel> dbResult = new List<FermiNonQualModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var GG = new SqlParameter("@gg", gg);
|
||||
@@ -724,7 +728,7 @@ namespace MP.Data.Controllers
|
||||
public bool InsManDelete(InsManualiModel currRecord)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInsManuali
|
||||
@@ -753,7 +757,7 @@ namespace MP.Data.Controllers
|
||||
public List<InsManualiModel> InsManFilt(string IdxMacc, DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
List<InsManualiModel> dbResult = new List<InsManualiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetInsManuali
|
||||
@@ -773,7 +777,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> InsManFreezeDay(string idxMacchina, DateTime dtCurr)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataElab = new SqlParameter("@pDataOra", dtCurr);
|
||||
@@ -794,7 +798,7 @@ namespace MP.Data.Controllers
|
||||
public bool InsManUpsert(InsManualiModel currRecord)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInsManuali
|
||||
@@ -835,7 +839,7 @@ namespace MP.Data.Controllers
|
||||
public bool InsManUpsert(List<InsManualiModel> listRecord)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
foreach (var currRecord in listRecord)
|
||||
{
|
||||
@@ -880,7 +884,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODL_ByKitParent(int IdxPodlParent)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
@@ -903,7 +907,7 @@ namespace MP.Data.Controllers
|
||||
public List<PODLExpModel> ListPODLByMacc(string idxMacchina, bool onlyFree, bool onlyDirect)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var OnlyFree = new SqlParameter("@onlyFree", onlyFree);
|
||||
@@ -927,7 +931,7 @@ namespace MP.Data.Controllers
|
||||
public List<ListValuesModel> ListValuesFilt(string tabName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetListValues
|
||||
@@ -948,7 +952,7 @@ namespace MP.Data.Controllers
|
||||
public bool MacchinaSetInsEnab(string idxMacchina, bool insEnabled)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
|
||||
var InsEnabled = new SqlParameter("@insEnabled", insEnabled);
|
||||
@@ -969,7 +973,7 @@ namespace MP.Data.Controllers
|
||||
public List<Macchine2SlaveModel> Macchine2Slave()
|
||||
{
|
||||
List<Macchine2SlaveModel> dbResult = new List<Macchine2SlaveModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetM2S
|
||||
@@ -990,7 +994,7 @@ namespace MP.Data.Controllers
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
@@ -1038,7 +1042,7 @@ namespace MP.Data.Controllers
|
||||
public MicroStatoMacchinaModel MicroStatoMacchina(string idxMacchina)
|
||||
{
|
||||
MicroStatoMacchinaModel dbResult = new MicroStatoMacchinaModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -1058,7 +1062,7 @@ namespace MP.Data.Controllers
|
||||
public List<MicroStatoMacchinaModel> MicroStatoMacchinaGetAll()
|
||||
{
|
||||
List<MicroStatoMacchinaModel> dbResult = new List<MicroStatoMacchinaModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -1076,7 +1080,7 @@ namespace MP.Data.Controllers
|
||||
public bool MicroStatoMacchinaUpsert(MicroStatoMacchinaModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -1112,7 +1116,7 @@ namespace MP.Data.Controllers
|
||||
public List<MappaStatoExplModel> MseGetSub(string idxMacc, string idxMacchSub)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1141,7 +1145,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLExpModel> OdlByIdx(int idxOdl, bool onlyUnused)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1170,7 +1174,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlClearSetup(int idxODL, string idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1197,7 +1201,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLExpModel> OdlCurrByMacc(string idxMacchina)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1226,7 +1230,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlDividiDaAltraTavola(int idxODL, int matrOpr, string idxMacchinaTo)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1256,7 +1260,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlFineProd(int idxODL, string idxMacchina, DateTime dtRif)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1286,7 +1290,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1319,7 +1323,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlInizioSetup(int idxODL, int matrOpr, string idxMacchina, decimal tcRich, int pzPallet, string note)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1350,7 +1354,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLModel> OdlLastByMacc(string idxMacchina)
|
||||
{
|
||||
List<ODLModel> dbResult = new List<ODLModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1379,7 +1383,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLExpModel> OdlListByMaccPeriodo(string idxMacchina, DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1408,7 +1412,7 @@ namespace MP.Data.Controllers
|
||||
public List<ODLModel> OdlReopenOdlMacc(string idxMacchina)
|
||||
{
|
||||
List<ODLModel> dbResult = new List<ODLModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1436,7 +1440,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlSetupPostumo(int idxODL, string idxMacchina)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1465,7 +1469,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlSetupPromPostuma(int idxPromOdl, int matrOpr, string idxMacchina)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1500,7 +1504,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlSplit(int idxODL, int matrOpr, string idxMacchina, decimal TCRich, int pzPallet, string note, bool startNewOdl, int qtyRich)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1537,7 +1541,7 @@ namespace MP.Data.Controllers
|
||||
public bool OdlUpdate(int idxODL, int matrOpr, decimal tCRichAttr, int pzPallet, string note)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1571,7 +1575,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
AnagOperatoriModel dbResult = null;
|
||||
AnagOperatoriModel answ = new AnagOperatoriModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
@@ -1594,7 +1598,7 @@ namespace MP.Data.Controllers
|
||||
public List<PzProdModel> PezziProdMacchina(string idxMacchina)
|
||||
{
|
||||
List<PzProdModel> dbResult = new List<PzProdModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
try
|
||||
@@ -1644,7 +1648,7 @@ namespace MP.Data.Controllers
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1688,7 +1692,7 @@ namespace MP.Data.Controllers
|
||||
public PODLExpModel PODLExp_getByKey(int idxPODL)
|
||||
{
|
||||
PODLExpModel dbResult = new PODLExpModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1719,7 +1723,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<PODLExpModel> PODLExp_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
PODLExpModel dbResult = new PODLExpModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1753,7 +1757,7 @@ namespace MP.Data.Controllers
|
||||
public List<RegistroControlliModel> RegControlliFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti)
|
||||
{
|
||||
List<RegistroControlliModel> dbResult = new List<RegistroControlliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
@@ -1782,7 +1786,7 @@ namespace MP.Data.Controllers
|
||||
public bool RegControlliInsert(string idxMacchina, int matrOpr, bool esitoOk, string note, DateTime dataOra)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
|
||||
@@ -1804,7 +1808,7 @@ namespace MP.Data.Controllers
|
||||
public List<RegistroControlliModel> RegControlliLast(string idxMacchina)
|
||||
{
|
||||
List<RegistroControlliModel> dbResult = new List<RegistroControlliModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
|
||||
@@ -1829,7 +1833,7 @@ namespace MP.Data.Controllers
|
||||
public List<RegistroDichiarazioniModel> RegDichiarGetFilt(string idxMacchina, string tagCode, int matrOpr, int idxODL, DateTime dataFrom, DateTime dataTo)
|
||||
{
|
||||
List<RegistroDichiarazioniModel> dbResult = new List<RegistroDichiarazioniModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var TagCode = new SqlParameter("@TagCode", tagCode);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
@@ -1855,7 +1859,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> RegDichiarInsert(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var TagCode = new SqlParameter("@TagCode", newRec.TagCode);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", newRec.IdxMacchina);
|
||||
@@ -1880,7 +1884,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> RegDichiarUpdate(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var Original_IdxDich = new SqlParameter("@Original_IdxDich", newRec.IdxDich);
|
||||
var DtRec = new SqlParameter("@DtRec", newRec.DtRec);
|
||||
@@ -1909,7 +1913,7 @@ namespace MP.Data.Controllers
|
||||
public List<RegistroScartiModel> RegScartiGetFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti)
|
||||
{
|
||||
List<RegistroScartiModel> dbResult = new List<RegistroScartiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
@@ -1934,7 +1938,7 @@ namespace MP.Data.Controllers
|
||||
public bool RegScartiInsert(RegistroScartiModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", newRec.IdxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra", newRec.DataOra);
|
||||
@@ -1963,7 +1967,7 @@ namespace MP.Data.Controllers
|
||||
public bool RegScartiKitDelete(RegistroScartiModel parentRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina);
|
||||
var DtRif = new SqlParameter("@DataOra", parentRec.DataOra);
|
||||
@@ -1986,7 +1990,7 @@ namespace MP.Data.Controllers
|
||||
public List<RegistroScartiKitModel> RegScartiKitGetFilt(RegistroScartiModel parentRec)
|
||||
{
|
||||
List<RegistroScartiKitModel> dbResult = new List<RegistroScartiKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina);
|
||||
var DtRif = new SqlParameter("@DataRif", parentRec.DataOra);
|
||||
@@ -2010,7 +2014,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
await Task.Delay(1);
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", newRec.IdxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra", newRec.DataOra);
|
||||
@@ -2037,7 +2041,7 @@ namespace MP.Data.Controllers
|
||||
public bool RegScartiKitUpdateQty(RegistroScartiKitModel currRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", currRec.IdxMacchina);
|
||||
var DtRif = new SqlParameter("@DataOra", currRec.DataOra);
|
||||
@@ -2066,7 +2070,7 @@ namespace MP.Data.Controllers
|
||||
try
|
||||
{
|
||||
var rigaProd = StatoProdMacchina(idxMacchina, DateTime.Now);
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var MaxAgeSec = new SqlParameter("@maxAgeSec ", maxAgeSec);
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
|
||||
@@ -2098,7 +2102,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> RipristinaStatoPrec(string idxMacchina, DateTime dtCurr, string valore, int idxStato = 0, int matrOpr = 0)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDataOra = new SqlParameter("@DataOra", dtCurr);
|
||||
@@ -2139,7 +2143,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneStatiModel> SMES_GetAll()
|
||||
{
|
||||
List<TransizioneStatiModel> dbResult = new List<TransizioneStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetSMES
|
||||
@@ -2156,7 +2160,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneStatiModel> SMES_GetByFam(int idxFam)
|
||||
{
|
||||
List<TransizioneStatiModel> dbResult = new List<TransizioneStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetSMES
|
||||
@@ -2175,7 +2179,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneStatiModel> SMES_getHwTransitions(string idxMacchina, int idxTipo)
|
||||
{
|
||||
List<TransizioneStatiModel> dbResult = new List<TransizioneStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -2197,7 +2201,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneStatiModel> SMES_getUserForced(string idxMacchina, int idxTipo)
|
||||
{
|
||||
List<TransizioneStatiModel> dbResult = new List<TransizioneStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -2218,7 +2222,7 @@ namespace MP.Data.Controllers
|
||||
public List<ST_AnagGruppi> ST_AnagGruppiList()
|
||||
{
|
||||
List<ST_AnagGruppi> dbResult = new List<ST_AnagGruppi>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetStAnagGruppi
|
||||
@@ -2232,7 +2236,7 @@ namespace MP.Data.Controllers
|
||||
public bool ST_CheckCleanByOdl(int idxOdl)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxOdl = new SqlParameter("@IdxOdl", idxOdl);
|
||||
|
||||
@@ -2247,7 +2251,7 @@ namespace MP.Data.Controllers
|
||||
public bool ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxOdl = new SqlParameter("@IdxOdl", idxOdl);
|
||||
var IdxST = new SqlParameter("@IdxST", idxST);
|
||||
@@ -2276,7 +2280,7 @@ namespace MP.Data.Controllers
|
||||
public List<ST_ActRow> STAR_byGrpOdl(string codGruppo, int idxODL)
|
||||
{
|
||||
List<ST_ActRow> dbResult = new List<ST_ActRow>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var CodGruppo = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
@@ -2301,7 +2305,7 @@ namespace MP.Data.Controllers
|
||||
public List<ST_ActRow> STAR_byGrpOdlLbl(string codGruppo, string label, int idxODL)
|
||||
{
|
||||
List<ST_ActRow> dbResult = new List<ST_ActRow>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var CodGruppo = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var Label = new SqlParameter("@Label", label);
|
||||
@@ -2325,7 +2329,7 @@ namespace MP.Data.Controllers
|
||||
public List<ST_ActRow> STAR_pendByOdl(int idxODL)
|
||||
{
|
||||
List<ST_ActRow> dbResult = new List<ST_ActRow>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
|
||||
@@ -2347,7 +2351,7 @@ namespace MP.Data.Controllers
|
||||
public List<TransizioneIngressiModel> StateMachineIngressi(int idxFam)
|
||||
{
|
||||
List<TransizioneIngressiModel> dbResult = new List<TransizioneIngressiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
dbResult = dbCtx
|
||||
@@ -2368,7 +2372,7 @@ namespace MP.Data.Controllers
|
||||
public StatoMacchineModel StatoMacchina(string idxMacchina)
|
||||
{
|
||||
StatoMacchineModel dbResult = new StatoMacchineModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetStatoMacc
|
||||
@@ -2388,7 +2392,7 @@ namespace MP.Data.Controllers
|
||||
public StatoProdModel StatoProdMacchina(string idxMacchina, DateTime dtReq)
|
||||
{
|
||||
StatoProdModel dbResult = new StatoProdModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", dtReq);
|
||||
@@ -2413,7 +2417,7 @@ namespace MP.Data.Controllers
|
||||
public List<TemplateKitModel> TemplateKitFilt(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTempKit
|
||||
@@ -2432,7 +2436,7 @@ namespace MP.Data.Controllers
|
||||
public TurniMaccModel TurnoMacchinaGet(string idxMacchina)
|
||||
{
|
||||
TurniMaccModel dbResult = new TurniMaccModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
dbResult = dbCtx
|
||||
@@ -2452,7 +2456,7 @@ namespace MP.Data.Controllers
|
||||
public List<TurniMaccModel> TurnoMacchinaGetAll()
|
||||
{
|
||||
List<TurniMaccModel> dbResult = new List<TurniMaccModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTurniMacc
|
||||
@@ -2471,7 +2475,7 @@ namespace MP.Data.Controllers
|
||||
public bool TurnoMacchinaToggle(string idxMacchina, int numTurno)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var NumTurno = new SqlParameter("@numTurno", numTurno);
|
||||
@@ -2493,7 +2497,7 @@ namespace MP.Data.Controllers
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
@@ -2511,7 +2515,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelCauScartoModel> VSCS_getAll()
|
||||
{
|
||||
List<vSelCauScartoModel> dbResult = new List<vSelCauScartoModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVSCS
|
||||
@@ -2530,7 +2534,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelOdlModel> VSOdlGetLastByMacc(string idxMacchina, int numRec)
|
||||
{
|
||||
List<vSelOdlModel> dbResult = new List<vSelOdlModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var NumRec = new SqlParameter("@numRec", numRec);
|
||||
@@ -2554,7 +2558,7 @@ namespace MP.Data.Controllers
|
||||
public List<vSelOdlModel> VSOdlGetUnused(string idxMacchina, bool showAll, int numDayAdd)
|
||||
{
|
||||
List<vSelOdlModel> dbResult = new List<vSelOdlModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var ShowAll = new SqlParameter("@showAll", showAll);
|
||||
@@ -2574,8 +2578,8 @@ namespace MP.Data.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.Repository.IOC;
|
||||
using MP.Data.Repository.Mtc;
|
||||
using MP.Data.Repository.Utils;
|
||||
using MP.Data.Services.IOC;
|
||||
using MP.Data.Services.Mtc;
|
||||
using MP.Data.Services.Utils;
|
||||
|
||||
@@ -25,6 +27,7 @@ namespace MP.Data
|
||||
services.TryAddSingleton<IMtcSetupRepository, MtcSetupRepository>();
|
||||
|
||||
// Repository Scoped
|
||||
services.TryAddScoped<IIocRepository, IocRepository>();
|
||||
services.TryAddScoped<IStatsAggrRepository, StatsAggrRepository>();
|
||||
services.TryAddScoped<IStatsDetailRepository, StatsDetailRepository>();
|
||||
|
||||
@@ -33,6 +36,7 @@ namespace MP.Data
|
||||
services.TryAddSingleton<MpIocController>();
|
||||
|
||||
// Servizi Scoped
|
||||
services.TryAddScoped<IIocService, IocService>();
|
||||
services.TryAddScoped<IStatsAggrService, StatsAggrService>();
|
||||
services.TryAddScoped<IStatsDetailService, StatsDetailService>();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" >
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -22,10 +22,16 @@ namespace MP.Data
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MoonProContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
//public MoonProContext(IConfiguration configuration)
|
||||
//{
|
||||
// _configuration = configuration;
|
||||
//}
|
||||
|
||||
//public MoonProContext(DbContextOptions<MoonProContext> options, IConfiguration configuration)
|
||||
//: base(options)
|
||||
//{
|
||||
// _configuration = configuration;
|
||||
//}
|
||||
|
||||
public MoonProContext(DbContextOptions<MoonProContext> options) : base(options)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.IOC
|
||||
{
|
||||
public abstract class BaseRepository : IBaseRepository
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
protected BaseRepository(IDbContextFactory<MoonProContext> ctxFactory)
|
||||
=> _ctxFactory = ctxFactory;
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Creazione dbcontext per singola transazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<MoonProContext> CreateContextAsync()
|
||||
=> await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Salvataggio dati asincrono
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SaveChangesAsync(DataLayerContext ctx)
|
||||
=> await ctx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected readonly DataLayerContext _dbCtx;
|
||||
protected BaseRepository(DataLayerContext db) => _dbCtx = db;
|
||||
public async Task<bool> SaveChangesAsync() => await _dbCtx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace MP.Data.Repository
|
||||
namespace MP.Data.Repository.IOC
|
||||
{
|
||||
public interface IBaseRepository
|
||||
{
|
||||
@@ -0,0 +1,39 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Repository.IOC
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per metodi IOC
|
||||
/// </summary>
|
||||
public interface IIocRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processing intera catena eventi verifica cambio stato in singola transazione e con unico DbContext
|
||||
/// </summary>
|
||||
/// <param name="tipoInput"></param>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="InizioStato"></param>
|
||||
/// <param name="IdxTipo"></param>
|
||||
/// <param name="CodArt"></param>
|
||||
/// <param name="Value"></param>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <param name="pallet"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet);
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta record MicroStato + EventList
|
||||
/// </summary>
|
||||
/// <param name="newRecMsm"></param>
|
||||
/// <param name="newRecEv"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Repository.IOC
|
||||
{
|
||||
public class IocRepository : BaseRepository, IIocRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public IocRepository(IDbContextFactory<MoonProContext> ctxFactory) : base(ctxFactory)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync(IsolationLevel.ReadCommitted);
|
||||
//await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
{
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", IdxMacchina);
|
||||
var pIdxTipo = new SqlParameter("@IdxTipo", IdxTipo);
|
||||
var pInizioStato = new SqlParameter("@InizioStato", InizioStato);
|
||||
var pCodArticolo = new SqlParameter("@codArticolo", CodArt);
|
||||
var pValue = new SqlParameter("@Value", Value);
|
||||
var pMatrOpr = new SqlParameter("@MatrOpr", MatrOpr);
|
||||
var pPallet = new SqlParameter("@pallet", pallet);
|
||||
|
||||
string opType = tipoInput switch
|
||||
{
|
||||
tipoInputEvento.barcode => "BARCODE",
|
||||
tipoInputEvento.hw => "HW",
|
||||
_ => "ND"
|
||||
};
|
||||
|
||||
TransizioneStatiModel? rigaTrans = null;
|
||||
|
||||
if (opType != "ND")
|
||||
{
|
||||
string sql = tipoInput switch
|
||||
{
|
||||
tipoInputEvento.barcode => "EXEC dbo.stp_TS_getUserForcedTrans @IdxMacchina, @IdxTipo",
|
||||
tipoInputEvento.hw => "EXEC dbo.stp_TS_getByIdxMacchIdxTipoEv @IdxMacchina, @IdxTipo",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
// ✅ prima chiamata ASYNC
|
||||
rigaTrans = (await dbCtx.DbSetSMES
|
||||
.FromSqlRaw(sql, pIdxMacchina, pIdxTipo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync()
|
||||
).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (rigaTrans != null && rigaTrans.IdxStato != rigaTrans.next_IdxStato)
|
||||
{
|
||||
var pIdxStato = new SqlParameter("@IdxStato", rigaTrans.next_IdxStato);
|
||||
|
||||
await dbCtx.Database.ExecuteSqlRawAsync(
|
||||
"EXEC dbo.stp_DDB_InsStatoBatch @IdxMacchina, @InizioStato, @IdxStato, @codArticolo, @Value, @MatrOpr, @pallet",
|
||||
pIdxMacchina, pInizioStato, pIdxStato, pCodArticolo, pValue, pMatrOpr, pPallet);
|
||||
|
||||
// eseguo solo se evento manuale/barcode
|
||||
if (tipoInput == tipoInputEvento.barcode)
|
||||
{
|
||||
var pMaxAgeSec = new SqlParameter("@maxAgeSec", 0);
|
||||
await dbCtx.Database.ExecuteSqlRawAsync(
|
||||
"EXEC stp_MSE_recalc @maxAgeSec, @idxMacchina",
|
||||
pMaxAgeSec, pIdxMacchina);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Debug($"Nessun cambio stato richiesto | {opType} | {IdxMacchina} | {IdxTipo}");
|
||||
}
|
||||
|
||||
// Nessuna eccezione = successo
|
||||
await tx.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tx.RollbackAsync();
|
||||
// Log dettagliato errore
|
||||
Log.Error(ex, $"Errore in CheckCambiaStatoBatchAsync: {IdxMacchina} | {tipoInput}");
|
||||
throw; // O return false; se il chiamante gestisce fallimenti
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv)
|
||||
{
|
||||
// eseguo in transazione...
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync(IsolationLevel.ReadCommitted);
|
||||
|
||||
try
|
||||
{
|
||||
// inizio con record microstato...
|
||||
var actRec = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
.FindAsync(newRecMsm.IdxMacchina);
|
||||
//.SingleOrDefaultAsync();
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx.DbSetMicroStatoMacc.Add(newRecMsm);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.IdxMicroStato = newRecMsm.IdxMicroStato;
|
||||
actRec.InizioStato = newRecMsm.InizioStato;
|
||||
actRec.Value = newRecMsm.Value;
|
||||
|
||||
// Update() allega l'entità e segna tutti i campi come Modified
|
||||
dbCtx.DbSetMicroStatoMacc.Update(actRec);
|
||||
}
|
||||
|
||||
// ora record EVList
|
||||
dbCtx.DbSetEvList.Add(newRecEv);
|
||||
|
||||
// EF Core 8 raggruppa automaticamente INSERT/UPDATE in un batch
|
||||
var rowsAffected = await dbCtx.SaveChangesAsync();
|
||||
await tx.CommitAsync();
|
||||
|
||||
return rowsAffected > 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
await tx.RollbackAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Protected Fields
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels.Mtc;
|
||||
using MP.Data.Repository.Utils;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Mtc
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository
|
||||
namespace MP.Data.Repository.Utils
|
||||
{
|
||||
public abstract class BaseRepository : IBaseRepository
|
||||
{
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MP.Data.Repository.Utils
|
||||
{
|
||||
public interface IBaseRepository
|
||||
{
|
||||
//Task<DataLayerContext> CreateContextAsync();
|
||||
//Task<bool> SaveChangesAsync(DataLayerContext ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Services.IOC
|
||||
{
|
||||
public interface IIocService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Processing intera catena eventi verifica cambio stato in singola transazione e con unico DbContext
|
||||
/// </summary>
|
||||
/// <param name="tipoInput"></param>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="InizioStato"></param>
|
||||
/// <param name="IdxTipo"></param>
|
||||
/// <param name="CodArt"></param>
|
||||
/// <param name="Value"></param>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <param name="pallet"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet);
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta record MicroStato + EventList
|
||||
/// </summary>
|
||||
/// <param name="newRecMsm"></param>
|
||||
/// <param name="newRecEv"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Repository.IOC;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Services.IOC
|
||||
{
|
||||
public class IocService : BaseServ, IIocService
|
||||
{
|
||||
|
||||
private readonly string _className;
|
||||
private readonly IIocRepository _repo;
|
||||
|
||||
public IocService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IIocRepository repo) : base(config, redis)
|
||||
{
|
||||
_className = "IocServ";
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
|
||||
{
|
||||
return await TraceAsync($"{_className}.CheckCambiaStatoBatch", async (activity) =>
|
||||
{
|
||||
// eseguo su repostory (DB)
|
||||
string operation = "UPDATE";
|
||||
bool success = await _repo.CheckCambiaStatoBatchAsync(tipoInput, IdxMacchina, InizioStato, IdxTipo, CodArt, Value, MatrOpr, pallet);
|
||||
|
||||
activity?.SetTag("db.operation", operation);
|
||||
|
||||
await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
|
||||
return success;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv)
|
||||
{
|
||||
return await TraceAsync($"{_className}.EvListMicroStatoInsert", async (activity) =>
|
||||
{
|
||||
// eseguo su repostory (DB)
|
||||
string operation = "UPDATE";
|
||||
bool success = await _repo.EvListMicroStatoInsertAsync(newRecMsm, newRecEv);
|
||||
|
||||
activity?.SetTag("db.operation", operation);
|
||||
|
||||
await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
|
||||
return success;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.DbModels.Anag;
|
||||
using MP.Data.MgModels;
|
||||
using MP.Data.Services.IOC;
|
||||
using MP.Data.Services.Mtc;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -988,16 +989,6 @@ namespace MP.IOC.Data
|
||||
int idxMicroStato = Convert.ToInt32(datiMacc["IdxMicroStato"]);
|
||||
int valIOB = Convert.ToInt32(valINT);
|
||||
next_idxMS = idxMicroStato;
|
||||
#if false
|
||||
// verifico esistenza tab SMI...
|
||||
var fiHASH = Utils.GetHashSMI(idxFamIn);
|
||||
bool trovato = await RedisKeyPresentAsync(fiHASH);
|
||||
if (!trovato)
|
||||
{
|
||||
// ricarico tabella (salvando in redis x ricerca successiva)!
|
||||
KeyValuePair<string, string>[] valori = await StateMachInByKeyAsync(idxFamIn);
|
||||
}
|
||||
#endif
|
||||
// recupero singolo valOut (stringa) x chiave
|
||||
string todoSMI = await ValoreSmiAsync(idxFamIn, idxMicroStato, valIOB);
|
||||
// solo se ho trovato un risultato nella tab SMI della famiglia macchina...
|
||||
@@ -4816,16 +4807,31 @@ namespace MP.IOC.Data
|
||||
private async Task<inputComandoMapo> scriviRigaEventoAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv)
|
||||
{
|
||||
bool inserito = false;
|
||||
try
|
||||
if (useFactory)
|
||||
{
|
||||
await using var scope = _scopeFactory.CreateAsyncScope();
|
||||
var iocService = scope.ServiceProvider.GetRequiredService<IIocService>();
|
||||
|
||||
// inserisco evento
|
||||
inserito = await IocDbController.EvListMicroStatoInsertAsync(newRecMsm, newRecEv);
|
||||
inserito = await iocService.EvListMicroStatoInsertAsync(newRecMsm, newRecEv);
|
||||
// faccio controllo per eventuale cambio stato da tab transizioni...
|
||||
await CheckCambiaStatoBatchAsync(tipoInputEvento.hw, newRecEv.IdxMacchina, newRecEv.InizioStato ?? DateTime.Now, newRecEv.IdxTipo, newRecEv.CodArticolo, newRecEv.Value, newRecEv.MatrOpr, newRecEv.pallet);
|
||||
|
||||
await iocService.CheckCambiaStatoBatchAsync(tipoInputEvento.hw, newRecEv.IdxMacchina, newRecEv.InizioStato ?? DateTime.Now, newRecEv.IdxTipo, newRecEv.CodArticolo, newRecEv.Value, newRecEv.MatrOpr, newRecEv.pallet);
|
||||
}
|
||||
catch (Exception exc)
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore in scriviRigaEvento | IdxMacchina {newRecEv.IdxMacchina} | IdxTipo {newRecEv.IdxTipo} | codArticolo {newRecEv.CodArticolo} | Value {newRecEv.Value} | MatrOpr {newRecEv.MatrOpr} | Pallet {newRecEv.pallet} | dTime {newRecEv.InizioStato}{Environment.NewLine}{exc}");
|
||||
|
||||
try
|
||||
{
|
||||
// inserisco evento
|
||||
inserito = await IocDbController.EvListMicroStatoInsertAsync(newRecMsm, newRecEv);
|
||||
// faccio controllo per eventuale cambio stato da tab transizioni...
|
||||
await CheckCambiaStatoBatchAsync(tipoInputEvento.hw, newRecEv.IdxMacchina, newRecEv.InizioStato ?? DateTime.Now, newRecEv.IdxTipo, newRecEv.CodArticolo, newRecEv.Value, newRecEv.MatrOpr, newRecEv.pallet);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in scriviRigaEvento | IdxMacchina {newRecEv.IdxMacchina} | IdxTipo {newRecEv.IdxTipo} | codArticolo {newRecEv.CodArticolo} | Value {newRecEv.Value} | MatrOpr {newRecEv.MatrOpr} | Pallet {newRecEv.pallet} | dTime {newRecEv.InizioStato}{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
// formatto output
|
||||
inputComandoMapo answ = new inputComandoMapo();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>8.16.2604.3008</Version>
|
||||
<Version>8.16.2604.3015</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+17
-4
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using MP.Core.Conf;
|
||||
using MP.Data;
|
||||
@@ -62,6 +63,20 @@ builder.Services.Configure<RedisScriptsConfig>(
|
||||
builder.Configuration.GetSection("RedisScripts"));
|
||||
logger.Info("RedisScript Provider configured");
|
||||
|
||||
// Metodi principali x accesso dati
|
||||
var connStr = builder.Configuration.GetConnectionString("MP.Data")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Data' mancante.");
|
||||
|
||||
builder.Services.AddDbContextFactory<MoonProContext>(options =>
|
||||
options.UseSqlServer(connStr)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
// MP.Data DbContext for Stats repositories
|
||||
string utilsConnString = builder.Configuration.GetConnectionString("MP.Utils") ?? "Server=localhost;Database=MoonPro_Utils; integrated security=True; MultipleActiveResultSets=True; App=MP.IOC;";
|
||||
builder.Services.AddDbContextFactory<MoonPro_UtilsContext>(options =>
|
||||
options.UseSqlServer(utilsConnString));
|
||||
|
||||
// MP.Data Services Utils - Statistiche DB
|
||||
builder.Services.AddIocDataLayer();
|
||||
|
||||
@@ -79,10 +94,7 @@ builder.Services.AddRazorComponents()
|
||||
//builder.Services.AddHealthChecks()
|
||||
// .AddSqlServer(builder.Configuration.GetConnectionString("CoreDb"));
|
||||
|
||||
// MP.Data DbContext for Stats repositories
|
||||
string utilsConnString = builder.Configuration.GetConnectionString("MP.Utils") ?? "Server=localhost;Database=MoonPro_Utils; integrated security=True; MultipleActiveResultSets=True; App=MP.IOC;";
|
||||
builder.Services.AddDbContextFactory<MoonPro_UtilsContext>(options =>
|
||||
options.UseSqlServer(utilsConnString));
|
||||
|
||||
|
||||
// generic controller
|
||||
builder.Services.AddControllers();
|
||||
@@ -104,6 +116,7 @@ var redisMux = ConnectionMultiplexer.Connect(confRedis);
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMux);
|
||||
|
||||
// oggetto principale accesso dati
|
||||
//builder.Services.AddScoped<MpDataService>();
|
||||
builder.Services.AddSingleton<MpDataService>();
|
||||
|
||||
logger.Info("Standard service configured");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 8.16.2604.3008</h4>
|
||||
<h4>Versione: 8.16.2604.3015</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2604.3008
|
||||
8.16.2604.3015
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2604.3008</version>
|
||||
<version>8.16.2604.3015</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user