From 5e8f866d3a6f8d3dfad77dfd706c9c98d3b10ab1 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 20 May 2026 18:57:45 +0200 Subject: [PATCH] Spostamento helper in baseObj --- IOB-UT-NEXT/Iob/BaseObj.cs | 64 ++++++-------------------------- IOB-WIN-FORM/IOB-WIN-FORM.csproj | 1 - IOB-WIN-FORM/Iob/Generic.cs | 56 ++++++++++++---------------- 3 files changed, 35 insertions(+), 86 deletions(-) diff --git a/IOB-UT-NEXT/Iob/BaseObj.cs b/IOB-UT-NEXT/Iob/BaseObj.cs index 1117abdc..0ceb3710 100644 --- a/IOB-UT-NEXT/Iob/BaseObj.cs +++ b/IOB-UT-NEXT/Iob/BaseObj.cs @@ -319,38 +319,20 @@ namespace IOB_UT_NEXT.Iob /// /// Verifica se sia in modalità DEMO avanzata (campionamento da set di valori ammessi...) /// - public static bool DemoInSample - { - get - { - return baseUtils.CRB("DemoInSample"); - } - } + public static bool DemoInSample => baseUtils.CRB("DemoInSample"); /// /// Verifica se sia in modalità DEMO x dati OUTPUT /// - public static bool DemoOut - { - get - { - return utils.CRB("DemoOut"); - } - } + public static bool DemoOut => utils.CRB("DemoOut"); /// /// Indicazione VETO PING a server sino alla data-ora indicata /// public static DateTime dtVetoPing { - get - { - return utils.dtVetoPing; - } - set - { - utils.dtVetoPing = value; - } + get => utils.dtVetoPing; + set => utils.dtVetoPing = value; } /// @@ -358,14 +340,8 @@ namespace IOB_UT_NEXT.Iob /// public static DateTime dtVetoQueueIN { - get - { - return utils.dtVetoQueueIN; - } - set - { - utils.dtVetoQueueIN = value; - } + get => utils.dtVetoQueueIN; + set => utils.dtVetoQueueIN = value; } /// @@ -373,40 +349,22 @@ namespace IOB_UT_NEXT.Iob /// public static DateTime dtVetoSend { - get - { - return utils.dtVetoSend; - } - set - { - utils.dtVetoSend = value; - } + get => utils.dtVetoSend; + set => utils.dtVetoSend = value; } /// /// Verifica se sia abilitato test lettura blocchi memoria all'avvio /// - public static bool EnableTest - { - get - { - return baseUtils.CRB("enableTest"); - } - } + public static bool EnableTest => baseUtils.CRB("enableTest"); /// /// stato Online/Offline del server MP IO (su REDIS) /// public static bool MPOnline { - get - { - return utils.MPIO_Online; - } - set - { - utils.MPIO_Online = value; - } + get => utils.MPIO_Online; + set => utils.MPIO_Online = value; } #endregion Public Properties diff --git a/IOB-WIN-FORM/IOB-WIN-FORM.csproj b/IOB-WIN-FORM/IOB-WIN-FORM.csproj index 35bd3a03..9df513cc 100644 --- a/IOB-WIN-FORM/IOB-WIN-FORM.csproj +++ b/IOB-WIN-FORM/IOB-WIN-FORM.csproj @@ -134,7 +134,6 @@ - diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index e48021f1..fb5e8769 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -61,9 +61,6 @@ 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(); @@ -1974,9 +1971,9 @@ namespace IOB_WIN_FORM.Iob /// public DateTime LastSendGet(string keyReq) { - DateTime lastSend = DateTime.Now.AddDays(-1); - string lastSendKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:LastSend"); - string rawVal = redisMan.redGetHashField(lastSendKey, keyReq); + DateTime lastSend = DateTime.Now.AddDays(-1); + string lastSendKey = GetStatusField("LastSend"); + string rawVal = redisMan.redGetHashField(lastSendKey, keyReq); if (!string.IsNullOrEmpty(rawVal)) { lastSend = DataSerializer.Deserialize(rawVal); @@ -1998,7 +1995,7 @@ namespace IOB_WIN_FORM.Iob /// public bool LastSendSet(string keyReq, DateTime dtRif) { - string lastSendKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:LastSend"); + string lastSendKey = GetStatusField("LastSend"); string rawVal = DataSerializer.Serialize(dtRif); KeyValuePair[] hashFields = new KeyValuePair[1]; hashFields[0] = new KeyValuePair(keyReq, rawVal); @@ -3690,7 +3687,7 @@ namespace IOB_WIN_FORM.Iob parentForm.displayTaskAndLog("[STOP] Stopping adapter - last periodic data read...", true); // salvo statistiche - string callKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:CallStats"); + string callKey = GetCallStatsKey(); await CallMetricsCollector.SaveToRedisAsync(redisMan.currDb, callKey, false); // chiudo la connessione all'adapter... @@ -4666,8 +4663,8 @@ namespace IOB_WIN_FORM.Iob get { Dictionary answ = new Dictionary(); - string redKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:POdlSent"); - string rawData = redisMan.getRSV(redKey); + string redKey = GetPOdlSentKey(); + string rawData = redisMan.getRSV(redKey); if (!string.IsNullOrEmpty(rawData)) { try @@ -4685,8 +4682,8 @@ namespace IOB_WIN_FORM.Iob set { string rawVal = JsonConvert.SerializeObject(value); - string redKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:POdlSent"); - redisMan.setRSV(redKey, rawVal); + string redKey = GetPOdlSentKey(); + redisMan.setRSV(redKey, rawVal); lgDebug($"Salvataggio status POdlSentFileArch | {value.Count} record"); } } @@ -4756,10 +4753,10 @@ namespace IOB_WIN_FORM.Iob /// /// Redis key del dizionari valori DataItemMem persistiti /// - protected string rKeyFluxMem - { - get => redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:FluxMem"); - } + protected string rKeyFluxMem + { + get => GetFluxMemKey(); + } protected Random rndGen { get; set; } = new Random(); @@ -6892,9 +6889,9 @@ namespace IOB_WIN_FORM.Iob string rawWeek = JsonConvert.SerializeObject(cPerInfo); redHashWeek.Add(cWeek, rawWeek); } - // salvo in redis... - string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:WeekStats"); - var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek); + // salvo in redis... + string fullKey = GetWeekStatsKey(); + var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek); // invio ANCHE in MP-IO l'update delle info... string remUrl = urlSetHashDict; @@ -6922,9 +6919,9 @@ namespace IOB_WIN_FORM.Iob week = cal.GetWeekOfYear(adesso, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); // verifico se ci sia la settimana indicata in elenco... string currWeek = $"{adesso:yyyy}-{week:00}"; - // recupero elenco delle settimane da processare da redis/WeekStats - string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:WeekStats"); - Dictionary currStats = redisMan.redGetHashDict(fullKey); + // recupero elenco delle settimane da processare da redis/WeekStats + string fullKey = GetWeekStatsKey(); + Dictionary currStats = redisMan.redGetHashDict(fullKey); if (currStats != null && currStats.Count > 0) { // definisco il DICT delle settimane da processare (= settimane passate, NON la corrente...) @@ -9063,12 +9060,7 @@ namespace IOB_WIN_FORM.Iob } return fatto; } - - /// - /// Oggetto gestione connessioni REDIS - /// - private RedisService redisService; - + private async Task ExecuteIobCheckWithRetry(int maxRetries) { var rand = new Random(); @@ -9684,10 +9676,10 @@ namespace IOB_WIN_FORM.Iob /// private async Task RecipeRemoveWeekStatus(string keyReq) { - string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:WeekStats"); - var okHashDict = redisMan.redRemoveHashField(fullKey, keyReq); - // rileggo status hash - Dictionary currDict = redisMan.redGetHashDict(fullKey); + string fullKey = GetWeekStatsKey(); + var okHashDict = redisMan.redRemoveHashField(fullKey, keyReq); + // rileggo status hash + Dictionary currDict = redisMan.redGetHashDict(fullKey); // invio ANCHE in MP-IO l'update delle info... string remUrl = urlSetHashDict; string dictPayload = JsonConvert.SerializeObject(currDict);