Modifica model macchine
This commit is contained in:
@@ -16,6 +16,14 @@ namespace MP.AppAuth.Controllers
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MPController(IConfiguration configuration)
|
||||
@@ -92,54 +100,6 @@ namespace MP.AppAuth.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagMicroStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagraficaMicroStati> AnagMicroStati()
|
||||
{
|
||||
List<AnagraficaMicroStati> dbResult = new List<AnagraficaMicroStati>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagMicroStati
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagraficaStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagraficaStati> AnagStati()
|
||||
{
|
||||
List<AnagraficaStati> dbResult = new List<AnagraficaStati>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagStati
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x ListValues
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ListValues> ListValues()
|
||||
{
|
||||
List<ListValues> dbResult = new List<ListValues>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetListValue
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Record AnagKeyValue
|
||||
/// </summary>
|
||||
@@ -210,6 +170,38 @@ namespace MP.AppAuth.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagMicroStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagraficaMicroStati> AnagMicroStati()
|
||||
{
|
||||
List<AnagraficaMicroStati> dbResult = new List<AnagraficaMicroStati>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagMicroStati
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagraficaStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagraficaStati> AnagStati()
|
||||
{
|
||||
List<AnagraficaStati> dbResult = new List<AnagraficaStati>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagStati
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Record Config
|
||||
/// </summary>
|
||||
@@ -288,6 +280,38 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x ListValues
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ListValues> ListValues()
|
||||
{
|
||||
List<ListValues> dbResult = new List<ListValues>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetListValue
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Record Vocabolario
|
||||
/// </summary>
|
||||
@@ -356,12 +380,5 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
public partial class Macchine
|
||||
[Table("Macchine")]
|
||||
public partial class MacchineModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string CodMacchina { get; set; }
|
||||
public int ColNum { get; set; }
|
||||
public string Css { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
public string IdxMacchina { get; set; }
|
||||
public string Locazione { get; set; }
|
||||
public string CodMacchina { get; set; }
|
||||
public string Nome { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
public string Locazione { get; set; }
|
||||
public string Note { get; set; }
|
||||
public int RowNum { get; set; }
|
||||
public string Css { get; set; }
|
||||
public string Url { get; set; }
|
||||
public int ColNum { get; set; }
|
||||
public int RowNum { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace MP.AppAuth
|
||||
public virtual DbSet<KeepAlive> DbSetKeepAlive { get; set; }
|
||||
public virtual DbSet<LinkMenuJqm> DbSetLinkMenuJqm { get; set; }
|
||||
public virtual DbSet<ListValues> DbSetListValue { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MacchineModel> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<UpdMan> DbSetUpdMan { get; set; }
|
||||
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
||||
|
||||
@@ -410,11 +410,11 @@ namespace MP.AppAuth
|
||||
entity.Property(e => e.Ordinal).HasColumnName("ordinal");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Macchine>(entity =>
|
||||
modelBuilder.Entity<MacchineModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.IdxMacchina);
|
||||
|
||||
entity.ToTable("Macchine");
|
||||
//entity.ToTable("Macchine");
|
||||
|
||||
entity.Property(e => e.IdxMacchina).HasMaxLength(50);
|
||||
|
||||
|
||||
@@ -26,6 +26,54 @@ namespace MP.AppAuth.Services
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
// gestione key Redis
|
||||
private const string redisBaseAddr = "MP:LAND";
|
||||
|
||||
private const string rKeyDirittiUser = $"{redisBaseAddr}:DIR_USER";
|
||||
|
||||
private const string rKeyMacchine = $"{redisBaseAddr}:MACCHINE";
|
||||
|
||||
private const string rKeyPermUser = $"{redisBaseAddr}:PERM_USER";
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static ILogger<AppAuthService> _logger;
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static string Modulo = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private StackExchange.Redis.IDatabase redisDb = null!;
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public AppAuthService(IConfiguration configuration, ILogger<AppAuthService> logger, IConnectionMultiplexer redisConnMult)
|
||||
@@ -64,6 +112,36 @@ namespace MP.AppAuth.Services
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string CodApp { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -114,54 +192,6 @@ namespace MP.AppAuth.Services
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagEventi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaIngressi>> AnagIngressi()
|
||||
{
|
||||
List<AnagraficaIngressi> dbResult = new List<AnagraficaIngressi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagIngressi();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagIngressi: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagEventi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaMicroStati>> AnagMicroStati()
|
||||
{
|
||||
List<AnagraficaMicroStati> dbResult = new List<AnagraficaMicroStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagMicroStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagMicroStati: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaStati>> AnagStati()
|
||||
{
|
||||
List<AnagraficaStati> dbResult = new List<AnagraficaStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagStati: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Gruppi
|
||||
/// </summary>
|
||||
@@ -178,22 +208,6 @@ namespace MP.AppAuth.Services
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ListValues
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ListValues>> ListValues()
|
||||
{
|
||||
List<ListValues> dbResult = new List<ListValues>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.ListValues();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per ListValues: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<AnagraficaGruppi>> AnagGruppiFilt(string codTipo)
|
||||
{
|
||||
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
|
||||
@@ -206,6 +220,22 @@ namespace MP.AppAuth.Services
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagEventi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaIngressi>> AnagIngressi()
|
||||
{
|
||||
List<AnagraficaIngressi> dbResult = new List<AnagraficaIngressi>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagIngressi();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagIngressi: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> AnagKeyValAdd(AnagKeyValueModel currRec)
|
||||
{
|
||||
bool answ = false;
|
||||
@@ -254,6 +284,22 @@ namespace MP.AppAuth.Services
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagEventi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaMicroStati>> AnagMicroStati()
|
||||
{
|
||||
List<AnagraficaMicroStati> dbResult = new List<AnagraficaMicroStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagMicroStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagMicroStati: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<AnagraficaOperatori>> AnagOperByGroupList(string codGruppo, string searchVal)
|
||||
{
|
||||
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
|
||||
@@ -283,6 +329,22 @@ namespace MP.AppAuth.Services
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AnagStati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagraficaStati>> AnagStati()
|
||||
{
|
||||
List<AnagraficaStati> dbResult = new List<AnagraficaStati>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.AnagStati();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagStati: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> ConfigAdd(ConfigModel currRec)
|
||||
{
|
||||
bool answ = false;
|
||||
@@ -382,6 +444,57 @@ namespace MP.AppAuth.Services
|
||||
CheckVoc();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ListValues
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ListValues>> ListValues()
|
||||
{
|
||||
List<ListValues> dbResult = new List<ListValues>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = MpDbController.ListValues();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per ListValues: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine gestite
|
||||
/// </summary>
|
||||
/// <param name="UserName"></param>
|
||||
/// <returns></returns>
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
List<MacchineModel>? dbResult = new List<MacchineModel>();
|
||||
string currKey = $"{rKeyMacchine}";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string? rawData = redisDb.StringGet(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2)
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MacchineModel>>(rawData);
|
||||
dbResult = tempResult ?? new List<MacchineModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
// recupero diritti utente
|
||||
dbResult = MpDbController.MacchineGetAll();
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco permessi dato utente
|
||||
/// </summary>
|
||||
@@ -539,84 +652,6 @@ namespace MP.AppAuth.Services
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
// gestione key Redis
|
||||
private const string redisBaseAddr = "MP:LAND";
|
||||
|
||||
private const string rKeyDirittiUser = $"{redisBaseAddr}:DIR_USER";
|
||||
|
||||
private const string rKeyPermUser = $"{redisBaseAddr}:PERM_USER";
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static ILogger<AppAuthService> _logger;
|
||||
|
||||
private static List<Macchine> ElencoMacchine = new List<Macchine>();
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static string Modulo = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private StackExchange.Redis.IDatabase redisDb = null!;
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string CodApp { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -216,9 +216,9 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="codGruppo"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineGetFilt(string codGruppo)
|
||||
public List<MacchineModel> MacchineGetFilt(string codGruppo)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
|
||||
@@ -71,9 +71,9 @@ namespace MP.Data.Controllers
|
||||
/// Elenco da tabella Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DbModels.Macchine> MacchineGetAll()
|
||||
public List<DbModels.MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<DbModels.Macchine> dbResult = new List<DbModels.Macchine>();
|
||||
List<DbModels.MacchineModel> dbResult = new List<DbModels.MacchineModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
@@ -90,9 +90,9 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="codGruppo"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineGetFilt(string codGruppo)
|
||||
public List<MacchineModel> MacchineGetFilt(string codGruppo)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
|
||||
@@ -1425,9 +1425,9 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineByMatrOper(int MatrOpr)
|
||||
public List<MacchineModel> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
@@ -1475,9 +1475,9 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="codGruppo"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineGetFilt(string codGruppo)
|
||||
public List<MacchineModel> MacchineGetFilt(string codGruppo)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
@@ -1514,7 +1514,7 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco id Macchine che abbiano dati FLuxLog, nel periodo indicato
|
||||
/// Elenco id MacchineModel che abbiano dati FLuxLog, nel periodo indicato
|
||||
/// </summary>
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
|
||||
@@ -126,9 +126,9 @@ namespace MP.Data.Controllers
|
||||
/// Elenco da tabella Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineGetAll()
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
|
||||
@@ -936,9 +936,9 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineByMatrOper(int MatrOpr)
|
||||
public List<MacchineModel> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
/// </summary>
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto ODL
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Machine
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
|
||||
@@ -10,8 +10,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data.DbModels
|
||||
{
|
||||
[Table("Macchine")]
|
||||
public partial class Macchine
|
||||
[Table("MacchineModel")]
|
||||
public partial class MacchineModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
/// </summary>
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
/// </summary>
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
/// </summary>
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Articolo
|
||||
/// </summary>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace MP.Data.DbModels
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual Macchine MachineNav { get; set; } = null!;
|
||||
public virtual MacchineModel MachineNav { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace MP.Data
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
public virtual DbSet<LinkMenuModel> DbSetLinkMenu { get; set; }
|
||||
public virtual DbSet<ListValuesModel> DbSetListValues { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MacchineModel> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MappaStatoExplModel> DbSetMSE { get; set; }
|
||||
public virtual DbSet<ODLModel> DbSetODL { get; set; }
|
||||
public virtual DbSet<ODLExpModel> DbSetODLExp { get; set; }
|
||||
@@ -190,7 +190,7 @@ namespace MP.Data
|
||||
.HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Macchine>(entity =>
|
||||
modelBuilder.Entity<MacchineModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.IdxMacchina);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace MP.Data
|
||||
|
||||
|
||||
public virtual DbSet<AnagArticoliModel> DbSetArticoli { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MacchineModel> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<FluxLogModel> DbSetFluxLog { get; set; }
|
||||
public virtual DbSet<DossierModel> DbSetDossiers { get; set; }
|
||||
public virtual DbSet<ParetoFluxLogDTO> DbSetParetoFluxLog { get; set; }
|
||||
@@ -111,7 +111,7 @@ namespace MP.Data
|
||||
.HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Macchine>(entity =>
|
||||
modelBuilder.Entity<MacchineModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.IdxMacchina);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace MP.Data
|
||||
public virtual DbSet<ResControlli> DbSetControlli { get; set; }
|
||||
public virtual DbSet<DdbTurni> DbSetDdbTurni { get; set; }
|
||||
public virtual DbSet<FLModel> DbSetFL { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MacchineModel> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<StatsODL> DbSetODL { get; set; }
|
||||
public virtual DbSet<OdlEnergyModel> DbSetOdlEnergy { get; set; }
|
||||
public virtual DbSet<ResScarti> DbSetScarti { get; set; }
|
||||
@@ -159,7 +159,7 @@ namespace MP.Data
|
||||
.HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Macchine>(entity =>
|
||||
modelBuilder.Entity<MacchineModel>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
|
||||
@@ -234,19 +234,19 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine>> MacchineByMatrOper(int MatrOpr)
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Macc:{MatrOpr}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -258,7 +258,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetFilt | MatrOpr: {MatrOpr} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
|
||||
@@ -125,14 +125,14 @@ namespace MP.Data.Services
|
||||
/// <summary>
|
||||
/// Cache elenco macchine abilitate all'utente, vuoto se scaduto reload
|
||||
/// </summary>
|
||||
public List<Macchine>? ListMachineEnabled
|
||||
public List<MacchineModel>? ListMachineEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Macchine>? answ = userListMachine;
|
||||
List<MacchineModel>? answ = userListMachine;
|
||||
if (DateTime.Now.Subtract(lastUserUpd).TotalSeconds > 30)
|
||||
{
|
||||
answ = new List<Macchine>();
|
||||
answ = new List<MacchineModel>();
|
||||
Log.Debug("ListMachineEnabled unvalidated");
|
||||
}
|
||||
return answ;
|
||||
@@ -710,7 +710,7 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<Macchine>? userListMachine { get; set; } = null;
|
||||
private List<MacchineModel>? userListMachine { get; set; } = null;
|
||||
private Dictionary<string, string> UserPrefs { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -167,18 +167,18 @@ namespace MP.Data.Services
|
||||
return outVal;
|
||||
}
|
||||
|
||||
public async Task<List<Macchine>> MacchineGetAll()
|
||||
public async Task<List<MacchineModel>> MacchineGetAll()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
string source = "DB";
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{Constants.redisMacchine}:ALL";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -190,7 +190,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
@@ -198,18 +198,18 @@ namespace MP.Data.Services
|
||||
//return Task.FromResult(dbController.MacchineGetAll());
|
||||
}
|
||||
|
||||
public async Task<List<Macchine>> MacchineGetByGruppo(string CodGruppo)
|
||||
public async Task<List<MacchineModel>> MacchineGetByGruppo(string CodGruppo)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
string source = "DB";
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{Constants.redisMacchine}:{CodGruppo}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -222,7 +222,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetByGruppo | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
|
||||
@@ -1246,7 +1246,43 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IOB_data> IobInfo(string IdxMacchina)
|
||||
public IOB_data IobInfo(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<IOB_data>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore: non trovato valore <IOB_data> valido in REDIS | key: {currKey}");
|
||||
Log.Info($"REDIS | conf: {redisConn.Configuration}");
|
||||
Log.Info($" --> Valore trovato:{Environment.NewLine}{rawData}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new IOB_data();
|
||||
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IOB_data> IobInfoAsync(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
@@ -1273,7 +1309,7 @@ namespace MP.Data.Services
|
||||
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"IobInfoAsync per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1431,11 +1467,11 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// Elenco MacchineModel dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine>> MacchineByMatrOper(int MatrOpr)
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
int rndWait = rnd.Next(0, 2);
|
||||
await Task.Delay(rndWait);
|
||||
@@ -1443,14 +1479,14 @@ namespace MP.Data.Services
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine> result = new List<Macchine>();
|
||||
List<MacchineModel> result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:MachByMatOp:{MatrOpr}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -1462,7 +1498,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user