diff --git a/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs b/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs index 99d9514..fa54934 100644 --- a/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs +++ b/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs @@ -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 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 _listTimb { get; set; } = new List(); - - protected List? ListTimbAppr { get; set; } - - protected List? ListTimbRich { get; set; } + [Parameter] + public List? ListRecords + { + get => listRecords; + set + { + listRecords = value; + ReloadData(); + } + } + private List? 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(); - } + } +#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() : 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 diff --git a/GPW.CORE.SMART/Components/Calendario.razor.cs b/GPW.CORE.SMART/Components/Calendario.razor.cs index 04e3cd4..6eca2a8 100644 --- a/GPW.CORE.SMART/Components/Calendario.razor.cs +++ b/GPW.CORE.SMART/Components/Calendario.razor.cs @@ -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? ListRecords { get; set; } = null; + public List? 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 DateCheck = new Dictionary(); @@ -44,6 +40,7 @@ namespace GPW.CORE.Smart.Components #region Private Properties private DateTime dtCurr { get; set; } = DateTime.Today; + private List? 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(); 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() diff --git a/GPW.CORE.SMART/Components/CompTimbra.razor b/GPW.CORE.SMART/Components/CompTimbra.razor index 5f3f193..f412f7c 100644 --- a/GPW.CORE.SMART/Components/CompTimbra.razor +++ b/GPW.CORE.SMART/Components/CompTimbra.razor @@ -7,7 +7,7 @@ else {
- +
diff --git a/GPW.CORE.SMART/Components/CompTimbra.razor.cs b/GPW.CORE.SMART/Components/CompTimbra.razor.cs index 61ff39a..08b9bb6 100644 --- a/GPW.CORE.SMART/Components/CompTimbra.razor.cs +++ b/GPW.CORE.SMART/Components/CompTimbra.razor.cs @@ -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() diff --git a/GPW.CORE.SMART/Components/DtCard.razor.cs b/GPW.CORE.SMART/Components/DtCard.razor.cs index 63dd271..0ca4052 100644 --- a/GPW.CORE.SMART/Components/DtCard.razor.cs +++ b/GPW.CORE.SMART/Components/DtCard.razor.cs @@ -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 { }