From aaeae6e99e71d1d1042b4ef7e39300518f036cc2 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Sat, 4 Jun 2022 17:44:37 +0200 Subject: [PATCH] Riorganizzazione classe con CodeMaid --- MP.Mon/Data/MpDataService.cs | 144 ++++++++++++++++---------------- MP.Mon/MP.Mon.csproj | 2 +- MP.Mon/Resources/ChangeLog.html | 2 +- MP.Mon/Resources/VersNum.txt | 2 +- MP.Mon/Resources/manifest.xml | 2 +- 5 files changed, 78 insertions(+), 74 deletions(-) diff --git a/MP.Mon/Data/MpDataService.cs b/MP.Mon/Data/MpDataService.cs index 37136dc7..ed18d200 100644 --- a/MP.Mon/Data/MpDataService.cs +++ b/MP.Mon/Data/MpDataService.cs @@ -1,16 +1,20 @@ -using MP.Data.DatabaseModels; -using System.Text; -using StackExchange.Redis; -using NLog; -using MP.Data.DTO; +using MP.Data.Conf; +using MP.Data.DatabaseModels; using Newtonsoft.Json; -using MP.Data; -using MP.Data.Conf; +using NLog; +using StackExchange.Redis; +using System.Text; namespace MP.Mon.Data { public class MpDataService : IDisposable { + #region Public Fields + + public static MP.Data.Controllers.MpMonController dbController; + + #endregion Public Fields + #region Private Fields private static IConfiguration _configuration; @@ -18,11 +22,6 @@ namespace MP.Mon.Data private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - /// - /// Dizionario dei tag configurati per IOB - /// - protected Dictionary> currTagConf { get; set; } = new Dictionary>(); - /// /// Oggetto per connessione a REDIS /// @@ -36,63 +35,6 @@ namespace MP.Mon.Data #endregion Private Fields - #region Public Fields - - public static MP.Data.Controllers.MpMonController dbController; - - #endregion Public Fields - - - /// - /// restituisce il valore da REDIS associato al tag richeisto - /// - /// Chiave in cui cercare il valore - /// - public async Task getTagConf(string redKey) - { - string outVal = ""; - // cerco in REDIS la conf x l'IOB - string rawData = await redisDb.StringGetAsync(redKey); - if (!string.IsNullOrEmpty(rawData)) - { - outVal = rawData; - } - return await Task.FromResult(outVal); - } - - /// - /// Prova a caricare da file la conf degli IOB se presente - /// - private void tryLoadIobTags() - { - Dictionary> currConf = new Dictionary>(); - string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location; - if (!string.IsNullOrEmpty(strExeFilePath)) - { - string? strWorkPath = Path.GetDirectoryName(strExeFilePath); - if (!string.IsNullOrEmpty(strWorkPath)) - { - string filePath = $"{strWorkPath}/Conf/iobTagsConf.json"; - if (File.Exists(filePath)) - { - string rawData = File.ReadAllText(filePath); - if (!string.IsNullOrEmpty(rawData)) - { - var fileConfData = JsonConvert.DeserializeObject(rawData); - if (fileConfData != null) - { - currConf = fileConfData.IobSetup; - } - } - } - if (currConf != null) - { - currTagConf = currConf; - } - } - } - } - #region Public Constructors public MpDataService(IConfiguration configuration, ILogger logger) @@ -127,6 +69,15 @@ namespace MP.Mon.Data #endregion Public Constructors + #region Protected Properties + + /// + /// Dizionario dei tag configurati per IOB + /// + protected Dictionary> currTagConf { get; set; } = new Dictionary>(); + + #endregion Protected Properties + #region Public Methods public Task> ConfigGetAll() @@ -140,6 +91,23 @@ namespace MP.Mon.Data dbController.Dispose(); } + /// + /// restituisce il valore da REDIS associato al tag richeisto + /// + /// Chiave in cui cercare il valore + /// + public async Task getTagConf(string redKey) + { + string outVal = ""; + // cerco in REDIS la conf x l'IOB + string rawData = await redisDb.StringGetAsync(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + outVal = rawData; + } + return await Task.FromResult(outVal); + } + public Task> MacchineGetAll() { return Task.FromResult(dbController.MacchineGetAll().ToList()); @@ -155,7 +123,43 @@ namespace MP.Mon.Data return Task.FromResult(dbResult); } - #endregion Public Methods + + #region Private Methods + + /// + /// Prova a caricare da file la conf degli IOB se presente + /// + private void tryLoadIobTags() + { + Dictionary> currConf = new Dictionary>(); + string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location; + if (!string.IsNullOrEmpty(strExeFilePath)) + { + string? strWorkPath = Path.GetDirectoryName(strExeFilePath); + if (!string.IsNullOrEmpty(strWorkPath)) + { + string filePath = $"{strWorkPath}/Conf/iobTagsConf.json"; + if (File.Exists(filePath)) + { + string rawData = File.ReadAllText(filePath); + if (!string.IsNullOrEmpty(rawData)) + { + var fileConfData = JsonConvert.DeserializeObject(rawData); + if (fileConfData != null) + { + currConf = fileConfData.IobSetup; + } + } + } + if (currConf != null) + { + currTagConf = currConf; + } + } + } + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Mon/MP.Mon.csproj b/MP.Mon/MP.Mon.csproj index c0261946..67b21d52 100644 --- a/MP.Mon/MP.Mon.csproj +++ b/MP.Mon/MP.Mon.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 6.15.2206.319 + 6.15.2206.417 diff --git a/MP.Mon/Resources/ChangeLog.html b/MP.Mon/Resources/ChangeLog.html index b1225424..22e8ca71 100644 --- a/MP.Mon/Resources/ChangeLog.html +++ b/MP.Mon/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MON MAPO -

Versione: 6.15.2206.319

+

Versione: 6.15.2206.417


Note di rilascio:
  • diff --git a/MP.Mon/Resources/VersNum.txt b/MP.Mon/Resources/VersNum.txt index 9b5b893d..eefcbdd1 100644 --- a/MP.Mon/Resources/VersNum.txt +++ b/MP.Mon/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2206.319 +6.15.2206.417 diff --git a/MP.Mon/Resources/manifest.xml b/MP.Mon/Resources/manifest.xml index b1bfe0eb..dd92f0a3 100644 --- a/MP.Mon/Resources/manifest.xml +++ b/MP.Mon/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2206.319 + 6.15.2206.417 https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.Mon.zip https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html false