Correzioni warnings vari e test compilazione, fix applicazioni CORE in generale
This commit is contained in:
@@ -346,14 +346,14 @@ namespace MP.Data.Controllers
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
bool fatto = false;
|
||||
var dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
.FirstOrDefault();
|
||||
var dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
dbResult.Valore = updRec.Valore;
|
||||
fatto = dbCtx.SaveChanges() > 0;
|
||||
fatto = await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
return fatto;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.DbModels.Anag;
|
||||
using NLog;
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
@@ -13,27 +11,9 @@ namespace MP.Data
|
||||
{
|
||||
public partial class MoonProContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
//public MoonProContext(IConfiguration configuration)
|
||||
//{
|
||||
// _configuration = configuration;
|
||||
//}
|
||||
|
||||
//public MoonProContext(DbContextOptions<MoonProContext> options, IConfiguration configuration)
|
||||
//: base(options)
|
||||
//{
|
||||
// _configuration = configuration;
|
||||
//}
|
||||
|
||||
public MoonProContext(DbContextOptions<MoonProContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
@@ -92,7 +72,6 @@ namespace MP.Data
|
||||
public virtual DbSet<RegCheckModel> DbSetRegWithCheck { get; set; }
|
||||
public virtual DbSet<SignalLogModel> DbSetSignalLog { get; set; }
|
||||
|
||||
|
||||
public virtual DbSet<ST_Act> DbSetStAct { get; set; }
|
||||
public virtual DbSet<ST_ActRow> DbSetStActRow { get; set; }
|
||||
public virtual DbSet<ST_AnagGruppi> DbSetStAnagGruppi { get; set; }
|
||||
@@ -130,26 +109,8 @@ namespace MP.Data
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = _configuration.GetConnectionString("MP.Data");
|
||||
if (string.IsNullOrEmpty(connString))
|
||||
{
|
||||
connString = _configuration.GetConnectionString("MP.All");
|
||||
}
|
||||
if (string.IsNullOrEmpty(connString))
|
||||
{
|
||||
connString = _configuration.GetConnectionString("MP.Land");
|
||||
}
|
||||
if (string.IsNullOrEmpty(connString))
|
||||
{
|
||||
connString = _configuration.GetConnectionString("MP.Mon");
|
||||
}
|
||||
if (string.IsNullOrEmpty(connString))
|
||||
{
|
||||
connString = _configuration.GetConnectionString("MP.STATS");
|
||||
}
|
||||
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
//optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;");
|
||||
// fallback si spera non necessario
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels.Mtc;
|
||||
using MP.Data.DbModels.Utils;
|
||||
using NLog;
|
||||
using System;
|
||||
|
||||
#nullable disable
|
||||
@@ -13,14 +11,6 @@ namespace MP.Data
|
||||
{
|
||||
public partial class MoonPro_UtilsContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -66,15 +56,8 @@ namespace MP.Data
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = _configuration.GetConnectionString("MP.Utils");
|
||||
if (!string.IsNullOrEmpty(connString))
|
||||
{
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
}
|
||||
else
|
||||
{
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_Utils;Trusted_Connection=True;");
|
||||
}
|
||||
// fallback (si spera non necessario)
|
||||
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_Utils;Trusted_Connection=True;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -468,10 +468,6 @@ namespace MP.Data.Services.IOC
|
||||
/// <returns></returns>
|
||||
private async Task<T> GetOrFetchAsync<T>(string cacheKey, Func<Task<T>> fetchFunc, TimeSpan expiration)
|
||||
{
|
||||
// GetOrSetAsync di Fusion cache:
|
||||
// - TryGetValue, se mancasse crea un lock solo per QUELLA key
|
||||
// - Esegue fetchFunc (la logica Redis + DB)
|
||||
// - Salva in memoria e rilascia il lock
|
||||
return await _cache.GetOrSetAsync<T>(
|
||||
cacheKey,
|
||||
async ct => await fetchFunc(),
|
||||
@@ -1066,19 +1062,19 @@ namespace MP.Data.Services.IOC
|
||||
string currVals = $"idxMacchina: {idxMacchina} | valOut: {valore} | dtEve: {dtEve} | dtCurr:{dtCurr}";
|
||||
if (dtEve == null || dtCurr == null)
|
||||
{
|
||||
Log.Warn($"procInput: null found | {currVals}");
|
||||
Log.Warn($"{_className} | procInput: null found | {currVals}");
|
||||
}
|
||||
else if (dtEve.Length < 17 || dtCurr.Length < 17)
|
||||
{
|
||||
Log.Info($"procInput: invalid data | {currVals}");
|
||||
Log.Info($"{_className} | procInput: invalid data | {currVals}");
|
||||
}
|
||||
else if (string.IsNullOrEmpty(idxMacchina))
|
||||
{
|
||||
Log.Info($"procInput: missing IdxMacchina | {currVals}");
|
||||
Log.Info($"{_className} | procInput: missing IdxMacchina | {currVals}");
|
||||
}
|
||||
else if (string.IsNullOrEmpty(valore))
|
||||
{
|
||||
Log.Info($"procInput: missing valOut | {currVals}");
|
||||
Log.Info($"{_className} | procInput: missing valOut | {currVals}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -47,10 +47,6 @@ namespace MP.Data.Services
|
||||
|
||||
public event Action EA_OperUpdated = null!;
|
||||
|
||||
public event Action EA_PageUpdated = null!;
|
||||
|
||||
public event Action EA_ResetFooterTimer = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Properties
|
||||
@@ -707,26 +703,12 @@ namespace MP.Data.Services
|
||||
|
||||
private AnagOperatoriModel? _rigaOper;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private string lastIdxMacc = "";
|
||||
|
||||
private DateTime lastUserUpd = DateTime.Now;
|
||||
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private string redisBaseKey = "MP:TAB:User";
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Conf;
|
||||
using MP.Data.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@@ -3945,75 +3945,13 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria _redisConn dato pat2Flush, metodo sincrono
|
||||
/// </summary>
|
||||
/// <param name="pat2Flush"></param>
|
||||
/// <returns></returns>
|
||||
private bool ExecFlushRedisPattern(RedisValue pat2Flush)
|
||||
{
|
||||
bool answ = false;
|
||||
var masterEndpoint = _redisConn.GetEndPoints()
|
||||
.Where(ep => _redisConn.GetServer(ep).IsConnected && !_redisConn.GetServer(ep).IsReplica)
|
||||
.FirstOrDefault();
|
||||
|
||||
// sepattern è "*" elimino intero DB...
|
||||
if (masterEndpoint != null && (pat2Flush.Equals(new RedisValue("*")) || pat2Flush == RedisValue.Null))
|
||||
{
|
||||
_redisConn.GetServer(masterEndpoint).FlushDatabase(database: _redisDb.Database);
|
||||
}
|
||||
else
|
||||
{
|
||||
var server = _redisConn.GetServer(masterEndpoint);
|
||||
var keys = server.Keys(database: _redisDb.Database, pattern: pat2Flush, pageSize: 1000);
|
||||
var batch = new List<RedisKey>();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
batch.Add(key);
|
||||
|
||||
// Flush in batches of 1000
|
||||
if (batch.Count >= 1000)
|
||||
{
|
||||
foreach (var item in batch)
|
||||
_redisDb.KeyDelete(item);
|
||||
|
||||
batch.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Flush remaining keys
|
||||
foreach (var item in batch)
|
||||
_redisDb.KeyDelete(item);
|
||||
}
|
||||
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)
|
||||
{
|
||||
redisDb.KeyDelete(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// notifico update ai client in ascolto x reset cache
|
||||
NotifyReloadRequest($"FlushRedisCache | {pat2Flush}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria _redisConn dato pat2Flush in async
|
||||
/// </summary>
|
||||
/// <param name="pat2Flush"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush)
|
||||
private async new Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush)
|
||||
{
|
||||
bool answ = false;
|
||||
var masterEndpoint = _redisConn.GetEndPoints()
|
||||
|
||||
Reference in New Issue
Block a user