From fddfbb6dfa9ed71634560f519019b191a6831948 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 16 Sep 2022 08:36:52 +0200 Subject: [PATCH] More cleanup! --- MP.SPEC/Components/ParamsFilter.razor | 174 ++++++++++++-------------- MP.SPEC/Data/MpDataService.cs | 106 +--------------- MP.SPEC/Pages/PARAMS.razor.cs | 3 - 3 files changed, 89 insertions(+), 194 deletions(-) diff --git a/MP.SPEC/Components/ParamsFilter.razor b/MP.SPEC/Components/ParamsFilter.razor index fe0ac1fa..71bfb86c 100644 --- a/MP.SPEC/Components/ParamsFilter.razor +++ b/MP.SPEC/Components/ParamsFilter.razor @@ -1,103 +1,95 @@ -@if (ListFlux == null || ListMacchine == null) -{ - -} -else -{ -
-
- @if (!liveUpdate) + +
+
+ @if (!liveUpdate) + { + + } + else + { + + } +
+
+
+ @if (showEditPar) { - +
+ +
+
+ +
+
+ +
} else { - +
+ +
} -
- -
-
- @if (showEditPar) - { -
- -
-
- -
-
- -
- } - else - { -
- -
- } -
- + + @if (ListMacchine != null) + { + foreach (var item in ListMacchine) { - foreach (var item in ListMacchine) - { - - } + } - -
-
- +
+
+ -
+ } +
-} - +
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 53d0711a..6c8a4c5c 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -5,7 +5,6 @@ using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System.Diagnostics; -using System.Text; namespace MP.SPEC.Data { @@ -16,11 +15,15 @@ namespace MP.SPEC.Data public MpDataService(IConfiguration configuration, ILogger logger) { _logger = logger; + _logger.LogInformation("Starting MpDataService INIT"); _configuration = configuration; // setup compoenti REDIS redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); redisDb = redisConn.GetDatabase(); + + _logger.LogInformation("Redis INIT"); + // setup canali pub/sub dataPipe = new MessagePipe(redisConn, Constants.ACT_MSE_DATA_KEY); blinkPipe = new MessagePipe(redisConn, Constants.ACT_BLINK_KEY); @@ -29,23 +32,13 @@ namespace MP.SPEC.Data string connStr = _configuration.GetConnectionString("Mp.Data"); if (string.IsNullOrEmpty(connStr)) { - _logger.LogError("ConnString empty!"); + _logger.LogError("DbController: ConnString empty!"); } else { dbController = new MP.Data.Controllers.MpSpecController(configuration); - StringBuilder sb = new StringBuilder(); - sb.AppendLine($"DbController OK"); - _logger.LogInformation(sb.ToString()); + _logger.LogInformation("DbController OK"); } - - // setup conf IOB da dizionario - tryLoadIobTags(); - -#if false - // avvio timers... - startTimers(); -#endif } #endregion Public Constructors @@ -535,92 +528,5 @@ namespace MP.SPEC.Data private IDatabase redisDb = null!; #endregion Private Fields - - #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) - { - // effettuo esplosione conf SE contenesse il valore "***" = tutti - // gli IOB - if (fileConfData.IobSetup.ContainsKey("***")) - { - // recupero elenco macchine... - var elencoMacc = dbController.MacchineGetAll(); - // x ogni macchina creo le righe standard da conf... - var baseConf = fileConfData.IobSetup.Where(x => x.Key == "***").FirstOrDefault(); - foreach (var item in elencoMacc) - { - if (!string.IsNullOrEmpty(item.IdxMacchina)) - { - // converto i valori x la macchina corrente... clono in - // nuovo oggetto - var specVal = baseConf.Value.Select(i => i.Clone()).ToList(); - // sostituisco segnaposto - foreach (var singleVal in specVal) - { - singleVal.TagLocation = singleVal.TagLocation.Replace("***", item.IdxMacchina); - } - // ora aggiungo eventuali valori in override... - if (fileConfData.IobSetup.ContainsKey(item.IdxMacchina)) - { - var otConf = fileConfData.IobSetup.Where(x => x.Key == item.IdxMacchina).FirstOrDefault(); - //verifico x ogni valore other... - foreach (var otTag in otConf.Value) - { - var ovrTag = specVal.Where(x => x.ColNum == otTag.ColNum && x.RowNum == otTag.RowNum).FirstOrDefault(); - // se contiene --> sovrascrivo - if (ovrTag != null) - { - //ovrTag = otTag.Clone(); - specVal.Remove(ovrTag); - specVal.Add(otTag.Clone()); - } - // se non contiene --> aggiungo - else - { - specVal.Add(otTag); - } - } - } - currConf.Add(item.IdxMacchina, specVal); - } - } - } - // altrimenti copio ed ho finito - else - { - currConf = fileConfData.IobSetup; - } - } - } - } - if (currConf != null) - { - currTagConf = currConf; - } - } - } - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/MP.SPEC/Pages/PARAMS.razor.cs b/MP.SPEC/Pages/PARAMS.razor.cs index fa828e97..a31b17f6 100644 --- a/MP.SPEC/Pages/PARAMS.razor.cs +++ b/MP.SPEC/Pages/PARAMS.razor.cs @@ -37,9 +37,6 @@ namespace MP.SPEC.Pages { isLoading = true; isFiltering = true; -#if false - await InvokeAsync(() => StateHasChanged()); -#endif // disabilito ricerca... MsgService.SearchVal = ""; MsgService.ShowSearch = false;