From b85b70847d4f43e602f6c0ff8991ac0c133cc6d8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 24 Jan 2025 18:16:11 +0100 Subject: [PATCH] Update API x record avanzamento list task --- LiMan.Api/Data/ApiDataService.cs | 5 +- LiMan.Api/Resources/ChangeLog.html | 2 +- LiMan.Api/Resources/VersNum.txt | 2 +- LiMan.Api/Resources/manifest.xml | 2 +- LiMan.DB/Services/CommonDataServices.cs | 118 ++++++++++++++++++++ LiMan.Transfer/Resources/ChangeLog.html | 2 +- LiMan.Transfer/Resources/VersNum.txt | 2 +- LiMan.Transfer/Resources/manifest.xml | 2 +- LiMan.UI/Components/AggregateStats.razor.cs | 13 +-- LiMan.UI/Data/LiManDataService.cs | 66 ++--------- LiMan.UI/LiMan.UI.csproj | 2 +- LiMan.UI/Resources/ChangeLog.html | 2 +- LiMan.UI/Resources/VersNum.txt | 2 +- LiMan.UI/Resources/manifest.xml | 2 +- 14 files changed, 143 insertions(+), 79 deletions(-) create mode 100644 LiMan.DB/Services/CommonDataServices.cs diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index 1160a3f..bfc5ec2 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -44,6 +44,7 @@ namespace LiMan.APi.Data /// /// /// + /// public ApiDataService(IConfiguration configuration, ILogger logger, IEmailSender emailSender, IRedisCacheClient redisCacheClient, IConnectionMultiplexer redisConnMult) //public ApiDataService(IConfiguration configuration, ILogger logger, IDistributedCache distributedCache, IEmailSender emailSender, IRedisCacheClient redisCacheClient) { @@ -1239,7 +1240,7 @@ namespace LiMan.APi.Data bool answ = redisHashKeySet(doneKey, res.Key, res.Value, scadenza); redisHashKeyDelete(runKey, res.Key); // sistemo hashset... - redisHashKeySet((RedisKey)$"{rKeyTaskDone}List", res.Key, res.Value); + redisHashKeySet((RedisKey)$"{rKeyTaskRun}List", CodImp, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); redisHashKeyDelete((RedisKey)$"{rKeyTaskRun}List", CodImp); // segnalo fatto done += answ ? 1 : 0; @@ -1270,7 +1271,7 @@ namespace LiMan.APi.Data bool answ = redisHashKeySet(runKey, res.Key, res.Value, scadenza); redisHashKeyDelete(reqKey, res.Key); // sistemo hashset... - redisHashKeySet((RedisKey)$"{rKeyTaskRun}List", res.Key, res.Value); + redisHashKeySet((RedisKey)$"{rKeyTaskRun}List", CodImp, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); redisHashKeyDelete((RedisKey)$"{rKeyTaskReq}List", CodImp); // segnalo fatto done += answ ? 1 : 0; diff --git a/LiMan.Api/Resources/ChangeLog.html b/LiMan.Api/Resources/ChangeLog.html index 4595438..783da5f 100644 --- a/LiMan.Api/Resources/ChangeLog.html +++ b/LiMan.Api/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.2319

+

Versione: 2.1.2501.2418


