Fix gestione filtri NLog x eventi MS indesiderati + update gestione redis new x UI

This commit is contained in:
Samuele Locatelli
2025-01-29 09:06:21 +01:00
parent 798acb1392
commit fcdef662b2
14 changed files with 242 additions and 167 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2909</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2909
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2909</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+130
View File
@@ -618,6 +618,136 @@ namespace LiMan.DB.Services
return answ;
}
/// <summary>
/// Recupera licenza dato IDX
/// </summary>
/// <param name="IdxLic"></param>
/// <returns></returns>
public LicenzaModel LicenzaNextGetByIdx(int IdxLic)
{
Stopwatch sw = new Stopwatch();
LicenzaModel dbResult = new LicenzaModel();
sw.Start();
dbResult = dbControllerNext.GetLicenza(IdxLic);
sw.Stop();
TimeSpan ts = sw.Elapsed;
Log.Trace($"Effettuata lettura da DB per LicenzeNextGetByIdx: {ts.TotalMilliseconds} ms");
return dbResult;
}
public async Task<bool> ReleaseDelete(ReleaseModel rec2del)
{
bool fatto = dbControllerNext.ReleaseDelete(rec2del);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Elenco Release dato Applicativo
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByApp(string CodApp)
{
string source = "DB";
List<ReleaseModel>? dbResult = new List<ReleaseModel>();
try
{
string currKey = $"{Const.rKeyConfig}:App:AllRel:{CodApp}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<ReleaseModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ReleaseModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.ReleaseGetByApp(CodApp);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<ReleaseModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<ReleaseModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ReleaseGetByApp | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during ReleaseGetByApp:{Environment.NewLine}{exc}");
}
return dbResult;
}
/// <summary>
/// Elenco Release dato Applicativo + versione minima
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <param name="VersMin">Versione minima richiesta</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByAppVers(string CodApp, string VersMin)
{
await Task.Delay(1);
List<ReleaseModel> dbResult = new List<ReleaseModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbControllerNext.ReleaseGetByAppVers(CodApp, VersMin);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB per ReleaseGetByAppVers | {CodApp} | vers >= {VersMin} | {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Ultima Release dato Applicativo VALIDA (= rilasciata)
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<string> ReleaseLastGetByApp(string CodApp)
{
string answ = "";
RedisKey currKey = $"{Const.rKeyConfig}:App:CurrRel";
var rawVal = await redisDb.HashGetAsync(currKey, CodApp);
if (rawVal.HasValue)
{
answ = $"{rawVal}";
}
else
{
var rawList = await ReleaseGetByApp(CodApp);
if (rawList != null)
{
var lastRel = rawList
.Where(x => x.IsReleased)
.OrderByDescending(x => x.VersVal)
.ThenByDescending(x => x.ReleaseDate)
.FirstOrDefault() ?? new ReleaseModel() { CodApp = CodApp };
answ = lastRel.VersNum;
// salvo su redis tab...
await redisDb.HashSetAsync(currKey, CodApp, answ);
}
}
return answ;
}
/// <summary>
/// Restituisce i task associati ad un dato EgwACC in stato DONE
/// </summary>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2909</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2909
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2909</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+43 -143
View File
@@ -63,6 +63,7 @@ namespace LiMan.UI.Data
public async Task<List<GLS.DatabaseModels.AnagApplicazioni>> ApplicazioniGLSGetAll()
{
#if false
List<GLS.DatabaseModels.AnagApplicazioni> dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
string cacheKey = mHash("GLS:Applicazioni");
string rawData;
@@ -84,7 +85,48 @@ namespace LiMan.UI.Data
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB + caching per ApplicazioniGLSGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
return await Task.FromResult(dbResult);
#endif
string source = "DB";
List<GLS.DatabaseModels.AnagApplicazioni>? dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
try
{
string currKey = $"{Const.rKeyConfig}:GLS:Applicazioni";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<GLS.DatabaseModels.AnagApplicazioni>>(rawData);
if (tempResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerGLS.GetApplicazioni();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ApplicazioniGLSGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during ApplicazioniGLSGetAll:{Environment.NewLine}{exc}");
}
return dbResult;
}
public async Task<bool> ApplicazioniGLSUpdate(GLS.DatabaseModels.AnagApplicazioni currItem)
@@ -438,23 +480,6 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
/// <summary>
/// Recupera licenza dato IDX
/// </summary>
/// <param name="IdxLic"></param>
/// <returns></returns>
public LicenzaModel LicenzaNextGetByIdx(int IdxLic)
{
Stopwatch sw = new Stopwatch();
LicenzaModel dbResult = new LicenzaModel();
sw.Start();
dbResult = dbControllerNext.GetLicenza(IdxLic);
sw.Stop();
TimeSpan ts = sw.Elapsed;
Log.Trace($"Effettuata lettura da DB per LicenzeNextGetByIdx: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Trasferisce una licenza da GLS a Next
/// </summary>
@@ -627,131 +652,6 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
public async Task<bool> ReleaseDelete(ReleaseModel rec2del)
{
bool fatto = dbControllerNext.ReleaseDelete(rec2del);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Elenco Release dato Applicativo
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByApp(string CodApp)
{
string source = "DB";
List<ReleaseModel>? dbResult = new List<ReleaseModel>();
try
{
string currKey = $"{Const.rKeyConfig}:App:AllRel:{CodApp}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<ReleaseModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ReleaseModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.ReleaseGetByApp(CodApp);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<ReleaseModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<ReleaseModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ReleaseGetByApp | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during ReleaseGetByApp:{Environment.NewLine}{exc}");
}
return dbResult;
#if false
await Task.Delay(1);
List<ReleaseModel> dbResult = new List<ReleaseModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbControllerNext.ReleaseGetByApp(CodApp);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB per ReleaseGetByApp | {CodApp} | {ts.TotalMilliseconds} ms");
return dbResult;
#endif
}
/// <summary>
/// Elenco Release dato Applicativo + versione minima
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <param name="VersMin">Versione minima richiesta</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByAppVers(string CodApp, string VersMin)
{
await Task.Delay(1);
List<ReleaseModel> dbResult = new List<ReleaseModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbControllerNext.ReleaseGetByAppVers(CodApp, VersMin);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB per ReleaseGetByAppVers | {CodApp} | vers >= {VersMin} | {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Ultima Release dato Applicativo VALIDA (= rilasciata)
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<string> ReleaseLastGetByApp(string CodApp)
{
string answ = "";
RedisKey currKey = $"{Const.rKeyConfig}:App:CurrRel";
var rawVal = await redisDb.HashGetAsync(currKey, CodApp);
if (rawVal.HasValue)
{
answ = $"{rawVal}";
}
else
{
var rawList = await ReleaseGetByApp(CodApp);
if (rawList != null)
{
var lastRel = rawList
.Where(x => x.IsReleased)
.OrderByDescending(x => x.VersVal)
.ThenByDescending(x => x.ReleaseDate)
.FirstOrDefault() ?? new ReleaseModel() { CodApp = CodApp };
answ = lastRel.VersNum;
// salvo su redis tab...
await redisDb.HashSetAsync(currKey, CodApp, answ);
}
}
return answ;
}
/// <summary>
/// Upsert record Release applicazione
/// </summary>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>2.1.2501.2907</Version>
<Version>2.1.2501.2909</Version>
<RootNamespace>LiMan.UI</RootNamespace>
<AssemblyName>LiMan.UI</AssemblyName>
</PropertyGroup>
+6 -11
View File
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Web;
using System;
using System.Collections.Generic;
@@ -20,19 +21,14 @@ namespace LiMan.UI
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Debug);
})
.UseNLog();
// importante x onorare i livelli di log impostati in appsettings.json
.UseNLog(new NLogAspNetCoreOptions() { RemoveLoggerFactoryFilter = false });
public static void Main(string[] args)
{
// inclusione NLog:
// https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5
// https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/
var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
var logger = LogManager.Setup()
.LoadConfigurationFromAppSettings()
.GetCurrentClassLogger();
try
{
logger.Info("LiMan.UI Application Starting Up");
@@ -48,7 +44,6 @@ namespace LiMan.UI
NLog.LogManager.Shutdown();
}
//CreateHostBuilder(args).Build().Run();
}
#endregion Public Methods
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2909</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2909
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2909</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+53 -3
View File
@@ -2,10 +2,60 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.Components.RenderTree.Renderer": "Warning",
"Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository": "Warning",
"Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware": "Warning",
"Microsoft.AspNetCore.Hosting.Diagnostics": "Warning",
"Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport": "Warning",
"Microsoft.AspNetCore.Server.Kestrel": "Warning",
"Microsoft.AspNetCore.SignalR.HubConnectionContext": "Warning",
"Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher": "Warning",
"Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning",
"Microsoft.WebTools.BrowserLink.Net.VsContentMiddleware": "Warning"
}
},
"NLog": {
"variables": {
"baseFileDir": "${basedir}/logs/",
"layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}"
},
"extensions": [
{ "assembly": "NLog.Extensions.Logging" },
{ "assembly": "NLog.Web.AspNetCore" }
],
"throwConfigExceptions": true,
"targets": {
"async": true,
"logfile": {
"type": "File",
"fileName": "${basedir}/logs/${shortdate}.log",
"archiveEvery": "Day",
"archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log",
"archiveNumbering": "DateAndSequence",
"archiveAboveSize": "1024000",
"archiveDateFormat": "HH",
"maxArchiveFiles": "60",
"maxArchiveDays": "30"
},
"logconsole": {
"type": "ColoredConsole",
"layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}"
}
},
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "logconsole"
},
{
"logger": "*",
"minLevel": "Info",
"writeTo": "logfile"
}
]
},
"AllowedHosts": "*",
"ConnectionStrings": {
"LiMan.GLS": "Server=W2019-SQL-STEAM;Database=SteamWare_Auth;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=LiMan.UI;",
@@ -37,7 +87,7 @@
},
"RuntimeOpt": {
"BaseUrl": "/ELM.UI",
"MultiRoleEnab": true
"MultiRoleEnab": true
},
"ApiUrl": "https://liman.egalware.com",
"HostOs": "Win"