From 4842e8d81fa8c7b4dfc86cfa81961fc732e36b4a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 11 Sep 2024 12:10:17 +0200 Subject: [PATCH] Update gest AnagFasi --- GPW.CORE.ADM/Components/Compo/FasiMan.razor | 69 ++- .../Components/Compo/FasiMan.razor.cs | 163 +++++- .../Components/Compo/ProgettiMan.razor | 4 +- .../Components/Compo/ProgettiMan.razor.cs | 6 +- GPW.CORE.ADM/GPW.CORE.ADM.csproj | 2 +- GPW.CORE.Data/Controllers/GPWController.cs | 389 +++++++++----- GPW.CORE.Data/DbModels/AnagFasiExplModel.cs | 57 +++ GPW.CORE.Data/DbModels/AnagTagFasiModel.cs | 23 + GPW.CORE.Data/DbModels/AnagTagModel.cs | 22 + GPW.CORE.Data/GPWContext.cs | 3 + GPW.CORE.Data/Services/GpwDataService.cs | 481 ++++++++++++------ Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 14 files changed, 881 insertions(+), 344 deletions(-) create mode 100644 GPW.CORE.Data/DbModels/AnagFasiExplModel.cs create mode 100644 GPW.CORE.Data/DbModels/AnagTagFasiModel.cs create mode 100644 GPW.CORE.Data/DbModels/AnagTagModel.cs diff --git a/GPW.CORE.ADM/Components/Compo/FasiMan.razor b/GPW.CORE.ADM/Components/Compo/FasiMan.razor index 86b3e4c..97a4159 100644 --- a/GPW.CORE.ADM/Components/Compo/FasiMan.razor +++ b/GPW.CORE.ADM/Components/Compo/FasiMan.razor @@ -37,8 +37,8 @@ Ore/Budget % Abil Attivo - Nuova Fase - + + @@ -58,25 +58,37 @@ } -
- @item.NomeFase -
@item.DescrizioneFase
+
+ @if (item.IdxFaseAncest > 0) + { +
+ } +
+ @item.NomeFase +
@item.DescrizioneFase
+
@if (item.IdxFaseAncest > 0) { - label?!? + } - + @if (item.EnableTime) { } else { - + } @@ -86,34 +98,43 @@ } else { - + } - colore ore - @*
- @($"{item.totOre:N2}") / @($"{item.budgetTime:N0}") -
*@ + @if (item.BudgetTime > 0) + { +
+ @($"{item.TotOre:N2}") / @($"{item.BudgetTime:N0}") +
+ } - abil + @if (item.IdxFaseAncest == 0) + { + @($"{item.PercOpen:P0}") + } - att - - - add sottofase +
+ +
- @* @if (item.ore == 0) - { - - } - else + @if (item.IdxFaseAncest == 0) + { + + } + + + @if (DelEnabled(item.TotOre, item.IdxFase, item.IdxFaseAncest)) + { + + } + @* else { } *@ - btn delete? } diff --git a/GPW.CORE.ADM/Components/Compo/FasiMan.razor.cs b/GPW.CORE.ADM/Components/Compo/FasiMan.razor.cs index aec0f82..ba274ab 100644 --- a/GPW.CORE.ADM/Components/Compo/FasiMan.razor.cs +++ b/GPW.CORE.ADM/Components/Compo/FasiMan.razor.cs @@ -7,16 +7,26 @@ namespace GPW.CORE.ADM.Components.Compo { public partial class FasiMan { + #region Public Properties [Parameter] - public List? ListRecords { get; set; } = null; + public List? ListRecords { get; set; } = null; + #endregion Public Properties - private bool isLoading { get; set; } = false; - private int totalCount { get; set; } = 0; + #region Protected Properties + [Inject] + protected MessageService AppMServ { get; set; } = null!; - protected string CheckSel(AnagFasiModel curItem) + [Inject] + protected GpwDataService GDataServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected string CheckSel(AnagFasiExplModel curItem) { string answ = ""; if (RecordSel != null) @@ -28,32 +38,26 @@ namespace GPW.CORE.ADM.Components.Compo return answ; } - protected override async Task OnParametersSetAsync() + protected async Task DoDelete(AnagFasiExplModel? selItem) { await Task.Delay(1); - totalCount = ListRecords.Count; - isLoading = false; + if (selItem != null) + { + } } - private string gridKey = "FasiMan"; - [Inject] - protected GpwDataService GDataServ { get; set; } = null!; - [Inject] - protected MessageService AppMServ { get; set; } = null!; - - private AnagFasiModel? RecordSel = null; - private AnagFasiModel? RecordEdit = null; - - protected void DoSelect(AnagFasiModel? selItem) - { - RecordSel = selItem; - RecordEdit = null; - } - protected void DoEdit(AnagFasiModel? selItem) + protected void DoEdit(AnagFasiExplModel? selItem) { RecordSel = null; RecordEdit = selItem; } + + protected void DoSelect(AnagFasiExplModel? selItem) + { + RecordSel = selItem; + RecordEdit = null; + } + protected async Task ForceReload() { RecordEdit = null; @@ -61,5 +65,120 @@ namespace GPW.CORE.ADM.Components.Compo await Task.Delay(1); isLoading = false; } + + /// + /// init valori da config + /// + /// + protected async Task initConf() + { + // leggo conf standard controllo RegAtt + var sWarningRatioPerc = await GDataServ.ConfigGetKey("WarningRatioPerc"); + if (sWarningRatioPerc != null) + { + double.TryParse(sWarningRatioPerc.valore, out warnRatio); + } + } + + protected override async Task OnInitializedAsync() + { + await initConf(); + await ReloadData(); + } + + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + totalCount = ListRecords.Count; + isLoading = false; + } + + #endregion Protected Methods + + #region Private Fields + + private string gridKey = "FasiMan"; + + private AnagFasiExplModel? RecordEdit = null; + + private AnagFasiExplModel? RecordSel = null; + + private double warnRatio = 50; + + #endregion Private Fields + + #region Private Properties + + private bool isLoading { get; set; } = false; + + private List ListTagFasi { get; set; } = new List(); + + private int totalCount { get; set; } = 0; + + #endregion Private Properties + + #region Private Methods + + /// + /// restituisce una classe css a seconda dei valori passati: + /// green: bdgt > real + /// orange: real > bdgt*warning + /// red: real > bdgt + /// std: errore... + /// + /// + /// + /// + private string ColorByVal(object real, object bdgt) + { + string specClass = "default"; + try + { + double valoreReal = Convert.ToDouble(real); + double valoreBdget = Convert.ToDouble(bdgt); + double valoreWarn = Convert.ToDouble(bdgt) * warnRatio / 100; + if (valoreReal >= valoreBdget) + { + specClass = "danger"; + } + else if (valoreReal >= valoreWarn) + { + specClass = "warning"; + } + else + { + specClass = "success"; + } + } + catch + { } + return $" bg-{specClass} bg-opacity-50 bg-gradient border border-{specClass} rounded"; + } + + private bool DelEnabled(decimal TotOre, int idxFase, int idxFaseAnc) + { + // se ha ore NON è eliminabile... + bool answ = TotOre == 0; + // se zero ore --> deve esere child oppure ancestor senza fasi... + if (answ) + { + // se ancestor + if (idxFaseAnc == 0) + { + // cerco fasi dato ancestor... + var listChild = GDataServ.AnagFasiByAncestor(idxFase); + // solo se NON ha fasi child + answ = listChild == null || listChild.Count == 0; + } + } + return answ; + } + + private async Task ReloadData() + { + ListTagFasi = await GDataServ.AnagTagFasiAll(); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor index 3374105..630933d 100644 --- a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor +++ b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor @@ -169,7 +169,7 @@
-
+
@($"{RecordSel.totOre:N2}") / @($"{RecordSel.budgetTime:N0}")
@@ -221,7 +221,7 @@
-
+
@($"{item.totOre:N2}") / @($"{item.budgetTime:N0}")
diff --git a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs index 61437a0..6286854 100644 --- a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs +++ b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs @@ -119,13 +119,13 @@ namespace GPW.CORE.ADM.Components.Compo RecordEdit = null; } - private List? ListFasiSel { get; set; } = null; + private List? ListFasiSel { get; set; } = null; protected async Task DoShowFasi(CalcOreProgettiModel? selItem) { FullEdit = false; // carico le fasi e le asso al controllo! - ListFasiSel = await GDataServ.AnagFasiByProj(selItem.IdxProgetto); + ListFasiSel = await GDataServ.AnagFasiExplByProj(selItem.IdxProgetto); ShowFasi = true; RecordSel = selItem; RecordEdit = null; @@ -285,7 +285,7 @@ namespace GPW.CORE.ADM.Components.Compo /// /// /// - private string colorByVal(object real, object bdgt) + private string ColorByVal(object real, object bdgt) { string specClass = "default"; try diff --git a/GPW.CORE.ADM/GPW.CORE.ADM.csproj b/GPW.CORE.ADM/GPW.CORE.ADM.csproj index 5bf67dd..1d89392 100644 --- a/GPW.CORE.ADM/GPW.CORE.ADM.csproj +++ b/GPW.CORE.ADM/GPW.CORE.ADM.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 4.1.2409.1110 + 4.1.2409.1111 diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 69a65df..2bb6fd7 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -21,6 +21,7 @@ namespace GPW.CORE.Data.Controllers #endregion Public Constructors #region Public Methods + /// /// Recupera l'elenco Clienti (tutti) /// @@ -48,13 +49,64 @@ namespace GPW.CORE.Data.Controllers return dbResult; } + /// + /// Elimina il cliente (se non ci sono relazioni con fasi attive, in tal caso rende disattivo...) + /// + /// + public bool AnagClientiDelete(AnagClientiModel remRec) + { + // init + bool answ = false; + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero cliente in primis... + var dbRec = localDbCtx + .DbSetAnagClienti + .Where(x => x.IdxCliente == remRec.IdxCliente) + .FirstOrDefault(); + if (dbRec != null) + { + // controllo se abbia progetti associati + var listFasi = localDbCtx + .DbSetAnagProgetti + .Where(x => x.IdxCliente == remRec.IdxCliente) + .ToList(); + // --> in tal caso disattivo... + if (listFasi != null && listFasi.Count > 0) + { + dbRec.Attivo = false; + //set modificato + localDbCtx.Entry(dbRec).State = EntityState.Modified; + } + else + { + // altrimenti elimino davvero... + localDbCtx + .DbSetAnagClienti + .Remove(dbRec); + } + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Errore in AnagClientiDelete:{Environment.NewLine}{exc}"); + } + } + return answ; + } + /// /// Recupera l'elenco Clienti (tutti) /// /// public bool AnagClientiUpsert(AnagClientiModel upsRec) { - // init + // init bool answ = false; // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) @@ -99,56 +151,6 @@ namespace GPW.CORE.Data.Controllers } return answ; } - /// - /// Elimina il cliente (se non ci sono relazioni con fasi attive, in tal caso rende disattivo...) - /// - /// - public bool AnagClientiDelete(AnagClientiModel remRec) - { - // init - bool answ = false; - // cerco su DB recuperando set di dati.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - // recupero cliente in primis... - var dbRec = localDbCtx - .DbSetAnagClienti - .Where(x => x.IdxCliente == remRec.IdxCliente) - .FirstOrDefault(); - if (dbRec != null) - { - // controllo se abbia progetti associati - var listFasi = localDbCtx - .DbSetAnagProgetti - .Where(x => x.IdxCliente == remRec.IdxCliente) - .ToList(); - // --> in tal caso disattivo... - if (listFasi != null && listFasi.Count > 0) - { - dbRec.Attivo = false; - //set modificato - localDbCtx.Entry(dbRec).State = EntityState.Modified; - } - else - { - // altrimenti elimino davvero... - localDbCtx - .DbSetAnagClienti - .Remove(dbRec); - } - } - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Errore in AnagClientiDelete:{Environment.NewLine}{exc}"); - } - } - return answ; - } /// /// Cerca un device dato il suo secret @@ -323,6 +325,39 @@ namespace GPW.CORE.Data.Controllers return dbResult; } + /// + /// Elenco fasi dato ancestor + /// + /// + /// + public List AnagFasiByAncestor(int idxFaseAnc) + { + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero intero set... + var searchRecord = localDbCtx + .DbSetAnagFasi + .Where(x => x.IdxFaseAncest == idxFaseAnc) + .Include(p => p.ProgettoNav) + .ToList(); + if (searchRecord != null) + { + dbResult = searchRecord; + } + } + catch (Exception exc) + { + Log.Error($"Errore in AnagFasiByAncestor:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Elenco fasi dato chiave progetto /// @@ -353,6 +388,35 @@ namespace GPW.CORE.Data.Controllers return dbResult; } + /// + /// Elenco FasiExpl dato chiave progetto + /// + /// + /// + public List AnagFasiExplByProj(int idxProj) + { + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var pIdxPrj = new SqlParameter("@idxProgetto", idxProj); + + dbResult = localDbCtx + .DbSetAnagFasiExpl + .FromSqlRaw("EXEC stp_AF_getByIdxProj @idxProgetto", pIdxPrj) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Errore in AnagFasiExplByProj:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Elenco Giustificativi /// @@ -522,7 +586,6 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - public AnagProgettiModel AnagProjByKey(int IdxProj) { // init dati necessari @@ -535,9 +598,9 @@ namespace GPW.CORE.Data.Controllers // recupero intero set.... var dbRec = localDbCtx .DbSetAnagProgetti - .Where(x => (x.IdxProgetto==IdxProj)) + .Where(x => (x.IdxProgetto == IdxProj)) .FirstOrDefault(); - if(dbRec!=null) + if (dbRec != null) { dbResult = dbRec; } @@ -549,6 +612,7 @@ namespace GPW.CORE.Data.Controllers } return dbResult; } + /// /// Elenco progetti calcolati con ore avanzamento filtrata /// @@ -579,7 +643,7 @@ namespace GPW.CORE.Data.Controllers public bool AnagProjDelete(AnagProgettiModel remRec) { - // init + // init bool answ = false; // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) @@ -624,85 +688,6 @@ namespace GPW.CORE.Data.Controllers return answ; } - - public bool AnagProjUpsert(AnagProgettiModel upsRec) - { - // init - bool answ = false; - // cerco su DB recuperando set di dati.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - // recupero cliente in primis... - var dbRec = localDbCtx - .DbSetAnagProgetti - .Where(x => x.IdxProgetto == upsRec.IdxProgetto) - .FirstOrDefault(); - if (dbRec == null) - { - localDbCtx - .DbSetAnagProgetti - .Add(upsRec); - } - else - { - dbRec.Attivo = upsRec.Attivo; - dbRec.Avvio = upsRec.Avvio; - dbRec.Chiusura = upsRec.Chiusura; - dbRec.CodExt = upsRec.CodExt; - dbRec.DescrProj = upsRec.DescrProj; - dbRec.Gruppo = upsRec.Gruppo; - dbRec.IdxCliente = upsRec.IdxCliente; - dbRec.NomeProj = upsRec.NomeProj; - dbRec.OldIdx = upsRec.OldIdx; - dbRec.Starred = upsRec.Starred; - //set modificato - localDbCtx.Entry(dbRec).State = EntityState.Modified; - } - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Errore in AnagProjUpsert:{Environment.NewLine}{exc}"); - } - } - return answ; - } - - public bool AnagProjUpdStatus(int IdxProj, bool Attivo, bool Starred) - { - // init - bool answ = false; - // cerco su DB recuperando set di dati.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - // recupero cliente in primis... - var dbRec = localDbCtx - .DbSetAnagProgetti - .Where(x => x.IdxProgetto == IdxProj) - .FirstOrDefault(); - if (dbRec != null) - { - dbRec.Attivo = Attivo; - dbRec.Starred = Starred; - //set modificato - localDbCtx.Entry(dbRec).State = EntityState.Modified; - } - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Errore in AnagProjUpdStatus:{Environment.NewLine}{exc}"); - } - } - return answ; - } - /// /// Clona record Progetti con stored /// @@ -752,6 +737,138 @@ namespace GPW.CORE.Data.Controllers return result != 0; } + public bool AnagProjUpdStatus(int IdxProj, bool Attivo, bool Starred) + { + // init + bool answ = false; + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero cliente in primis... + var dbRec = localDbCtx + .DbSetAnagProgetti + .Where(x => x.IdxProgetto == IdxProj) + .FirstOrDefault(); + if (dbRec != null) + { + dbRec.Attivo = Attivo; + dbRec.Starred = Starred; + //set modificato + localDbCtx.Entry(dbRec).State = EntityState.Modified; + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Errore in AnagProjUpdStatus:{Environment.NewLine}{exc}"); + } + } + return answ; + } + + public bool AnagProjUpsert(AnagProgettiModel upsRec) + { + // init + bool answ = false; + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero cliente in primis... + var dbRec = localDbCtx + .DbSetAnagProgetti + .Where(x => x.IdxProgetto == upsRec.IdxProgetto) + .FirstOrDefault(); + if (dbRec == null) + { + localDbCtx + .DbSetAnagProgetti + .Add(upsRec); + } + else + { + dbRec.Attivo = upsRec.Attivo; + dbRec.Avvio = upsRec.Avvio; + dbRec.Chiusura = upsRec.Chiusura; + dbRec.CodExt = upsRec.CodExt; + dbRec.DescrProj = upsRec.DescrProj; + dbRec.Gruppo = upsRec.Gruppo; + dbRec.IdxCliente = upsRec.IdxCliente; + dbRec.NomeProj = upsRec.NomeProj; + dbRec.OldIdx = upsRec.OldIdx; + dbRec.Starred = upsRec.Starred; + //set modificato + localDbCtx.Entry(dbRec).State = EntityState.Modified; + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Errore in AnagProjUpsert:{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Elenco Tags + /// + /// + public List AnagTagAll() + { + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero intero set... + dbResult = localDbCtx + .DbSetAnagTag + .OrderBy(x => x.Descrizione) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Errore in AnagTagAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Elenco Tags + /// + /// + public List AnagTagFasiAll() + { + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + // recupero intero set... + dbResult = localDbCtx + .DbSetAnagTagFasi + .OrderBy(x => x.Descrizione) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Errore in AnagTagFasiAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Vista dati per FASE con totalizzaizone ore budget/real /// @@ -762,11 +879,11 @@ namespace GPW.CORE.Data.Controllers CalcOreFasiModel dbResult = new CalcOreFasiModel(); using (GPWContext localDbCtx = new GPWContext(_configuration)) { - var parIdxFase = new SqlParameter("@idxFase", idxFase); + var parIdxFase = new SqlParameter("@idxFaseAnc", idxFase); var rawResult = localDbCtx .DbSetCalcOreFasi - .FromSqlRaw("EXEC stp_AF_getByIdxFase_Child @idxFase", parIdxFase) + .FromSqlRaw("EXEC stp_AF_getByIdxFase_Child @idxFaseAnc", parIdxFase) .ToList(); if (rawResult != null && rawResult.Count > 0) { diff --git a/GPW.CORE.Data/DbModels/AnagFasiExplModel.cs b/GPW.CORE.Data/DbModels/AnagFasiExplModel.cs new file mode 100644 index 0000000..b7960a0 --- /dev/null +++ b/GPW.CORE.Data/DbModels/AnagFasiExplModel.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GPW.CORE.Data.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + public partial class AnagFasiExplModel + { + [Key] + public int IdxFase { get; set; } + public int? IdxProgetto { get; set; } + /// + /// codice fase gerarchico (F.1.2. = Fase 1, sottofase 2) - aggiornare con trigger! + /// + public string CodFase { get; set; } = ""; + /// + /// fase ANCESTOR (contenitore), 0 = è top level + /// + public int IdxFaseAncest { get; set; } = 0; + public string NomeFase { get; set; } = ""; + public string DescrizioneFase { get; set; } = ""; + /// + /// indica se sia abilitata o meno a ricevere assegnazioni di record temporali + /// + public bool EnableTime { get; set; } = true; + /// + /// indica se sia abilitata o meno a ricevere assegnazioni di record di spesa + /// + public bool EnableMoney { get; set; } = false; + public bool Attivo { get; set; } = true; + /// + /// codice univoco + /// + public string CodClasse { get; set; } = ""; + /// + /// codice esterno + /// + public string CodExt { get; set; } = ""; + + public decimal TotOre { get; set; } = 0; + /// + /// Budget del progetto (in ore) + /// + public decimal BudgetTime { get; set; } = 0; + public decimal BudgetMoney { get; set; } = 0; + public double PercOpen { get; set; } = 0; + public string CodTagFase { get; set; } = ""; + + } +} diff --git a/GPW.CORE.Data/DbModels/AnagTagFasiModel.cs b/GPW.CORE.Data/DbModels/AnagTagFasiModel.cs new file mode 100644 index 0000000..69dd7cd --- /dev/null +++ b/GPW.CORE.Data/DbModels/AnagTagFasiModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace GPW.CORE.Data.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("AnagTagFasi")] + public partial class AnagTagFasiModel + { + [Key] + public string CodTagFase { get; set; } = ""; + public string Descrizione { get; set; } = ""; + public bool Enabled { get; set; } = true; + public string CodGruppo { get; set; } = ""; + + } +} diff --git a/GPW.CORE.Data/DbModels/AnagTagModel.cs b/GPW.CORE.Data/DbModels/AnagTagModel.cs new file mode 100644 index 0000000..bbc78bd --- /dev/null +++ b/GPW.CORE.Data/DbModels/AnagTagModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace GPW.CORE.Data.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("AnagTagModel")] + public partial class AnagTagModel + { + [Key] + public string CodTag { get; set; } = ""; + public string Descrizione { get; set; } = ""; + public bool Enabled { get; set; } = true; + + } +} diff --git a/GPW.CORE.Data/GPWContext.cs b/GPW.CORE.Data/GPWContext.cs index eeb5a0a..5933e6e 100644 --- a/GPW.CORE.Data/GPWContext.cs +++ b/GPW.CORE.Data/GPWContext.cs @@ -46,6 +46,7 @@ namespace GPW.CORE.Data public virtual DbSet DbSetTimbratureExpl { get; set; } = null!; public virtual DbSet DbSetAnagClienti { get; set; } = null!; public virtual DbSet DbSetAnagFasi { get; set; } = null!; + public virtual DbSet DbSetAnagFasiExpl { get; set; } = null!; public virtual DbSet DbSetAnagProgetti { get; set; } = null!; public virtual DbSet DbSetAnagGruppi { get; set; } = null!; public virtual DbSet DbSetAnagOrari { get; set; } = null!; @@ -66,6 +67,8 @@ namespace GPW.CORE.Data public virtual DbSet DbSetDipAndAnom { get; set; } = null!; public virtual DbSet DbSetTeRaExpl { get; set; } = null!; public virtual DbSet DbSetStatsDayPres { get; set; } = null!; + public virtual DbSet DbSetAnagTag { get; set; } = null!; + public virtual DbSet DbSetAnagTagFasi { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/GPW.CORE.Data/Services/GpwDataService.cs b/GPW.CORE.Data/Services/GpwDataService.cs index 273882d..d0bcdef 100644 --- a/GPW.CORE.Data/Services/GpwDataService.cs +++ b/GPW.CORE.Data/Services/GpwDataService.cs @@ -248,6 +248,47 @@ namespace GPW.CORE.Data.Services return dbResult; } + /// + /// Elenco fasi dato ancestor + /// + /// + /// + public List AnagFasiByAncestor(int idxFaseAnc) + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyFasiAnc}:{idxFaseAnc}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = redisDb.StringGet(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.AnagFasiByAncestor(idxFaseAnc); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + redisDb.StringSet(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagFasiByAncestor | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } /// /// Recupera info x una specifica FASE /// @@ -286,6 +327,8 @@ namespace GPW.CORE.Data.Services return dbResult; } + + /// /// Elenco fasi dato progetto /// @@ -329,6 +372,49 @@ namespace GPW.CORE.Data.Services return dbResult; } + /// + /// Elenco fasi dato progetto + /// + /// + /// + public async Task?> AnagFasiExplByProj(int idxProj) + { + string source = "DB"; + List? dbResult = new List(); + // cerco "secca "in redis... + string currKey = $"{rKeyFasiByProj}_EXPL:{idxProj}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.AnagFasiExplByProj(idxProj); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagFasiExplByProj | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Elenco Giustificativi /// @@ -371,6 +457,47 @@ namespace GPW.CORE.Data.Services return dbResult; } + /// + /// Elenco gruppi (tutti) + /// + /// + public async Task> AnagGruppiAll() + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyProjAll}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.AnagGruppiAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagGruppiAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Recupera l'elenco gruppi abilitati x il dipendente /// @@ -512,156 +639,6 @@ namespace GPW.CORE.Data.Services Log.Debug($"AnagProjByKey | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } - /// - /// Eliminazione record Progetto - /// - se ha fasi associati >> logica (disattiva) - /// - se non ha fasi elimino record - /// - /// - /// - public async Task AnagProjDelete(AnagProgettiModel remItem) - { - bool answ = false; - try - { - answ = dbController.AnagProjDelete(remItem); - // invalido la cache... - await ExecFlushRedisPattern($"{redisBaseAddr}:*"); - } - catch (Exception exc) - { - Log.Error($"Eccezione in AnagProjDelete{Environment.NewLine}{exc}"); - } - return answ; - } - - /// - /// Upsert record Progetti - /// - /// - /// - public async Task AnagProjUpsert(AnagProgettiModel currItem) - { - bool answ = false; - try - { - answ = dbController.AnagProjUpsert(currItem); - // invalido la cache... - await ExecFlushRedisPattern($"{redisBaseAddr}:*"); - } - catch (Exception exc) - { - Log.Error($"Eccezione in AnagProjUpsert{Environment.NewLine}{exc}"); - } - return answ; - } - - /// - /// Upsert record Progetti x stato attivo e starred - /// - /// - /// - /// - /// - public async Task AnagProjUpdStatus(int IdxProj, bool Attivo, bool Starred) - { - bool answ = false; - try - { - answ = dbController.AnagProjUpdStatus(IdxProj, Attivo, Starred); - // invalido la cache... - await ExecFlushRedisPattern($"{redisBaseAddr}:*"); - } - catch (Exception exc) - { - Log.Error($"Eccezione in AnagProjUpdStatus{Environment.NewLine}{exc}"); - } - return answ; - } - - /// - /// Clona record Progetti con stored - /// - /// - /// - /// - /// - public async Task AnagProjDoClone(int IdxProj, string NewName, bool DoYearSubst) - { - bool answ = false; - try - { - answ = dbController.AnagProjDoClone(IdxProj, NewName, DoYearSubst); - // invalido la cache... - await ExecFlushRedisPattern($"{redisBaseAddr}:*"); - } - catch (Exception exc) - { - Log.Error($"Eccezione in AnagProjDoClone{Environment.NewLine}{exc}"); - } - return answ; - } - - /// - /// Forza ricalcolo statistiche progetti (ALL) - /// - /// - public async Task AnagProjForceUpdate() - { - bool answ = false; - try - { - answ = dbController.AnagProjForceUpdate(); - // invalido la cache... - await ExecFlushRedisPattern($"{redisBaseAddr}:*"); - } - catch (Exception exc) - { - Log.Error($"Eccezione in AnagProjForceUpdate{Environment.NewLine}{exc}"); - } - return answ; - } - - /// - /// Elenco gruppi (tutti) - /// - /// - public async Task> AnagGruppiAll() - { - string source = "DB"; - List? dbResult = new List(); - string currKey = $"{rKeyProjAll}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.AnagGruppiAll(); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"AnagGruppiAll | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } /// /// Elenco progetti calcolati con ore avanzamento filtrata @@ -713,6 +690,73 @@ namespace GPW.CORE.Data.Services Log.Debug($"AnagProjCalcFilt | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + + /// + /// Eliminazione record Progetto + /// - se ha fasi associati >> logica (disattiva) + /// - se non ha fasi elimino record + /// + /// + /// + public async Task AnagProjDelete(AnagProgettiModel remItem) + { + bool answ = false; + try + { + answ = dbController.AnagProjDelete(remItem); + // invalido la cache... + await ExecFlushRedisPattern($"{redisBaseAddr}:*"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in AnagProjDelete{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Clona record Progetti con stored + /// + /// + /// + /// + /// + public async Task AnagProjDoClone(int IdxProj, string NewName, bool DoYearSubst) + { + bool answ = false; + try + { + answ = dbController.AnagProjDoClone(IdxProj, NewName, DoYearSubst); + // invalido la cache... + await ExecFlushRedisPattern($"{redisBaseAddr}:*"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in AnagProjDoClone{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Forza ricalcolo statistiche progetti (ALL) + /// + /// + public async Task AnagProjForceUpdate() + { + bool answ = false; + try + { + answ = dbController.AnagProjForceUpdate(); + // invalido la cache... + await ExecFlushRedisPattern($"{redisBaseAddr}:*"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in AnagProjForceUpdate{Environment.NewLine}{exc}"); + } + return answ; + } + /// /// Recupera info x uno specifico PROJ /// @@ -732,6 +776,134 @@ namespace GPW.CORE.Data.Services return dbResult; } + /// + /// Upsert record Progetti x stato attivo e starred + /// + /// + /// + /// + /// + public async Task AnagProjUpdStatus(int IdxProj, bool Attivo, bool Starred) + { + bool answ = false; + try + { + answ = dbController.AnagProjUpdStatus(IdxProj, Attivo, Starred); + // invalido la cache... + await ExecFlushRedisPattern($"{redisBaseAddr}:*"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in AnagProjUpdStatus{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Upsert record Progetti + /// + /// + /// + public async Task AnagProjUpsert(AnagProgettiModel currItem) + { + bool answ = false; + try + { + answ = dbController.AnagProjUpsert(currItem); + // invalido la cache... + await ExecFlushRedisPattern($"{redisBaseAddr}:*"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in AnagProjUpsert{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Elenco TagFasi + /// + /// + public async Task> AnagTagAll() + { + string source = "DB"; + List? dbResult = new List(); + // cerco "secca "in redis... + string currKey = $"{rKeyTags}:GEN"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.AnagTagAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagTagAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Elenco TagFasi + /// + /// + public async Task> AnagTagFasiAll() + { + string source = "DB"; + List? dbResult = new List(); + // cerco "secca "in redis... + string currKey = $"{rKeyTags}:FASI"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.AnagTagFasiAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagTagFasiAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Vista dati per FASE (tipicamente master...) con totalizzaizone ore budget/real e stato fase /// @@ -2055,9 +2227,11 @@ namespace GPW.CORE.Data.Services protected const string rKeyDailyData = $"{redisBaseAddr}:Cache:DailyData"; protected const string rKeyDipendenti = $"{redisBaseAddr}:Cache:Dipendenti"; protected const string rKeyEventListDip = $"{redisBaseAddr}:Cache:EventListDip"; - protected const string rKeyFasiAll = $"{redisBaseAddr}:Cache:FasiAll"; - protected const string rKeyFasiByProj = $"{redisBaseAddr}:Cache:FasiByProj"; - protected const string rKeyFasiSearch = $"{redisBaseAddr}:Cache:FasiSearch"; + protected const string rKeyFasi = $"{redisBaseAddr}:Cache:Fasi"; + protected const string rKeyFasiAll = $"{redisBaseAddr}:Cache:Fasi:All"; + protected const string rKeyFasiAnc = $"{redisBaseAddr}:Cache:Fasi:Ancest"; + protected const string rKeyFasiByProj = $"{redisBaseAddr}:Cache:Fasi:ByProj"; + protected const string rKeyFasiSearch = $"{redisBaseAddr}:Cache:Fasi:Search"; protected const string rKeyGiust = $"{redisBaseAddr}:Cache:Giustif"; protected const string rKeyGrpAll = $"{redisBaseAddr}:Cache:GrpAll"; protected const string rKeyGrpUser = $"{redisBaseAddr}:Cache:GrpUser"; @@ -2068,6 +2242,7 @@ namespace GPW.CORE.Data.Services protected const string rKeyReportData = $"{redisBaseAddr}:Cache:ReportData"; protected const string rKeyRilTemp = $"{redisBaseAddr}:Cache:RilTemp"; protected const string rKeyStatPresDay = $"{redisBaseAddr}:Cache:StatPresDay"; + protected const string rKeyTags = $"{redisBaseAddr}:Cache:Tags"; protected const string rKeyVC19 = $"{redisBaseAddr}:Cache:VC19"; protected const string rKeyVetoIns = $"{redisBaseAddr}:Cache:VetoInsert"; protected const string rKeyWeekStats = $"{redisBaseAddr}:Cache:WeekStats"; diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 98168d1..de6aa02 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 4.1.2409.1110

+

Versione: 4.1.2409.1111


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index a6bba2f..29c15b0 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -4.1.2409.1110 +4.1.2409.1111 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 1f0ae15..7d7610e 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 4.1.2409.1110 + 4.1.2409.1111 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false