diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index dbe9c8c..ce2b3e7 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -3,20 +3,13 @@ using GPW.CORE.Data.DTO; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using NLog; using Newtonsoft.Json; +using NLog; namespace GPW.CORE.Data.Controllers { public class GPWController : IDisposable { - #region Private Fields - - private static IConfiguration _configuration = null!; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields - #region Public Constructors public GPWController(IConfiguration configuration) @@ -82,6 +75,7 @@ namespace GPW.CORE.Data.Controllers } return dbResult; } + /// /// Recupera singola fase /// @@ -114,6 +108,7 @@ namespace GPW.CORE.Data.Controllers } return dbResult; } + /// /// Elenco fasi dato chiave progetto /// @@ -143,41 +138,6 @@ namespace GPW.CORE.Data.Controllers } return dbResult; } - /// - /// Imposta stato di una fase - /// - /// ID - /// Stato attivo true/false (se è amster -_> aggiorna sottofasi x trigger su DB - /// - public async Task FasiSetActive(int idxFase, bool isActive) - { - // init dati necessari - bool fatto = false; - // cerco su DB recuperando set di dati.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - // recupero intero set... - var dbResult = localDbCtx - .DbSetAnagFasi - .Where(x => x.IdxFase == idxFase) - .FirstOrDefault(); - if (dbResult != null) - { - dbResult.Attivo = isActive; - await localDbCtx.SaveChangesAsync(); - fatto = true; - } - } - catch (Exception exc) - { - Log.Error($"Errore in FasiSetActive:{Environment.NewLine}{exc}"); - } - } - await Task.Delay(1); - return fatto; - } public List AnagGruppiAll() { @@ -224,33 +184,18 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - public List AnagProjAll(bool onlyActive) + public List AnagKeyValGetAll() { - // init dati necessari - List dbResult = new List(); - // cerco su DB recuperando set di dati.... + List dbResult = new List(); using (GPWContext localDbCtx = new GPWContext(_configuration)) { - try - { - // recupero intero set.... - dbResult = localDbCtx - .DbSetAnagProgetti - .Where(x => ((bool)(x.Attivo ?? false) == true && onlyActive == true) || !onlyActive) - .Include(c => c.ClienteNav) - .Include(g => g.GruppiNav) - .OrderBy(x => x.NomeProj) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Errore in AnagProjAll:{Environment.NewLine}{exc}"); - } + dbResult = localDbCtx + .DbSetAnagKeyValue + .ToList(); } return dbResult; } - /// /// Dati orario del dipendente indicato /// @@ -281,25 +226,27 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - /// - /// Vista dati per progetto con totalizzaizone ore budget/real - /// - /// - /// - public CalcOreProgettiModel CalcOreProj(int idxProj) + public List AnagProjAll(bool onlyActive) { - CalcOreProgettiModel dbResult = new CalcOreProgettiModel(); + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) { - var idxProgetto = new SqlParameter("@idxProgetto", idxProj); - - var rawResult = localDbCtx - .DbSetCalcOreProj - .FromSqlRaw("EXEC stp_AP_getByIdxPrj @idxProgetto", idxProgetto) - .ToList(); - if (rawResult != null && rawResult.Count > 0) + try { - dbResult = rawResult[0]; + // recupero intero set.... + dbResult = localDbCtx + .DbSetAnagProgetti + .Where(x => ((bool)(x.Attivo ?? false) == true && onlyActive == true) || !onlyActive) + .Include(c => c.ClienteNav) + .Include(g => g.GruppiNav) + .OrderBy(x => x.NomeProj) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Errore in AnagProjAll:{Environment.NewLine}{exc}"); } } return dbResult; @@ -329,6 +276,30 @@ namespace GPW.CORE.Data.Controllers return dbResult; } + /// + /// Vista dati per progetto con totalizzaizone ore budget/real + /// + /// + /// + public CalcOreProgettiModel CalcOreProj(int idxProj) + { + CalcOreProgettiModel dbResult = new CalcOreProgettiModel(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + var idxProgetto = new SqlParameter("@idxProgetto", idxProj); + + var rawResult = localDbCtx + .DbSetCalcOreProj + .FromSqlRaw("EXEC stp_AP_getByIdxPrj @idxProgetto", idxProgetto) + .ToList(); + if (rawResult != null && rawResult.Count > 0) + { + dbResult = rawResult[0]; + } + } + return dbResult; + } + /// /// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente /// @@ -463,365 +434,49 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - public List AnagKeyValGetAll() - { - List dbResult = new List(); - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - dbResult = localDbCtx - .DbSetAnagKeyValue - .ToList(); - } - return dbResult; - } - public void Dispose() { Log.Info("Dispose di GPWController"); } /// - /// Elenco pareto progetti ordinati da filtro + /// Imposta stato di una fase /// - /// - /// - /// - /// + /// ID + /// + /// Stato attivo true/false (se è amster -_> aggiorna sottofasi x trigger su DB + /// /// - public List ParetoRegAtt(int idxDip, DateTime dataStart, DateTime dataEnd, int maxResult) - { - List dbResult = new List(); - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - var idxDipendente = new SqlParameter("@idxDipendente", idxDip); - var inizio = new SqlParameter("@inizio", dataStart); - var fine = new SqlParameter("@fine", dataEnd); - var maxRes = new SqlParameter("@maxRes", maxResult); - - dbResult = localDbCtx - .DbSetParetoRegAtt - .FromSqlRaw("EXEC stp_freqProjByDipPeriodo @idxDipendente, @inizio,@fine,@maxRes", idxDipendente, inizio, fine, maxRes) - .ToList(); - } - return dbResult; - } - - public bool RegAttDelete(RegAttivitaModel currItem) - { - bool answ = false; - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - localDbCtx.Remove(currItem); - - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in RegAttUpdate{Environment.NewLine}{exc}"); - } - } - return answ; - } - - /// - /// Recupera ultima attività dipendente - /// - /// - /// cerca ultima solo tra attive (=true) o tutte (=false) - /// - public RegAttivitaModel RegAttLastByDip(int IdxDipendente, bool onlyActive) - { - RegAttivitaModel? dbResult = new RegAttivitaModel(); - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - dbResult = localDbCtx - .DbSetRegAttivita - .Where(x => x.FasiNav.Attivo || !onlyActive) - .OrderByDescending(x => x.Inizio) - .FirstOrDefault(x => x.IdxDipendente == IdxDipendente); - } - catch (Exception exc) - { - Log.Error($"Eccezione in RegAttLastByDip{Environment.NewLine}{exc}"); - } - if (dbResult == null) - { - dbResult = new RegAttivitaModel(); - } - } - if (dbResult == null) - { - dbResult = new RegAttivitaModel(); - } - return dbResult; - } - - public bool RegAttUpdate(RegAttivitaModel currItem) - { - bool answ = false; - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - if (currItem.IdxRa == 0) - { - localDbCtx.Entry(currItem).State = EntityState.Added; - } - else - { - var currRec = localDbCtx - .DbSetRegAttivita - .FirstOrDefault(x => x.IdxRa == currItem.IdxRa); - if (currRec != null) - { - currRec.IdxDipendente = currItem.IdxDipendente; - currRec.IdxFase = currItem.IdxFase; - currRec.Inizio = currItem.Inizio; - currRec.Fine = currItem.Fine; - currRec.Descrizione = currItem.Descrizione; - - localDbCtx - .DbSetRegAttivita - .Update(currRec); - } - // altrimenti aggiungo - else - { - localDbCtx - .DbSetRegAttivita - .Update(currItem); - } - } - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in RegAttUpdate{Environment.NewLine}{exc}"); - } - } - return answ; - } - - /// - /// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente - /// - /// Dipendente interessato - /// Data di riferimento (ultima/corrente) - /// NUm settimane precedenti da recuperare - /// - public List RilTempList(int idxDipendente, DateTime dtInizio, DateTime dtFine) + public async Task FasiSetActive(int idxFase, bool isActive) { // init dati necessari - List dbResult = new List(); + bool fatto = false; // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - dbResult = localDbCtx - .DbSetRilievoTemp - .Where(x => x.IdxDipendente == idxDipendente && dtInizio <= x.DtRilievo && x.DtRilievo <= dtFine) - .ToList(); - } - return dbResult; - } - - public bool RilTempUpdate(RilievoTempModel currItem) - { - bool answ = false; - using (GPWContext localDbCtx = new GPWContext(_configuration)) { try { - var currRec = localDbCtx - .DbSetRilievoTemp - .FirstOrDefault(x => x.IdxDipendente == currItem.IdxDipendente && x.DtRilievo == currItem.DtRilievo); - if (currRec != null) + // recupero intero set... + var dbResult = localDbCtx + .DbSetAnagFasi + .Where(x => x.IdxFase == idxFase) + .FirstOrDefault(); + if (dbResult != null) { - // aggiorno solo entrata/uscita - currRec.TempRil = currItem.TempRil; - - localDbCtx - .DbSetRilievoTemp - .Update(currRec); - } - // altrimenti aggiungo - else - { - localDbCtx - .DbSetRilievoTemp - .Add(currItem); - } - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in RilTempUpdate{Environment.NewLine}{exc}"); - } - } - return answ; - } - - /// - /// Annulla modifiche su una specifica entity (cancel update) - /// - /// - /// - public bool rollBackEntity(object item) - { - bool answ = false; - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - if (localDbCtx.Entry(item).State == EntityState.Deleted || localDbCtx.Entry(item).State == EntityState.Modified) - { - localDbCtx.Entry(item).Reload(); + dbResult.Attivo = isActive; + await localDbCtx.SaveChangesAsync(); + fatto = true; } } catch (Exception exc) { - Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}"); + Log.Error($"Errore in FasiSetActive:{Environment.NewLine}{exc}"); } } - return answ; + await Task.Delay(1); + return fatto; } - public List TimbratureDay(DateTime dateRif, int IdxDip) - { - List dbResult = new List(); - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - dbResult = localDbCtx - .DbSetTimbrature - .Where(x => x.DataOra.Date == dateRif.Date && x.IdxDipendente == IdxDip) - .OrderByDescending(x => x.DataOra) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Eccezione in TimbratureDay{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - - public bool TimbratureDelete(TimbratureModel currItem) - { - bool answ = false; - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - try - { - localDbCtx.Remove(currItem); - - localDbCtx.SaveChanges(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TimbratureDelete{Environment.NewLine}{exc}"); - } - } - 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 - /// - /// Dipendente interessato - /// Data di riferimento (ultima/corrente) - /// NUm settimane precedenti da recuperare - /// - public List WeekOverview(int idxDipendente, DateTime dtRif, int numWeek) - { - // init dati necessari - List dbResult = new List(); - List weekList = new List(); - - // aggiungo sett corrente + quelle richieste... - for (int i = numWeek; i >= 0; i--) - { - var currWeek = new WeekData(dtRif.AddDays(-i * 7)); - weekList.Add(currWeek); - } - - // cerco su DB settimana x settimana.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - foreach (var item in weekList) - { - var totOreTim = localDbCtx - .DbSetTimbratureExpl - .Where(x => x.IdxDipendente == idxDipendente && x.DataLav >= item.inizio && x.DataLav <= item.fine) - .Sum(x => (double)x.HLav); - var totMinLav = localDbCtx - .DbSetRegAttivitaExpl - .Where(x => x.IdxDipendente == idxDipendente && x.DataLav >= item.inizio && x.DataLav <= item.fine) - .Sum(x => (int)x.MinRegAtt); - - // aggiungo alla lista... - var weekData = new WeekStatDTO() - { - IdxDipendente = idxDipendente, - Anno = item.anno, - WeekNumber = item.weekNumber, - Inizio = item.inizio, - Fine = item.fine, - SumOreLav = totOreTim, - SumOreComm = (double)totMinLav / 60, - }; - dbResult.Add(weekData); - } - } - return dbResult; - } - - public List GetChecksVC19(int maxNum) { List dbResult = new List(); @@ -997,7 +652,453 @@ namespace GPW.CORE.Data.Controllers return done; } + /// + /// Elenco pareto progetti ordinati da filtro + /// + /// + /// + /// + /// + /// + public List ParetoRegAtt(int idxDip, DateTime dataStart, DateTime dataEnd, int maxResult) + { + List dbResult = new List(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + var idxDipendente = new SqlParameter("@idxDipendente", idxDip); + var inizio = new SqlParameter("@inizio", dataStart); + var fine = new SqlParameter("@fine", dataEnd); + var maxRes = new SqlParameter("@maxRes", maxResult); + + dbResult = localDbCtx + .DbSetParetoRegAtt + .FromSqlRaw("EXEC stp_freqProjByDipPeriodo @idxDipendente, @inizio,@fine,@maxRes", idxDipendente, inizio, fine, maxRes) + .ToList(); + } + return dbResult; + } + + public bool RegAttDelete(RegAttivitaModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + localDbCtx.Remove(currItem); + + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegAttUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Recupera ultima attività dipendente + /// + /// + /// cerca ultima solo tra attive (=true) o tutte (=false) + /// + public RegAttivitaModel RegAttLastByDip(int IdxDipendente, bool onlyActive) + { + RegAttivitaModel? dbResult = new RegAttivitaModel(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetRegAttivita + .Where(x => x.FasiNav.Attivo || !onlyActive) + .OrderByDescending(x => x.Inizio) + .FirstOrDefault(x => x.IdxDipendente == IdxDipendente); + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegAttLastByDip{Environment.NewLine}{exc}"); + } + if (dbResult == null) + { + dbResult = new RegAttivitaModel(); + } + } + if (dbResult == null) + { + dbResult = new RegAttivitaModel(); + } + return dbResult; + } + + public bool RegAttUpdate(RegAttivitaModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + if (currItem.IdxRa == 0) + { + localDbCtx.Entry(currItem).State = EntityState.Added; + } + else + { + var currRec = localDbCtx + .DbSetRegAttivita + .FirstOrDefault(x => x.IdxRa == currItem.IdxRa); + if (currRec != null) + { + currRec.IdxDipendente = currItem.IdxDipendente; + currRec.IdxFase = currItem.IdxFase; + currRec.Inizio = currItem.Inizio; + currRec.Fine = currItem.Fine; + currRec.Descrizione = currItem.Descrizione; + + localDbCtx + .DbSetRegAttivita + .Update(currRec); + } + // altrimenti aggiungo + else + { + localDbCtx + .DbSetRegAttivita + .Update(currItem); + } + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegAttUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Elimina record registro malattie (SE non confermato) + /// + /// + public bool RegMalattieDelete(RegMalattieModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetRegMalattie + .FirstOrDefault(x => x.IdxRegMal == currItem.IdxRegMal && !x.conf); + if (currRec != null) + { + localDbCtx + .DbSetRegMalattie + .Remove(currRec); + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegMalattieDelete{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// recupera elenco reg malattie del dipendente + /// + /// + /// + /// + /// + public List RegMalattieGetByDip(int idxDipendente, int maxRecord) + { + List dbResult = new List(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + DateTime oggi = DateTime.Today; + dbResult = localDbCtx + .DbSetRegMalattie + .Where(x => (idxDipendente == 0 || x.idxDipendente == idxDipendente)) + .OrderByDescending(x => x.dtInizio) + .Take(maxRecord) + .ToList(); + } + return dbResult; + } + + /// + /// Inserisce/Aggiorna record registro malattie + /// + /// + public bool RegMalattieUpsert(RegMalattieModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetRegMalattie + .FirstOrDefault(x => x.IdxRegMal == currItem.IdxRegMal); + if (currRec != null) + { + // aggiorno i campi + currRec.codCert = currItem.codCert; + currRec.idxDipendente = currItem.idxDipendente; + currRec.dtInizio = currItem.dtInizio; + currRec.numGG = currItem.numGG; + + localDbCtx + .DbSetRegMalattie + .Update(currRec); + } + // altrimenti aggiungo + else + { + localDbCtx + .DbSetRegMalattie + .Add(currItem); + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegMalattieUpsert{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente + /// + /// Dipendente interessato + /// Data di riferimento (ultima/corrente) + /// NUm settimane precedenti da recuperare + /// + public List RilTempList(int idxDipendente, DateTime dtInizio, DateTime dtFine) + { + // init dati necessari + List dbResult = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + dbResult = localDbCtx + .DbSetRilievoTemp + .Where(x => x.IdxDipendente == idxDipendente && dtInizio <= x.DtRilievo && x.DtRilievo <= dtFine) + .ToList(); + } + return dbResult; + } + + public bool RilTempUpdate(RilievoTempModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetRilievoTemp + .FirstOrDefault(x => x.IdxDipendente == currItem.IdxDipendente && x.DtRilievo == currItem.DtRilievo); + if (currRec != null) + { + // aggiorno solo entrata/uscita + currRec.TempRil = currItem.TempRil; + + localDbCtx + .DbSetRilievoTemp + .Update(currRec); + } + // altrimenti aggiungo + else + { + localDbCtx + .DbSetRilievoTemp + .Add(currItem); + } + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RilTempUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Annulla modifiche su una specifica entity (cancel update) + /// + /// + /// + public bool rollBackEntity(object item) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + if (localDbCtx.Entry(item).State == EntityState.Deleted || localDbCtx.Entry(item).State == EntityState.Modified) + { + localDbCtx.Entry(item).Reload(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}"); + } + } + return answ; + } + + public List TimbratureDay(DateTime dateRif, int IdxDip) + { + List dbResult = new List(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetTimbrature + .Where(x => x.DataOra.Date == dateRif.Date && x.IdxDipendente == IdxDip) + .OrderByDescending(x => x.DataOra) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione in TimbratureDay{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + public bool TimbratureDelete(TimbratureModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + localDbCtx.Remove(currItem); + + localDbCtx.SaveChanges(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in TimbratureDelete{Environment.NewLine}{exc}"); + } + } + 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 + /// + /// Dipendente interessato + /// Data di riferimento (ultima/corrente) + /// NUm settimane precedenti da recuperare + /// + public List WeekOverview(int idxDipendente, DateTime dtRif, int numWeek) + { + // init dati necessari + List dbResult = new List(); + List weekList = new List(); + + // aggiungo sett corrente + quelle richieste... + for (int i = numWeek; i >= 0; i--) + { + var currWeek = new WeekData(dtRif.AddDays(-i * 7)); + weekList.Add(currWeek); + } + + // cerco su DB settimana x settimana.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + foreach (var item in weekList) + { + var totOreTim = localDbCtx + .DbSetTimbratureExpl + .Where(x => x.IdxDipendente == idxDipendente && x.DataLav >= item.inizio && x.DataLav <= item.fine) + .Sum(x => (double)x.HLav); + var totMinLav = localDbCtx + .DbSetRegAttivitaExpl + .Where(x => x.IdxDipendente == idxDipendente && x.DataLav >= item.inizio && x.DataLav <= item.fine) + .Sum(x => (int)x.MinRegAtt); + + // aggiungo alla lista... + var weekData = new WeekStatDTO() + { + IdxDipendente = idxDipendente, + Anno = item.anno, + WeekNumber = item.weekNumber, + Inizio = item.inizio, + Fine = item.fine, + SumOreLav = totOreTim, + SumOreComm = (double)totMinLav / 60, + }; + dbResult.Add(weekData); + } + } + return dbResult; + } #endregion Public Methods + + #region Private Fields + + private static IConfiguration _configuration = null!; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/GPW.CORE.Data/DbModels/RegMalattieModel.cs b/GPW.CORE.Data/DbModels/RegMalattieModel.cs index 74e931f..838919a 100644 --- a/GPW.CORE.Data/DbModels/RegMalattieModel.cs +++ b/GPW.CORE.Data/DbModels/RegMalattieModel.cs @@ -8,7 +8,7 @@ namespace GPW.CORE.Data.DbModels // // This is here so CodeMaid doesn't reorganize this document // - [Table("RegMalattie")] + [Table("RegistroMalattie")] public partial class RegMalattieModel { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] @@ -16,6 +16,7 @@ namespace GPW.CORE.Data.DbModels public int idxDipendente { get; set; } public DateTime dtInizio { get; set; } = DateTime.Today; public int numGG { get; set; } = 1; - public string codCert { get; set; } = ""; + public string codCert { get; set; } = ""; + public bool conf { get; set; } = false; } } diff --git a/GPW.CORE.WRKLOG/Components/RecFaseStart.razor b/GPW.CORE.WRKLOG/Components/RecFaseStart.razor index 4903341..a26d9b9 100644 --- a/GPW.CORE.WRKLOG/Components/RecFaseStart.razor +++ b/GPW.CORE.WRKLOG/Components/RecFaseStart.razor @@ -74,7 +74,6 @@ else
Attenzione!: progetto inattivo: verificare con amministrazione prima di procedere!
- } } @@ -146,137 +145,4 @@ else } -@code { - private int _idxFase = 0; - private int minDur = 30; - private bool doClose = true; - private string descrizione = ""; - - private string cssCheckOre = ""; - - private CalcOreFasiModel? CalcOreFasi { get; set; } = null; - private AnagFasiModel? currFase { get; set; } = null; - private AnagFasiModel? ancestFase { get; set; } = null; - private AnagProgettiModel? currProj { get; set; } = null; - - [Parameter] - public int idxFase - { - get - { - return _idxFase; - } - set - { - _idxFase = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } - } - - [Parameter] - public EventCallback RecStarted { get; set; } - - private bool buttonEnabled - { - get - { - bool answ = !VetoProj; - if (CalcOreFasi != null) - { - if (CalcOreFasi.Attivo!=null && !(bool)CalcOreFasi.Attivo) - { - if (VetoInsert) - { - answ = false; - } - else - { - answ = true; - } - } - } - return answ; - } - } - - private bool VetoInsert - { - get => GDataServ.VetoInsert; - } - private bool VetoProj - { - get - { - bool answ = false; - if (currProj != null) - { - var projAttivo = true; - _ = bool.TryParse($"{currProj.Attivo}", out projAttivo); - answ = !projAttivo; - } - return answ; - } - } - - private async Task StartRecord() - { - // calcolo dataora chiusura... - DateTime newInizio = CORE.Data.Utils.DateRounded(DateTime.Now, 5, true); - - // chiudo attività precedente (se c'è) odierna - if (doClose) - { - var lastRA = await GDataServ.RegAttLastByDip(AppMServ.IdxDipendente, false); - if (lastRA != null && lastRA.Inizio.Date == DateTime.Today) - { - lastRA.Fine = newInizio; - await GDataServ.RegAttUpdate(lastRA); - } - } - // registro nuova attività - RegAttivitaModel newItem = new RegAttivitaModel() - { - IdxDipendente = AppMServ.IdxDipendente, - Inizio = newInizio, - Fine = newInizio.AddMinutes(minDur), - IdxFase = idxFase, - Descrizione = descrizione - }; - await GDataServ.RegAttUpdate(newItem); - // segnalo fatto - await RecStarted.InvokeAsync(false); - } - - private async Task ClosePage() - { - await RecStarted.InvokeAsync(false); - } - - protected async Task ReloadData() - { - // recupero dati fase completi... - currFase = await GDataServ.AnagFasiByKey(idxFase); - if (currFase != null) - { - if (currFase.IdxProgetto != null) - { - currProj = await GDataServ.AnagProjSearch((int)currFase.IdxProgetto); - } - ancestFase = await GDataServ.AnagFasiByKey(currFase.IdxFaseAncest); - int idxFaseTgt = currFase.IdxFaseAncest == 0 ? currFase.IdxFase : currFase.IdxFaseAncest; - CalcOreFasi = await GDataServ.CalcOreFase(idxFaseTgt); - cssCheckOre = "text-success"; - if (CalcOreFasi.percUsed > 1) - { - cssCheckOre = "text-danger"; - } - else if (CalcOreFasi.percUsed * 100 > 80) - { - cssCheckOre = "text-warning"; - } - } - } - -} diff --git a/GPW.CORE.WRKLOG/Components/RecFaseStart.razor.cs b/GPW.CORE.WRKLOG/Components/RecFaseStart.razor.cs new file mode 100644 index 0000000..671bcac --- /dev/null +++ b/GPW.CORE.WRKLOG/Components/RecFaseStart.razor.cs @@ -0,0 +1,154 @@ +using GPW.CORE.Data.DbModels; +using Microsoft.AspNetCore.Components; + +namespace GPW.CORE.WRKLOG.Components +{ + public partial class RecFaseStart + { + #region Public Properties + + [Parameter] + public int idxFase + { + get + { + return _idxFase; + } + + set + { + _idxFase = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + + [Parameter] + public EventCallback RecStarted { get; set; } + + #endregion Public Properties + + #region Protected Methods + + protected async Task ReloadData() + { + // recupero dati fase completi... + currFase = await GDataServ.AnagFasiByKey(idxFase); + if (currFase != null) + { + if (currFase.IdxProgetto != null) + { + currProj = await GDataServ.AnagProjSearch((int)currFase.IdxProgetto); + } + + ancestFase = await GDataServ.AnagFasiByKey(currFase.IdxFaseAncest); + int idxFaseTgt = currFase.IdxFaseAncest == 0 ? currFase.IdxFase : currFase.IdxFaseAncest; + CalcOreFasi = await GDataServ.CalcOreFase(idxFaseTgt); + cssCheckOre = "text-success"; + if (CalcOreFasi.percUsed > 1) + { + cssCheckOre = "text-danger"; + } + else if (CalcOreFasi.percUsed * 100 > 80) + { + cssCheckOre = "text-warning"; + } + } + } + + #endregion Protected Methods + + #region Private Fields + + private int _idxFase = 0; + private string cssCheckOre = ""; + private string descrizione = ""; + private bool doClose = true; + private int minDur = 30; + + #endregion Private Fields + + #region Private Properties + + private AnagFasiModel? ancestFase { get; set; } = null; + + private bool buttonEnabled + { + get + { + bool answ = !VetoProj; + if (CalcOreFasi != null) + { + if (CalcOreFasi.Attivo != null && !(bool)CalcOreFasi.Attivo) + { + if (VetoInsert) + { + answ = false; + } + else + { + answ = true; + } + } + } + + return answ; + } + } + + private CalcOreFasiModel? CalcOreFasi { get; set; } = null; + private AnagFasiModel? currFase { get; set; } = null; + private AnagProgettiModel? currProj { get; set; } = null; + private bool VetoInsert { get => GDataServ.VetoInsert; } + + private bool VetoProj + { + get + { + bool answ = false; + if (currProj != null) + { + var projAttivo = true; + _ = bool.TryParse($"{currProj.Attivo}", out projAttivo); + answ = !projAttivo; + } + + return answ; + } + } + + #endregion Private Properties + + #region Private Methods + + private async Task ClosePage() + { + await RecStarted.InvokeAsync(false); + } + + private async Task StartRecord() + { + // calcolo dataora chiusura... + DateTime newInizio = CORE.Data.Utils.DateRounded(DateTime.Now, 5, true); + // chiudo attività precedente (se c'è) odierna + if (doClose) + { + var lastRA = await GDataServ.RegAttLastByDip(AppMServ.IdxDipendente, false); + if (lastRA != null && lastRA.Inizio.Date == DateTime.Today) + { + lastRA.Fine = newInizio; + await GDataServ.RegAttUpdate(lastRA); + } + } + + // registro nuova attività + RegAttivitaModel newItem = new RegAttivitaModel() + { IdxDipendente = AppMServ.IdxDipendente, Inizio = newInizio, Fine = newInizio.AddMinutes(minDur), IdxFase = idxFase, Descrizione = descrizione }; + await GDataServ.RegAttUpdate(newItem); + // segnalo fatto + await RecStarted.InvokeAsync(false); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Components/RegMalattia.razor b/GPW.CORE.WRKLOG/Components/RegMalattia.razor new file mode 100644 index 0000000..56dfb9b --- /dev/null +++ b/GPW.CORE.WRKLOG/Components/RegMalattia.razor @@ -0,0 +1,55 @@ +@if (isLoading) +{ + +} +else +{ + @if (ListRecords == null) + { + + } + else + { + @if (ListRecords.Count == 0) + { +
+ Nessu record registrato +
+ } + else + { + + + + + + + + + + + @foreach (var item in ListRecords.OrderByDescending(x => x.dtInizio)) + { + + + + + + + } + +
DataGiorniCodice
+ @item.dtInizio.ToString("dd MMM yyyy"), @item.dtInizio.ToString("dddd") + + @item.numGG + + @item.codCert + + @if (!item.conf) + { + + } +
+ } + } +} \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Components/RegMalattia.razor.cs b/GPW.CORE.WRKLOG/Components/RegMalattia.razor.cs new file mode 100644 index 0000000..905a1a1 --- /dev/null +++ b/GPW.CORE.WRKLOG/Components/RegMalattia.razor.cs @@ -0,0 +1,69 @@ +using GPW.CORE.Data.DbModels; +using GPW.CORE.WRKLOG.Data; +using Microsoft.AspNetCore.Components; + +namespace GPW.CORE.WRKLOG.Components +{ + public partial class RegMalattia + { + #region Protected Properties + + [Inject] + protected MessageService AppMServ { get; set; } = null!; + + [Inject] + protected GpwDataService DataService { get; set; } = null!; + + [Parameter] + public int IdxDipendente { get; set; } + [Parameter] + public bool isLoading + { + get => loading; + set + { + if (loading != value) + { + loading = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + protected bool loading { get; set; } = false; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private List? ListRecords = null; + + #endregion Private Fields + + #region Private Methods + + private async Task ReloadData() + { + ListRecords = null; + await Task.Delay(1); + ListRecords = await DataService.RegMalattieGetByDip(IdxDipendente, 10); + } + + private async Task DeleteRec(RegMalattieModel selItem) + { + await DataService.RegMalattieDelete(selItem); + await ReloadData(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Data/GpwDataService.cs b/GPW.CORE.WRKLOG/Data/GpwDataService.cs index 325d733..a6a9205 100644 --- a/GPW.CORE.WRKLOG/Data/GpwDataService.cs +++ b/GPW.CORE.WRKLOG/Data/GpwDataService.cs @@ -10,62 +10,9 @@ namespace GPW.CORE.WRKLOG.Data { public class GpwDataService : IDisposable { - #region Private Fields - - private static IConfiguration _configuration = null!; - private static ILogger _logger = null!; - private static JsonSerializerSettings? JSSettings; - - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - - //private readonly IEmailSender _emailSender; - //private readonly UserManager _userManager; - private readonly IDistributedCache distributedCache; - - private readonly IMemoryCache memoryCache; - private List cachedDataList = new List(); - - /// - /// Durata assoluta massima della cache IN SECONDI - /// - private int chAbsExp = 60 * 5; - - /// - /// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire rimossa - /// NON estende oltre il tempo massimo di validità della cache (chAbsExp) - /// - private int chSliExp = 60 * 1; - - #endregion Private Fields - - #region Protected Fields - - protected const string rKeyAKV = "Cache:AKV"; - protected const string rKeyAnOrDip = "Cache:AnOrariDip"; - protected const string rKeyCalcOreFase = "Cache:CalcOreFase"; - protected const string rKeyCalcOreProj = "Cache:CalcOreProj"; - protected const string rKeyCliAll = "Cache:CliAll"; - protected const string rKeyDailyData = "Cache:DailyData"; - protected const string rKeyDipendenti = "Cache:Dipendenti"; - protected const string rKeyFasiAll = "Cache:FasiAll"; - protected const string rKeyFasiByProj = "Cache:FasiByProj"; - protected const string rKeyFasiSearch = "Cache:FasiSearch"; - protected const string rKeyGrpAll = "Cache:GrpAll"; - protected const string rKeyGrpUser = "Cache:GrpUser"; - protected const string rKeyParetoRegAtt = "Cache:ParetoRegAtt"; - protected const string rKeyProjAll = "Cache:ProjAll"; - protected const string rKeyRilTemp = "Cache:RilTemp"; - protected const string rKeyVC19 = "Cache:VC19"; - protected const string rKeyVetoIns = "Cache:VetoInsert"; - protected const string rKeyWeekStats = "Cache:WeekStats"; - protected static string connStringBBM = ""; - - #endregion Protected Fields - #region Public Fields public static CORE.Data.Controllers.GPWController dbController = null!; - public bool VetoInsert = false; #endregion Public Fields @@ -80,9 +27,7 @@ namespace GPW.CORE.WRKLOG.Data this.memoryCache = memoryCache; this.distributedCache = distributedCache; - // json serializer... - // FIX errore loop circolare - // https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ + // json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ JSSettings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore @@ -111,40 +56,6 @@ namespace GPW.CORE.WRKLOG.Data #endregion Public Properties - #region Private Methods - - private DistributedCacheEntryOptions cacheOpt(bool fastCache) - { - var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10; - var numSecSliExp = fastCache ? chSliExp : chSliExp * 10; - return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); - } - - private DistributedCacheEntryOptions cacheOpt(int multFact) - { - var numSecAbsExp = chAbsExp * multFact; - var numSecSliExp = chSliExp * multFact; - return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); - } - - #endregion Private Methods - - #region Protected Methods - - /// - /// Registra in cache chiave se non fosse già in elenco - /// - /// - protected void trackCache(string newKey) - { - if (!cachedDataList.Contains(newKey)) - { - cachedDataList.Add(newKey); - } - } - - #endregion Protected Methods - #region Public Methods /// @@ -252,6 +163,38 @@ namespace GPW.CORE.WRKLOG.Data return await Task.FromResult(dbResult); } + /// + /// Recupera info x una specifica FASE + /// + /// + public async Task AnagFasiByKey(int idxFase) + { + AnagFasiModel? dbResult = new AnagFasiModel(); + // cerco "secca "in redis... + string currKey = $"{rKeyFasiSearch}:{idxFase}"; + string rawData; + var redisDataList = await distributedCache.GetAsync(currKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + dbResult = JsonConvert.DeserializeObject(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagFasiByKey(idxFase); + // salvo in cache + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB + caching per AnagFasiSearch: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + /// /// Elenco fasi dato progetto /// @@ -285,38 +228,6 @@ namespace GPW.CORE.WRKLOG.Data return await Task.FromResult(dbResult); } - /// - /// Recupera info x una specifica FASE - /// - /// - public async Task AnagFasiByKey(int idxFase) - { - AnagFasiModel? dbResult = new AnagFasiModel(); - // cerco "secca "in redis... - string currKey = $"{rKeyFasiSearch}:{idxFase}"; - string rawData; - var redisDataList = await distributedCache.GetAsync(currKey); - if (redisDataList != null) - { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject(rawData); - } - else - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.AnagFasiByKey(idxFase); - // salvo in cache - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per AnagFasiSearch: {ts.TotalMilliseconds} ms"); - } - return await Task.FromResult(dbResult); - } - /// /// Recupera l'elenco gruppi abilitati x il dipendente /// @@ -781,6 +692,83 @@ namespace GPW.CORE.WRKLOG.Data return answ; } + /// + /// Effettua eliminazione record registro malattie (SE non confermato) + /// + /// + /// + public async Task RegMalattieDelete(RegMalattieModel currItem) + { + bool answ = false; + try + { + dbController.RegMalattieDelete(currItem); + // invalido la cache... + await InvalidateAllCache(); + answ = true; + } + catch + { } + return answ; + } + + /// + /// Restituisce elenco malattie dipendente + /// + /// Dipendente interessato + /// max record da recuperare + /// + public async Task> RegMalattieGetByDip(int idxDipendente, int maxRecord) + { + List? dbResult = new List(); + string currKey = $"{rKeyDipendenti}:{idxDipendente}:RegMal:{maxRecord}"; + trackCache(currKey); + string rawData; + var redisDataList = await distributedCache.GetAsync(currKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + dbResult = JsonConvert.DeserializeObject>(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.RegMalattieGetByDip(idxDipendente, maxRecord); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB + caching per GetRegMalattieDip: {ts.TotalMilliseconds} ms"); + } + if (dbResult == null) + { + dbResult = new List(); + } + return await Task.FromResult(dbResult); + } + + /// + /// Registra o aggiorna record registro malattie + /// + /// + /// + public async Task RegMalattieUpsert(RegMalattieModel currItem) + { + bool answ = false; + try + { + dbController.RegMalattieUpsert(currItem); + // invalido la cache... + await InvalidateAllCache(); + answ = true; + } + catch + { } + return answ; + } + /// /// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente /// @@ -842,6 +830,24 @@ namespace GPW.CORE.WRKLOG.Data dbController.rollBackEntity(item); } + /// + /// Elenco timbrature di un giorno + /// + /// + /// + /// + public async Task> TimbratureDay(DateTime dateRif, int IdxDip) + { + List? dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.TimbratureDay(dateRif, IdxDip); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB + caching per TimbratureDay: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + public async Task TimbratureDelete(TimbratureModel currItem) { bool answ = false; @@ -871,24 +877,93 @@ namespace GPW.CORE.WRKLOG.Data { } return answ; } - /// - /// Elenco timbrature di un giorno - /// - /// - /// - /// - public async Task> TimbratureDay(DateTime dateRif, int IdxDip) - { - List? dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.TimbratureDay(dateRif, IdxDip); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per TimbratureDay: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } #endregion Public Methods + + #region Protected Fields + + protected const string rKeyAKV = "Cache:AKV"; + protected const string rKeyAnOrDip = "Cache:AnOrariDip"; + protected const string rKeyCalcOreFase = "Cache:CalcOreFase"; + protected const string rKeyCalcOreProj = "Cache:CalcOreProj"; + protected const string rKeyCliAll = "Cache:CliAll"; + protected const string rKeyDailyData = "Cache:DailyData"; + protected const string rKeyDipendenti = "Cache:Dipendenti"; + protected const string rKeyFasiAll = "Cache:FasiAll"; + protected const string rKeyFasiByProj = "Cache:FasiByProj"; + protected const string rKeyFasiSearch = "Cache:FasiSearch"; + protected const string rKeyGrpAll = "Cache:GrpAll"; + protected const string rKeyGrpUser = "Cache:GrpUser"; + protected const string rKeyParetoRegAtt = "Cache:ParetoRegAtt"; + protected const string rKeyProjAll = "Cache:ProjAll"; + protected const string rKeyRilTemp = "Cache:RilTemp"; + protected const string rKeyVC19 = "Cache:VC19"; + protected const string rKeyVetoIns = "Cache:VetoInsert"; + protected const string rKeyWeekStats = "Cache:WeekStats"; + protected static string connStringBBM = ""; + + #endregion Protected Fields + + #region Protected Methods + + /// + /// Registra in cache chiave se non fosse già in elenco + /// + /// + protected void trackCache(string newKey) + { + if (!cachedDataList.Contains(newKey)) + { + cachedDataList.Add(newKey); + } + } + + #endregion Protected Methods + + #region Private Fields + + private static IConfiguration _configuration = null!; + private static ILogger _logger = null!; + private static JsonSerializerSettings? JSSettings; + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + //private readonly IEmailSender _emailSender; + //private readonly UserManager _userManager; + private readonly IDistributedCache distributedCache; + + private readonly IMemoryCache memoryCache; + private List cachedDataList = new List(); + + /// + /// Durata assoluta massima della cache IN SECONDI + /// + private int chAbsExp = 60 * 5; + + /// + /// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire + /// rimossa NON estende oltre il tempo massimo di validità della cache (chAbsExp) + /// + private int chSliExp = 60 * 1; + + #endregion Private Fields + + #region Private Methods + + private DistributedCacheEntryOptions cacheOpt(bool fastCache) + { + var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10; + var numSecSliExp = fastCache ? chSliExp : chSliExp * 10; + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); + } + + private DistributedCacheEntryOptions cacheOpt(int multFact) + { + var numSecAbsExp = chAbsExp * multFact; + var numSecSliExp = chSliExp * multFact; + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj index 9ffb9b1..6f09178 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.2210.1416 + 3.0.2301.0216 enable enable diff --git a/GPW.CORE.WRKLOG/Pages/Illness.razor b/GPW.CORE.WRKLOG/Pages/Illness.razor index a7853ed..8e617e2 100644 --- a/GPW.CORE.WRKLOG/Pages/Illness.razor +++ b/GPW.CORE.WRKLOG/Pages/Illness.razor @@ -1,24 +1,63 @@ @page "/Illness" -

Illness

- -
- -
    -
  • Indicazione data inizio (preselezione = oggi)
  • -
  • Numero giorni dichiarati
  • -
  • Codice certificato INPS
  • -
  • - -
  • -
- ...di conseguenza deve -
    -
  • Partire un email di segnalazione ad ADMIN (verificare lista configurata...)
  • -
  • registrare voce in permessi/giustificativi di MAL (verificare durata da conf ore dipendente...)
  • -
+
+
+

Malattia

+
+
+
+
+ @if (isLoading) + { + + } + else + { +
    +
  • +
    + Inizio Malattia +
    +
    + +
    +
  • +
  • +
    + Giorni Malattia +
    +
    + +
    +
  • +
  • +
    + Codice Certificato (INPS) +
    +
    + +
    +
  • +
  • + +
  • +
+ } + + + ...di conseguenza deve +
    +
  • Partire un email di segnalazione ad ADMIN (verificare lista configurata...)
  • +
  • registrare voce in permessi/giustificativi di MAL (verificare durata da conf ore dipendente...)
  • +
+
+
+ +
+
+
diff --git a/GPW.CORE.WRKLOG/Pages/Illness.razor.cs b/GPW.CORE.WRKLOG/Pages/Illness.razor.cs index 9dd54b1..eef2f25 100644 --- a/GPW.CORE.WRKLOG/Pages/Illness.razor.cs +++ b/GPW.CORE.WRKLOG/Pages/Illness.razor.cs @@ -1,23 +1,82 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using GPW.CORE.Data.DbModels; +using GPW.CORE.WRKLOG.Data; using Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using GPW.CORE.WRKLOG; -using GPW.CORE.WRKLOG.Shared; -using GPW.CORE.WRKLOG.Components; namespace GPW.CORE.WRKLOG.Pages { public partial class Illness { + #region Protected Properties + + [Inject] + protected MessageService AppMServ { get; set; } = null!; + + [Inject] + protected GpwDataService DataService { get; set; } = null!; + + protected int idxDipendente + { + get => currRecord.idxDipendente; + set => currRecord.idxDipendente = value; + } + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Registra il record + /// + /// + protected async Task insertRecord() + { + isLoading = true; + // forzo dipendente + idxDipendente = AppMServ.IdxDipendente; + await Task.Delay(1); + // effettuo insert... + await DataService.RegMalattieUpsert(currRecord); + await Task.Delay(1); + // aggiorno display... + idxDipendente = 0; + await Task.Delay(1); + ReloadData(); + } + + protected override void OnInitialized() + { + ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool isLoading = false; + + #endregion Private Fields + + #region Private Properties + + private RegMalattieModel currRecord { get; set; } = new RegMalattieModel(); + + #endregion Private Properties + + #region Private Methods + + private void ReloadData() + { + isLoading = true; + currRecord = new RegMalattieModel() + { + idxDipendente = AppMServ.IdxDipendente, + dtInizio = DateTime.Today, + numGG = 1, + codCert = "00000000" + }; + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index bf88226..62b2c72 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 3.0.2210.1416

+

Versione: 3.0.2301.0216


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index a69629a..fe858b7 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -3.0.2210.1416 +3.0.2301.0216 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 4187af3..da21bfb 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 3.0.2210.1416 + 3.0.2301.0216 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false