From e223f66b4e2ab2c6f2727fd698ff831934a6e156 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 21 Aug 2019 12:24:58 +0200 Subject: [PATCH] Completato prototipo con scrittura su REDIS valori serializzati --- AppData/AppData.csproj | 3 +++ AppData/ComLib.cs | 61 ++++++++++++++++++++++++++++++++++++++++-- NKC_WF/Utility.aspx.cs | 2 +- NKC_WF/Web.config | 6 +++-- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/AppData/AppData.csproj b/AppData/AppData.csproj index 89c7685..33b7396 100644 --- a/AppData/AppData.csproj +++ b/AppData/AppData.csproj @@ -40,6 +40,9 @@ ..\packages\StackExchange.Redis.2.0.601\lib\net461\StackExchange.Redis.dll + + ..\NKC_WF\ExtLib\SteamWare.dll + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 5c8bc80..385f26f 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using SteamWare; using System; using System.Collections.Generic; using System.Linq; @@ -239,6 +240,11 @@ namespace AppData } } } + + #endregion + + #region metodi helper di conversione + /// /// Helper x serializzare l'oggetto /// @@ -260,18 +266,69 @@ namespace AppData return answ; } + #endregion + + #region metodi x data persistence + + /// + /// Salvo il Takt inviato + /// + /// Origine del dato: SERV / PROD / NEST + /// + /// + public static bool saveTakt(string origin, Takt currData) + { + bool answ = false; + try + { + // calcolo valori redis + string redKey = $"NKC:{origin.ToUpper()}:TAKT:{currData.TaktId}"; + string redVal = serializeTakt(currData); + // scrivo per ora solo su REDIS + memLayer.ML.setRSV(redKey, redVal); + answ = true; + } + catch + { } + return answ; + } + + /// + /// Salvo il Takt inviato + /// + /// Origine del dato: SERV / PROD / NEST + /// + /// + public static Takt readTakt(string origin, string TaktId) + { + Takt answ = null; + try + { + string redKey = $"NKC:{origin.ToUpper()}:TAKT:{TaktId}"; + string redVal = memLayer.ML.getRSV(redKey); + answ = deserializeTakt(redVal); + } + catch + { } + return answ; + } + + #endregion + #region metodi per PROD /// /// Fornisce il prossimo TAKT da elaborare oppure null se non ce ne fossero altri da elaborare per la data CORRENTE /// /// - public int getNextTakt() + public Takt prodGetNextTakt() { - return 0; + return null; } + #endregion + } } diff --git a/NKC_WF/Utility.aspx.cs b/NKC_WF/Utility.aspx.cs index d140312..1e58614 100644 --- a/NKC_WF/Utility.aspx.cs +++ b/NKC_WF/Utility.aspx.cs @@ -111,7 +111,7 @@ namespace NKC_WF // scrivo su label lblOut.Text = jsonData; // salvo in redis / DB - + ComLib.saveTakt("SERV", currTakt); } } } \ No newline at end of file diff --git a/NKC_WF/Web.config b/NKC_WF/Web.config index 24592bb..913cab8 100644 --- a/NKC_WF/Web.config +++ b/NKC_WF/Web.config @@ -33,8 +33,10 @@ - - + + +