From dc1bac2237db8738f943c07fee07b5c8bf6ed512 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 10 Apr 2026 12:41:16 +0200 Subject: [PATCH] Aggiunto retrieve dati (da convertire x grafico) --- MP.Data/Services/Utils/StatsDetailService.cs | 78 +++++++++++--------- MP.IOC/Components/Pages/CallStats.razor.cs | 4 +- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/MP.Data/Services/Utils/StatsDetailService.cs b/MP.Data/Services/Utils/StatsDetailService.cs index 52af5707..19b482f5 100644 --- a/MP.Data/Services/Utils/StatsDetailService.cs +++ b/MP.Data/Services/Utils/StatsDetailService.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; + namespace MP.Data.Services.Utils { public class StatsDetailService : BaseServ, IStatsDetailService @@ -43,11 +44,12 @@ namespace MP.Data.Services.Utils } return await GetOrSetCacheAsync( cacheKey, - async () => await _repo.GetFiltAsync(dtStart, dtEnd), - UltraLongCache + async () => await _repo.GetFiltAsync(dtStart, dtEnd, sDest, sType), + LongCache ); }); } + /// public async Task> GetParetoAsync(DateTime dtStart, DateTime dtEnd, int maxRec, string sDest = "", string sType = "") { @@ -65,7 +67,7 @@ namespace MP.Data.Services.Utils return await GetOrSetCacheAsync( cacheKey, async () => await _repo.GetParetoAsync(dtStart, dtEnd, maxRec, sDest, sType), - UltraLongCache + LongCache ); }); } @@ -83,6 +85,42 @@ namespace MP.Data.Services.Utils }); } + /// + public async Task GetRangeAsync(string sEnvir, string sType) + { + return await TraceAsync($"{_className}.GetRange", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:Range:{sEnvir}:{sType}", + async () => await _repo.GetRangeAsync(sEnvir, sType), + UltraFastCache + ); + }); + } + + /// + public async Task UpsertManyAsync(List listRecords, bool removeOld) + { + return await TraceAsync($"{_className}.UpsertMany", async (activity) => + { + string operation = "UpsertMany"; + var success = await _repo.UpsertManyAsync(listRecords, removeOld); + + activity?.SetTag("db.operation", operation); + + if (success > 0) + { + await ClearCacheAsync($"{_redisBaseKey}:{_className}:*"); + } + + return success; + }); + } + + #endregion Public Methods + + #region Protected Methods + /// /// metodo locale per recupero e trasformazione dati da includere con processo generare di tracking & cache /// @@ -154,39 +192,7 @@ namespace MP.Data.Services.Utils return result; } - /// - public async Task GetRangeAsync(string sEnvir, string sType) - { - return await TraceAsync($"{_className}.GetRange", async (activity) => - { - return await GetOrSetCacheAsync( - $"{_redisBaseKey}:{_className}:Range:{sEnvir}:{sType}", - async () => await _repo.GetRangeAsync(sEnvir, sType), - UltraFastCache - ); - }); - } - - /// - public async Task UpsertManyAsync(List listRecords, bool removeOld) - { - return await TraceAsync($"{_className}.UpsertMany", async (activity) => - { - string operation = "UpsertMany"; - var success = await _repo.UpsertManyAsync(listRecords, removeOld); - - activity?.SetTag("db.operation", operation); - - if (success > 0) - { - await ClearCacheAsync($"{_redisBaseKey}:{_className}:*"); - } - - return success; - }); - } - - #endregion Public Methods + #endregion Protected Methods #region Private Fields diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index 566a327e..f4e18cd8 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -134,8 +134,10 @@ namespace MP.IOC.Components.Pages /// private async Task ShowDetail(string selDetail) { - await Task.Delay(10); currDetail = selDetail; + // recupero dettaglio 7gg... + DateTime adesso = DateTime.Now; + var detailList = await StatsDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail); } } } \ No newline at end of file