diff --git a/GPW.CORE.UI/Data/GpwDataService.cs b/GPW.CORE.UI/Data/GpwDataService.cs index b0e5d75..6e98472 100644 --- a/GPW.CORE.UI/Data/GpwDataService.cs +++ b/GPW.CORE.UI/Data/GpwDataService.cs @@ -305,7 +305,7 @@ namespace GPW.CORE.UI.Data public async Task> DailyDetails(int idxDipendente, DateTime dtInizio, DateTime dtFine) { List? dbResult = new List(); - string currKey = $"{rKeyDailyData}:{idxDipendente}:{dtInizio.ToString("yyyy-MM-dd")}:{dtInizio.ToString("yyyy-MM-dd")}"; + string currKey = $"{rKeyDailyData}:{idxDipendente}:{dtInizio.ToString("yyyy-MM-dd")}:{dtFine.ToString("yyyy-MM-dd")}"; if (!cachedDataList.Contains(currKey)) { cachedDataList.Add(currKey); diff --git a/GPW.CORE.UI/Pages/FastRec.razor b/GPW.CORE.UI/Pages/FastRec.razor index c70b5ab..e16dbfc 100644 --- a/GPW.CORE.UI/Pages/FastRec.razor +++ b/GPW.CORE.UI/Pages/FastRec.razor @@ -2,6 +2,13 @@ @using GPW.CORE.UI @using GPW.CORE.UI.Components +@using CORE.Data.DbModels +@using CORE.Data.DTO +@using UI.Data + +@inject IJSRuntime JSRuntime +@inject GpwDataService GDataServ +@inject MessageService AppMServ
@@ -50,7 +57,11 @@ }
- display della SOLA giornata corrente (titolo + riga)... + + @foreach (var currItem in ListRecords) + { + + }
@@ -60,6 +71,8 @@ @code { + private List ListFasi = new List(); + private List ListRecords = new List(); private int _tipoSearch = 0; public int TipoSearch @@ -78,8 +91,16 @@ } } + protected int startHour = 7; + protected int endHour = 21; + protected bool isLoading = false; private int idxFaseSel = 0; + private int idxDipendente + { + get => AppMServ.IdxDipendente; + } + private void SelFase(int idxFase) { idxFaseSel = idxFase; @@ -89,4 +110,79 @@ { idxFaseSel = 0; } + + private async Task ReloadData() + { + isLoading = true; + DateTime oggi = DateTime.Today; + var rawData=await GDataServ.DailyDetails(idxDipendente, oggi, oggi.AddDays(1)); + ListRecords = rawData.Where(x=> x.DtRif==oggi).ToList(); + await Task.Delay(100); + checkHourRange(); + await Task.Delay(100); + isLoading = false; + } + + protected override async Task OnInitializedAsync() + { + await ReloadData(); + } + + private void checkHourRange() + { + int minHour = 9; + int maxHour = 18; + if (ListRecords != null) + { + int roundMin = 15; + // per ogni giornata + foreach (var giornata in ListRecords) + { + var minRecTimb = giornata.ListTimbr + .Where(x => x.Entrata == true) + .OrderBy(x => x.DataOra) + .FirstOrDefault(); + if (minRecTimb != null) + { + if (minHour > minRecTimb.DataOra.AddMinutes(-roundMin).Hour) + { + minHour = minRecTimb.DataOra.AddMinutes(-roundMin).Hour; + } + } + var minRecRa = giornata.ListRA + .OrderBy(x => x.Inizio) + .FirstOrDefault(); + if (minRecRa != null) + { + if (minHour > minRecRa.Inizio.AddMinutes(-roundMin).Hour) + { + minHour = minRecRa.Inizio.AddMinutes(-roundMin).Hour; + } + } + var maxRecTimb = giornata.ListTimbr + .Where(x => x.Entrata == false) + .OrderByDescending(x => x.DataOra) + .FirstOrDefault(); + if (maxRecTimb != null) + { + if (maxHour < maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1) + { + maxHour = maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1; + } + } + var maxRecRa = giornata.ListRA + .OrderByDescending(x => x.Fine) + .FirstOrDefault(); + if (maxRecRa != null) + { + if (maxHour < maxRecRa.Fine.AddMinutes(roundMin).Hour + 1) + { + maxHour = maxRecRa.Fine.AddMinutes(roundMin).Hour + 1; + } + } + } + } + startHour = minHour; + endHour = maxHour; + } }