From 8d8dc0bc5abc22154b7953a15c553da2a5e5b532 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 10 Jan 2022 19:32:37 +0100 Subject: [PATCH] OK edit timbrature (ma le chiude...) --- GPW.CORE.Data/Controllers/GPWController.cs | 37 +++++++++++ GPW.CORE.UI/Components/TimbList.razor | 19 +++++- GPW.CORE.UI/Components/TimbrEditor.razor | 21 ++++++- GPW.CORE.UI/Components/TimbrEditor.razor.cs | 69 +++++++++++++++------ GPW.CORE.UI/Data/GpwDataService.cs | 17 ++++- GPW.CORE.UI/GPW.CORE.UI.csproj | 2 +- GPW.CORE.UI/Pages/Planner.razor | 2 +- GPW.CORE.UI/Program.cs | 1 + Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 11 files changed, 143 insertions(+), 31 deletions(-) diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 2119399..54f834c 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -369,6 +369,43 @@ namespace GPW.CORE.Data.Controllers return answ; } + public bool TimbratureUpdate(TimbratureModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetTimbrature + .FirstOrDefault(x => x.IdxDipendente == currItem.IdxDipendente && x.DataOra==currItem.DataOra); + if (currRec != null) + { + // aggiorno solo entrata/uscita + currRec.Entrata = currItem.Entrata; + + localDbCtx + .DbSetTimbrature + .Update(currRec); + } + // altrimenti aggiungo + else + { + localDbCtx + .DbSetTimbrature + .Add(currItem); + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in TimbratureUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + /// /// Recupera overview di un periodo settimanale x dipendente, data riferimento, numero settimane precedenti /// diff --git a/GPW.CORE.UI/Components/TimbList.razor b/GPW.CORE.UI/Components/TimbList.razor index 218437b..064db74 100644 --- a/GPW.CORE.UI/Components/TimbList.razor +++ b/GPW.CORE.UI/Components/TimbList.razor @@ -27,7 +27,7 @@ } - + @if (@item.Entrata == false) @@ -61,8 +61,21 @@ // aggiorno await GDataServ.TimbratureDelete(currRecord); - // elimino dalla lista... - ListTimb.Remove(currRecord); +#if false + // elimino dalla lista... + ListTimb.Remove(currRecord); +#endif + + // registro fatto + await ItemUpdated.InvokeAsync(true); + } + + protected async void ScambioInOut(TimbratureModel currRecord) + { + currRecord.Entrata = !currRecord.Entrata; + + // aggiorno + await GDataServ.TimbratureUpdate(currRecord); // registro fatto await ItemUpdated.InvokeAsync(true); diff --git a/GPW.CORE.UI/Components/TimbrEditor.razor b/GPW.CORE.UI/Components/TimbrEditor.razor index 781f4d1..243b739 100644 --- a/GPW.CORE.UI/Components/TimbrEditor.razor +++ b/GPW.CORE.UI/Components/TimbrEditor.razor @@ -23,7 +23,7 @@
- +
@@ -35,7 +35,22 @@ Mancate timbrature -
Content
+
+
+
+ +
+
+
+ | + +
+
+
+ +
+
+
@@ -46,7 +61,7 @@
- +
diff --git a/GPW.CORE.UI/Components/TimbrEditor.razor.cs b/GPW.CORE.UI/Components/TimbrEditor.razor.cs index 8e77e6b..1982147 100644 --- a/GPW.CORE.UI/Components/TimbrEditor.razor.cs +++ b/GPW.CORE.UI/Components/TimbrEditor.razor.cs @@ -15,6 +15,7 @@ using GPW.CORE.UI; using GPW.CORE.UI.Shared; using GPW.CORE.Data.DbModels; using GPW.CORE.UI.Data; +using System.Net; namespace GPW.CORE.UI.Components { @@ -31,6 +32,9 @@ namespace GPW.CORE.UI.Components [Parameter] public List ListTimb { get; set; } = new List(); + [Parameter] + public DateTime DataRif { get; set; } + [Parameter] public EventCallback CloseReq { get; set; } @@ -43,16 +47,6 @@ namespace GPW.CORE.UI.Components [Inject] protected GpwDataService GDataServ { get; set; } - protected async Task ReloadData() - { -#if false - gruppiList = await GDataServ.AnagGruppiAll(); - var allProj = await GDataServ.AnagProjAll(); - projList = allProj.Where(x => x.Attivo == true && x.Gruppo == gruppoSel).OrderBy(x => x.ClienteNav.RagSociale).ThenBy(x => x.NomeProj).ToList(); - var allFasi = await GDataServ.AnagFasiAll(); - fasiList = allFasi.Where(x => x.IdxProgetto == idxProj).ToList(); -#endif - } protected List ListTimbAppr { @@ -63,6 +57,28 @@ namespace GPW.CORE.UI.Components get => ListTimb.Where(x => x.Approv == false).ToList(); } + protected bool IsUscita { get; set; } = false; + + protected string txtMsgInOut + { + get => IsUscita ? "Uscita" : "Entrata"; + } + + protected override async Task OnInitializedAsync() + { + DateTime adesso = DateTime.Now; + // prendo primo record timbrature o oggi... + if (ListTimb != null && ListTimb.Count > 0) + { + DataRif = ListTimb.FirstOrDefault().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); + } + /// /// Indico item selezionato /// @@ -86,19 +102,34 @@ namespace GPW.CORE.UI.Components await ItemUpdated.InvokeAsync(true); } - + [Inject] + private IHttpContextAccessor httpContextAccessor { get; set; } + + protected async void AddRequest() + { + //var remoteIp = httpContextAccessor.HttpContext.Connection?.RemoteIpAddress.ToString(); + TimbratureModel currRecord = new TimbratureModel() + { + Entrata = !IsUscita, + Approv = false, + CodTipoTimb = "NoTim", + DataOra = DataRif, + IdxDipendente = AppMServ.IdxDipendente, + Ipv4 = ""//$"{remoteIp}" + }; + + // aggiorno + await GDataServ.TimbratureUpdate(currRecord); + + // registro fatto + await ItemUpdated.InvokeAsync(true); + } + /// /// Elimino record /// - protected async void DoDelete() + protected async void ReportUpdated() { - // chiedo verifica - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record selezionato??")) - return; -#if false - // aggiorno - await GDataServ.RegAttDelete(currRecord); -#endif // registro fatto await ItemUpdated.InvokeAsync(true); } diff --git a/GPW.CORE.UI/Data/GpwDataService.cs b/GPW.CORE.UI/Data/GpwDataService.cs index efe9981..ff560b9 100644 --- a/GPW.CORE.UI/Data/GpwDataService.cs +++ b/GPW.CORE.UI/Data/GpwDataService.cs @@ -615,7 +615,22 @@ namespace GPW.CORE.UI.Data { } return answ; } - + + public async Task TimbratureUpdate(TimbratureModel currItem) + { + bool answ = false; + try + { + dbController.TimbratureUpdate(currItem); + // invalido la cache... + await InvalidateAllCache(); + answ = true; + } + catch + { } + return answ; + } + #endregion Public Methods } diff --git a/GPW.CORE.UI/GPW.CORE.UI.csproj b/GPW.CORE.UI/GPW.CORE.UI.csproj index 28ba9da..38ad84f 100644 --- a/GPW.CORE.UI/GPW.CORE.UI.csproj +++ b/GPW.CORE.UI/GPW.CORE.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 3.0.2201.1018 + 3.0.2201.1019 enable enable diff --git a/GPW.CORE.UI/Pages/Planner.razor b/GPW.CORE.UI/Pages/Planner.razor index 7807b89..c1d99f7 100644 --- a/GPW.CORE.UI/Pages/Planner.razor +++ b/GPW.CORE.UI/Pages/Planner.razor @@ -16,7 +16,7 @@ else if (ListTimbr != null) diff --git a/GPW.CORE.UI/Program.cs b/GPW.CORE.UI/Program.cs index 7e49134..1acda6a 100644 --- a/GPW.CORE.UI/Program.cs +++ b/GPW.CORE.UI/Program.cs @@ -25,6 +25,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddHttpContextAccessor(); var app = builder.Build(); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 7e390f5..e1b8b66 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 3.0.2201.1018

+

Versione: 3.0.2201.1019


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 3a68e13..8a7f820 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -3.0.2201.1018 +3.0.2201.1019 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 6675caf..91283e7 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 3.0.2201.1018 + 3.0.2201.1019 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false