From 79954366899550f7c1919ccaf738e5189d5b0c00 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 Apr 2023 13:31:31 +0200 Subject: [PATCH] Ok salvataggio SVG su redis --- WebDoorCreator.Core/Constants.cs | 1 + .../Services/QueueDataService.cs | 25 +++++++++++-------- WebDoorCreator.UI/temp/Conf.yaml | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/WebDoorCreator.Core/Constants.cs b/WebDoorCreator.Core/Constants.cs index cdcc997..198d564 100644 --- a/WebDoorCreator.Core/Constants.cs +++ b/WebDoorCreator.Core/Constants.cs @@ -23,6 +23,7 @@ namespace WebDoorCreator.Core public static readonly string CALC_REQ_PROC = $"{BASE_HASH}:CalcRequests:Processing"; public static readonly string CALC_REQ_DONE = $"{BASE_HASH}:CalcRequests:Completed"; public static readonly string CALC_REQ_DDF_CACHE = $"{BASE_HASH}:CalcRequests:CacheDDF"; + public static readonly string CALC_REQ_SVG_CACHE = $"{BASE_HASH}:CalcRequests:CacheSVG"; // REDIS Channels messaggi x QueueMan (verso UI/srv) public static readonly string CALC_REQ_QUEUE = $"CalcRequest"; diff --git a/WebDoorCreator.Data/Services/QueueDataService.cs b/WebDoorCreator.Data/Services/QueueDataService.cs index 7bcf6c0..c492c82 100644 --- a/WebDoorCreator.Data/Services/QueueDataService.cs +++ b/WebDoorCreator.Data/Services/QueueDataService.cs @@ -101,11 +101,8 @@ namespace WebDoorCreator.Data.Services // salvo nell'archivio REDIS delle porte il DDF corrente (key=doorId.versNumb), potrebbe // venire buono anche x eventuale UNDO... - RedisKey currKey = new RedisKey($"{Constants.CALC_REQ_DDF_CACHE}:{sDoorId}:{sCurrVers}"); - - string rawData = JsonConvert.SerializeObject(FullDDF, JSSettings); - await redisDb.StringSetAsync(currKey, FullDDF, DayLongCache); - //await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + RedisKey currDdfKey = new RedisKey($"{Constants.CALC_REQ_DDF_CACHE}:{sDoorId}:{sCurrVers}"); + await redisDb.StringSetAsync(currDdfKey, FullDDF, DayLongCache); // invio sul canale dei messaggi il numero di items in coda attuali x chiedere esecuzione... numPending = await NumRequestPending(); @@ -117,19 +114,27 @@ namespace WebDoorCreator.Data.Services Log.Debug($"SendCalcReq | DoorId: {DoorId} enqueued in: {ts.TotalMilliseconds} ms"); + // FIXME TODO!!!! levare quando ci sarĂ  il vero sw in esecuzione... + // simulazione ritorno dati... - await Task.Delay(200); - - // invio il FINTO messaggio di ritorno... - string retMess = ""; string fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg"); if (File.Exists(fileName)) { - retMess = File.ReadAllText(fileName); + // update indici idxSim++; idxSim = idxSim % 4; + // leggo file + string svgCont = File.ReadAllText(fileName); + // salvo in area REDIS + RedisKey currSvgKey = new RedisKey($"{Constants.CALC_REQ_SVG_CACHE}:{sDoorId}:{sCurrVers}"); + await redisDb.StringSetAsync(currSvgKey, svgCont, DayLongCache); + } + // simulo attesa segnalazione messaggio porta calcolata + await Task.Delay(300); + string retMess = $"{sDoorId}:{sCurrVers}"; + // invio il FINTO messaggio di ritorno... CalcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, retMess); return currVers; diff --git a/WebDoorCreator.UI/temp/Conf.yaml b/WebDoorCreator.UI/temp/Conf.yaml index ed9eb17..6109fdc 100644 --- a/WebDoorCreator.UI/temp/Conf.yaml +++ b/WebDoorCreator.UI/temp/Conf.yaml @@ -3,7 +3,7 @@ #Door1 code: 0015943 -date: 2023-04-19T13:16:56.3256631+02:00 +date: 2023-04-19T13:29:39.4079805+02:00 material: wood measures: millimiters order: