From f78fb92d524fdf381cdbc991af46da6a1a742948 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 Apr 2023 08:49:27 +0200 Subject: [PATCH] Ancora update x metodi accesso e gestione code --- .../Controllers/QueueController.cs | 61 ++++++++++++++++++- .../Services/QueueDataService.cs | 29 +++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs index 66901a9..bf04d07 100644 --- a/WebDoorCreator.API/Controllers/QueueController.cs +++ b/WebDoorCreator.API/Controllers/QueueController.cs @@ -32,6 +32,7 @@ namespace WebDoorCreator.API.Controllers long numQueue = await QDService.NumRequestPending(); return numQueue; } + /// /// Lunghezza coda in fase di processing /// @@ -43,6 +44,62 @@ namespace WebDoorCreator.API.Controllers return numQueue; } + /// + /// Invio elenco messaggi elaborazioni (se ho errori --> messaggi oppure libero) + /// + /// + /// + [HttpPost("PostProcessingMessage")] + public async Task PostProcessingMessage(Dictionary ProcMessageList) + { + bool answ = false; + await Task.Delay(1); + return answ; + } + + /// + /// Invio elenco risultati elaborazioni (modalità boolean di esecuzione corretta) + /// + /// + /// + [HttpPost("PostProcessingResult")] + public async Task PostProcessingResult(Dictionary ProcResultList) + { + bool answ = false; + //VC19Check answ = new VC19Check() + //{ + // Result = "KO" + //}; + //var result = await _DataService.InsertCheck(DecodedData, "10.74.82.255"); + //if (result) + //{ + // answ = new VC19Check + // { + // DTRecord = DateTime.Now, + // CheckRecorded = true, + // TimbrRecorder = true, + // Result = $"OK, Check Recorded for {DecodedData.nam.fn} {DecodedData.nam.gn} {DecodedData.dob:yyyy.MM.dd}" + // }; + //} + //else + //{ } + await Task.Delay(1); + return answ; + } + + /// + /// Invio elenco risultati elaborazioni come elenco di SVG + /// + /// + /// + [HttpPost("PostProcessingSvg")] + public async Task PostProcessingSvg(Dictionary ProcSvgList) + { + bool answ = false; + await Task.Delay(1); + return answ; + } + /// /// Elenco richieste in stato pending /// @@ -51,7 +108,7 @@ namespace WebDoorCreator.API.Controllers public async Task?> ShowPending() { var actQueue = await QDService.RequestPending(); - return actQueue;// != null && actQueue.Count > 0 ? actQueue : null; + return actQueue; } /// @@ -74,7 +131,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("TakeProcessingItems")] public async Task> TakeProcessingItems(int numItems) { - var actQueue = await QDService.RequestPending(); + var actQueue = await QDService.TakeProcessingItems(numItems); return actQueue; } diff --git a/WebDoorCreator.Data/Services/QueueDataService.cs b/WebDoorCreator.Data/Services/QueueDataService.cs index 530973d..fbec85f 100644 --- a/WebDoorCreator.Data/Services/QueueDataService.cs +++ b/WebDoorCreator.Data/Services/QueueDataService.cs @@ -174,6 +174,7 @@ namespace WebDoorCreator.API.Data Log.Debug($"RequestPending | {source} in: {ts.TotalMilliseconds} ms"); return dictResult; } + /// /// Get Queue request processing /// @@ -202,6 +203,34 @@ namespace WebDoorCreator.API.Data return dictResult; } + /// + /// Get Queue request pending, removing from queue and putting on processing queue + /// + /// Dictionary of DoorId, saveVersNumb + public async Task> TakeProcessingItems(int numItems) + { + string source = "REDIS"; + long numReq = 0; + Dictionary dictResult = new Dictionary(); + // cerco da cache + RedisKey currKey = new RedisKey(Constants.CALC_REQ_PEND); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + numReq = redisDb.HashLength(currKey); + if (numReq > 0) + { + var rawData = await redisDb.HashGetAllAsync(currKey); + foreach (var item in rawData) + { + dictResult.Add($"{item.Name}", $"{item.Value}"); + } + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"TakeProcessingItems | {source} in: {ts.TotalMilliseconds} ms"); + return dictResult; + } + #endregion Public Methods #region Protected Fields