Fix comportamento display a cascata

This commit is contained in:
Samuele Locatelli
2023-01-13 18:47:41 +01:00
parent a18011e45d
commit cea53a124c
5 changed files with 68 additions and 85 deletions
@@ -1,4 +1,5 @@
using GPW.CORE.Data.DbModels;
using GPW.CORE.Data.DTO;
using GPW.CORE.Smart.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
@@ -10,39 +11,26 @@ namespace GPW.CORE.Smart.Components
{
#region Public Properties
[Parameter]
public DateTime DataRif { get; set; }
private DateTime DataRif = DateTime.Now;
[Parameter]
public int IdxDipendente { get; set; } = -1;
[Parameter]
public List<TimbratureModel> ListTimb
{
get
{
return _listTimb;
}
set
{
if (_listTimb != value)
{
_listTimb = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
#endregion Public Properties
#region Protected Properties
protected List<TimbratureModel> _listTimb { get; set; } = new List<TimbratureModel>();
protected List<TimbratureModel>? ListTimbAppr { get; set; }
protected List<TimbratureModel>? ListTimbRich { get; set; }
[Parameter]
public List<DailyDataDTO>? ListRecords
{
get => listRecords;
set
{
listRecords = value;
ReloadData();
}
}
private List<DailyDataDTO>? listRecords { get; set; } = null;
#endregion Protected Properties
@@ -57,10 +45,12 @@ namespace GPW.CORE.Smart.Components
{
remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
}
#if false
if (ListTimbRich == null)
{
ListTimbRich = new List<TimbratureModel>();
}
}
#endif
// verifico se si trattasse di timbratura uscita da attività del giorno precedente...
if (IsUscita)
@@ -91,8 +81,10 @@ namespace GPW.CORE.Smart.Components
IdxDipendente = MService.IdxDipendente,
Ipv4 = $"{remoteIp}"
};
#if false
ListTimb.Add(currRecord);
ListTimbRich.Add(currRecord);
ListTimbRich.Add(currRecord);
#endif
await CDataServ.TimbratureUpdate(currRecord);
// aggiungo apertura ad oggi
@@ -105,8 +97,10 @@ namespace GPW.CORE.Smart.Components
IdxDipendente = MService.IdxDipendente,
Ipv4 = $"{remoteIp}"
};
#if false
ListTimb.Add(currRecord);
ListTimbRich.Add(currRecord);
ListTimbRich.Add(currRecord);
#endif
await CDataServ.TimbratureUpdate(currRecord);
}
}
@@ -123,20 +117,20 @@ namespace GPW.CORE.Smart.Components
Ipv4 = $"{remoteIp}"
};
#if false
// aggiungo alla lista...
ListTimb.Add(currRecord);
ListTimbRich.Add(currRecord);
ListTimbRich.Add(currRecord);
#endif
// aggiorno
await CDataServ.TimbratureUpdate(currRecord);
await Task.Delay(10);
await ReloadData();
await Task.Delay(1);
ReloadData();
}
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
await ReloadData();
ReloadData();
}
#endregion Protected Methods
@@ -194,30 +188,11 @@ namespace GPW.CORE.Smart.Components
await InvokeAsync(StateHasChanged);
}
private async Task ReloadData()
private void ReloadData()
{
DateTime adesso = DateTime.Now;
ListTimb = (ListTimb == null) ? new List<TimbratureModel>() : ListTimb;
// prendo primo record timbrature o oggi...
if (ListTimb.Count > 0)
{
var firstRec = ListTimb.FirstOrDefault();
if (firstRec != null)
{
DataRif = firstRec.DataOra.Date.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5);
}
}
else
{
DataRif = DateTime.Today.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5);
}
await Task.Delay(1);
if (ListTimb != null)
{
ListTimbAppr = ListTimb.Where(x => x.Approv == true).OrderByDescending(x => x.DataOra).ToList();
ListTimbRich = ListTimb.Where(x => x.Approv == false).OrderByDescending(x => x.DataOra).ToList();
}
//DateTime adesso = DateTime.Now;
//DataRif = DateTime.Today.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5);
DataRif = DateTime.Now;
}
#endregion Private Methods
+17 -16
View File
@@ -1,7 +1,6 @@
using GPW.CORE.Data.DTO;
using GPW.CORE.Smart.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.Smart.Components
{
@@ -13,7 +12,15 @@ namespace GPW.CORE.Smart.Components
public int IdxDipendente { get; set; } = -1;
[Parameter]
public List<DailyDataDTO>? ListRecords { get; set; } = null;
public List<DailyDataDTO>? ListRecords
{
get => listRecords;
set
{
listRecords = value;
reloadData();
}
}
#endregion Public Properties
@@ -24,17 +31,6 @@ namespace GPW.CORE.Smart.Components
#endregion Protected Fields
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
dtCurr = DateTime.Today;
await Task.Delay(1);
await reloadData();
}
#endregion Protected Methods
#region Private Fields
private Dictionary<DateTime, string> DateCheck = new Dictionary<DateTime, string>();
@@ -44,6 +40,7 @@ namespace GPW.CORE.Smart.Components
#region Private Properties
private DateTime dtCurr { get; set; } = DateTime.Today;
private List<DailyDataDTO>? listRecords { get; set; } = null;
[Inject]
private MessageService MService { get; set; } = null!;
@@ -67,13 +64,14 @@ namespace GPW.CORE.Smart.Components
private void DisplayDate(DateTime dtSel)
{
dtCurr = dtSel;
MService.targetDate = dtSel;
showDetail = true;
updateDetail();
MService.ReportDateChange();
}
private async Task reloadData()
private void reloadData()
{
await Task.Delay(1);
DateCheck = new Dictionary<DateTime, string>();
string cssOkComm = "bg-success text-light rounded-circle p-1";
string cssOkLav = "bg-warning text-light rounded-circle p-1";
@@ -100,8 +98,11 @@ namespace GPW.CORE.Smart.Components
private async Task ReloadMonth(DateTime dtSel)
{
dtCurr = dtSel;
MService.targetDate = dtSel;
showDetail = false;
await reloadData();
await Task.Delay(1);
MService.ReportDateChange();
//await reloadData();
}
private async Task resetCal()
+1 -1
View File
@@ -7,7 +7,7 @@
else
{
<div class="row m-3">
<BottoniEntrEsc IdxDipendente="@IdxDipCurr"></BottoniEntrEsc>
<BottoniEntrEsc IdxDipendente="@IdxDipCurr" ListRecords="@listRecords"></BottoniEntrEsc>
</div>
<div class="row mt-2">
<div class="col">
@@ -34,10 +34,8 @@ namespace GPW.CORE.Smart.Components
protected override async Task OnParametersSetAsync()
{
await updateNextTimb();
//await Task.Delay(1);
//await InvokeAsync(StateHasChanged);
await reloadData();
await updateNextTimb();
}
#endregion Protected Methods
@@ -82,9 +80,12 @@ namespace GPW.CORE.Smart.Components
#region Private Methods
private void MService_EA_DateChanged()
private async void MService_EA_DateChanged()
{
dtCurr = MService.targetDate;
await Task.Delay(1);
await reloadData();
await InvokeAsync(StateHasChanged);
}
private async void MService_EA_TimbUpd()
+12 -6
View File
@@ -34,17 +34,23 @@ namespace GPW.CORE.Smart.Components
{
try
{
uiTimer.Elapsed -= ElapsedTimerUi;
uiTimer.Stop();
uiTimer.Dispose();
if (uiTimer != null)
{
uiTimer.Elapsed -= ElapsedTimerUi;
uiTimer.Stop();
uiTimer.Dispose();
}
}
catch
{ }
try
{
timbTimer.Elapsed -= ElapsedTimerTimb;
timbTimer.Stop();
timbTimer.Dispose();
if (timbTimer != null)
{
timbTimer.Elapsed -= ElapsedTimerTimb;
timbTimer.Stop();
timbTimer.Dispose();
}
}
catch
{ }