From f5c4503fc2fe75e4e502ec854ff7b42825e95a0b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 2 Aug 2021 18:09:01 +0200 Subject: [PATCH] Aggiunta metodo getTask2Exe in uscita GWMS --- GWMS.UI/Controllers/IOBController.cs | 56 +++++++++++++++------------- GWMS.UI/Data/GWMSDataService.cs | 48 ++++++++++++++++++++++++ GWMS.UI/GWMS.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 6 files changed, 82 insertions(+), 30 deletions(-) diff --git a/GWMS.UI/Controllers/IOBController.cs b/GWMS.UI/Controllers/IOBController.cs index 1fd2502..0692bcc 100644 --- a/GWMS.UI/Controllers/IOBController.cs +++ b/GWMS.UI/Controllers/IOBController.cs @@ -1,6 +1,7 @@ using GWMS.Data.DatabaseModels; using GWMS.UI.Data; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; @@ -499,6 +500,35 @@ namespace GWMS.UI.Controllers return ""; } + /// + /// Recupera TASK richiesto x macchina: + /// + /// GET: IOB/getTask2Exe/SIMUL_03 + /// + /// + /// + /// Json contenente 1..n task da eseguire + [HttpGet("getTask2Exe/{id}")] + public string getTask2Exe(string id) + { + string answ = ""; +#if false + // scrivo keep alive!!! (se necessario, altrimenti è in cache...) + MapoDb.MapoDb connDb = new MapoDb.MapoDb(); + DataLayer DataLayerObj = new DataLayer(); + connDb.scriviKeepAlive(id, DateTime.Now); +#endif + try + { + // leggo da REDIS eventuale elenco task x macchina... + Dictionary valori = _DataService.mTaskMacchina(id).Result; + answ = JsonConvert.SerializeObject(valori); + } + catch + { } + return answ; + } + /// /// Input singolo valore /// @@ -616,32 +646,6 @@ namespace GWMS.UI.Controllers return answ; } - /// - /// Recupera TASK richiesto x macchina: - /// - /// GET: IOB/getTask2Exe/SIMUL_03 - /// - /// - /// - /// Json contenente 1..n task da eseguire - public string getTask2Exe(string id) - { - string answ = ""; - // scrivo keep alive!!! (se necessario, altrimenti è in cache...) - MapoDb.MapoDb connDb = new MapoDb.MapoDb(); - DataLayer DataLayerObj = new DataLayer(); - connDb.scriviKeepAlive(id, DateTime.Now); - try - { - // leggo da REDIS eventuale elenco task x macchina... - Dictionary valori = DataLayerObj.mTaskMacchina(id); - answ = JsonConvert.SerializeObject(valori); - } - catch - { } - return answ; - } - // GET: IOB (è un check alive del server) public string Index() { diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 799fbb8..7bac480 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -93,6 +93,16 @@ namespace GWMS.UI.Data #region Protected Methods + /// + /// Hash dati EXE TASK x la macchina specificata + /// + /// + /// + protected static string exeTaskHash(string idxMacchina) + { + return mHash(string.Format("ExeTask:{0}", idxMacchina)); + } + protected string getCacheKey(string TableName, SelectOrderData CurrFilter) { string answ = $"{TableName}:P_{CurrFilter.PlantId:00}:S_{CurrFilter.SupplierId:00}:T_{CurrFilter.TransporterId:00}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}"; @@ -103,6 +113,16 @@ namespace GWMS.UI.Data #region Public Methods + /// + /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...) + /// + /// + /// + public static string mHash(string dataType) + { + return $"DATA:{dataType}"; + } + public async Task> ConfigGetAll() { //return Task.FromResult(dbController.ActionsGetAll()); @@ -180,6 +200,34 @@ namespace GWMS.UI.Data return await Task.FromResult(dbResult); } + /// + /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato + /// + /// + /// + public async Task> mTaskMacchina(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + string cacheKey = exeTaskHash(idxMacchina); + string rawData; + var redisDataList = await distributedCache.GetAsync(cacheKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + answ = JsonConvert.DeserializeObject>(rawData); + } + } + catch (Exception exc) + { + Log.Info($"Errore in recupero dati EXE TASK x Redis mTaskMacchina - idxMacchina {idxMacchina}{Environment.NewLine}{exc}"); + } + return answ; + } + public async Task> OrdersGetFilt(SelectOrderData CurrFilter) { List dbResult = new List(); diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 059e395..d7a7945 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.0.2108.0217 + 1.0.2108.0218 95c9f021-52d1-4390-a670-5810b7b777b0 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 763fc40..c3428b4 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

Versione: 1.0.2108.0217

+

Versione: 1.0.2108.0218


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 4016396..f4b9d3b 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2108.0217 +1.0.2108.0218 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 62d2cb2..28eecb2 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2108.0217 + 1.0.2108.0218 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false