Note di rilascio:
  • diff --git a/LiMan.Api/Resources/VersNum.txt b/LiMan.Api/Resources/VersNum.txt index cb17b19..dcc83d1 100644 --- a/LiMan.Api/Resources/VersNum.txt +++ b/LiMan.Api/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2319 +2.1.2501.2418 diff --git a/LiMan.Api/Resources/manifest.xml b/LiMan.Api/Resources/manifest.xml index a5105c9..060585e 100644 --- a/LiMan.Api/Resources/manifest.xml +++ b/LiMan.Api/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2319 + 2.1.2501.2418 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.DB/Services/CommonDataServices.cs b/LiMan.DB/Services/CommonDataServices.cs new file mode 100644 index 0000000..119d333 --- /dev/null +++ b/LiMan.DB/Services/CommonDataServices.cs @@ -0,0 +1,118 @@ +using Core; +using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NLog; +using StackExchange.Redis; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime; +using System.Text; +using System.Threading.Tasks; + +namespace LiMan.DB.Services +{ + /// + /// Classe common x gestione servizi sui dati (DB + REDIS) x UI ed API + /// + public class CommonDataServices : IDisposable + { + #region Public Constructors + + /// + /// Costruttore principale + /// + /// + /// + /// + /// + /// + public CommonDataServices(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) + { + _configuration = configuration; + // Conf cache + redisConn = redisConnMult; + redisDb = this.redisConn.GetDatabase(); + + // json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ + JSSettings = new JsonSerializerSettings() + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; + + // conf messagepipe: setup canali pub/sub + EnrollMessPipe = new MessagePipe(redisConn, Const.ENRL_MSG_PIPE); + TaskMessPipe = new MessagePipe(redisConn, Const.TASK_MSG_PIPE); + + _emailSender = emailSender; + // conf DB + string connStrDB = _configuration.GetConnectionString("LiMan.DB"); + if (string.IsNullOrEmpty(connStrDB)) + { + Log.Error("Empty ConnString for LiMan.DB!"); + } + else + { + dbControllerNext = new LiMan.DB.Controllers.DbController(configuration); + Log.Info("DbController for LiMan.DB OK"); + } + } + + #endregion Public Constructors + + #region Public Properties + + /// + /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi enroll + /// + public MessagePipe EnrollMessPipe { get; set; } = null!; + + /// + /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi Task + /// + public MessagePipe TaskMessPipe { get; set; } = null!; + + #endregion Public Properties + + #region Public Methods + + public virtual void Dispose() + { + // Clear database controller + dbControllerNext.Dispose(); + } + + #endregion Public Methods + + #region Protected Fields + + protected static IConfiguration _configuration; + protected static Controllers.DbController dbControllerNext; + protected static JsonSerializerSettings? JSSettings; + + protected static Logger Log = LogManager.GetCurrentClassLogger(); + + /// + /// Oggetto per invio email + /// + protected readonly IEmailSender _emailSender; + + /// + /// Oggetto per connessione a REDIS + /// + protected IConnectionMultiplexer redisConn = null!; + + /// + /// Oggetto DB redis da impiegare x chiamate R/W + /// + protected IDatabase redisDb = null!; + + protected Random rnd = new Random(); + + #endregion Protected Fields + } +} \ No newline at end of file diff --git a/LiMan.Transfer/Resources/ChangeLog.html b/LiMan.Transfer/Resources/ChangeLog.html index acf77c5..7f77331 100644 --- a/LiMan.Transfer/Resources/ChangeLog.html +++ b/LiMan.Transfer/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

    Versione: 2.1.2501.2315

    +

    Versione: 2.1.2501.2418


    Note di rilascio:
      diff --git a/LiMan.Transfer/Resources/VersNum.txt b/LiMan.Transfer/Resources/VersNum.txt index 660932b..dcc83d1 100644 --- a/LiMan.Transfer/Resources/VersNum.txt +++ b/LiMan.Transfer/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2315 +2.1.2501.2418 diff --git a/LiMan.Transfer/Resources/manifest.xml b/LiMan.Transfer/Resources/manifest.xml index 34ed275..0201b07 100644 --- a/LiMan.Transfer/Resources/manifest.xml +++ b/LiMan.Transfer/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2315 + 2.1.2501.2418 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.UI/Components/AggregateStats.razor.cs b/LiMan.UI/Components/AggregateStats.razor.cs index 789120f..805ee01 100644 --- a/LiMan.UI/Components/AggregateStats.razor.cs +++ b/LiMan.UI/Components/AggregateStats.razor.cs @@ -223,6 +223,7 @@ namespace LiMan.UI.Components isLoading = true; InfoStats = await LMDService.InstallStatusGetInfo(DtInizio, DtFine, CodInstSel, CodTipoApp); ReloadDevices(); + ReloadTaskStatus(); isLoading = false; } @@ -260,15 +261,9 @@ namespace LiMan.UI.Components /// private void ReloadTaskStatus() { - TaskReq = new Dictionary(); - TaskRun = new Dictionary(); - TaskDone = new Dictionary(); - if (!string.IsNullOrEmpty(CodImpSel)) - { - TaskReq = LMDService.TaskListReqGet(CodImpSel); - TaskRun = LMDService.TaskListRunGet(CodImpSel); - TaskDone = LMDService.TaskListDoneGet(CodImpSel); - } + TaskReq = LMDService.TaskListReqGet(CodImpSel); + TaskRun = LMDService.TaskListRunGet(CodImpSel); + TaskDone = LMDService.TaskListDoneGet(CodImpSel); } /// diff --git a/LiMan.UI/Data/LiManDataService.cs b/LiMan.UI/Data/LiManDataService.cs index a784708..1b3d135 100644 --- a/LiMan.UI/Data/LiManDataService.cs +++ b/LiMan.UI/Data/LiManDataService.cs @@ -6,6 +6,7 @@ using LiMan.DB; using LiMan.DB.Controllers; using LiMan.DB.DBModels; using LiMan.DB.DTO; +using LiMan.DB.Services; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Distributed; @@ -28,70 +29,36 @@ using static Core.Enum; namespace LiMan.UI.Data { - public class LiManDataService : IDisposable + public class LiManDataService : CommonDataServices { #region Public Fields public static GLS.Controllers.LicManController dbControllerGLS; - public static DB.Controllers.DbController dbControllerNext; #endregion Public Fields #region Public Constructors - public LiManDataService(IConfiguration configuration, ILogger logger, IMemoryCache memoryCache, IDistributedCache distributedCache, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) + public LiManDataService(IConfiguration configuration, IMemoryCache memoryCache, IDistributedCache distributedCache, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) : base(configuration, redisConnMult, emailSender) { - _logger = logger; - _configuration = configuration; - // Conf cache - redisConn = redisConnMult; - redisDb = this.redisConn.GetDatabase(); - - // json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ - JSSettings = new JsonSerializerSettings() - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }; - - // conf messagepipe: setup canali pub/sub - EnrollMessPipe = new MessagePipe(redisConn, Const.ENRL_MSG_PIPE); - TaskMessPipe = new MessagePipe(redisConn, Const.TASK_MSG_PIPE); - - _emailSender = emailSender; // conf cache this.memoryCache = memoryCache; this.distributedCache = distributedCache; // conf DB string connStrGLS = _configuration.GetConnectionString("LiMan.GLS"); - string connStrDB = _configuration.GetConnectionString("LiMan.DB"); - if (string.IsNullOrEmpty(connStrDB) || string.IsNullOrEmpty(connStrGLS)) + if (string.IsNullOrEmpty(connStrGLS)) { - _logger.LogError("Almost one ConnString empty!"); + Log.Error("Empty ConnString for LiMan.GLS!"); } else { dbControllerGLS = new LiMan.GLS.Controllers.LicManController(configuration); - dbControllerNext = new LiMan.DB.Controllers.DbController(configuration); - _logger.LogInformation("DbControllers OK"); + Log.Info("DbController for LiMan.GLS OK"); } } #endregion Public Constructors - #region Public Properties - - /// - /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi enroll - /// - public MessagePipe EnrollMessPipe { get; set; } = null!; - - /// - /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi Task - /// - public MessagePipe TaskMessPipe { get; set; } = null!; - - #endregion Public Properties - #region Public Methods public async Task> ApplicazioniGLSGetAll() @@ -597,8 +564,9 @@ namespace LiMan.UI.Data return await Task.FromResult(dbControllerGLS.DbForceMigrate()); } - public void Dispose() + public override void Dispose() { + base.Dispose(); // Clear database controller dbControllerGLS.Dispose(); } @@ -1662,8 +1630,6 @@ namespace LiMan.UI.Data /// protected const string rKeyTaskRun = $"{rKeyBaseComm}:TaskRun"; - protected static JsonSerializerSettings? JSSettings; - /// /// Durata cache lunga IN SECONDI /// @@ -1674,18 +1640,6 @@ namespace LiMan.UI.Data /// protected int cacheTtlShort = 60 * 1; - /// - /// Oggetto per connessione a REDIS - /// - protected IConnectionMultiplexer redisConn = null!; - - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - protected IDatabase redisDb = null!; - - protected Random rnd = new Random(); - #endregion Protected Fields #region Protected Properties @@ -1763,10 +1717,6 @@ namespace LiMan.UI.Data #region Private Fields - private static IConfiguration _configuration; - private static ILogger _logger; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - private readonly IEmailSender _emailSender; private readonly IDistributedCache distributedCache; private readonly IMemoryCache memoryCache; diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 428dd91..bd91a46 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 2.1.2501.2408 + 2.1.2501.2418 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index 00e00ef..783da5f 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

      Versione: 2.1.2501.2408

      +

      Versione: 2.1.2501.2418


      Note di rilascio:
      • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index c23613c..dcc83d1 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2408 +2.1.2501.2418 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index bbb80e2..060585e 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2408 + 2.1.2501.2418 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false