Update controller x usare scoped service x input in modalità connectionFactory x process input
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user