From 65f7f57e025cb77c2b87ad5684fd3c2ee7315db2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 4 Apr 2022 16:32:51 +0200 Subject: [PATCH] =?UTF-8?q?OK=20split=20attivit=C3=A0=20su=20+=20giornate?= =?UTF-8?q?=20(chiede=20ed=20esegue...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/RegAttEditor.razor.cs | 50 ++++++++++++++++++- GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/GPW.CORE.WRKLOG/Components/RegAttEditor.razor.cs b/GPW.CORE.WRKLOG/Components/RegAttEditor.razor.cs index fa35cc6..b7eb17b 100644 --- a/GPW.CORE.WRKLOG/Components/RegAttEditor.razor.cs +++ b/GPW.CORE.WRKLOG/Components/RegAttEditor.razor.cs @@ -290,7 +290,55 @@ namespace GPW.CORE.WRKLOG.Components // aggiorno if (currRecord != null) { - await GDataServ.RegAttUpdate(currRecord); + //await GDataServ.RegAttUpdate(currRecord); + + // prearo lista inserimento + List data2ins = new List(); + + // se inizio/fine stesso giorno processo + if (currRecord.Fine.Date.Equals(currRecord.Inizio.Date)) + { + data2ins.Add(currRecord); + } + // in caso di eventuale supero della mezzanotte --> chiedo se si vuole split su 2 attività... + else + { + bool doSplit = await JSRuntime.InvokeAsync("confirm", "L'attività si protrae su più giorni, vuoi suddividere in record per ogni giornata?"); + // chiedo verifica x splittare in N+1 periodi (N = giorni) + if (doSplit) + { + RegAttivitaModel currRA = currRecord.Clone() as RegAttivitaModel; + // primo record è inizio --> mezzanote + DateTime lastInizio = currRA.Inizio; + DateTime lastFine = currRA.Inizio.Date.AddDays(1).AddSeconds(0); + currRA.Fine = lastFine; + data2ins.Add(currRA); + // calcolo i gg + int numGG = currRecord.Fine.Date.Subtract(currRecord.Inizio.Date).Days; + // ciclo + for (int i = 0; i < numGG; i++) + { + // splitto... inizio = fine + 1 sec... + currRA = currRecord.Clone() as RegAttivitaModel; + currRA.Inizio = lastFine.AddSeconds(0); + // porto avanti ultima fine... + lastFine = lastFine.AddDays(1); + //// calcolo NUOVA fine x singolo ciclo + //lastFine = currRecord.Inizio.Date.AddDays(i + 2).AddSeconds(-1); + currRA.Fine = currRA.Fine > lastFine ? lastFine : currRA.Fine; + data2ins.Add(currRA); + } + } + else + { + data2ins.Add(currRecord); + } + } + // ciclo x inserire + foreach (var item in data2ins) + { + await GDataServ.RegAttUpdate(item); + } } // resetto clone e record corrente... AppMServ.clonedRA = null; diff --git a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj index e99dbc9..a5bb13b 100644 --- a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj +++ b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj @@ -2,7 +2,7 @@ net6.0 - 3.0.2204.0412 + 3.0.2204.0416 enable enable diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 77768bc..ca3be09 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 3.0.2204.0412

+

Versione: 3.0.2204.0416


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 0b70de7..b6a835b 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -3.0.2204.0412 +3.0.2204.0416 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 373dfe8..9cdb235 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 3.0.2204.0412 + 3.0.2204.0416 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false