diff --git a/IOB-WIN-FORM/IOB-WIN-FORM.csproj b/IOB-WIN-FORM/IOB-WIN-FORM.csproj
index 9df513cc..35bd3a03 100644
--- a/IOB-WIN-FORM/IOB-WIN-FORM.csproj
+++ b/IOB-WIN-FORM/IOB-WIN-FORM.csproj
@@ -134,6 +134,7 @@
+
diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs
index 0848a5bb..e48021f1 100644
--- a/IOB-WIN-FORM/Iob/Generic.cs
+++ b/IOB-WIN-FORM/Iob/Generic.cs
@@ -1,6 +1,7 @@
using EgwProxy.Ftp;
using IOB_UT_NEXT;
using IOB_UT_NEXT.Config;
+using IOB_WIN_FORM.Iob.Services;
using MapoSDK;
using MathNet.Numerics.Statistics;
using Newtonsoft.Json;
@@ -25,7 +26,6 @@ using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
-using IOB_WIN_FORM.Iob.Services;
using YamlDotNet.Core.Tokens;
using static IOB_UT_NEXT.BaseAlarmConf;
using static IOB_UT_NEXT.CustomObj;
@@ -60,6 +60,9 @@ namespace IOB_WIN_FORM.Iob
// init oggetto redis...
redisMan = new RedisIobCache(IobConfNew.MapoMes.IpAddr, IobConfNew.General.FilenameIOB, $"{IobConfNew.General.IobType}", IobConfNew.General.MinDeltaSec);
+
+ // init RedisService per astrarre le chiamate alla cache
+ redisService = new RedisService(redisMan, IobConfNew.General.FilenameIOB, IobConfNew.General.IobType);
// init code
SetupQueue();
@@ -9061,6 +9064,11 @@ namespace IOB_WIN_FORM.Iob
return fatto;
}
+ ///
+ /// Oggetto gestione connessioni REDIS
+ ///
+ private RedisService redisService;
+
private async Task ExecuteIobCheckWithRetry(int maxRetries)
{
var rand = new Random();
diff --git a/IOB-WIN-FORM/Iob/Services/RedisService.cs b/IOB-WIN-FORM/Iob/Services/RedisService.cs
new file mode 100644
index 00000000..a92a9938
--- /dev/null
+++ b/IOB-WIN-FORM/Iob/Services/RedisService.cs
@@ -0,0 +1,49 @@
+using System;
+using IOB_UT_NEXT;
+
+namespace IOB_WIN_FORM.Iob.Services
+{
+ ///
+ /// Servizio applicativo che funge da wrapper semantico per le operazioni Redis.
+ /// Incapsula la costruzione delle chiavi per proteggere la logica di business dalla struttura fisica delle chiavi.
+ ///
+ public class RedisService
+ {
+ private readonly RedisIobCache _redisMan;
+ private readonly string _filenameIob;
+ private readonly tipoAdapter _tipo;
+
+ public RedisService(RedisIobCache redisMan, string filenameIob, tipoAdapter tipo)
+ {
+ _redisMan = redisMan ?? throw new ArgumentNullException(nameof(redisMan));
+ _filenameIob = filenameIob ?? throw new ArgumentNullException(nameof(filenameIob));
+ _tipo = tipo;
+ }
+
+ ///
+ /// Recupera un valore specifico dal hash dello stato dell'IOB.
+ ///
+ /// Il campo del hash da recuperare.
+ /// Il valore come stringa.
+ public string GetStatusField(string field)
+ {
+ string key = $"IOB:Status:{_filenameIob}";
+ // Nota: Utilizziamo redHash per generare la chiave base se necessario,
+ // ma qui puntiamo direttamente alla struttura concordata.
+ return _redisMan.redGetHashField(key, field);
+ }
+
+ ///
+ /// Imposta un valore nel hash dello stato dell'IOB.
+ ///
+ /// Il campo del hash da impostare.
+ /// Il valore da impostare.
+ public void SetStatusField(string field, string value)
+ {
+ string key = $"IOB:Status:{_filenameIob}";
+ _redisMan.redSetHashField(key, field, value);
+ }
+
+ // Altri metodi semantici verranno aggiunti man mano che il refactoring procede.
+ }
+}