Merge branch 'feature/CodeAssisted_01' into develop
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>8.16.2606.119</Version>
|
||||
<Version>8.16.2606.408</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP_TAB3</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
+41
-12
@@ -2,16 +2,18 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using MP.Data;
|
||||
using MP.Data.Services;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using StackExchange.Redis;
|
||||
using static Org.BouncyCastle.Math.EC.ECCurve;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
using ZiggyCreatures.Caching.Fusion.Backplane.StackExchangeRedis;
|
||||
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -27,15 +29,45 @@ var cString = configuration.GetConnectionString("Redis");
|
||||
string connStringRedis = cString ?? "localhost:6379, DefaultDatabase=5, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false";
|
||||
//string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
// avvio oggetto shared x redis...
|
||||
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
IConnectionMultiplexer redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
|
||||
// Add services x accesso dati
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
|
||||
// ✅ FusionCache
|
||||
builder.Services.AddFusionCache()
|
||||
.WithDistributedCache(sp => sp.GetRequiredService<IDistributedCache>())
|
||||
.WithSerializer(new FusionCacheNewtonsoftJsonSerializer())
|
||||
.WithBackplane(new RedisBackplane(new RedisBackplaneOptions
|
||||
{
|
||||
ConnectionMultiplexerFactory = () => Task.FromResult(redisMultiplexer)
|
||||
}));
|
||||
|
||||
// Metodi principali x accesso dati
|
||||
var connStr = builder.Configuration.GetConnectionString("MP.Data")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Data' mancante.");
|
||||
// aggiungo il costruttore x i vari DbContextFactory
|
||||
builder.Services.AddDbContextFactory<MoonProContext>(options =>
|
||||
options.UseSqlServer(connStr)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
var connStrFL = builder.Configuration.GetConnectionString("MP.Flux")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante.");
|
||||
builder.Services.AddDbContextFactory<MoonPro_FluxContext>(options =>
|
||||
options.UseSqlServer(connStrFL)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
|
||||
|
||||
// Init centralizzato Repository/Servizi da MP.Data Services
|
||||
builder.Services.AddTabDataLayer();
|
||||
|
||||
#if false
|
||||
builder.Services.AddSingleton<TabDataFeeder>();
|
||||
builder.Services.AddSingleton<StatusData>();
|
||||
builder.Services.AddSingleton<ListSelectDataSrv>();
|
||||
@@ -43,13 +75,10 @@ builder.Services.AddSingleton<OrderDataSrv>();
|
||||
builder.Services.AddSingleton<SharedMemService>();
|
||||
builder.Services.AddSingleton<TabDataService>();
|
||||
builder.Services.AddScoped<MessageService>();
|
||||
#if false
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
#endif
|
||||
// aggiunta helper local/session storage service
|
||||
builder.Services.AddScoped<ISessionStorageService, SessionStorageService>();
|
||||
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
||||
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
||||
#endif
|
||||
|
||||
// gestione email
|
||||
builder.Services.Configure<MailKitMailSettings>(builder.Configuration.GetSection(nameof(MailKitMailSettings)));
|
||||
@@ -62,7 +91,7 @@ logger.Info("Aggiunti services");
|
||||
var app = builder.Build();
|
||||
|
||||
// aggiunt base URL x routing corretto
|
||||
var pathBase= configuration.GetValue<string>("SpecialConf:AppUrl") ?? (configuration.GetValue<string>("OptConf:AppUrl") ?? "");
|
||||
var pathBase = configuration.GetValue<string>("SpecialConf:AppUrl") ?? (configuration.GetValue<string>("OptConf:AppUrl") ?? "");
|
||||
app.UsePathBase(pathBase);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -78,7 +107,7 @@ app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
// gestione static files: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0
|
||||
string BasePathDisegni = configuration.GetValue<string>("ServerConf:BasePathDisegni") ?? configuration.GetValue<string>("OptConf:BasePathDisegni")?? "";
|
||||
string BasePathDisegni = configuration.GetValue<string>("ServerConf:BasePathDisegni") ?? configuration.GetValue<string>("OptConf:BasePathDisegni") ?? "";
|
||||
if (!string.IsNullOrEmpty(BasePathDisegni))
|
||||
{
|
||||
// verifico esista folder disegni
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.119</h4>
|
||||
<h4>Versione: 8.16.2606.408</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.119
|
||||
8.16.2606.408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.119</version>
|
||||
<version>8.16.2606.408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -8,16 +8,10 @@
|
||||
"AllowedHosts": "*",
|
||||
"CodApp": "MP.TAB",
|
||||
"ConnectionStrings": {
|
||||
//"Redis": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=6,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
|
||||
//"MP.All": "Server=SQL2022PROD;Database=Donati_LAV_MoonPro_prod; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
//"MP.Mon": "Server=SQL2022PROD;Database=Donati_LAV_MoonPro_prod; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
//"MP.IS": "Server=SQL2022PROD;Database=MoonPro_IS_EdilChim; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;",
|
||||
//"MP.Tab": "Server=SQL2022PROD;Database=Donati_LAV_MoonPro_prod; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
//"MP.Mag": "Server=SQL2022PROD;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;"
|
||||
|
||||
"Redis": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
|
||||
"MP.All": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
"MP.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
"MP.Flux": "Server=SQL2016DEV;Database=MoonPro_FluxData; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
"MP.Mon": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
"MP.IS": "Server=SQL2016DEV;Database=MoonPro_IS_EdilChim; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;",
|
||||
"MP.Tab": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;",
|
||||
|
||||
@@ -12,16 +12,23 @@ namespace MP.AppAuth.Controllers
|
||||
{
|
||||
public class AppAuthController
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public AppAuthController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
Log.Info("Avviata classe AppAuthController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -189,8 +196,6 @@ namespace MP.AppAuth.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x gestione Update
|
||||
/// </summary>
|
||||
@@ -225,12 +230,5 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,16 @@ namespace MP.AppAuth.Controllers
|
||||
{
|
||||
public class AppUserController : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public AppUserController(IConfiguration configuration)
|
||||
@@ -19,7 +29,7 @@ namespace MP.AppAuth.Controllers
|
||||
Log.Info("Avviata classe AppUserController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -42,18 +52,28 @@ namespace MP.AppAuth.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
#region Protected Methods
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Free managed resources here
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Fields
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,19 +10,15 @@ namespace MP.AppAuth.Controllers
|
||||
{
|
||||
public class MPController : IDisposable
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public static MPController dbController;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
private bool _disposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
@@ -32,7 +28,7 @@ namespace MP.AppAuth.Controllers
|
||||
Log.Info("Avviata classe MpController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -271,15 +267,6 @@ namespace MP.AppAuth.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (dbController != null)
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x ListValues
|
||||
/// </summary>
|
||||
@@ -380,5 +367,27 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Free managed resources here
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.AppAuth
|
||||
{
|
||||
public static class DataServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per IOC
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddAuthLandDataLayer(this IServiceCollection services)
|
||||
{
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,12 @@ namespace MP.AppAuth
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. DbContextOptions must be supplied.")]
|
||||
public MoonProContext()
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. DbContextOptions must be supplied.")]
|
||||
public MoonProContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@@ -20,10 +20,6 @@ namespace MP.AppAuth.Services
|
||||
// diritti (cablato)
|
||||
public const string RoleSuperAdmin = "MoonPro_SuperAdmin";
|
||||
|
||||
public static AppAuthController dbController;
|
||||
public static MPController MpDbController;
|
||||
public static AppUserController userController;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Private Fields
|
||||
@@ -37,15 +33,15 @@ namespace MP.AppAuth.Services
|
||||
|
||||
private const string rKeyPermUser = $"{redisBaseAddr}:PERM_USER";
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
private static ILogger<AppAuthService> _logger;
|
||||
private readonly ILogger<AppAuthService> _logger;
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private readonly JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static string Modulo = "";
|
||||
private string Modulo = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
@@ -60,23 +56,27 @@ namespace MP.AppAuth.Services
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
private readonly IConnectionMultiplexer redisConn;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private StackExchange.Redis.IDatabase redisDb = null!;
|
||||
private readonly StackExchange.Redis.IDatabase redisDb;
|
||||
|
||||
private Random rnd = new Random();
|
||||
private readonly Random rnd = new Random();
|
||||
|
||||
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
|
||||
|
||||
private readonly AppAuthController _appAuthController;
|
||||
private readonly MPController _mpController;
|
||||
private readonly AppUserController _appUserController;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public AppAuthService(IConfiguration configuration, ILogger<AppAuthService> logger, IConnectionMultiplexer redisConnMult)
|
||||
public AppAuthService(IConfiguration configuration, ILogger<AppAuthService> logger, IConnectionMultiplexer redisConnMult, AppAuthController appAuthController, MPController mpController, AppUserController appUserController)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
@@ -103,9 +103,9 @@ namespace MP.AppAuth.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new AppAuthController(configuration);
|
||||
MpDbController = new MPController(configuration);
|
||||
userController = new AppUserController(configuration);
|
||||
_appAuthController = appAuthController;
|
||||
_mpController = mpController;
|
||||
_appUserController = appUserController;
|
||||
_logger.LogInformation("DbController OK");
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace MP.AppAuth.Services
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string CodApp { get; set; } = "";
|
||||
private string CodApp { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
@@ -153,7 +153,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaCausaliScarto> dbResult = new List<AnagraficaCausaliScarto>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagCauSca();
|
||||
dbResult = _mpController.AnagCauSca();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagCauSca: {ts.TotalMilliseconds} ms");
|
||||
@@ -169,7 +169,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagClassiTempo> dbResult = new List<AnagClassiTempo>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagClassiTempo();
|
||||
dbResult = _mpController.AnagClassiTempo();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagClassiTempo: {ts.TotalMilliseconds} ms");
|
||||
@@ -185,7 +185,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaEventi> dbResult = new List<AnagraficaEventi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagEventi();
|
||||
dbResult = _mpController.AnagEventi();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagEventi: {ts.TotalMilliseconds} ms");
|
||||
@@ -201,7 +201,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagGruppiGetAll();
|
||||
dbResult = _appAuthController.AnagGruppiGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagGruppiAll: {ts.TotalMilliseconds} ms");
|
||||
@@ -213,7 +213,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagGruppiFilt(codTipo);
|
||||
dbResult = _appAuthController.AnagGruppiFilt(codTipo);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagGruppiFilt: {ts.TotalMilliseconds} ms");
|
||||
@@ -229,7 +229,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaIngressi> dbResult = new List<AnagraficaIngressi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagIngressi();
|
||||
dbResult = _mpController.AnagIngressi();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagIngressi: {ts.TotalMilliseconds} ms");
|
||||
@@ -241,7 +241,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.AnagKeyValuesUpsert(currRec);
|
||||
answ = _mpController.AnagKeyValuesUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"AnagKeyValAdd | Aggiunto rec | NomeVar: {currRec.NomeVar} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -253,7 +253,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.AnagKeyValuesDelete(NomeVar);
|
||||
answ = _mpController.AnagKeyValuesDelete(NomeVar);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"AnagKeyValDelete | Effettuata cancellazione | NomeVar: {NomeVar} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -265,7 +265,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagKeyValuesGetAll();
|
||||
dbResult = _mpController.AnagKeyValuesGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagKeyValList: {ts.TotalMilliseconds} ms");
|
||||
@@ -277,7 +277,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.AnagKeyValuesUpsert(currRec);
|
||||
answ = _mpController.AnagKeyValuesUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"AnagKeyValUpd | Effettuata modifica | NomeVar: {currRec.NomeVar} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -293,7 +293,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaMicroStati> dbResult = new List<AnagraficaMicroStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagMicroStati();
|
||||
dbResult = _mpController.AnagMicroStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagMicroStati: {ts.TotalMilliseconds} ms");
|
||||
@@ -305,7 +305,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var rawData = dbController
|
||||
var rawData = _appAuthController
|
||||
.AnagOpByGruppoGetFilt(codGruppo, searchVal);
|
||||
dbResult = rawData
|
||||
.GroupBy(user => user.MatrOpr)
|
||||
@@ -322,7 +322,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagOpGetAll(searchVal);
|
||||
dbResult = _appAuthController.AnagOpGetAll(searchVal);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagOperList: {ts.TotalMilliseconds} ms");
|
||||
@@ -338,7 +338,7 @@ namespace MP.AppAuth.Services
|
||||
List<AnagraficaStati> dbResult = new List<AnagraficaStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagStati();
|
||||
dbResult = _mpController.AnagStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagStati: {ts.TotalMilliseconds} ms");
|
||||
@@ -350,7 +350,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.ConfigUpsert(currRec);
|
||||
answ = _mpController.ConfigUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"ConfigAdd | Aggiunto rec | Chiave: {currRec.Chiave} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -362,7 +362,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.ConfigDelete(Chiave);
|
||||
answ = _mpController.ConfigDelete(Chiave);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"ConfigDelete | Effettuata cancellazione | Chiave: {Chiave} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -374,7 +374,7 @@ namespace MP.AppAuth.Services
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.ConfigGetAll();
|
||||
dbResult = _mpController.ConfigGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per ConfigList: {ts.TotalMilliseconds} ms");
|
||||
@@ -386,7 +386,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.ConfigUpsert(currRec);
|
||||
answ = _mpController.ConfigUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"ConfigUpd | Effettuata modifica | Chiave: {currRec.Chiave} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -415,7 +415,7 @@ namespace MP.AppAuth.Services
|
||||
else
|
||||
{
|
||||
// recupero diritti utente
|
||||
dbResult = userController.DirittiUtente(UserName, Modulo);
|
||||
dbResult = _appUserController.DirittiUtente(UserName, Modulo);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
@@ -430,11 +430,8 @@ namespace MP.AppAuth.Services
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
if (MpDbController != null)
|
||||
{
|
||||
MpDbController.Dispose();
|
||||
}
|
||||
// Clear database controllers
|
||||
_mpController?.Dispose();
|
||||
}
|
||||
|
||||
public async Task FlushRedisCache()
|
||||
@@ -455,7 +452,7 @@ namespace MP.AppAuth.Services
|
||||
List<ListValues> dbResult = new List<ListValues>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.ListValues();
|
||||
dbResult = _mpController.ListValues();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per ListValues: {ts.TotalMilliseconds} ms");
|
||||
@@ -484,7 +481,7 @@ namespace MP.AppAuth.Services
|
||||
else
|
||||
{
|
||||
// recupero diritti utente
|
||||
dbResult = MpDbController.MacchineGetAll();
|
||||
dbResult = _mpController.MacchineGetAll();
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
@@ -526,7 +523,7 @@ namespace MP.AppAuth.Services
|
||||
else
|
||||
{
|
||||
// recupero diritti utente
|
||||
var userRightList = userController.DirittiUtente(UserName, Modulo);
|
||||
var userRightList = _appUserController.DirittiUtente(UserName, Modulo);
|
||||
// proietto come funzioni...
|
||||
var ListFunc = userRightList.Select(x => x.Funzione).ToList();
|
||||
// trasformo i permessi utente
|
||||
@@ -534,7 +531,7 @@ namespace MP.AppAuth.Services
|
||||
{
|
||||
ListFunc = new List<string>();
|
||||
}
|
||||
dbResult = dbController.PermessiGetByFunc(ListFunc);
|
||||
dbResult = _appAuthController.PermessiGetByFunc(ListFunc);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
@@ -565,7 +562,7 @@ namespace MP.AppAuth.Services
|
||||
List<UpdMan> dbResult = new List<UpdMan>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.UpdManGetAll();
|
||||
dbResult = _appAuthController.UpdManGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per UpdManList: {ts.TotalMilliseconds} ms");
|
||||
@@ -577,7 +574,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.VocabolarioUpsert(currRec);
|
||||
answ = _mpController.VocabolarioUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"VocabolarioAdd | Aggiunto rec | lingua: {currRec.Lingua} | lemma: {currRec.Lemma} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -589,7 +586,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.VocabolarioDelete(currRec);
|
||||
answ = _mpController.VocabolarioDelete(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"VocabolarioDelete | Effettuata cancellazione | lingua: {currRec.Lingua} | lemma: {currRec.Lemma} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -601,7 +598,7 @@ namespace MP.AppAuth.Services
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.VocabolarioGetAll();
|
||||
dbResult = _mpController.VocabolarioGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per VocabolarioList: {ts.TotalMilliseconds} ms");
|
||||
@@ -613,7 +610,7 @@ namespace MP.AppAuth.Services
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
answ = MpDbController.VocabolarioUpsert(currRec);
|
||||
answ = _mpController.VocabolarioUpsert(currRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"VocabolarioUpd | Effettuata modifica | lingua: {currRec.Lingua} | lemma: {currRec.Lemma} | durata: {ts.TotalMilliseconds} ms");
|
||||
@@ -641,7 +638,7 @@ namespace MP.AppAuth.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
Vocabolario = dbController
|
||||
Vocabolario = _appAuthController
|
||||
.VocabolarioGetAll()
|
||||
.ToDictionary(x => $"{x.Lingua}#{x.Lemma}", x => x.Traduzione);
|
||||
rawData = JsonConvert.SerializeObject(Vocabolario);
|
||||
@@ -665,10 +662,10 @@ namespace MP.AppAuth.Services
|
||||
{
|
||||
bool answ = false;
|
||||
var masterEndpoint = redisConn.GetEndPoints()
|
||||
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
|
||||
.FirstOrDefault();
|
||||
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
|
||||
.FirstOrDefault();
|
||||
|
||||
// sepattern è "*" elimino intero DB...
|
||||
// se pattern è "*" elimino intero DB...
|
||||
if (masterEndpoint != null && (pat2Flush.Equals(new RedisValue("*")) || pat2Flush == RedisValue.Null))
|
||||
{
|
||||
redisConn.GetServer(masterEndpoint).FlushDatabase(database: redisDb.Database);
|
||||
@@ -699,4 +696,4 @@ namespace MP.AppAuth.Services
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace MP.Core
|
||||
|
||||
public const string redisAnagGruppi = redisBaseAddr + "Cache:AnagGruppi";
|
||||
public const string redisAnagStati = redisBaseAddr + "Cache:AnagStati";
|
||||
public const string redisAnagGruppiOpr = redisBaseAddr + "Cache:GrpByOpr";
|
||||
|
||||
public const string redisArtByDossier = redisBaseAddr + "Cache:ArtByDossier";
|
||||
public const string redisArtList = redisBaseAddr + "Cache:ArtList";
|
||||
|
||||
@@ -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,18 +15,30 @@ 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))
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
connStr = _configuration.GetConnectionString("MP.Data");
|
||||
}
|
||||
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,20 +138,18 @@ 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()
|
||||
{
|
||||
_configuration = null;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,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>
|
||||
@@ -172,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>
|
||||
@@ -188,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>
|
||||
@@ -206,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>
|
||||
@@ -224,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>
|
||||
@@ -243,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
|
||||
{
|
||||
@@ -262,11 +253,30 @@ namespace MP.Data.Controllers
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Free managed resources here
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
private readonly IConfiguration _configuration;
|
||||
#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()
|
||||
@@ -253,6 +258,8 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
@@ -268,6 +275,8 @@ namespace MP.Data.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Conteggio num articoli Async
|
||||
@@ -275,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();
|
||||
@@ -291,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
|
||||
@@ -327,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")
|
||||
@@ -344,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)
|
||||
@@ -364,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()
|
||||
@@ -383,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();
|
||||
|
||||
@@ -421,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")
|
||||
@@ -435,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")
|
||||
@@ -450,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")
|
||||
@@ -466,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)
|
||||
@@ -488,6 +497,7 @@ namespace MP.Data.Controllers
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
#endif
|
||||
#if false
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config Async
|
||||
@@ -495,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()
|
||||
@@ -511,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)
|
||||
@@ -642,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);
|
||||
@@ -869,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)
|
||||
@@ -891,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)
|
||||
@@ -914,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)
|
||||
@@ -936,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)
|
||||
@@ -957,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)
|
||||
@@ -980,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)))
|
||||
@@ -995,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);
|
||||
@@ -1012,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)
|
||||
@@ -1060,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()
|
||||
@@ -1076,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)
|
||||
@@ -1085,6 +1095,8 @@ namespace MP.Data.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato)
|
||||
/// </summary>
|
||||
@@ -1099,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);
|
||||
@@ -1124,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);
|
||||
|
||||
@@ -1142,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
|
||||
@@ -1162,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);
|
||||
@@ -1187,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);
|
||||
@@ -1210,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)
|
||||
@@ -1226,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
|
||||
@@ -1265,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
|
||||
@@ -1298,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()
|
||||
@@ -1315,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);
|
||||
|
||||
@@ -1350,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()
|
||||
@@ -1372,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);
|
||||
@@ -1434,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)
|
||||
@@ -1450,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
|
||||
@@ -1470,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
|
||||
@@ -1503,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()
|
||||
@@ -1522,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()
|
||||
@@ -1538,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()
|
||||
@@ -1556,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()
|
||||
@@ -1595,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()
|
||||
@@ -1630,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)
|
||||
@@ -1670,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)
|
||||
@@ -1687,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
|
||||
@@ -1703,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)
|
||||
@@ -1737,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)
|
||||
@@ -1751,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)
|
||||
@@ -1775,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)))
|
||||
@@ -1791,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
|
||||
@@ -1847,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
|
||||
@@ -1859,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()
|
||||
@@ -1885,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)
|
||||
@@ -1912,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)
|
||||
@@ -1925,7 +1938,8 @@ namespace MP.Data.Controllers
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record + vecchi della data-ora indicata
|
||||
@@ -1934,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)
|
||||
@@ -1960,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))
|
||||
@@ -1976,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)
|
||||
@@ -2006,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
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using DnsClient.Protocol;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using static MP.Core.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
@@ -19,6 +15,10 @@ namespace MP.Data.Controllers
|
||||
public MpVocController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
string connStr = _configuration.GetConnectionString("MP.Voc");
|
||||
options = new DbContextOptionsBuilder<MoonPro_VocContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
Log.Info("Avviata classe MpVocController");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace MP.Data.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
private DbContextOptions<MoonPro_VocContext> options;
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config
|
||||
/// </summary>
|
||||
@@ -33,15 +34,12 @@ namespace MP.Data.Controllers
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_VocContext(options);
|
||||
return dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -55,15 +53,12 @@ namespace MP.Data.Controllers
|
||||
public List<LingueModel> LingueGetAll()
|
||||
{
|
||||
List<LingueModel> dbResult = new List<LingueModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetLilngue
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lingua)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_VocContext(options);
|
||||
return dbCtx
|
||||
.DbSetLilngue
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lingua)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,15 +68,12 @@ namespace MP.Data.Controllers
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_VocContext(options);
|
||||
return dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using MP.AppAuth.Controllers;
|
||||
using MP.AppAuth.Services;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.Repository.Anag;
|
||||
using MP.Data.Repository.Dossier;
|
||||
using MP.Data.Repository.FluxLog;
|
||||
using MP.Data.Repository.IOC;
|
||||
using MP.Data.Repository.MpLand;
|
||||
using MP.Data.Repository.MpMon;
|
||||
using MP.Data.Repository.MpVoc;
|
||||
using MP.Data.Repository.Mtc;
|
||||
using MP.Data.Repository.Production;
|
||||
using MP.Data.Repository.System;
|
||||
using MP.Data.Repository.Utils;
|
||||
using MP.Data.Services;
|
||||
using MP.Data.Services.IOC;
|
||||
@@ -15,6 +23,8 @@ namespace MP.Data
|
||||
{
|
||||
public static class DataServiceCollectionExtensions
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per IOC
|
||||
/// </summary>
|
||||
@@ -24,6 +34,7 @@ namespace MP.Data
|
||||
{
|
||||
// Repository Singleton
|
||||
services.TryAddSingleton<IMtcSetupRepository, MtcSetupRepository>();
|
||||
services.TryAddSingleton<IProductionRepository, ProductionRepository>();
|
||||
|
||||
// Repository Scoped
|
||||
services.TryAddScoped<IIocRepository, IocRepository>();
|
||||
@@ -41,6 +52,41 @@ namespace MP.Data
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per LAND
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddLandDataLayer(this IServiceCollection services)
|
||||
{
|
||||
// Controllers MP.AppAuth (dipendenze di AppAuthService)
|
||||
services.TryAddScoped<AppAuthController>();
|
||||
services.TryAddScoped<MPController>();
|
||||
services.TryAddScoped<AppUserController>();
|
||||
|
||||
// Servizi LAND
|
||||
services.TryAddSingleton<IMpLandRepository, MpLandRepository>();
|
||||
services.TryAddSingleton<MpIocController>();
|
||||
services.TryAddSingleton<SyncService>();
|
||||
services.TryAddSingleton<TabDataService>();
|
||||
services.TryAddSingleton<LandDataService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per MON
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddMonDataLayer(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddSingleton<IMpMonRepository, MpMonRepository>();
|
||||
services.TryAddSingleton<MonDataFeeder>();
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per SPEC
|
||||
/// </summary>
|
||||
@@ -49,39 +95,79 @@ namespace MP.Data
|
||||
public static IServiceCollection AddSpecDataLayer(this IServiceCollection services)
|
||||
{
|
||||
// ---------- Start Repository ----------
|
||||
// Singleton
|
||||
services.TryAddSingleton<IAnagRepository, AnagRepository>();
|
||||
|
||||
// Scoped
|
||||
|
||||
services.TryAddScoped<IAnagRepository, AnagRepository>();
|
||||
|
||||
services.TryAddScoped<IProductionRepository, ProductionRepository>();
|
||||
services.TryAddScoped<IDossierRepository, DossierRepository>();
|
||||
services.TryAddScoped<IFluxLogRepository, FluxLogRepository>();
|
||||
services.TryAddScoped<ISystemRepository, SystemRepository>();
|
||||
services.TryAddScoped<IMpMonRepository, MpMonRepository>();
|
||||
services.TryAddScoped<IMpVocRepository, MpVocRepository>();
|
||||
services.TryAddScoped<IMpLandRepository, MpLandRepository>();
|
||||
// ---------- End Repository ----------
|
||||
|
||||
|
||||
// ---------- Start Servizi ----------
|
||||
|
||||
// Singleton
|
||||
|
||||
// Scoped
|
||||
|
||||
//services.TryAddSingleton<MpDataService>();
|
||||
// ---------- End Servizi ----------
|
||||
|
||||
|
||||
// ---------- Start Altro ----------
|
||||
// Singleton
|
||||
services.TryAddSingleton<AppAuthService>();
|
||||
services.TryAddSingleton<ListSelectDataSrv>();
|
||||
services.TryAddSingleton<MpIocController>();
|
||||
services.TryAddScoped<AppAuthController>();
|
||||
services.TryAddScoped<MPController>();
|
||||
services.TryAddScoped<AppUserController>();
|
||||
services.TryAddScoped<AppAuthService>();
|
||||
services.TryAddScoped<OrderDataSrv>();
|
||||
services.TryAddScoped<ListSelectDataSrv>();
|
||||
services.TryAddSingleton<SharedMemService>();
|
||||
services.TryAddSingleton<TabDataService>();
|
||||
services.TryAddSingleton<TabDataFeeder>();
|
||||
|
||||
// Scoped
|
||||
services.TryAddScoped<TabDataFeeder>();
|
||||
services.AddScoped<ISessionStorageService, SessionStorageService>();
|
||||
services.AddScoped<ILocalStorageService, LocalStorageService>();
|
||||
|
||||
// ---------- End Altro ----------
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per STATS
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddStatsDataLayer(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IMpVocRepository, MpVocRepository>();
|
||||
|
||||
services.AddSingleton<TranslateSrv>();
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta repository/servizi specifici per TAB
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddTabDataLayer(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddSingleton<IAnagRepository, AnagRepository>();
|
||||
services.TryAddSingleton<IProductionRepository, ProductionRepository>();
|
||||
services.TryAddSingleton<IMpMonRepository, MpMonRepository>();
|
||||
|
||||
services.TryAddSingleton<ISystemRepository, SystemRepository>();
|
||||
|
||||
services.TryAddSingleton<MpIocController>();
|
||||
services.TryAddSingleton<TabDataFeeder>();
|
||||
services.TryAddSingleton<StatusData>();
|
||||
services.TryAddSingleton<ListSelectDataSrv>();
|
||||
services.TryAddSingleton<OrderDataSrv>();
|
||||
services.TryAddSingleton<SharedMemService>();
|
||||
services.TryAddSingleton<TabDataService>();
|
||||
services.TryAddScoped<MessageService>();
|
||||
// aggiunta helper local/session storage service
|
||||
services.TryAddScoped<ISessionStorageService, SessionStorageService>();
|
||||
services.TryAddScoped<ILocalStorageService, LocalStorageService>();
|
||||
return services;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -16,6 +17,7 @@ namespace MP.Data.DbModels
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int AlarmLogId { get; set; } = 0;
|
||||
public DateTime DtRif { get; set; } = DateTime.Now;
|
||||
[Precision(18, 6)]
|
||||
public decimal Duration { get; set; } = 0;
|
||||
public string MachineId { get; set; } = "";
|
||||
public string MemAddress { get; set; } = "";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MP.Data.DbModels
|
||||
{
|
||||
@@ -6,6 +7,7 @@ namespace MP.Data.DbModels
|
||||
{
|
||||
[Key]
|
||||
public string DbName { get; set; } = "";
|
||||
[Precision(18, 6)]
|
||||
public decimal DbSizeMb { get; set; } = 0;
|
||||
public int NumTables { get; set; } = 0;
|
||||
public string BigTable { get; set; } = "";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -35,11 +36,13 @@ namespace MP.Data.DbModels
|
||||
/// <summary>
|
||||
/// Tempo Ciclo std
|
||||
/// </summary>
|
||||
[Precision(18, 6)]
|
||||
public decimal TCiclo { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Minuti prodotti (da TC e pz prod
|
||||
/// </summary>
|
||||
[Precision(18, 6)]
|
||||
public decimal MinProd { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +53,7 @@ namespace MP.Data.DbModels
|
||||
[NotMapped]
|
||||
public bool IsWork
|
||||
{
|
||||
get => IdxTipoEv == 1;
|
||||
get => IdxTipoEv == 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -19,7 +20,9 @@ namespace MP.Data.DbModels
|
||||
public string CodArticolo { get; set; } = "";
|
||||
public string IdxMacchina { get; set; }
|
||||
public int NumPezzi { get; set; }
|
||||
[Precision(18, 6)]
|
||||
public decimal Tcassegnato { get; set; }
|
||||
[Precision(18, 6)]
|
||||
public decimal TCRichAttr { get; set; }
|
||||
public DateTime? DataInizio { get; set; }
|
||||
public DateTime? DataFine { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -21,6 +22,7 @@ namespace MP.Data.DbModels
|
||||
[MaxLength(50)]
|
||||
public string IdxMacchina { get; set; }
|
||||
public int NumPezzi { get; set; }
|
||||
[Precision(18, 6)]
|
||||
public decimal Tcassegnato { get; set; }
|
||||
public DateTime? DataInizio { get; set; }
|
||||
public DateTime? DataFine { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -28,6 +29,7 @@ namespace MP.Data.DbModels
|
||||
[MaxLength(50)]
|
||||
public string IdxMacchina { get; set; }
|
||||
public int NumPezzi { get; set; } = 1;
|
||||
[Precision(18, 6)]
|
||||
public decimal Tcassegnato { get; set; } = 1;
|
||||
public DateTime? DueDate { get; set; }
|
||||
public int Priorita { get; set; } = 1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -29,6 +30,7 @@ namespace MP.Data.DbModels
|
||||
[MaxLength(50)]
|
||||
public string IdxMacchina { get; set; }
|
||||
public int NumPezzi { get; set; } = 1;
|
||||
[Precision(18, 6)]
|
||||
public decimal Tcassegnato { get; set; } = 1;
|
||||
public DateTime? DueDate { get; set; }
|
||||
public int Priorita { get; set; } = 1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -24,10 +25,12 @@ namespace MP.Data.DbModels
|
||||
/// <summary>
|
||||
/// Score Cicli Associati
|
||||
/// </summary>
|
||||
[Precision(18, 6)]
|
||||
public decimal ChildScore { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Score complessivo
|
||||
/// </summary>
|
||||
[Precision(18, 6)]
|
||||
public decimal TotalScore { get; set; } = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace MP.Data
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
#if false
|
||||
private IConfiguration _configuration;
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -27,15 +29,17 @@ namespace MP.Data
|
||||
/// Indispensabile x prima generazione migrations EFCore
|
||||
/// </summary>
|
||||
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. use DbContextoptions instead.")]
|
||||
public MoonPro_FluxContext()
|
||||
{
|
||||
}
|
||||
|
||||
#if false
|
||||
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. use DbContextoptions instead.")]
|
||||
public MoonPro_FluxContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public MoonPro_FluxContext(DbContextOptions<MoonPro_FluxContext> options) : base(options)
|
||||
{
|
||||
@@ -69,6 +73,7 @@ namespace MP.Data
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
#if false
|
||||
string connString = _configuration.GetConnectionString("MP.Flux");
|
||||
if (!string.IsNullOrEmpty(connString))
|
||||
{
|
||||
@@ -77,7 +82,9 @@ namespace MP.Data
|
||||
else
|
||||
{
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_FluxData;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_FluxData;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,20 @@ namespace MP.Data
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
#if false
|
||||
private IConfiguration _configuration;
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
#if false
|
||||
public MoonPro_STATSContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public MoonPro_STATSContext(DbContextOptions<MoonPro_STATSContext> options) : base(options)
|
||||
{
|
||||
@@ -68,10 +72,7 @@ namespace MP.Data
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = _configuration.GetConnectionString("MP.Stats");
|
||||
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
//optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_STATS;Trusted_Connection=True;");
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_STATS;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
|
||||
@@ -17,16 +14,16 @@ namespace MP.Data
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
//private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MoonPro_VocContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
//public MoonPro_VocContext(IConfiguration configuration)
|
||||
//{
|
||||
// _configuration = configuration;
|
||||
//}
|
||||
|
||||
public MoonPro_VocContext(DbContextOptions<MoonPro_VocContext> options) : base(options)
|
||||
{
|
||||
@@ -52,11 +49,16 @@ namespace MP.Data
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
//if (!optionsBuilder.IsConfigured)
|
||||
//{
|
||||
// string connString = _configuration.GetConnectionString("MP.Voc");
|
||||
|
||||
// optionsBuilder.UseSqlServer(connString);
|
||||
//}
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = _configuration.GetConnectionString("MP.Voc");
|
||||
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
// fallback si spera non necessario
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,40 @@ namespace MP.Data.Repository.Anag
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RepartiDTO>> GruppiRepartoDtoByOperAsync(int matrOpr)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var listReparti = await AnagGruppiGetTipoAsync("REPARTO");
|
||||
|
||||
var listMacc = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
var listOpr = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
var gruppiOpr = await dbCtx.DbSetGrp2Oper
|
||||
.Where(x => x.MatrOpr == matrOpr)
|
||||
.Select(x => x.CodGruppo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
return listReparti
|
||||
.Where(r => gruppiOpr.Contains(r.CodGruppo))
|
||||
.Select(x => new RepartiDTO()
|
||||
{
|
||||
CodGruppo = x.CodGruppo,
|
||||
TipoGruppo = x.TipoGruppo,
|
||||
DescrGruppo = x.DescrGruppo,
|
||||
SelEnabled = x.SelEnabled,
|
||||
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(y => y.IdxMacchina).Distinct().Count(),
|
||||
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(y => y.MatrOpr).Distinct().Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
@@ -431,14 +465,13 @@ namespace MP.Data.Repository.Anag
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni da cache o DB
|
||||
|
||||
/// Recupero dizionario traduzioni
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
public async Task<Dictionary<string, string>> VocabolarioGetLangAsync(string lingua)
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
using var dbCtx = _ctxFactory.CreateDbContextAsync().GetAwaiter().GetResult();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
|
||||
@@ -75,14 +75,6 @@ namespace MP.Data.Repository.Anag
|
||||
/// <returns>Lista di valori ammessi</returns>
|
||||
Task<List<ListValuesModel>> AnagTipoArtLvAsync();
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
/// <returns>Lista di codici articolo</returns>
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio num articoli Async
|
||||
/// </summary>
|
||||
@@ -154,6 +146,20 @@ namespace MP.Data.Repository.Anag
|
||||
/// <returns>True se aggiornato</returns>
|
||||
Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Gruppi tipo REPARTOin formato DTO con conteggi del numero record trovati filtrati per operatore
|
||||
/// </summary>
|
||||
/// <returns>Lista di DTO reparti con conteggio macchine e operatori</returns>
|
||||
Task<List<RepartiDTO>> GruppiRepartoDtoByOperAsync(int matrOpr);
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
/// <returns>Lista di codici articolo</returns>
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x tabella/colonna Async
|
||||
/// </summary>
|
||||
@@ -191,11 +197,11 @@ namespace MP.Data.Repository.Anag
|
||||
Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds);
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni da cache o DB
|
||||
/// Recupero dizionario traduzioni
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
Task<Dictionary<string, string>> VocabolarioGetLangAsync(string lingua);
|
||||
Dictionary<string, string> VocabolarioGetLang(string lingua);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Dossier
|
||||
{
|
||||
public class DossierRepository : IDossierRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public DossierRepository(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ArticleWithDossierAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Select(i => i.CodArticolo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersDeleteRecordAsync(DossierModel currRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == currRec.IdxDossier)
|
||||
.FirstOrDefaultAsync();
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.Remove(currVal);
|
||||
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<DossierModel>> DossiersGetLastFiltAsync(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd, int MaxRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodArticolo == "*" || x.CodArticolo == CodArticolo) && (x.DtRif >= DtStart && x.DtRif <= DtEnd))
|
||||
.Include(m => m.MachineNav)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.OrderByDescending(x => x.DtRif)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersInsertAsync(DossierModel newRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDtMin = new SqlParameter("@DtMin", dtMin);
|
||||
var pDtMax = new SqlParameter("@DtMax", dtMax);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_FL_TakeSnapshotLast @IdxMacchina,@DtMin,@DtMax", pIdxMacchina, pDtMin, pDtMax);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersUpdateValoreAsync(DossierModel editRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == editRec.IdxDossier)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Valore = editRec.Valore;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Dossier
|
||||
{
|
||||
public interface IDossierRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
Task<bool> DossiersDeleteRecordAsync(DossierModel currRec);
|
||||
|
||||
Task<List<DossierModel>> DossiersGetLastFiltAsync(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd, int MaxRec);
|
||||
|
||||
Task<bool> DossiersInsertAsync(DossierModel newRec);
|
||||
|
||||
Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax);
|
||||
|
||||
Task<bool> DossiersUpdateValoreAsync(DossierModel editRec);
|
||||
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static EgwCoreLib.Utils.DtUtils;
|
||||
|
||||
namespace MP.Data.Repository.FluxLog
|
||||
{
|
||||
public class FluxLogRepository : IFluxLogRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public FluxLogRepository(IConfiguration configuration, IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<StatDedupDTO>> FluxLogDataReduxAsync(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem)
|
||||
{
|
||||
List<StatDedupDTO> procStats = new List<StatDedupDTO>();
|
||||
Log.Info($"Inizio FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
TimeSpan step = TimeSpan.FromHours(1);
|
||||
switch (intReq)
|
||||
{
|
||||
case Enums.DataInterval.minute:
|
||||
step = TimeSpan.FromMinutes(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
case Enums.DataInterval.hour:
|
||||
step = TimeSpan.FromHours(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
case Enums.DataInterval.day:
|
||||
step = TimeSpan.FromDays(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMaccSel);
|
||||
var pOnlyTest = new SqlParameter("@OnlyTest", false);
|
||||
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
foreach (var item in fluxList)
|
||||
{
|
||||
Log.Info($"FluxLogDataReduxAsync | Flux: {item}");
|
||||
int numRecProc = 0;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var pCodFlux = new SqlParameter("@CodFlux", item);
|
||||
DateTime dtCursStart = currPeriodo.Inizio;
|
||||
DateTime dtCursEnd = dtCursStart.Add(step);
|
||||
bool setCompleted = false;
|
||||
while (!setCompleted)
|
||||
{
|
||||
var currFlux = await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (x.CodFlux == item) && (x.dtEvento >= dtCursStart && x.dtEvento < dtCursEnd) && (x.IdxMacchina == idxMaccSel))
|
||||
.ToListAsync();
|
||||
|
||||
int numRec = currFlux.Count;
|
||||
numRecProc += numRec;
|
||||
if (numRec > maxItem)
|
||||
{
|
||||
List<Periodo> listPeriodi = new List<Periodo>();
|
||||
|
||||
switch (valMode)
|
||||
{
|
||||
case Enums.ValSelection.First:
|
||||
var recStart = currFlux.Skip(1).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(recStart.dtEvento, dtCursEnd));
|
||||
break;
|
||||
|
||||
case Enums.ValSelection.Last:
|
||||
var recEnd = currFlux.LastOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtCursStart, recEnd.dtEvento));
|
||||
break;
|
||||
|
||||
case Enums.ValSelection.Center:
|
||||
int idx = 1;
|
||||
var recCent = currFlux.Skip(idx / (maxItem + 1)).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtCursStart, recCent.dtEvento));
|
||||
if (maxItem > 1)
|
||||
{
|
||||
for (int i = 2; i < maxItem; i++)
|
||||
{
|
||||
DateTime dtInizio = recCent.dtEvento;
|
||||
recCent = currFlux.Skip(i / (maxItem + 1)).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtInizio, recCent.dtEvento));
|
||||
}
|
||||
}
|
||||
listPeriodi.Add(new Periodo(recCent.dtEvento.AddSeconds(1), dtCursEnd));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var slot in listPeriodi)
|
||||
{
|
||||
var pDtStart = new SqlParameter("@DtStart", slot.Inizio);
|
||||
var pDtEnd = new SqlParameter("@DtEnd", slot.Fine);
|
||||
await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC man.stp_ReduceFluxLog @IdxMacchina, @CodFlux, @DtStart, @DtEnd, @OnlyTest", pIdxMacchina, pCodFlux, pDtStart, pDtEnd, pOnlyTest);
|
||||
}
|
||||
}
|
||||
|
||||
dtCursStart = dtCursEnd;
|
||||
dtCursEnd = dtCursStart.Add(step);
|
||||
setCompleted = dtCursStart >= currPeriodo.Fine;
|
||||
}
|
||||
sw.Stop();
|
||||
StatDedupDTO currStat = new StatDedupDTO()
|
||||
{
|
||||
IdxMacchina = idxMaccSel,
|
||||
CodFlux = item,
|
||||
Interval = intReq,
|
||||
Num4Int = maxItem,
|
||||
NumRec = numRecProc,
|
||||
ProcTime = sw.Elapsed.TotalSeconds
|
||||
};
|
||||
procStats.Add(currStat);
|
||||
}
|
||||
Log.Info($"FINE FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
return procStats;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
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() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
|
||||
.AsNoTracking()
|
||||
.GroupBy(x => x.CodFlux)
|
||||
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
|
||||
.OrderByDescending(x => x.Qty)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using static EgwCoreLib.Utils.DtUtils;
|
||||
|
||||
namespace MP.Data.Repository.FluxLog
|
||||
{
|
||||
public interface IFluxLogRepository
|
||||
{
|
||||
Task<List<StatDedupDTO>> FluxLogDataReduxAsync(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem);
|
||||
|
||||
Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec);
|
||||
|
||||
Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpLand
|
||||
{
|
||||
public interface IMpLandRepository
|
||||
{
|
||||
Task<List<DbSizeModel>> AllDbInfoAsync();
|
||||
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
|
||||
Task<List<RemoteRebootLogModel>> RemRebootLogGetAllAsync();
|
||||
|
||||
Task<List<RemoteRebootLogModel>> RemRebootLogGetLastAsync();
|
||||
|
||||
Task<List<RemoteRebootLogModel>> RemRebootLogGetLastNoMaccAsync();
|
||||
|
||||
Task<List<MacchineModel>> MacchineGetAllAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpLand
|
||||
{
|
||||
public class MpLandRepository : IMpLandRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFluxLog;
|
||||
private readonly IDbContextFactory<MoonPro_STATSContext> _ctxFactoryStats;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MpLandRepository(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL,
|
||||
IDbContextFactory<MoonPro_STATSContext> ctxFactorySta)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFluxLog = ctxFactoryFL;
|
||||
_ctxFactoryStats= ctxFactorySta;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<DbSizeModel>> AllDbInfoAsync()
|
||||
{
|
||||
List<DbSizeModel> dbResult = new List<DbSizeModel>();
|
||||
string stp_DbInfo = @"
|
||||
;WITH TableRowCounts AS (
|
||||
SELECT
|
||||
t.name AS TableName,
|
||||
SUM(p.rows) AS RowNum
|
||||
FROM sys.tables t
|
||||
JOIN sys.partitions p ON t.object_id = p.object_id
|
||||
WHERE p.index_id IN (0, 1)
|
||||
GROUP BY t.name
|
||||
),
|
||||
LargestTable AS (
|
||||
SELECT TOP 1 RowNum, TableName
|
||||
FROM TableRowCounts
|
||||
ORDER BY RowNum DESC
|
||||
)
|
||||
SELECT
|
||||
DB_name() as DbName,
|
||||
CAST(SUM(size) * 8.0 / 1024 AS DECIMAL(18,2)) AS DbSizeMb,
|
||||
(SELECT COUNT(*) FROM sys.tables) AS NumTables,
|
||||
(SELECT TableName FROM LargestTable) AS BigTable,
|
||||
(SELECT RowNum FROM LargestTable) AS BigTableRows
|
||||
FROM sys.master_files
|
||||
WHERE database_id = DB_ID();
|
||||
";
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.All")))
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Flux")))
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFluxLog.CreateDbContextAsync();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Stats")))
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryStats.CreateDbContextAsync();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetRemRebLog
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.IdxReboot)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetLastAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_getLast")
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RemoteRebootLogModel>> RemRebootLogGetLastNoMaccAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_GetLastNoMachine")
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpMon
|
||||
{
|
||||
public interface IMpMonRepository
|
||||
{
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
|
||||
Task<List<MacchineModel>> MacchineGetAllAsync();
|
||||
|
||||
Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo);
|
||||
|
||||
Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpMon
|
||||
{
|
||||
public class MpMonRepository : IMpMonRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MpMonRepository(IDbContextFactory<MoonProContext> ctxFactory)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
List<MacchineModel> dbResult;
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
dbResult = dbResult
|
||||
.Where(x => !string.IsNullOrEmpty(x.locazione))
|
||||
.OrderBy(x => x.locazione).ToList();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
var dbResult = await dbCtx
|
||||
.DbSetMSE
|
||||
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpVoc
|
||||
{
|
||||
public interface IMpVocRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// recupero elenco lingue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<LingueModel>> LingueGetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Recupero tutte le voci dizionario, async
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<VocabolarioModel>> VocabolarioGetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni x singola lingua
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
Dictionary<string, string> VocabolarioGetLang(string lingua);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.MpVoc
|
||||
{
|
||||
public class MpVocRepository : IMpVocRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MpVocRepository(IDbContextFactory<MoonPro_VocContext> ctxFactory)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LingueModel>> LingueGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLilngue
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lingua)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
using var dbCtx = _ctxFactory.CreateDbContextAsync().GetAwaiter().GetResult();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Lingua.ToLower() == lingua.ToLower())
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
// Proietto in dizionario
|
||||
return rawList
|
||||
.DistinctBy(t => t.Lemma, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(t => t.Lemma, t => t.Traduzione, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonPro_VocContext> _ctxFactory;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public abstract class BaseRepository
|
||||
{
|
||||
#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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public interface IProductionRepository
|
||||
{
|
||||
#region ODL Methods
|
||||
|
||||
Task<List<ODLExpModel>> ListODLFiltAsync(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<ODLExpModel> OdlByKeyAsync(int IdxOdl);
|
||||
|
||||
Task<bool> ODLCloseAsync(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd);
|
||||
|
||||
Task<List<ODLModel>> OdlGetCurrentAsync();
|
||||
|
||||
Task<List<StatODLModel>> OdlGetStatAsync(int IdxOdl);
|
||||
|
||||
Task<List<int>> OdlByBatchAsync(string batchSel);
|
||||
|
||||
#endregion
|
||||
|
||||
#region PODL Methods
|
||||
|
||||
Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<PODLModel> PODL_getByKeyAsync(int idxPODL);
|
||||
|
||||
Task<PODLModel> PODL_getByOdlAsync(int idxODL);
|
||||
|
||||
Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds);
|
||||
|
||||
Task<bool> PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note, DateTime dtEvent);
|
||||
|
||||
Task<bool> PODL_updateRecipe(int idxPODL, string recipeName);
|
||||
|
||||
Task<bool> PODLDeleteRecordAsync(PODLExpModel currRec);
|
||||
|
||||
Task<bool> PODLUpdateRecordAsync(PODLModel editRec);
|
||||
|
||||
Task<bool> PodlIstKitDeleteAsync(int IdxPODL);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Kit Methods
|
||||
|
||||
Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del);
|
||||
|
||||
Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd);
|
||||
|
||||
Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt);
|
||||
|
||||
Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec);
|
||||
|
||||
Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del);
|
||||
|
||||
Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild);
|
||||
|
||||
Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda);
|
||||
|
||||
Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del);
|
||||
|
||||
Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit);
|
||||
|
||||
Task<List<WipSetupKitModel>> WipKitFiltAsync(string KeyFilt);
|
||||
|
||||
Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec);
|
||||
|
||||
Task<List<TksScoreModel>> TksScoreAsync(string KeyFilt, int MaxResult);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Macchine / Gruppi Methods
|
||||
|
||||
Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo);
|
||||
|
||||
Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr);
|
||||
|
||||
Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd);
|
||||
|
||||
Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del);
|
||||
|
||||
Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec);
|
||||
|
||||
Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del);
|
||||
|
||||
Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec);
|
||||
|
||||
Task<StatoMacchineModel> StatoMacchinaAsync(string idxMacchina);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc Production Methods
|
||||
|
||||
Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000);
|
||||
|
||||
Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl);
|
||||
|
||||
Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo);
|
||||
Task<bool> OperatoriUpsertAsync(AnagOperatoriModel updRec);
|
||||
|
||||
Task<List<string>> ParametriGetFiltAsync(string IdxMacchina);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public class ProductionRepository : IProductionRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
public ProductionRepository(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task<MoonProContext> GetMoonProContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - ODL
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ODLExpModel>> ListODLFiltAsync(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var InCorso = new SqlParameter("@InCorso", inCorso);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGruppo = new SqlParameter("@CodGruppo", Reparto);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", IdxMacchina);
|
||||
var DataFrom = new SqlParameter("@DataFrom", startDate);
|
||||
var DataTo = new SqlParameter("@DataTo", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.FromSqlRaw("EXEC stp_ODL_getByFiltSpec @InCorso, @CodArt, @KeyRich, @CodGruppo, @IdxMacchina, @DataFrom, @DataTo", InCorso, CodArt, KeyRich, CodGruppo, IdxMacc, DataFrom, DataTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ODLExpModel> OdlByKeyAsync(int IdxOdl)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.IdxOdl == IdxOdl);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ODLCloseAsync(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd)
|
||||
{
|
||||
bool fatto = false;
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
|
||||
try
|
||||
{
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina);
|
||||
fatto = dbResult != 0;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
NLog.LogManager.GetCurrentClassLogger().Error($"Eccezione durante ODLCloseAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ODLModel>> OdlGetCurrentAsync()
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODL
|
||||
.Where(x => x.DataInizio != null && x.DataFine == null)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<StatODLModel>> OdlGetStatAsync(int IdxOdl)
|
||||
{
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetStatOdl
|
||||
.FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<int>> OdlByBatchAsync(string batchSel)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_InveContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbGiacenzeData
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxOdl > 0)
|
||||
.Select(x => x.IdxOdl)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - PODL
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DateFrom = new SqlParameter("@DtInizio", startDate);
|
||||
var DateTo = new SqlParameter("@DtFine", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByCodArt @CodArticolo, @onlyAvail", pCodArticolo, pOnlyAvail)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByParentKitIdx @IdxPodlParent", pIdxPodlParent)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DateFrom = new SqlParameter("@DtInizio", startDate);
|
||||
var DateTo = new SqlParameter("@DtFine", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByFiltSpecKit @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<PODLModel> PODL_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.FirstOrDefaultAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<PODLModel> PODL_getByOdlAsync(int idxODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxOdl == idxODL)
|
||||
.FirstOrDefaultAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds)
|
||||
{
|
||||
if (missingIds == null || !missingIds.Any())
|
||||
return new Dictionary<int, int>();
|
||||
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => missingIds.Contains(x.IdxOdl))
|
||||
.ToDictionaryAsync(x => x.IdxOdl, x => x.IdxPromessa);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note, DateTime dtEvent)
|
||||
{
|
||||
bool answ = false;
|
||||
PODLModel recPODL = new PODLModel()
|
||||
{
|
||||
IdxPromessa = editRec.IdxPromessa,
|
||||
KeyRichiesta = editRec.KeyRichiesta,
|
||||
KeyBCode = editRec.KeyBCode,
|
||||
IdxOdl = editRec.IdxOdl,
|
||||
CodArticolo = editRec.CodArticolo,
|
||||
CodGruppo = editRec.CodGruppo,
|
||||
IdxMacchina = editRec.IdxMacchina,
|
||||
NumPezzi = editRec.NumPezzi,
|
||||
Tcassegnato = editRec.Tcassegnato,
|
||||
DueDate = editRec.DueDate,
|
||||
Priorita = editRec.Priorita,
|
||||
PzPallet = editRec.PzPallet,
|
||||
Note = editRec.Note,
|
||||
CodCli = editRec.CodCli,
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (currRec != null)
|
||||
{
|
||||
var IdxPromessa = new SqlParameter("@idxPromessa", recPODL.IdxPromessa);
|
||||
var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", recPODL.IdxMacchina);
|
||||
var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich);
|
||||
var PzPallet = new SqlParameter("@PzPallet", pzPallet);
|
||||
var Note = new SqlParameter("@Note", note);
|
||||
var DtEvento = new SqlParameter("@dtEvento", dtEvent);
|
||||
await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_ODL_inizioSetupPromessa @idxPromessa, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note, @dtEvento", IdxPromessa, MatrOpr, IdxMacchina, TCRichAttr, PzPallet, Note, DtEvento);
|
||||
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODL_updateRecipe(int idxPODL, string recipeName)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Recipe = recipeName;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
answ = await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODLDeleteRecordAsync(PODLExpModel currRec)
|
||||
{
|
||||
PODLModel recPODL = new PODLModel()
|
||||
{
|
||||
IdxPromessa = currRec.IdxPromessa,
|
||||
KeyRichiesta = currRec.KeyRichiesta,
|
||||
KeyBCode = currRec.KeyBCode,
|
||||
IdxOdl = currRec.IdxOdl,
|
||||
CodArticolo = currRec.CodArticolo,
|
||||
CodGruppo = currRec.CodGruppo,
|
||||
IdxMacchina = currRec.IdxMacchina,
|
||||
NumPezzi = currRec.NumPezzi,
|
||||
Tcassegnato = currRec.Tcassegnato,
|
||||
DueDate = currRec.DueDate,
|
||||
Priorita = currRec.Priorita,
|
||||
PzPallet = currRec.PzPallet,
|
||||
Note = currRec.Note,
|
||||
CodCli = currRec.CodCli,
|
||||
InsertDate = currRec.InsertDate
|
||||
};
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
dbCtx
|
||||
.DbSetPODL
|
||||
.Remove(currVal);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODLUpdateRecordAsync(PODLModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.CodGruppo = editRec.CodGruppo;
|
||||
currRec.CodArticolo = editRec.CodArticolo;
|
||||
currRec.IdxMacchina = editRec.IdxMacchina;
|
||||
currRec.KeyBCode = editRec.KeyBCode;
|
||||
currRec.KeyRichiesta = editRec.KeyRichiesta;
|
||||
currRec.NumPezzi = editRec.NumPezzi;
|
||||
currRec.Tcassegnato = editRec.Tcassegnato;
|
||||
currRec.Attivabile = editRec.Attivabile;
|
||||
currRec.Note = editRec.Note;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetPODL
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PodlIstKitDeleteAsync(int IdxPODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_PodlIstKit_delete @IdxPODL", pIdxPODL);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Kit
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetInstKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
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)))
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetInstKit
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArtParent = editRec.CodArtParent;
|
||||
actRec.CodArtChild = editRec.CodArtChild;
|
||||
actRec.QtyART = editRec.QtyART;
|
||||
actRec.QtyKIT = editRec.QtyKIT;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetTempKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
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)))
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var recArt = await dbCtx
|
||||
.DbSetArticoli
|
||||
.FirstOrDefaultAsync(x => x.CodArticolo == editRec.CodArtParent);
|
||||
if (recArt == null)
|
||||
{
|
||||
AnagArticoliModel newRecArt = new AnagArticoliModel()
|
||||
{
|
||||
CodArticolo = editRec.CodArtParent,
|
||||
Tipo = "KIT",
|
||||
DescArticolo = $"Articolo KIT - {DateTime.Now:yyyy-MM-dd HH:mm:ss}",
|
||||
Disegno = "",
|
||||
Azienda = codAzienda,
|
||||
CurrRev = "",
|
||||
ProdRev = ""
|
||||
};
|
||||
dbCtx
|
||||
.DbSetArticoli
|
||||
.Add(newRecArt);
|
||||
}
|
||||
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == editRec.CodArtParent && x.CodArtChild == editRec.CodArtChild)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetTempKit
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.Qty = editRec.Qty;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.DataIns < dateLimit)
|
||||
.ToListAsync();
|
||||
if (actRec != null && actRec.Any())
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.RemoveRange(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<WipSetupKitModel>> WipKitFiltAsync(string KeyFilt)
|
||||
{
|
||||
List<WipSetupKitModel> dbResult = new List<WipSetupKitModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt.Contains(KeyFilt))
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Add(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArt = editRec.CodArt;
|
||||
actRec.DescArt = editRec.DescArt;
|
||||
actRec.Qta = editRec.Qta;
|
||||
actRec.DataIns = editRec.DataIns;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<TksScoreModel>> TksScoreAsync(string KeyFilt, int MaxResult)
|
||||
{
|
||||
List<TksScoreModel> dbResult = new List<TksScoreModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
var pMaxRes = new SqlParameter("@maxResult", MaxResult);
|
||||
dbResult = await dbCtx
|
||||
.DbSetTksScore
|
||||
.FromSqlRaw("EXEC stp_TKS_Search @KeyFilt, @maxResult", pKeyFilt, pMaxRes)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Macchine/Gruppi
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(g => g.MatrOpr == MatrOpr)
|
||||
.Join(dbCtx.DbSetGrp2Macc,
|
||||
g => g.CodGruppo,
|
||||
m => m.CodGruppo,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => x.dtEvento >= dtStart && x.dtEvento <= dtEnd)
|
||||
.Select(i => i.IdxMacchina)
|
||||
.Distinct()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.IdxMacchina == rec2del.IdxMacchina)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.DbSetGrp2Macc.Remove(dbRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.IdxMacchina == upsRec.IdxMacchina)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec == null)
|
||||
{
|
||||
await dbCtx.DbSetGrp2Macc.AddAsync(upsRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.MatrOpr == rec2del.MatrOpr)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.DbSetGrp2Oper.Remove(dbRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.MatrOpr == upsRec.MatrOpr)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec == null)
|
||||
{
|
||||
await dbCtx.DbSetGrp2Oper.AddAsync(upsRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<StatoMacchineModel> StatoMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetStatoMacc
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Misc
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMSE
|
||||
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_InveContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbGiacenzeData
|
||||
.Where(x => x.IdxOdl == IdxOdl)
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbOperatori
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbOperatori,
|
||||
g => g.MatrOpr,
|
||||
m => m.MatrOpr,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<bool> OperatoriUpsertAsync(AnagOperatoriModel updRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbOperatori
|
||||
.FindAsync(updRec.MatrOpr);
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.Entry(dbRec).CurrentValues.SetValues(updRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ParametriGetFiltAsync(string IdxMacchina)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina))
|
||||
.Take(1000)
|
||||
.Select(i => i.CodFlux)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.System
|
||||
{
|
||||
public interface ISystemRepository
|
||||
{
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
|
||||
Task<bool> ConfigUpdateAsync(ConfigModel updRec);
|
||||
|
||||
Task<bool> EvListInsertAsync(EventListModel newRec);
|
||||
|
||||
Task<bool> ForceDbMaintAsync(bool doExec, bool doUpdStat, bool doSave, int minPgCnt, int minAvgFrag, int maxAvgFragReb);
|
||||
|
||||
Task<List<LinkMenuModel>> ListLinkAllAsync();
|
||||
|
||||
Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink);
|
||||
|
||||
Task<List<LinkMenuModel>> ElencoLinkAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.System
|
||||
{
|
||||
public class SystemRepository : ISystemRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public SystemRepository(IDbContextFactory<MoonProContext> ctxFactory, IConfiguration configuration)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new();
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
dbResult.Valore = updRec.Valore;
|
||||
fatto = await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
_ = await dbCtx
|
||||
.DbSetEvList
|
||||
.AddAsync(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ForceDbMaintAsync(bool doExec, bool doUpdStat, bool doSave, int minPgCnt, int minAvgFrag, int maxAvgFragReb)
|
||||
{
|
||||
await using var dbCtx = new MoonProAdminContext(_configuration);
|
||||
|
||||
_ = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC man.stp_Utility_Maintanance");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LinkMenuModel>> ListLinkAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Ordine)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Ordine)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<List<LinkMenuModel>> ElencoLinkAsync()
|
||||
{
|
||||
return ListLinkFiltAsync("SpecLink");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
using static Org.BouncyCastle.Asn1.Cmp.Challenge;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -19,10 +21,12 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public BaseServ(IConfiguration configuration, IConnectionMultiplexer redConn)
|
||||
public BaseServ(IConfiguration configuration, IFusionCache cache, IConnectionMultiplexer redConn)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_cache = cache;
|
||||
|
||||
slowLogThresh = _configuration.GetValue<double>("ServerConf:slowLogThresh", 1);
|
||||
// Verifica conf trace...
|
||||
_traceEnabled = _configuration.GetValue<bool>("Otel:EnableTracing", false);
|
||||
|
||||
@@ -161,13 +165,23 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
protected static readonly ActivitySource ActivitySource = new ActivitySource("MP.IOC");
|
||||
|
||||
protected static IConfiguration _configuration = null!;
|
||||
/// <summary>
|
||||
/// Oggetto gestione FusionCache
|
||||
/// </summary>
|
||||
protected readonly IFusionCache _cache;
|
||||
|
||||
/// <summary>
|
||||
/// Path base chiavi REDIS
|
||||
/// </summary>
|
||||
protected readonly string _redisBaseKey = "MP:IOC";
|
||||
|
||||
/// <summary>
|
||||
/// Abilitazione operazioni tracing generiche
|
||||
/// </summary>
|
||||
protected readonly bool _traceEnabled = false;
|
||||
|
||||
protected IConfiguration _configuration = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
@@ -180,8 +194,19 @@ namespace MP.Data.Services
|
||||
protected IDatabase _redisDb = null!;
|
||||
|
||||
protected JsonSerializerSettings? JSSettings;
|
||||
|
||||
protected string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache Lunga standard (300 sec)
|
||||
/// </summary>
|
||||
protected int redisLongTimeCache = 300;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache Breve standard (5 sec)
|
||||
/// </summary>
|
||||
protected int redisShortTimeCache = 5;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
@@ -281,6 +306,75 @@ namespace MP.Data.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementa gestione FusionCache+ tracking attività
|
||||
/// - recupero cache da memoria o da obj esterno + cache memoria
|
||||
/// - recupero da fetchFunc se mancasse + store in cache L1/L2
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="cacheKey"></param>
|
||||
/// <param name="fetchFunc"></param>
|
||||
/// <param name="expiration"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task<T> GetOrFetchAsync<T>(string operationName, string cacheKey, Func<Task<T>> fetchFunc, TimeSpan expiration, params string[] tagList)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity(operationName);
|
||||
string source;
|
||||
var tryGet = await _cache.TryGetAsync<T>(cacheKey);
|
||||
if (tryGet.HasValue)
|
||||
{
|
||||
source = "MEMORY";
|
||||
var result = tryGet.Value!;
|
||||
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
// se supero la soglia loggo...
|
||||
if (activity?.Duration.TotalMilliseconds > slowLogThresh)
|
||||
{
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool fromDb = false;
|
||||
// cache in redis
|
||||
var cacheOptions = new FusionCacheEntryOptions()
|
||||
.SetDuration(expiration)
|
||||
.SetFailSafe(true);
|
||||
// cache in RAM per 1/3 del tempo x risparmiare risorse
|
||||
cacheOptions.MemoryCacheDuration = expiration / 3;
|
||||
|
||||
var final = await _cache.GetOrSetAsync<T>(
|
||||
cacheKey,
|
||||
async _ =>
|
||||
{
|
||||
fromDb = true;
|
||||
return await fetchFunc();
|
||||
},
|
||||
options: cacheOptions,
|
||||
tags: tagList
|
||||
);
|
||||
|
||||
source = fromDb ? "DB" : "REDIS";
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
// switch log in base a source..
|
||||
switch (source)
|
||||
{
|
||||
case "DB":
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms", reqLevel: NLog.LogLevel.Info);
|
||||
break;
|
||||
|
||||
case "REDIS":
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms", reqLevel: NLog.LogLevel.Debug);
|
||||
break;
|
||||
|
||||
default:
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms");
|
||||
break;
|
||||
}
|
||||
return final!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper generale di lettura da cache o da funzione (DB) con caching successivo
|
||||
/// </summary>
|
||||
@@ -327,6 +421,18 @@ namespace MP.Data.Services
|
||||
return result!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un timeout dal valore secondi richiesti + tempo random +/-3%
|
||||
/// </summary>
|
||||
/// <param name="durationSec"></param>
|
||||
/// <returns></returns>
|
||||
protected TimeSpan GetRandTOut(double durationSec)
|
||||
{
|
||||
double noise = (rand.NextDouble() * 0.06) - 0.03;
|
||||
double rValue = durationSec * (1 + noise);
|
||||
return TimeSpan.FromSeconds(rValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper trace messaggio log (SE abilitato)
|
||||
/// </summary>
|
||||
@@ -396,6 +502,7 @@ namespace MP.Data.Services
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
@@ -408,12 +515,14 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private Random rand = new Random();
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Path base chiavi REDIS
|
||||
/// Soglia minima (ms) per log timing in console
|
||||
/// </summary>
|
||||
protected readonly string _redisBaseKey = "MP:IOC";
|
||||
private double slowLogThresh = 0;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -23,17 +23,19 @@ namespace MP.Data.Services.IOC
|
||||
public IocService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IFusionCache cache,
|
||||
IIocRepository repo,
|
||||
IServiceScopeFactory scopeFactory,
|
||||
//Microsoft.Extensions.Caching.Memory.IMemoryCache cache
|
||||
IFusionCache cache) : base(config, redis)
|
||||
IServiceScopeFactory scopeFactory
|
||||
) : base(config, cache, redis)
|
||||
{
|
||||
_className = "IocServ";
|
||||
int.TryParse(config.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
|
||||
int.TryParse(config.GetValue<string>("ServerConf:redisShortTimeCache"), out redisShortTimeCache);
|
||||
_repo = repo;
|
||||
_scopeFactory = scopeFactory;
|
||||
_cache = cache;
|
||||
#if false
|
||||
_cache = cache;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -79,7 +81,7 @@ namespace MP.Data.Services.IOC
|
||||
result = await GetCurrOdlByProdAsync(idxMacchina);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
_redisDb.StringSet(currKey, rawData, GetRandTOut(redisLongTimeCache));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -261,16 +263,18 @@ namespace MP.Data.Services.IOC
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Restituisce un timeout dai minuti richiesti + tempo random 1..60 sec
|
||||
/// </summary>
|
||||
/// <param name="stdMinutes"></param>
|
||||
/// <returns></returns>
|
||||
protected TimeSpan getRandTOut(double stdMinutes)
|
||||
protected TimeSpan GetRandTOut(double stdMinutes)
|
||||
{
|
||||
double rndValue = stdMinutes + (double)rand.Next(1, 60) / 60;
|
||||
return TimeSpan.FromMinutes(rndValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -278,7 +282,9 @@ namespace MP.Data.Services.IOC
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IFusionCache _cache;
|
||||
#if false
|
||||
private readonly IFusionCache _cache;
|
||||
#endif
|
||||
|
||||
private readonly string _className;
|
||||
|
||||
@@ -295,9 +301,11 @@ namespace MP.Data.Services.IOC
|
||||
/// </summary>
|
||||
private string dtFormat = "yyyyMMddHHmmssfff";
|
||||
|
||||
#if false
|
||||
private int redisLongTimeCache = 5;
|
||||
|
||||
private int redisShortTimeCache = 2;
|
||||
private int redisShortTimeCache = 2;
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -417,7 +425,7 @@ namespace MP.Data.Services.IOC
|
||||
{
|
||||
result = await _repo.ConfigGetAllAsync();
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(MP.Data.Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
await _redisDb.StringSetAsync(MP.Data.Utils.redisConfKey, rawData, GetRandTOut(redisLongTimeCache));
|
||||
}
|
||||
Log.Debug($"ConfigGetAllAsync Read from {source}");
|
||||
if (result == null)
|
||||
@@ -544,7 +552,7 @@ namespace MP.Data.Services.IOC
|
||||
var fullList = await Macchine2SlaveGetAllAsync();
|
||||
result = fullList.Select(x => x.IdxMacchina).ToHashSet<string>();
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache * 10));
|
||||
await _redisDb.StringSetAsync(currKey, rawData, GetRandTOut(redisLongTimeCache * 10));
|
||||
}
|
||||
return result;
|
||||
}, TimeSpan.FromMinutes(15));
|
||||
@@ -566,7 +574,7 @@ namespace MP.Data.Services.IOC
|
||||
var fullList = await Macchine2SlaveGetAllAsync();
|
||||
result = fullList.Select(x => x.IdxMacchinaSlave).Distinct().ToHashSet<string>();
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache * 10));
|
||||
await _redisDb.StringSetAsync(currKey, rawData, GetRandTOut(redisLongTimeCache * 10));
|
||||
}
|
||||
return result;
|
||||
}, TimeSpan.FromMinutes(15));
|
||||
@@ -593,7 +601,7 @@ namespace MP.Data.Services.IOC
|
||||
result = await _repo.Macchine2SlaveAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache * 10));
|
||||
await _redisDb.StringSetAsync(currKey, rawData, GetRandTOut(redisLongTimeCache * 10));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -21,8 +22,14 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public LandDataService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public LandDataService(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache,
|
||||
Repository.MpLand.IMpLandRepository mpLandRepository
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
_mpLandRepository = mpLandRepository;
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Land");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
@@ -31,28 +38,21 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpLandController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"LandService | MpLandController OK");
|
||||
sb.AppendLine($"LandService | MpLandRepository OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static MpLandController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce info dimensione, tabelle e num righe DB
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DbSizeModel> AllDbInfo()
|
||||
public async Task<List<DbSizeModel>> AllDbInfoAsync()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
@@ -61,7 +61,7 @@ namespace MP.Data.Services
|
||||
List<DbSizeModel> result = new List<DbSizeModel>();
|
||||
// cerco in _redisConn...
|
||||
string currKey = $"{redisBaseKey}:DbInfo:ALL";
|
||||
RedisValue rawData = _redisDb.StringGet(currKey);
|
||||
RedisValue rawData = await _redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<DbSizeModel>>($"{rawData}");
|
||||
@@ -69,17 +69,17 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.AllDbInfo();
|
||||
result = await _mpLandRepository.AllDbInfoAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraFastCache);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<DbSizeModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"AllDbInfo | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"AllDbInfoAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -88,15 +88,15 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="UserName"></param>
|
||||
/// <returns></returns>
|
||||
public List<IobDTO> IobListAll()
|
||||
public async Task<List<IobDTO>> IobListAllAsync()
|
||||
{
|
||||
string source = "DB";
|
||||
List<IobDTO>? dbResult = new List<IobDTO>();
|
||||
string currKey = $"{redisBaseKey}:IobList";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string? rawData = _redisDb.StringGet(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2)
|
||||
var rawData = await _redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<IobDTO>>(rawData);
|
||||
@@ -105,10 +105,10 @@ namespace MP.Data.Services
|
||||
else
|
||||
{
|
||||
// recupero RRL missing
|
||||
var listRRl = dbController.RemRebootLogGetLast();
|
||||
var listRRlAdd = dbController.RemRebootLogGetLastNoMacc();
|
||||
var listRRl = await _mpLandRepository.RemRebootLogGetLastAsync();
|
||||
var listRRlAdd = await _mpLandRepository.RemRebootLogGetLastNoMaccAsync();
|
||||
// recupero lista macchine
|
||||
var ListMacch = dbController.MacchineGetAll();
|
||||
var ListMacch = await _mpLandRepository.MacchineGetAllAsync();
|
||||
// ...converto in DTO
|
||||
dbResult = ListMacch
|
||||
.Select(x => new IobDTO(x, IobInfo(x.IdxMacchina), MachIobConf(x.IdxMacchina)))
|
||||
@@ -125,14 +125,14 @@ namespace MP.Data.Services
|
||||
|
||||
// serializzo in cache _redisConn
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
_redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<IobDTO>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobListAll | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
Log.Debug($"IobListAllAsync | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.RemRebootLogGetAll();
|
||||
result = _mpLandRepository.RemRebootLogGetAllAsync().GetAwaiter().GetResult();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraFastCache);
|
||||
@@ -194,7 +194,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.RemRebootLogGetLast();
|
||||
result = _mpLandRepository.RemRebootLogGetLastAsync().GetAwaiter().GetResult();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraFastCache);
|
||||
@@ -219,7 +219,6 @@ namespace MP.Data.Services
|
||||
if (disposing)
|
||||
{
|
||||
// Free managed resources here
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
// Free unmanaged resources here
|
||||
@@ -234,6 +233,7 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly Repository.MpLand.IMpLandRepository _mpLandRepository;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _disposed = false;
|
||||
private string redisBaseKey = "MP:LAND:Cache";
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Repository.Anag;
|
||||
using MP.Data.Repository.Production;
|
||||
using MP.Data.Repository.System;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
@@ -9,8 +11,8 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -19,33 +21,34 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public class ListSelectDataSrv : BaseServ
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IAnagRepository _anagRepository;
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
private readonly ISystemRepository _systemRepository;
|
||||
private bool _disposed = false;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public ListSelectDataSrv(IConfiguration configuration, IConnectionMultiplexer redConn, IAnagRepository anagRepository) : base(configuration, redConn)
|
||||
public ListSelectDataSrv(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache,
|
||||
IAnagRepository anagRepository,
|
||||
IProductionRepository productionRepository,
|
||||
ISystemRepository systemRepository
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
_anagRepository = anagRepository;
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.All");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
dbController = new Controllers.MpSpecController(configuration);
|
||||
sb.AppendLine($"ListSelectDataSrv | MpSpecController OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
_productionRepository = productionRepository;
|
||||
_systemRepository = systemRepository;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpSpecController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -106,7 +109,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.ConfigGetAllAsync();
|
||||
result = await _systemRepository.ConfigGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, LongCache);
|
||||
@@ -162,7 +165,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.ListLinkAllAsync();
|
||||
result = await _systemRepository.ListLinkAllAsync();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
@@ -198,7 +201,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.ListLinkFiltAsync(tipoLink);
|
||||
result = await _systemRepository.ListLinkFiltAsync(tipoLink);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
@@ -234,7 +237,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.MacchineByMatrOperAsync(MatrOpr);
|
||||
result = await _productionRepository.MacchineByMatrOperAsync(MatrOpr);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
@@ -266,15 +269,6 @@ namespace MP.Data.Services
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IAnagRepository _anagRepository;
|
||||
private bool _disposed = false;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MonDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public MonDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn, Repository.MpMon.IMpMonRepository mpMonRepository) : base(configuration, redConn, mpMonRepository)
|
||||
{
|
||||
// setup canali pub/sub
|
||||
dataPipe = new MessagePipe(redisConn, Constants.MON_ACT_MSE_DATA_KEY);
|
||||
|
||||
@@ -5,6 +5,7 @@ using MP.Data.Repository.Mtc;
|
||||
using StackExchange.Redis;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services.Mtc
|
||||
{
|
||||
@@ -18,7 +19,8 @@ namespace MP.Data.Services.Mtc
|
||||
public MtcSetupService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IMtcSetupRepository repo) : base(config, redis)
|
||||
IFusionCache cache,
|
||||
IMtcSetupRepository repo) : base(config, cache, redis)
|
||||
{
|
||||
_className = "MtcSetup";
|
||||
_repo = repo;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Repository.Production;
|
||||
using MP.Data.Repository.System;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
@@ -8,6 +11,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -16,32 +20,31 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public class OrderDataSrv : BaseServ
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
private readonly ISystemRepository _systemRepository;
|
||||
private bool _disposed = false;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public OrderDataSrv(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public OrderDataSrv(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache,
|
||||
IProductionRepository productionRepository,
|
||||
ISystemRepository systemRepository
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.All");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpSpecController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"OrderDataSrv | MpSpecController OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
_productionRepository = productionRepository;
|
||||
_systemRepository = systemRepository;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpSpecController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -66,7 +69,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.ConfigGetAllAsync();
|
||||
result = await _systemRepository.ConfigGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, LongCache);
|
||||
@@ -109,7 +112,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.ListODLFiltAsync(inCorso, CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate);
|
||||
result = await _productionRepository.ListODLFiltAsync(inCorso, CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await _redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -140,13 +143,5 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _disposed = false;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -13,7 +14,11 @@ namespace MP.Data.Services
|
||||
/// Init servizio TAB
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public SchedulerDataService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public SchedulerDataService(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -15,7 +16,11 @@ namespace MP.Data.Services
|
||||
/// Init servizio TAB
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public SharedMemService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public SharedMemService(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Conf;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -20,9 +19,10 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatusData(IConfiguration configuration, IConnectionMultiplexer redConn)
|
||||
public StatusData(IConfiguration configuration, IConnectionMultiplexer redConn, Repository.MpMon.IMpMonRepository mpMonRepository)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_mpMonRepository = mpMonRepository;
|
||||
|
||||
// setup componenti REDIS
|
||||
this.redisConn = redConn;
|
||||
@@ -42,9 +42,8 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new MpMonController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"StatusData | MpMonController OK");
|
||||
sb.AppendLine($"StatusData | MpMonRepository OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
|
||||
@@ -70,8 +69,6 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static MpMonController dbController { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei tag configurati per IOB
|
||||
/// </summary>
|
||||
@@ -102,7 +99,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
result = await _mpMonRepository.ConfigGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
@@ -186,7 +183,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.MacchineGetAll());
|
||||
result = await _mpMonRepository.MacchineGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -198,7 +195,6 @@ namespace MP.Data.Services
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
//return Task.FromResult(dbController.MacchineGetAll());
|
||||
}
|
||||
|
||||
public async Task<List<MacchineModel>> MacchineGetByGruppo(string CodGruppo)
|
||||
@@ -217,8 +213,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.MacchineGetFilt(CodGruppo));
|
||||
//result = dbController.MacchineGetFilt(CodGruppo);
|
||||
result = await _mpMonRepository.MacchineGetFiltAsync(CodGruppo);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -339,7 +334,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.MseGetAllAsync(maxAge);
|
||||
result = await _mpMonRepository.MseGetAllAsync(maxAge);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(Constants.redisMseKey, rawData, UltraFastCache);
|
||||
@@ -383,8 +378,6 @@ namespace MP.Data.Services
|
||||
MachineProdStatus.Clear();
|
||||
// REDIS dispose
|
||||
redisDb = null;
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
// Free unmanaged resources here
|
||||
@@ -397,6 +390,7 @@ namespace MP.Data.Services
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private readonly Repository.MpMon.IMpMonRepository _mpMonRepository;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _disposed = false;
|
||||
|
||||
@@ -512,7 +506,7 @@ namespace MP.Data.Services
|
||||
if (fileConfData.IobSetup.ContainsKey("***"))
|
||||
{
|
||||
// recupero elenco macchine...
|
||||
var elencoMacc = dbController.MacchineGetAll();
|
||||
var elencoMacc = _mpMonRepository.MacchineGetAllAsync().GetAwaiter().GetResult();
|
||||
// x ogni macchina creo le righe standard da conf...
|
||||
var baseConf = fileConfData.IobSetup.Where(x => x.Key == "***").FirstOrDefault();
|
||||
foreach (var item in elencoMacc)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TabDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public TabDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn, Repository.MpMon.IMpMonRepository mpMonRepository) : base(configuration, redConn, mpMonRepository)
|
||||
{
|
||||
// setup canali pub/sub
|
||||
dataPipe = new MessagePipe(redisConn, Constants.TAB_ACT_MSE_DATA_KEY, false);
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -15,6 +16,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -26,7 +28,12 @@ namespace MP.Data.Services
|
||||
/// Init servizio TAB
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public TabDataService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public TabDataService(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache,
|
||||
MpIocController iocContr
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@@ -41,7 +48,7 @@ namespace MP.Data.Services
|
||||
StringBuilder sb = new StringBuilder();
|
||||
dbTabController = new Controllers.MpTabController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpTabController OK");
|
||||
dbIocController = new Controllers.MpIocController(configuration);
|
||||
dbIocController = iocContr;// new Controllers.MpIocController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpIocController OK");
|
||||
dbInveController = new Controllers.MpInveController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpInveController OK");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Conf;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Repository.FluxLog;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
@@ -13,6 +14,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -23,35 +25,57 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TranslateSrv(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
|
||||
public TranslateSrv(
|
||||
IConfiguration configuration,
|
||||
IConnectionMultiplexer redConn,
|
||||
IFusionCache cache,
|
||||
Repository.MpVoc.IMpVocRepository mpVocRepository
|
||||
) : base(configuration, cache, redConn)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Voc");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("MP.Voc: ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpVocController(configuration);
|
||||
InitDict();
|
||||
sw.Stop();
|
||||
Log.Info($"TranslateSrv | MpVocController OK | {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
_mpVocRepository = mpVocRepository;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpVocController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue traduzione dato vocabolario da Lingua + Lemma
|
||||
/// </summary>
|
||||
/// <param name="lemma"></param>
|
||||
/// <param name="lingua"></param>
|
||||
/// <returns></returns>
|
||||
public string Traduci(string lemma, string lingua = "IT")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(lemma)) return string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(lingua)) return lemma;
|
||||
|
||||
string linguaKey = lingua.ToLowerInvariant().Trim();
|
||||
string cacheKey = $"vocab:{linguaKey}";
|
||||
|
||||
// FusionCache gestisce il lock e recupera l'intero dizionario della lingua.
|
||||
// Se è in L1 (Memory), restituisce l'oggetto C# istantaneamente.
|
||||
// Se non c'è, passa a L2 (Redis) o invoca la factory per caricarlo.
|
||||
var dizionarioLingua = _cache.GetOrSet<Dictionary<string, string>>(
|
||||
cacheKey,
|
||||
_ => _mpVocRepository.VocabolarioGetLang(linguaKey),
|
||||
options => options
|
||||
.SetDuration(TimeSpan.FromHours(8)) // Durata logica della cache
|
||||
.SetFailSafe(true, TimeSpan.FromHours(1)) // Se Redis/DB è giù, usa i vecchi dati L1
|
||||
);
|
||||
|
||||
// Ricerca O(1) nel dizionario in memoria
|
||||
if (dizionarioLingua != null && dizionarioLingua.TryGetValue(lemma, out var traduzione))
|
||||
{
|
||||
return traduzione;
|
||||
}
|
||||
|
||||
// Fallback: se la parola non è censita, restituisce il lemma originale (lingua + lemma)
|
||||
return $"{lingua}_{lemma}";
|
||||
}
|
||||
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
@@ -73,7 +97,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
result = await _mpVocRepository.ConfigGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, LongCache);
|
||||
@@ -85,7 +109,8 @@ namespace MP.Data.Services
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
@@ -93,12 +118,15 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache()
|
||||
{
|
||||
#if false
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
// rileggo vocabolario!
|
||||
var rawData = await VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
return answ;
|
||||
return answ;
|
||||
#endif
|
||||
return await FlushFusionCacheAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,9 +135,51 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
{
|
||||
#if false
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
return answ;
|
||||
#endif
|
||||
return await FlushFusionCacheAsync(KeyReq);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancellazione FusionCache (totale)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> FlushFusionCacheAsync()
|
||||
{
|
||||
await _cache.ClearAsync(allowFailSafe: false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancellazione FusionCache dato singolo tag
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> FlushFusionCacheAsync(string tag)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(tag)) return false;
|
||||
|
||||
await _cache.RemoveByTagAsync(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancellazione FusionCache dato elenco tags
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> FlushFusionCacheAsync(List<string> listTags)
|
||||
{
|
||||
if (listTags == null || listTags.Count == 0) return false;
|
||||
|
||||
// Generiamo i Task di rimozione ed eseguiamoli in parallelo su Redis/L1
|
||||
var tasks = listTags
|
||||
.Where(tag => !string.IsNullOrWhiteSpace(tag))
|
||||
.Select(tag => _cache.RemoveByTagAsync(tag).AsTask());
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,6 +188,17 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
public async Task<List<LingueModel>> LingueGetAll()
|
||||
{
|
||||
string currKey = $"{redisBaseKey}:Lang";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "LingueGetAll",
|
||||
cacheKey: currKey,
|
||||
expiration: GetRandTOut(redisShortTimeCache),
|
||||
fetchFunc: async () => await _mpVocRepository.LingueGetAllAsync() ?? new(),
|
||||
tagList: [currKey]
|
||||
);
|
||||
|
||||
#if false
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -133,7 +214,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.LingueGetAll();
|
||||
result = await _mpVocRepository.LingueGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
@@ -144,9 +225,11 @@ namespace MP.Data.Services
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"LingueGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Traduzione termine
|
||||
/// </summary>
|
||||
@@ -162,7 +245,8 @@ namespace MP.Data.Services
|
||||
answ = DictVocab[key];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
@@ -170,6 +254,18 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAll()
|
||||
{
|
||||
string currKey = $"{redisBaseKey}:VocAll";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "VocabolarioGetAll",
|
||||
cacheKey: currKey,
|
||||
expiration: GetRandTOut(redisShortTimeCache),
|
||||
fetchFunc: async () => await _mpVocRepository.VocabolarioGetAllAsync() ?? new(),
|
||||
tagList: [currKey]
|
||||
);
|
||||
|
||||
|
||||
#if false
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -185,7 +281,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.VocabolarioGetAll();
|
||||
result = await _mpVocRepository.VocabolarioGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
@@ -196,63 +292,41 @@ namespace MP.Data.Services
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Vocabolario x recupero rapido traduzioni
|
||||
/// </summary>
|
||||
protected static Dictionary<string, string> DictVocab = new Dictionary<string, string>();
|
||||
protected static Dictionary<string, string> DictVocab = new Dictionary<string, string>();
|
||||
#endif
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Free managed resources here
|
||||
DictVocab.Clear();
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
// Free unmanaged resources here
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
// Call base class implementation.
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _disposed = false;
|
||||
|
||||
private string redisBaseKey = "MP:Voc:Cache";
|
||||
|
||||
private readonly Repository.MpVoc.IMpVocRepository _mpVocRepository;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione dict vari
|
||||
/// </summary>
|
||||
private static void InitDict()
|
||||
{
|
||||
// inizializzo dizionario vocabolario
|
||||
var rawData = dbController.VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Esegue flush memoria _redisConn dato pat2Flush
|
||||
/// </summary>
|
||||
@@ -291,26 +365,10 @@ namespace MP.Data.Services
|
||||
}
|
||||
}
|
||||
answ = true;
|
||||
#if false
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services.Utils
|
||||
{
|
||||
@@ -19,7 +20,8 @@ namespace MP.Data.Services.Utils
|
||||
public StatsAggrService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IStatsAggrRepository repo) : base(config, redis)
|
||||
IFusionCache cache,
|
||||
IStatsAggrRepository repo) : base(config, cache, redis)
|
||||
{
|
||||
_className = "StatsAggr";
|
||||
_repo = repo;
|
||||
|
||||
@@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services.Utils
|
||||
{
|
||||
@@ -19,7 +20,9 @@ namespace MP.Data.Services.Utils
|
||||
public StatsCodeService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IStatsCodeRepository repo) : base(config, redis)
|
||||
IFusionCache cache,
|
||||
IStatsCodeRepository repo
|
||||
) : base(config, cache, redis)
|
||||
{
|
||||
_className = "StatsStatusCode";
|
||||
_repo = repo;
|
||||
|
||||
@@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services.Utils
|
||||
{
|
||||
@@ -19,7 +20,9 @@ namespace MP.Data.Services.Utils
|
||||
public StatsDetailService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IStatsDetailRepository repo) : base(config, redis)
|
||||
IFusionCache cache,
|
||||
IStatsDetailRepository repo
|
||||
) : base(config,cache, redis)
|
||||
{
|
||||
_className = "StatsDetail";
|
||||
_repo = repo;
|
||||
|
||||
@@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace MP.Data.Services.Utils
|
||||
{
|
||||
@@ -19,7 +20,9 @@ namespace MP.Data.Services.Utils
|
||||
public StatsErrService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IStatsErrRepository repo) : base(config, redis)
|
||||
IFusionCache cache,
|
||||
IStatsErrRepository repo
|
||||
) : base(config,cache, redis)
|
||||
{
|
||||
_className = "StatsErr";
|
||||
_repo = repo;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.INVE</RootNamespace>
|
||||
<Version>8.16.2606.119</Version>
|
||||
<Version>8.16.2606.408</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOINVE </i>
|
||||
<h4>Versione: 8.16.2606.119</h4>
|
||||
<h4>Versione: 8.16.2606.408</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.119
|
||||
8.16.2606.408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.119</version>
|
||||
<version>8.16.2606.408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -7,6 +7,7 @@ using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.DbModels.Anag;
|
||||
using MP.Data.MgModels;
|
||||
using MP.Data.Repository.Production;
|
||||
using MP.Data.Services.IOC;
|
||||
using MP.Data.Services.Mtc;
|
||||
using Newtonsoft.Json;
|
||||
@@ -22,17 +23,22 @@ namespace MP.IOC.Data
|
||||
public class MpDataService
|
||||
{
|
||||
#region Public Constructors
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
|
||||
public MpDataService(
|
||||
IConfiguration configuration,
|
||||
ILogger<MpDataService> logger,
|
||||
IServiceScopeFactory scopeFactory,
|
||||
IProductionRepository productionRepository,
|
||||
MpIocController mpIocCtr,
|
||||
IMtcSetupService mtcServ)
|
||||
{
|
||||
_logger = logger;
|
||||
_logger.LogInformation("Starting MpDataService INIT");
|
||||
_configuration = configuration;
|
||||
_scopeFactory = scopeFactory;
|
||||
_productionRepository = productionRepository;
|
||||
IocDbController = mpIocCtr;
|
||||
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
@@ -58,8 +64,10 @@ namespace MP.IOC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
SpecDbController = new MpSpecController(configuration);
|
||||
#if false
|
||||
SpecDbController = new MpSpecController(configuration);
|
||||
IocDbController = new MpIocController(configuration);
|
||||
#endif
|
||||
Log.Info("DbControllers INIT OK");
|
||||
}
|
||||
|
||||
@@ -83,9 +91,11 @@ namespace MP.IOC.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static MpIocController IocDbController { get; set; } = null!;
|
||||
public static MpMongoController mongoController { get; set; } = null!;
|
||||
public static MpSpecController SpecDbController { get; set; } = null!;
|
||||
public static MpIocController IocDbController { get; set; } = null!;
|
||||
#if false
|
||||
public static MpSpecController SpecDbController { get; set; } = null!;
|
||||
#endif
|
||||
public MessagePipe BroadastMsgPipe { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
@@ -1209,7 +1219,7 @@ namespace MP.IOC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await SpecDbController.MacchineGetFiltAsync(codGruppo);
|
||||
result = await _productionRepository.MacchineGetFiltAsync(codGruppo);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
@@ -1622,7 +1632,7 @@ namespace MP.IOC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await SpecDbController.PODL_getByKeyAsync(idxPODL);
|
||||
result = await _productionRepository.PODL_getByKeyAsync(idxPODL);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>8.16.2606.119</Version>
|
||||
<Version>8.16.2606.408</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+12
-4
@@ -42,18 +42,26 @@ 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.AddMemoryCache();
|
||||
|
||||
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;";
|
||||
string connStrUtils = builder.Configuration.GetConnectionString("MP.Utils")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Utils' mancante.");
|
||||
//?? "Server=localhost;Database=MoonPro_Utils; integrated security=True; MultipleActiveResultSets=True; App=MP.IOC;";
|
||||
builder.Services.AddDbContextFactory<MoonPro_UtilsContext>(options =>
|
||||
options.UseSqlServer(utilsConnString));
|
||||
options.UseSqlServer(connStrUtils).EnableSensitiveDataLogging(false)
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
var connStrFL = builder.Configuration.GetConnectionString("MP.Flux")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante.");
|
||||
builder.Services.AddDbContextFactory<MoonPro_FluxContext>(options =>
|
||||
options.UseSqlServer(connStrFL)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
// MP.Data Services Utils - Statistiche DB
|
||||
builder.Services.AddIocDataLayer();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 8.16.2606.119</h4>
|
||||
<h4>Versione: 8.16.2606.408</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.119
|
||||
8.16.2606.408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.119</version>
|
||||
<version>8.16.2606.408</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>
|
||||
|
||||
@@ -5,6 +5,7 @@ using MP.Data.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Components
|
||||
{
|
||||
@@ -21,9 +22,10 @@ namespace MP.Land.Components
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnParametersSet()
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
ReloadData();
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
protected void SortRequested(Sorter.SortCallBack e)
|
||||
@@ -117,9 +119,9 @@ namespace MP.Land.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadData()
|
||||
private async Task ReloadDataAsync()
|
||||
{
|
||||
ListRecord = LDService.AllDbInfo();
|
||||
ListRecord = await LDService.AllDbInfoAsync();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>MP.Land</RootNamespace>
|
||||
<Version>8.16.2606.0119</Version>
|
||||
<Version>8.16.2606.0408</Version>
|
||||
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
|
||||
|
||||
@@ -173,11 +173,11 @@ namespace MP.Land.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected void DataInit()
|
||||
protected async Task DataInitAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
// recupero TUTTI i dati IobList già completi anche on i RemoteRebootLog
|
||||
AllRecords = LDService.IobListAll();
|
||||
AllRecords = await LDService.IobListAllAsync();
|
||||
|
||||
|
||||
#if false
|
||||
@@ -216,7 +216,7 @@ namespace MP.Land.Pages
|
||||
AppMService.PageName = "IobList";
|
||||
AppMService.PageIcon = "fas fa-computer pe-2";
|
||||
await SetupRight();
|
||||
DataInit();
|
||||
await DataInitAsync();
|
||||
}
|
||||
|
||||
protected void ResetSearch()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo Tablet MAPO - DotNet6</i>
|
||||
<h4>Versione: 8.16.2606.0119</h4>
|
||||
<h4>Versione: 8.16.2606.0408</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.0119
|
||||
8.16.2606.0408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.0119</version>
|
||||
<version>8.16.2606.0408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
+48
-11
@@ -1,26 +1,27 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.AspNetCore.Authentication.Negotiate;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using MP.AppAuth.Services;
|
||||
using MP.Data.Services;
|
||||
using MP.Data;
|
||||
using MP.Land.Data;
|
||||
using MP.TaskMan.Services;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
using ZiggyCreatures.Caching.Fusion.Backplane.StackExchangeRedis;
|
||||
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
|
||||
|
||||
namespace MP.Land
|
||||
{
|
||||
@@ -125,12 +126,22 @@ namespace MP.Land
|
||||
options.FallbackPolicy = options.DefaultPolicy;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// REDIS setup
|
||||
string connStringRedis = Configuration.GetConnectionString("Redis");
|
||||
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
// avvio oggetto shared x redis...
|
||||
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
IConnectionMultiplexer redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
|
||||
// ✅ FusionCache
|
||||
services.AddFusionCache()
|
||||
.WithDistributedCache(sp => sp.GetRequiredService<IDistributedCache>())
|
||||
.WithSerializer(new FusionCacheNewtonsoftJsonSerializer())
|
||||
.WithBackplane(new RedisBackplane(new RedisBackplaneOptions
|
||||
{
|
||||
ConnectionMultiplexerFactory = () => Task.FromResult(redisMultiplexer)
|
||||
}));
|
||||
|
||||
services.AddLocalization();
|
||||
|
||||
@@ -138,12 +149,38 @@ namespace MP.Land
|
||||
services.AddServerSideBlazor();
|
||||
|
||||
services.AddSingleton<IConfiguration>(Configuration);
|
||||
|
||||
// aggiungo il costruttore x i vari DbContextFactory
|
||||
var connStr = Configuration.GetConnectionString("MP.Land")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Land' mancante.");
|
||||
services.AddDbContextFactory<MoonProContext>(options =>
|
||||
options.UseSqlServer(connStr)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
var connStrFlux = Configuration.GetConnectionString("MP.Flux")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante.");
|
||||
services.AddDbContextFactory<MoonPro_FluxContext>(options =>
|
||||
options.UseSqlServer(connStrFlux)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
var connStrStats = Configuration.GetConnectionString("MP.Stats")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Stats' mancante.");
|
||||
services.AddDbContextFactory<MoonPro_STATSContext>(options =>
|
||||
options.UseSqlServer(connStrStats)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
//init servizi specifici LAND
|
||||
//services.AddAuthLandDataLayer();
|
||||
services.AddLandDataLayer();
|
||||
services.AddSingleton<LicenseService>();
|
||||
services.AddSingleton<SyncService>();
|
||||
services.AddSingleton<RestCallService>();
|
||||
services.AddSingleton<TaskService>();
|
||||
services.AddSingleton<TabDataService>();
|
||||
services.AddSingleton<LandDataService>();
|
||||
//services.AddSingleton<SyncService>();
|
||||
//services.AddSingleton<TabDataService>();
|
||||
//services.AddSingleton<LandDataService>();
|
||||
|
||||
services.AddScoped<AppAuthService>();
|
||||
services.AddScoped<LMessageService>();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.MON</RootNamespace>
|
||||
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
|
||||
<Version>8.16.2606.119</Version>
|
||||
<Version>8.16.2606.408</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+15
-1
@@ -1,3 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using MP.Data;
|
||||
using MP.Data.Services;
|
||||
using MP.MON.Components;
|
||||
using NLog;
|
||||
@@ -26,10 +29,21 @@ string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"))
|
||||
// avvio oggetto shared x redis...
|
||||
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
|
||||
// aggiungo il costruttore x i vari DbContextFactory
|
||||
var connStr = builder.Configuration.GetConnectionString("MP.Mon")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Mon' mancante.");
|
||||
builder.Services.AddDbContextFactory<MoonProContext>(options =>
|
||||
options.UseSqlServer(connStr)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
|
||||
// Add services to the container.
|
||||
logger.Info("Setup Services");
|
||||
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<MonDataFeeder>();
|
||||
// Init centralizzato Repository/Servizi da MP.Data Services
|
||||
builder.Services.AddMonDataLayer();
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.119</h4>
|
||||
<h4>Versione: 8.16.2606.408</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.119
|
||||
8.16.2606.408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.119</version>
|
||||
<version>8.16.2606.408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.MON.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
|
||||
}
|
||||
},
|
||||
"NLog": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>MP.Prog</RootNamespace>
|
||||
<Version>8.16.2606.0119</Version>
|
||||
<Version>8.16.2606.0408</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 8.16.2606.0119</h4>
|
||||
<h4>Versione: 8.16.2606.0408</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.0119
|
||||
8.16.2606.0408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.0119</version>
|
||||
<version>8.16.2606.0408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -88,9 +88,6 @@ namespace MP.Prog
|
||||
});
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT");
|
||||
|
||||
//// Registrazione Elmah:
|
||||
//// https://github.com/ElmahCore/ElmahCore
|
||||
//app.UseElmah();
|
||||
|
||||
// fix forwarders
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
@@ -152,14 +149,6 @@ namespace MP.Prog
|
||||
o.SlidingExpiration = true;
|
||||
});
|
||||
|
||||
//// Elmah
|
||||
//services.AddElmah();
|
||||
//string elmaConn = "Data Source=SQL2016DEV;Initial Catalog=Elmah;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=SHERPA.BBM;";
|
||||
//services.AddElmah<SqlErrorLog>(options =>
|
||||
//{
|
||||
// options.ConnectionString = elmaConn;
|
||||
//});
|
||||
|
||||
#if false
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.RIOC</RootNamespace>
|
||||
<Version>8.16.2606.119</Version>
|
||||
<Version>8.16.2606.408</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+6
-3
@@ -37,13 +37,16 @@ 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.AddMemoryCache();
|
||||
|
||||
builder.Services.AddDbContextFactory<MoonProContext>(options =>
|
||||
options.UseSqlServer(connStr)
|
||||
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
|
||||
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
|
||||
var connStrFL = builder.Configuration.GetConnectionString("MP.Flux")
|
||||
?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante.");
|
||||
builder.Services.AddDbContextFactory<MoonPro_FluxContext>(options =>
|
||||
options.UseSqlServer(connStrFL)
|
||||
.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;";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-RIOC </i>
|
||||
<h4>Versione: 8.16.2606.119</h4>
|
||||
<h4>Versione: 8.16.2606.408</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.119
|
||||
8.16.2606.408
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.119</version>
|
||||
<version>8.16.2606.408</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Yarp": "Debug",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
@@ -80,6 +82,7 @@
|
||||
"ConnectionStrings": {
|
||||
"MP.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; App=MP.IOC;",
|
||||
"MP.Utils": "Server=SQL2016DEV;Database=MoonPro_Utils; User ID=sa;Password=keyhammer16; integrated security=False; App=MP.RIOC;",
|
||||
"MP.Flux": "Server=SQL2016DEV;Database=MoonPro_FluxData; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.RIOC;",
|
||||
"Redis": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
|
||||
"RedisAdmin": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true"
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
// eseguo chiusura finale
|
||||
CurrAction.IsActive = false;
|
||||
MDService.ActionSetReqAsync(CurrAction);
|
||||
await Task.Delay(1);
|
||||
await MDService.ActionSetReqAsync(CurrAction);
|
||||
}
|
||||
|
||||
protected async Task doConfirm()
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
<h4>Operatori</h4>
|
||||
</div>
|
||||
<div class="px-0">
|
||||
<button @onclick="() => ToggleAddNew()" class="btn @addNewCss btn-sm"><i class="fa-solid @addNewIcon"></i> @addNewTxt</button>
|
||||
@if (AddEnabled)
|
||||
{
|
||||
<button @onclick="() => ToggleAddNew()" class="btn @addNewCss btn-sm"><i class="fa-solid @addNewIcon"></i> @addNewTxt</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,25 +36,51 @@
|
||||
<table class="table table-sm table-striped small">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><button class="btn btn-sm btn-info" title="Reset" @onclick="DoReset"><i class="fa-solid fa-rotate"></i></button></th>
|
||||
<th><i class="fa-solid fa-key"></i> Matr.</th>
|
||||
<th><i class="fa-solid fa-object-group"></i> Anagr.</th>
|
||||
<th class="text-end"></th>
|
||||
@if (DelEnabled)
|
||||
{
|
||||
<th class="text-end"></th>
|
||||
}
|
||||
@if (StaChgEnab)
|
||||
{
|
||||
<th class="text-end"></th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<tr class="@cssRow(item)">
|
||||
<td>
|
||||
<div>@record.MatrOpr</div>
|
||||
<button class="btn btn-sm btn-info" title="Mostra Assegnazioni" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Cognome @record.Nome</div>
|
||||
<td class="@cssCol(item)">
|
||||
<div>@item.MatrOpr</div>
|
||||
</td>
|
||||
|
||||
<td class="text-end">
|
||||
<button @onclick="() => DoDelete(record)" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button>
|
||||
<td class="@cssCol(item)">
|
||||
<div>@item.Cognome @item.Nome</div>
|
||||
</td>
|
||||
@if (DelEnabled)
|
||||
{
|
||||
<td class="text-end">
|
||||
<button @onclick="() => DoDelete(item)" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button>
|
||||
</td>
|
||||
}
|
||||
@if (StaChgEnab)
|
||||
{
|
||||
<td class="text-end">
|
||||
@if (item.isEnabled)
|
||||
{
|
||||
<button class="btn btn-sm btn-warning" title="Disabilita Operatore" @onclick="() => ToggleStatusOpr(item)"><i class="fa-solid fa-thumbs-down"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-success" title="Abilita Operatore" @onclick="() => ToggleStatusOpr(item)"><i class="fa-solid fa-thumbs-up"></i></button>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user