diff --git a/GPW.CORE.UI/Components/WeekStat.razor b/GPW.CORE.UI/Components/WeekStat.razor
index 2e252b9..c2a0df0 100644
--- a/GPW.CORE.UI/Components/WeekStat.razor
+++ b/GPW.CORE.UI/Components/WeekStat.razor
@@ -2,15 +2,22 @@
- statistiche
+
+
+ L: @currData?.SumOreLav.ToString("N2")
+
+
+ C: @currData?.SumOreComm.ToString("N2")
+
+
@@ -19,5 +26,5 @@
@code {
[Parameter]
- public CORE.Data.WeekData? currData { get; set; }
+ public CORE.Data.DTO.WeekStatDTO? currData { get; set; }
}
diff --git a/GPW.CORE.UI/Data/GpwDataService.cs b/GPW.CORE.UI/Data/GpwDataService.cs
index 65967a6..4f6ee6b 100644
--- a/GPW.CORE.UI/Data/GpwDataService.cs
+++ b/GPW.CORE.UI/Data/GpwDataService.cs
@@ -41,6 +41,7 @@ namespace GPW.CORE.UI.Data
#region Protected Fields
protected const string rKeyDipendenti = "Cache:Dipendenti";
+ protected const string rKeyWeekStats = "Cache:WeekStats";
protected const string rKeyQrRemnants = "Cache:QrRemnants";
protected const string rKeyRemnants = "Cache:Remnants";
protected static string connStringBBM = "";
@@ -104,19 +105,39 @@ namespace GPW.CORE.UI.Data
}
///
- /// Elenco ultime settimane
+ /// Statistiche ultime settimane
///
+ ///
+ ///
///
///
- public async Task
> LastWeeks(int numWeek)
+ public async Task> LastWeeks(int idxDipendente, DateTime dtRif,int numWeek)
{
- List dbResult = new List();
- DateTime oggi = DateTime.Today;
- // aggiungo sett corrente + quelle richeiste...
- for (int i = numWeek; i >=0; i--)
+ List? dbResult = new List();
+ string currKey = $"{rKeyWeekStats}:{idxDipendente}:{dtRif.ToString("yyyy-MM-dd")}:{numWeek}";
+
+ string rawData;
+ var redisDataList = await distributedCache.GetAsync(currKey);
+ if (redisDataList != null)
{
- var currWeek = new CORE.Data.WeekData(oggi.AddDays(-i*7));
- dbResult.Add(currWeek);
+ rawData = Encoding.UTF8.GetString(redisDataList);
+ dbResult = JsonConvert.DeserializeObject>(rawData);
+ }
+ else
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = dbController.WeekOverview(idxDipendente,dtRif,numWeek);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ redisDataList = Encoding.UTF8.GetBytes(rawData);
+ await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(false));
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Trace($"Effettuata lettura da DB + caching per LastWeeks: {ts.TotalMilliseconds} ms");
+ }
+ if (dbResult == null)
+ {
+ dbResult = new List();
}
return await Task.FromResult(dbResult);
}
diff --git a/GPW.CORE.UI/Pages/Planner.razor.cs b/GPW.CORE.UI/Pages/Planner.razor.cs
index e625bbd..9a052bc 100644
--- a/GPW.CORE.UI/Pages/Planner.razor.cs
+++ b/GPW.CORE.UI/Pages/Planner.razor.cs
@@ -25,7 +25,7 @@ namespace GPW.CORE.UI.Pages
private string currRecord;
- private List weekStatList;
+ private List weekStatList;
#if false
private WeekPlanModel currRecord = null;
@@ -215,7 +215,7 @@ namespace GPW.CORE.UI.Pages
private async Task ReloadData()
{
isLoading = true;
- weekStatList = await DataService.LastWeeks(4);
+ weekStatList = await DataService.LastWeeks(1,DateTime.Today, 4);
#if false
ListRecords = await DataService.WeekPlanGet();
#endif