SPEC:
- aggiunta pagina operatori - completato fix
This commit is contained in:
@@ -15,15 +15,30 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
public class MpIocController
|
||||
{
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
#region Public Constructors
|
||||
|
||||
public MpIocController(IConfiguration configuration)
|
||||
public MpIocController(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
#if false
|
||||
_configuration = configuration;
|
||||
#endif
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
#if false
|
||||
string connStr = configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
string connStrFlux = configuration.GetConnectionString("MP.Flux");
|
||||
optionsFlux = new DbContextOptionsBuilder<MoonPro_FluxContext>()
|
||||
.UseSqlServer(connStrFlux)
|
||||
.Options;
|
||||
#endif
|
||||
Log.Info("Avviata classe MpIocController");
|
||||
}
|
||||
|
||||
@@ -43,7 +58,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var DtRif = new SqlParameter("@DtRif", dtRif);
|
||||
var MachineId = new SqlParameter("@MachineId", machineId);
|
||||
@@ -63,7 +78,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagStatiModel>> AnagStatiGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetAnagStati
|
||||
@@ -81,7 +96,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetLastByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var dbResult = await dbCtx
|
||||
@@ -107,7 +122,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxOdl = new SqlParameter("@idxOdl ", idxOdl);
|
||||
var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
|
||||
@@ -138,7 +153,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(options);
|
||||
await using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
//await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
@@ -224,7 +239,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", DateTime.Now);
|
||||
@@ -267,7 +282,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", DateTime.Now);
|
||||
@@ -306,7 +321,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfFluxModel>> ConfFluxFiltAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = _ctxFactoryFL.CreateDbContext();
|
||||
|
||||
var query = dbCtx.DbSetConfFlux
|
||||
.AsNoTracking()
|
||||
@@ -326,7 +341,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
@@ -343,7 +358,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
bool fatto = false;
|
||||
var dbResult = await dbCtx
|
||||
@@ -365,7 +380,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<DatiMacchineModel>> DatiMacchineGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetDatiMacchine
|
||||
@@ -388,7 +403,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var InizioStato = new SqlParameter("@InizioStato", inizioStato);
|
||||
@@ -411,7 +426,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<DecNumArticoliModel>> DecNumArtGetFiltAsync(string codArt = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var query = dbCtx.DbSetDecNumArt
|
||||
.AsNoTracking()
|
||||
@@ -432,17 +447,13 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<DossierModel>> DossGetLastByMaccAsync(string idxMacc)
|
||||
{
|
||||
List<DossierModel> dbResult = new();
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
dbResult = await dbCtx
|
||||
.DbSetDossiers
|
||||
.FromSqlRaw("exec dbo.stp_DOSS_getLastByMacch @idxMacchina", IdxMacchina)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.FromSqlRaw("exec dbo.stp_DOSS_getLastByMacch @idxMacchina", IdxMacchina)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -452,7 +463,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbCtx.DbSetEvList.Add(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
@@ -467,7 +478,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> EvListMicroStatoInsertAsync(MicroStatoMacchinaModel newRecMsm, EventListModel newRecEv)
|
||||
{
|
||||
// eseguo in transazione...
|
||||
await using var dbCtx = new MoonProContext(options);
|
||||
await using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
@@ -518,18 +529,15 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<FluxLogModel>> FluxLogFirstByMaccAsync(string idxMacc, int numMax)
|
||||
{
|
||||
List<FluxLogModel> dbResult = new();
|
||||
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var NumMax = new SqlParameter("@numMax", numMax);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetFluxLog
|
||||
.FromSqlRaw("exec dbo.stp_FL_getFirstByMacc @IdxMacchina, @numMax", IdxMacchina, NumMax)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.FromSqlRaw("exec dbo.stp_FL_getFirstByMacc @IdxMacchina, @numMax", IdxMacchina, NumMax)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -543,17 +551,15 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
|
||||
{
|
||||
List<FluxLogModel> dbResult = new List<FluxLogModel>();
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
|
||||
.OrderByDescending(x => x.dtEvento)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
|
||||
.OrderByDescending(x => x.dtEvento)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -563,15 +569,13 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FluxLogInsertAsync(FluxLogModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
|
||||
var currRec = dbCtx
|
||||
.DbSetFluxLog
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
.DbSetFluxLog
|
||||
.Add(newRec);
|
||||
return await dbCtx.SaveChangesAsync()>0;
|
||||
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -581,8 +585,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FluxLogTakeSnapshotLastAsync(string idxMacc, DateTime dataInizio, DateTime dataFine)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var DataInizio = new SqlParameter("@DtMin", dataInizio);
|
||||
@@ -591,8 +594,7 @@ namespace MP.Data.Controllers
|
||||
var result = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_FL_TakeSnapshotLast @IdxMacchina, @DtMin, @DtMax", IdxMacchina, DataInizio, DataFine);
|
||||
fatto = result > 0;
|
||||
return fatto;
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -605,7 +607,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> KeepAliveUpsertAsync(string IdxMacc, DateTime OraServer, DateTime OraMacc)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var currRec = await dbCtx
|
||||
.DbSetKeepAlive
|
||||
@@ -638,7 +640,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetLinkMenu
|
||||
@@ -658,7 +660,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var query = dbCtx
|
||||
.DbSetListValues
|
||||
@@ -682,7 +684,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<Macchine2SlaveModel>> Macchine2SlaveAsync()
|
||||
{
|
||||
List<Macchine2SlaveModel> dbResult = new List<Macchine2SlaveModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetM2S
|
||||
@@ -700,7 +702,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MacchineModel>> MacchineGetAllAsync()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -712,7 +714,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<MacchineModel?> MacchineGetByIdxAsync(string IdxMacchina)
|
||||
{
|
||||
MacchineModel dbResult = null;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -729,7 +731,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
@@ -763,7 +765,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> MacchineUpsertAsync(MacchineModel entity)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = await dbCtx
|
||||
@@ -791,7 +793,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MicroStatoMacchinaModel>> MicroStatoMacchinaGetByIdxMaccAsync(string IdxMacc)
|
||||
{
|
||||
List<MicroStatoMacchinaModel> dbResult = new List<MicroStatoMacchinaModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -809,7 +811,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> MicroStatoMacchinaUpsertAsync(MicroStatoMacchinaModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var actRec = await dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
@@ -842,7 +844,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
@@ -862,7 +864,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataInizio = new SqlParameter("@DataInizio", dataInizio);
|
||||
@@ -884,7 +886,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataInizio = new SqlParameter("@DataInizio", dataInizio);
|
||||
@@ -913,7 +915,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<ODLExpModel> OdlCurrByMaccAsync(string idxMacchina)
|
||||
{
|
||||
ODLExpModel answ = new();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
// attenzione: se la stored resituisce una tabella, il primo elemento va recuperato in RAM!!!
|
||||
@@ -936,7 +938,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var idxMaccParam = new SqlParameter("@IdxMacchina", idxMacchina ?? "");
|
||||
var numDayPrevParam = new SqlParameter("@NumDayPrev", numDayPrev);
|
||||
@@ -958,7 +960,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> OdlFixMachineSlaveAsync(string idxMacchina, int numDayPrev, int doInsert)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var NumDayPrev = new SqlParameter("@NumDayPrev", numDayPrev);
|
||||
@@ -977,7 +979,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<ODLExpModel> OdlLastByMaccAsync(string idxMacchina)
|
||||
{
|
||||
ODLExpModel answ = new();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
// attenzione: se la stored resituisce una tabella, il primo elemento va recuperato in RAM!!!
|
||||
@@ -1001,7 +1003,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataFrom = new SqlParameter("@dataFrom", dtStart);
|
||||
@@ -1023,7 +1025,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<PzProdModel> PezziProdMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
PzProdModel dbResult = new PzProdModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
dbResult = (await dbCtx
|
||||
@@ -1046,7 +1048,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", codArticolo);
|
||||
@@ -1069,7 +1071,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RecalcMseAsync(string idxMacchina, int maxAgeSec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var rigaProd = await StatoProdMacchinaAsync(idxMacchina, DateTime.Now);
|
||||
var MaxAgeSec = new SqlParameter("@maxAgeSec ", maxAgeSec);
|
||||
@@ -1093,7 +1095,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(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
|
||||
@@ -1114,7 +1116,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegDichiarInsertAsync(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var TagCode = new SqlParameter("@TagCode", newRec.TagCode);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", newRec.IdxMacchina);
|
||||
@@ -1136,7 +1138,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegDichiarUpdateAsync(RegistroDichiarazioniModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var Original_IdxDich = new SqlParameter("@Original_IdxDich", newRec.IdxDich);
|
||||
var DtRec = new SqlParameter("@DtRec", newRec.DtRec);
|
||||
@@ -1157,7 +1159,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RegScartiInsertAsync(RegistroScartiModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@idxMacchina", newRec.IdxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra", newRec.DataOra);
|
||||
@@ -1184,7 +1186,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> RemRebootLogAddAndCleanAsync(RemoteRebootLogModel newRec, bool doClean, int num2keep)
|
||||
{
|
||||
bool fatto = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
// 1. Transazione minima: SOLO INSERT + COMMIT
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
@@ -1227,7 +1229,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemRebootLogAddAsync(RemoteRebootLogModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -1242,7 +1244,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetRemRebLog
|
||||
@@ -1258,7 +1260,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetLastAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
var dbResult = await dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_getLast")
|
||||
@@ -1273,7 +1275,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemRebootLogKeepLastAsync(int num2keep)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var pNum2Keep = new SqlParameter("@num2keep", num2keep);
|
||||
// La SP gestisce già la logica di soglia (1.5x), ma la specifico x sicurezza
|
||||
@@ -1291,7 +1293,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SignalLogInsertAsync(SignalLogModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var currRec = dbCtx
|
||||
.DbSetSignalLog
|
||||
@@ -1307,7 +1309,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneStatiModel>> SMES_getHwTransitionsAsync(string idxMacchina, int idxTipo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -1327,7 +1329,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneStatiModel>> SMES_getUserForcedAsync(string idxMacchina, int idxTipo)
|
||||
{
|
||||
await using var dbCtx = new MoonProContext(options);
|
||||
await using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var IdxTipo = new SqlParameter("@IdxTipo", idxTipo);
|
||||
@@ -1346,18 +1348,14 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public List<TransizioneIngressiModel> StateMachineIngressi(int idxFam)
|
||||
{
|
||||
List<TransizioneIngressiModel> dbResult = new List<TransizioneIngressiModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
dbResult = dbCtx
|
||||
.DbSetSMI
|
||||
.FromSqlRaw("exec dbo.stp_TRI_getByIdxFamIng @IdxFamigliaIngresso", IdxFamIn)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
return dbCtx
|
||||
.DbSetSMI
|
||||
.FromSqlRaw("exec dbo.stp_TRI_getByIdxFamIng @IdxFamigliaIngresso", IdxFamIn)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1366,7 +1364,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<TransizioneIngressiModel>> StateMachineIngressiAsync(int idxFam)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
var dbResult = await dbCtx
|
||||
@@ -1386,7 +1384,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<StatoProdModel> StatoProdMacchinaAsync(string idxMacchina, DateTime dtReq)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DataOra = new SqlParameter("@DataOra ", dtReq);
|
||||
@@ -1406,7 +1404,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetMSFD
|
||||
@@ -1424,7 +1422,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<VMSFDModel?> VMSFDGetByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
var dbResult = (await dbCtx
|
||||
@@ -1444,7 +1442,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetMultiByMaccAsync(string idxMacc)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
|
||||
|
||||
@@ -1461,9 +1459,14 @@ namespace MP.Data.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
#if false
|
||||
private static IConfiguration _configuration;
|
||||
#endif
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#if false
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#endif
|
||||
private DbContextOptions<MoonPro_FluxContext> optionsFlux;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
@@ -15,10 +15,21 @@ namespace MP.Data.Controllers
|
||||
public class MpLandController : IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
protected readonly IDbContextFactory<MoonPro_STATSContext> _ctxFactorySta;
|
||||
|
||||
public MpLandController(IConfiguration configuration)
|
||||
public MpLandController(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL,
|
||||
IDbContextFactory<MoonPro_STATSContext> ctxFactorySta)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
_ctxFactorySta = ctxFactorySta;
|
||||
#if false
|
||||
string connStr = _configuration.GetConnectionString("MP.Land");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
@@ -26,7 +37,8 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
.Options;
|
||||
#endif
|
||||
Log.Info("Avviato MpLandController");
|
||||
}
|
||||
|
||||
@@ -34,6 +46,7 @@ namespace MP.Data.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Restituisce info dimensione, tabelle e num righe DB gestiti
|
||||
/// </summary>
|
||||
@@ -70,58 +83,53 @@ namespace MP.Data.Controllers
|
||||
// leggo per DB principale
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.All")))
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
// leggo per FluxLog
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Flux")))
|
||||
{
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
using var dbCtx = _ctxFactoryFL.CreateDbContext();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
// leggo per Stats
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Stats")))
|
||||
{
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using var dbCtx = _ctxFactorySta.CreateDbContext();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AllDbInfo:{Environment.NewLine}{exc}");
|
||||
Log.Error($"Eccezione in AllDbInfoAsync:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config
|
||||
@@ -130,15 +138,12 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -154,16 +159,13 @@ namespace MP.Data.Controllers
|
||||
public List<AnagOperatoriModel> ElencoOperatori()
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbOperatori
|
||||
.Where(s => s.MatrOpr > 0)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbOperatori
|
||||
.Where(s => s.MatrOpr > 0)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -173,13 +175,10 @@ namespace MP.Data.Controllers
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbSetMacchine
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,15 +188,12 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetAll()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.IdxReboot)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbSetRemRebLog
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.IdxReboot)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,15 +203,12 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetLast()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_getLast")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_getLast")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -225,15 +218,12 @@ namespace MP.Data.Controllers
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetLastNoMacc()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_GetLastNoMachine")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
return dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_GetLastNoMachine")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -244,7 +234,7 @@ namespace MP.Data.Controllers
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -283,7 +273,9 @@ namespace MP.Data.Controllers
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly DbContextOptions<MoonProContext> options;
|
||||
#if false
|
||||
private readonly DbContextOptions<MoonProContext> options;
|
||||
#endif
|
||||
private bool _disposed = false;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -1,31 +1,36 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static EgwCoreLib.Utils.DtUtils;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
public class MpSpecController
|
||||
{
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
#region Public Constructors
|
||||
|
||||
public MpSpecController(IConfiguration configuration)
|
||||
public MpSpecController(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
#if false
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
.Options;
|
||||
#endif
|
||||
Log.Info("Avviata classe MpSpecController");
|
||||
}
|
||||
|
||||
@@ -41,7 +46,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<AnagCountersModel> AnagCountersGetNextAsync(string cntType)
|
||||
{
|
||||
AnagCountersModel answ = new AnagCountersModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
bool outTable = true;
|
||||
if (outTable)
|
||||
{
|
||||
@@ -102,7 +107,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync(string TableName = "EvList", string FieldName = "Common")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
var dbResult = await dbCtx
|
||||
@@ -129,7 +134,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AnagGruppiDeleteAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
@@ -161,7 +166,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagGruppiModel>> AnagGruppiGetTipoAsync(string tipoGruppo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.Where(x => x.TipoGruppo == tipoGruppo)
|
||||
@@ -176,7 +181,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
// in primis recupero i reparti...
|
||||
var listReparti = await AnagGruppiGetTipoAsync("REPARTO");
|
||||
|
||||
@@ -211,7 +216,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
@@ -279,7 +284,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var result = await dbCtx
|
||||
.DbSetArticoli
|
||||
.CountAsync();
|
||||
@@ -295,7 +300,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountSearchAsync(string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli.AsNoTracking();
|
||||
|
||||
// filtro tipo articolo
|
||||
@@ -331,7 +336,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountUsedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var result = await dbCtx
|
||||
.DbSetCounter
|
||||
.FromSqlRaw("EXEC stp_ART_CountUsed")
|
||||
@@ -348,7 +353,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ArticoliDeleteRecordAsync(AnagArticoliModel currRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currVal = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo == currRec.CodArticolo)
|
||||
@@ -368,7 +373,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetByTipoAsync(string tipo, string azienda = "*")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.AsNoTracking()
|
||||
@@ -387,7 +392,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetSearchAsync(int numRecord, string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli
|
||||
.AsNoTracking();
|
||||
|
||||
@@ -425,7 +430,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUnusedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_ART_getNotUsed")
|
||||
@@ -439,7 +444,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUsedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_ART_getUsed")
|
||||
@@ -454,7 +459,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<AnagArticoliModel>> ArticoliInKitAsync()
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_TempKIT_getArtChild")
|
||||
@@ -470,7 +475,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo == editRec.CodArticolo)
|
||||
@@ -500,7 +505,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
@@ -516,7 +521,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new ConfigModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
@@ -647,7 +652,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetEvList
|
||||
.AddAsync(newRec);
|
||||
@@ -874,7 +879,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.IdxMacchina == rec2del.IdxMacchina)
|
||||
@@ -896,7 +901,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.IdxMacchina == upsRec.IdxMacchina)
|
||||
@@ -919,7 +924,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.MatrOpr == rec2del.MatrOpr)
|
||||
@@ -941,7 +946,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.MatrOpr == upsRec.MatrOpr)
|
||||
@@ -962,7 +967,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd)
|
||||
@@ -985,7 +990,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => (string.IsNullOrEmpty(keyKit) && string.IsNullOrEmpty(keyExtOrd)) || (x.KeyKit.Contains(keyKit) && !string.IsNullOrEmpty(keyKit)) || (x.KeyExtOrd.Contains(keyExtOrd) && !string.IsNullOrEmpty(keyExtOrd)))
|
||||
@@ -1000,7 +1005,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="KeyFilt">Chiave x filtro conf su tab WKS</param>
|
||||
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
@@ -1017,7 +1022,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="editRec"></param>
|
||||
public async Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
@@ -1065,7 +1070,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenuModel>> ListLinkAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.AsNoTracking()
|
||||
@@ -1081,7 +1086,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
@@ -1106,7 +1111,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<ODLExpModel>> ListODLFiltAsync(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(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var InCorso = new SqlParameter("@InCorso", inCorso);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
@@ -1131,7 +1136,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
|
||||
@@ -1149,7 +1154,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
return await dbCtx
|
||||
@@ -1169,7 +1174,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
@@ -1194,7 +1199,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
@@ -1217,7 +1222,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ListValuesModel>> ListValuesFiltAsync(string tabName, string fieldName)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetListValues
|
||||
.Where(x => x.TableName == tabName && x.FieldName == fieldName)
|
||||
@@ -1233,7 +1238,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
return await dbCtx
|
||||
@@ -1272,7 +1277,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
return await dbCtx
|
||||
@@ -1305,7 +1310,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -1322,7 +1327,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(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
@@ -1357,7 +1362,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<ODLExpModel> OdlByKeyAsync(int IdxOdl)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.AsNoTracking()
|
||||
@@ -1379,7 +1384,7 @@ namespace MP.Data.Controllers
|
||||
bool fatto = false;
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
DateTime adesso = DateTime.Now;
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
@@ -1441,7 +1446,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ODLModel>> OdlGetCurrentAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODL
|
||||
.Where(x => x.DataInizio != null && x.DataFine == null)
|
||||
@@ -1457,7 +1462,7 @@ namespace MP.Data.Controllers
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
dbResult = await dbCtx
|
||||
@@ -1477,7 +1482,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
@@ -1510,7 +1515,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> ParametriGetFiltAsync(string IdxMacchina)
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -1529,7 +1534,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<PODLModel> PODL_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1545,7 +1550,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<PODLModel> PODL_getByOdlAsync(int idxODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1563,7 +1568,7 @@ namespace MP.Data.Controllers
|
||||
if (missingIds == null || !missingIds.Any())
|
||||
return new Dictionary<int, int>();
|
||||
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1602,7 +1607,7 @@ namespace MP.Data.Controllers
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1637,7 +1642,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> PODL_updateRecipe(int idxPODL, string recipeName)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
@@ -1677,7 +1682,7 @@ namespace MP.Data.Controllers
|
||||
CodCli = currRec.CodCli,
|
||||
InsertDate = currRec.InsertDate
|
||||
};
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
@@ -1694,7 +1699,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="IdxPODL">IdxPODL parent</param>
|
||||
public async Task<bool> PodlIstKitDeleteAsync(int IdxPODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
@@ -1710,7 +1715,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> PODLUpdateRecordAsync(PODLModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
@@ -1744,7 +1749,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<StatoMacchineModel> StatoMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetStatoMacc
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
@@ -1758,7 +1763,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
@@ -1782,7 +1787,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => (string.IsNullOrEmpty(KitCode) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(KitCode) && !string.IsNullOrEmpty(KitCode)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild)))
|
||||
@@ -1798,7 +1803,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="codAzienda"></param>
|
||||
public async Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
// verifico preliminarmente articolo...
|
||||
var recArt = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -1854,7 +1859,7 @@ namespace MP.Data.Controllers
|
||||
List<TksScoreModel> dbResult = new List<TksScoreModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
var pMaxRes = new SqlParameter("@maxResult", MaxResult);
|
||||
dbResult = await dbCtx
|
||||
@@ -1866,13 +1871,14 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario di una lingua
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
@@ -1892,7 +1898,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> VocabolarioUpsertAsync(VocabolarioModel upsRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetVocabolario
|
||||
.Where(x => x.Lingua == upsRec.Lingua && x.Lemma == upsRec.Lemma)
|
||||
@@ -1919,7 +1925,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
@@ -1932,7 +1938,8 @@ namespace MP.Data.Controllers
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record + vecchi della data-ora indicata
|
||||
@@ -1941,7 +1948,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.DataIns < dateLimit)
|
||||
@@ -1967,7 +1974,7 @@ namespace MP.Data.Controllers
|
||||
// solo se filtro valido...
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt.Contains(KeyFilt))
|
||||
@@ -1983,7 +1990,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="editRec"></param>
|
||||
public async Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
@@ -2013,7 +2020,9 @@ namespace MP.Data.Controllers
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#if false
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -19,11 +19,15 @@ namespace MP.Data.Controllers
|
||||
public MpStatsController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Stats");
|
||||
options = new DbContextOptionsBuilder<MoonPro_STATSContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpStatsController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
private DbContextOptions<MoonPro_STATSContext> options;
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -33,13 +37,10 @@ namespace MP.Data.Controllers
|
||||
public List<AzioniUL> ActionsGetAll()
|
||||
{
|
||||
List<AzioniUL> dbResult = new List<AzioniUL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
using var dbCtx = new MoonPro_STATSContext(options);
|
||||
return dbCtx
|
||||
.DbSetAzioniUL
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,13 +50,10 @@ namespace MP.Data.Controllers
|
||||
public List<AnagFLTransModel> AnagFLTransGetAll()
|
||||
{
|
||||
List<AnagFLTransModel> dbResult = new List<AnagFLTransModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagFLTrans
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_STATSContext(options);
|
||||
return dbCtx
|
||||
.DbSetAnagFLTrans
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +65,7 @@ namespace MP.Data.Controllers
|
||||
public List<StatsAnagArticoli> ArticoliGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<StatsAnagArticoli> dbResult = new List<StatsAnagArticoli>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -88,7 +86,7 @@ namespace MP.Data.Controllers
|
||||
public List<StatsODL> CommesseGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<StatsODL> dbResult = new List<StatsODL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetODL
|
||||
@@ -107,7 +105,7 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
@@ -133,7 +131,7 @@ namespace MP.Data.Controllers
|
||||
public List<FLModel> FluxLogRawData(string IdxMacchina, DateTime DtStart, DateTime DtEnd, string fluxType)
|
||||
{
|
||||
List<FLModel> dbResult = new List<FLModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetFL
|
||||
@@ -153,7 +151,7 @@ namespace MP.Data.Controllers
|
||||
public List<string> FluxTypeList()
|
||||
{
|
||||
List<string> dbResult = new List<string>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetFL
|
||||
@@ -172,7 +170,7 @@ namespace MP.Data.Controllers
|
||||
public List<MacchineStatModel> MacchineEnergy()
|
||||
{
|
||||
List<MacchineStatModel> dbResult = new List<MacchineStatModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMaccStat
|
||||
@@ -188,7 +186,7 @@ namespace MP.Data.Controllers
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMacchine
|
||||
@@ -204,7 +202,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MaccEnergyCheckModel>> MacchineEnergyCheckGetAllAsync()
|
||||
{
|
||||
List<MaccEnergyCheckModel> dbResult = new List<MaccEnergyCheckModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchineCheck
|
||||
@@ -222,7 +220,7 @@ namespace MP.Data.Controllers
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -248,7 +246,7 @@ namespace MP.Data.Controllers
|
||||
public List<ResControlli> StatControlliGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<ResControlli> dbResult = new List<ResControlli>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -280,7 +278,7 @@ namespace MP.Data.Controllers
|
||||
public List<DdbTurni> StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int FirstRecord, int NumRecord)
|
||||
{
|
||||
List<DdbTurni> dbResult = new List<DdbTurni>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -312,7 +310,7 @@ namespace MP.Data.Controllers
|
||||
public int StatDdbGetCount(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
int numResult = 0;
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
numResult = dbCtx
|
||||
.DbSetDdbTurni
|
||||
@@ -335,7 +333,7 @@ namespace MP.Data.Controllers
|
||||
public List<OdlEnergyModel> StatOdlEnergyGetFilt(string IdxMacchina, DateTime DtStart, DateTime DtEnd, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<OdlEnergyModel> dbResult = new List<OdlEnergyModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DtStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DtEnd);
|
||||
@@ -361,7 +359,7 @@ namespace MP.Data.Controllers
|
||||
public List<StatsODL> StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<StatsODL> dbResult = new List<StatsODL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -389,7 +387,7 @@ namespace MP.Data.Controllers
|
||||
public List<ResScarti> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<ResScarti> dbResult = new List<ResScarti>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -417,7 +415,7 @@ namespace MP.Data.Controllers
|
||||
public List<TurniOee> StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<TurniOee> dbResult = new List<TurniOee>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -443,7 +441,7 @@ namespace MP.Data.Controllers
|
||||
public List<UserActionLog> StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<UserActionLog> dbResult = new List<UserActionLog>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
@@ -467,7 +465,7 @@ namespace MP.Data.Controllers
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
using (var dbCtx = new MoonPro_STATSContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
|
||||
Reference in New Issue
Block a user