diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 01cf3cf..5d94637 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -530,29 +530,115 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - /// - /// Recupera l'elenco delle ultime attività inserite da un dipendente + /// Recupera l'elenco dei dettaglio giornaliero attività di tutti i dipendenti, dato giorno riferimento /// - /// Dipendente interessato - /// Num record da recuperare + /// Data di riferimento /// - public List UserLastRec(int idxDipendente, int numRec) + public List DailyDetailAllDip(DateTime dtRif) { - List listRec = new List(); + //resetto valoredtRif a giornata (mezzanotte) + dtRif = dtRif.Date; + // init dati necessari + List dbResult = new List(); + List rawTimbExp = new List(); + List rawTimbr = new List(); + List rawRegAtt = new List(); + List rawRilTemp = new List(); + List rawCheckC19 = new List(); + + // fermate/festività/ferie + List rawFermateAz = new List(); + List rawMalattie = new List(); + List rawRichDip = new List(); + // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) { - listRec = localDbCtx - .DbSetRegAttivita - .Where(x => x.IdxDipendente == idxDipendente) - .Include(a => a.FasiNav).ThenInclude(p => p.ProgettoNav).ThenInclude(c => c.ClienteNav) - .OrderByDescending(x => x.IdxRa) - .Take(numRec) - .AsNoTracking() + // recupero intero set dati timbrature e attività.... + rawTimbExp = localDbCtx + .DbSetTimbratureExpl + .Where(x => dtRif == x.DataLav) .ToList(); + + rawTimbr = localDbCtx + .DbSetTimbrature + .Where(x => dtRif == x.DataOra.Date) + .ToList(); + + rawRegAtt = localDbCtx + .DbSetRegAttivita + .Where(x => dtRif == x.Inizio.Date) + .Include(a => a.FasiNav).ThenInclude(p => p.ProgettoNav).ThenInclude(c => c.ClienteNav) + .ToList(); + + rawRilTemp = localDbCtx + .DbSetRilievoTemp + .Where(x => dtRif <= x.DtRilievo.Date) + .ToList(); + + rawCheckC19 = localDbCtx + .DbSetCheckVc19 + .Where(x => dtRif <= x.DtCheck.Date) + .ToList(); + + // recupero fermate e malattie/permessi del dipendente... + rawFermateAz = localDbCtx + .DbSetCalFesteFerie + .Where(x => x.data == dtRif) + .ToList(); + rawMalattie = localDbCtx + .DbSetRegMalattie + .Where(x => x.DtInizio.Date <= dtRif && x.DtInizio.AddDays(x.NumGG) >= dtRif) + .ToList(); + rawRichDip = localDbCtx + .DbSetRegRichieste + .Where(x => x.DtStart.Date <= dtRif && x.DtEnd >= dtRif) + .ToList(); + + // calcolo elenco DIP + List listDip = rawTimbExp.Select(x => x.IdxDipendente).Distinct().ToList(); + + // x ogni giorno scompongo il set di info... + foreach (var idxDip in listDip) + { + DailyDataDTO currDayDto = new DailyDataDTO() + { + IdxDipendente = idxDip, + DtRif = dtRif, + ListRA = rawRegAtt + .Where(x => x.IdxDipendente == idxDip) + .OrderBy(x => x.Inizio) + .ToList(), + ListTimbr = rawTimbr + .Where(x => x.IdxDipendente == idxDip) + .OrderBy(x => x.DataOra) + .ToList(), + TimbrExpl = rawTimbExp + .Where(x => x.IdxDipendente == idxDip) + .FirstOrDefault(), + ListRilTemp = rawRilTemp + .Where(x => x.IdxDipendente == idxDip) + .ToList(), + ListCheckC19 = rawCheckC19 + .Where(x => x.IdxDipendente == idxDip) + .ToList(), + ListFermateAzienda = rawFermateAz, + ListMalattie = rawMalattie + .Where(x => x.IdxDipendente == idxDip) + .ToList(), + ListFerieDip = rawRichDip + .Where(x => x.IdxDipendente == idxDip) + .ToList(), + ListRichiesteDip = rawRichDip + .Where(x => x.IdxDipendente == idxDip) + .ToList() + }; + + dbResult.Add(currDayDto); + } } - return listRec; + return dbResult; } /// @@ -669,117 +755,6 @@ namespace GPW.CORE.Data.Controllers return dbResult; } - /// - /// Recupera l'elenco dei dettaglio giornaliero attività di tutti i dipendenti, dato giorno riferimento - /// - /// Data di riferimento - /// - public List DailyDetailAllDip(DateTime dtRif) - { - //resetto valoredtRif a giornata (mezzanotte) - dtRif = dtRif.Date; - // init dati necessari - List dbResult = new List(); - List rawTimbExp = new List(); - List rawTimbr = new List(); - List rawRegAtt = new List(); - List rawRilTemp = new List(); - List rawCheckC19 = new List(); - - // fermate/festività/ferie - List rawFermateAz = new List(); - List rawMalattie = new List(); - List rawRichDip = new List(); - - // cerco su DB recuperando set di dati.... - using (GPWContext localDbCtx = new GPWContext(_configuration)) - { - // recupero intero set dati timbrature e attività.... - rawTimbExp = localDbCtx - .DbSetTimbratureExpl - .Where(x => dtRif == x.DataLav) - .ToList(); - - rawTimbr = localDbCtx - .DbSetTimbrature - .Where(x => dtRif == x.DataOra.Date) - .ToList(); - - rawRegAtt = localDbCtx - .DbSetRegAttivita - .Where(x => dtRif == x.Inizio.Date) - .Include(a => a.FasiNav).ThenInclude(p => p.ProgettoNav).ThenInclude(c => c.ClienteNav) - .ToList(); - - rawRilTemp = localDbCtx - .DbSetRilievoTemp - .Where(x => dtRif <= x.DtRilievo.Date) - .ToList(); - - rawCheckC19 = localDbCtx - .DbSetCheckVc19 - .Where(x => dtRif <= x.DtCheck.Date) - .ToList(); - - // recupero fermate e malattie/permessi del dipendente... - rawFermateAz = localDbCtx - .DbSetCalFesteFerie - .Where(x => x.data == dtRif) - .ToList(); - rawMalattie = localDbCtx - .DbSetRegMalattie - .Where(x => x.DtInizio.Date <= dtRif && x.DtInizio.AddDays(x.NumGG) >= dtRif) - .ToList(); - rawRichDip = localDbCtx - .DbSetRegRichieste - .Where(x => x.DtStart.Date <= dtRif && x.DtEnd >= dtRif) - .ToList(); - - // calcolo elenco DIP - List listDip = rawTimbExp.Select(x => x.IdxDipendente).Distinct().ToList(); - - // x ogni giorno scompongo il set di info... - foreach (var idxDip in listDip) - { - DailyDataDTO currDayDto = new DailyDataDTO() - { - IdxDipendente = idxDip, - DtRif = dtRif, - ListRA = rawRegAtt - .Where(x => x.IdxDipendente == idxDip) - .OrderBy(x => x.Inizio) - .ToList(), - ListTimbr = rawTimbr - .Where(x => x.IdxDipendente == idxDip) - .OrderBy(x => x.DataOra) - .ToList(), - TimbrExpl = rawTimbExp - .Where(x => x.IdxDipendente == idxDip) - .FirstOrDefault(), - ListRilTemp = rawRilTemp - .Where(x => x.IdxDipendente == idxDip) - .ToList(), - ListCheckC19 = rawCheckC19 - .Where(x => x.IdxDipendente == idxDip) - .ToList(), - ListFermateAzienda = rawFermateAz, - ListMalattie = rawMalattie - .Where(x => x.IdxDipendente == idxDip) - .ToList(), - ListFerieDip = rawRichDip - .Where(x => x.IdxDipendente == idxDip) - .ToList(), - ListRichiesteDip = rawRichDip - .Where(x => x.IdxDipendente == idxDip) - .ToList() - }; - - dbResult.Add(currDayDto); - } - } - return dbResult; - } - public bool DbForceMigrate() { bool answ = false; @@ -1253,7 +1228,6 @@ namespace GPW.CORE.Data.Controllers currRec.Fine = currItem.Fine; currRec.Descrizione = currItem.Descrizione; - localDbCtx.Entry(currRec).State = EntityState.Modified; localDbCtx @@ -1374,11 +1348,10 @@ namespace GPW.CORE.Data.Controllers } /// - /// recupera elenco reg malattie del dipendente + /// Recupera elenco reg malattie (tutte, dato max dalla + recente) /// /// /// - /// public List RegMalattieGetAll(int maxRecord) { List dbResult = new List(); @@ -1422,6 +1395,28 @@ namespace GPW.CORE.Data.Controllers return dbResult; } + /// + /// Recupera elenco reg malattie dato periodo + /// + /// + /// + /// + public List RegMalattieGetByPeriod(DateTime DtFrom, DateTime DtTo) + { + List dbResult = new List(); + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + DateTime oggi = DateTime.Today; + dbResult = localDbCtx + .DbSetRegMalattie + .Where(x => (x.DtInizio.AddDays(x.NumGG) >= DtFrom && x.DtInizio <= DtTo)) + .Include(d => d.DipNav) + .OrderByDescending(x => x.DtInizio) + .ToList(); + } + return dbResult; + } + /// /// Inserisce/Aggiorna record registro malattie /// @@ -1914,6 +1909,30 @@ namespace GPW.CORE.Data.Controllers return answ; } + /// + /// Recupera l'elenco delle ultime attività inserite da un dipendente + /// + /// Dipendente interessato + /// Num record da recuperare + /// + public List UserLastRec(int idxDipendente, int numRec) + { + List listRec = new List(); + // cerco su DB recuperando set di dati.... + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + listRec = localDbCtx + .DbSetRegAttivita + .Where(x => x.IdxDipendente == idxDipendente) + .Include(a => a.FasiNav).ThenInclude(p => p.ProgettoNav).ThenInclude(c => c.ClienteNav) + .OrderByDescending(x => x.IdxRa) + .Take(numRec) + .AsNoTracking() + .ToList(); + } + return listRec; + } + /// /// Recupera overview di un periodo settimanale x dipendente, data riferimento, numero /// settimane precedenti diff --git a/GPW.CORE.WRKLOG/Components/Compo/CalendarioAziendale.razor.cs b/GPW.CORE.WRKLOG/Components/Compo/CalendarioAziendale.razor.cs index 7e59040..77f4b1c 100644 --- a/GPW.CORE.WRKLOG/Components/Compo/CalendarioAziendale.razor.cs +++ b/GPW.CORE.WRKLOG/Components/Compo/CalendarioAziendale.razor.cs @@ -124,6 +124,8 @@ namespace GPW.CORE.WRKLOG.Components.Compo await Task.Delay(1); if (UseRadz) { + // il mese viene preimpostato sul trimestre corrente... + startMonth = (Month)((DateTime.Today.Month / 6) * 6); ToggleData = new SelectGlobalToggle() { leftString = "Personali", @@ -144,9 +146,6 @@ namespace GPW.CORE.WRKLOG.Components.Compo protected override void OnParametersSet() { - // il mese viene preimpostato sul trimestre corrente... - startMonth = (Month)((DateTime.Today.Month / 6) * 6); - //startMonth = DateTime.Today.Month <= 6 ? Month.January : Month.July; FilterData(); TaskList = EvDtoList.Select(x => Converter.ToBlazorCalTask(x)).ToList(); scheduler.Reload(); @@ -236,10 +235,6 @@ namespace GPW.CORE.WRKLOG.Components.Compo } } -#if false - private List TasksFilt { get; set; } = new List(); -#endif - private void FixCalendar() { ModoDisplay = ToggleData.isActive ? DisplayedView.Annual : DisplayedView.Monthly; diff --git a/GPW.CORE.WRKLOG/Components/Compo/TaskDetail.razor b/GPW.CORE.WRKLOG/Components/Compo/TaskDetail.razor index aa15bc7..c501eee 100644 --- a/GPW.CORE.WRKLOG/Components/Compo/TaskDetail.razor +++ b/GPW.CORE.WRKLOG/Components/Compo/TaskDetail.razor @@ -22,6 +22,15 @@ } + @if (model.DtEnd.Subtract(model.DtStart).TotalHours < 24) + { + + + Data: + @($"{model.DtStart:ddd yyyy-MM-dd}") + + + } Inizio: @@ -34,6 +43,15 @@ @(EventDTO.DateForm(model.CodTipo, model.DtEnd)) + @if (model.IdxDipendente == idxDipendente) + { + + + Note: + @model.Note + + + } @@ -41,11 +59,17 @@ [Parameter] public EventDTO ThisTask { get; set; } = null!; + [Inject] + protected MessageService AppMServ { get; set; } = null!; + EventDTO model = new EventDTO(); protected override void OnParametersSet() { model = ThisTask; } - + protected int idxDipendente + { + get => AppMServ.IdxDipendente; + } } \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Components/Pages/DayOff.razor.cs b/GPW.CORE.WRKLOG/Components/Pages/DayOff.razor.cs index 032ab44..17404ba 100644 --- a/GPW.CORE.WRKLOG/Components/Pages/DayOff.razor.cs +++ b/GPW.CORE.WRKLOG/Components/Pages/DayOff.razor.cs @@ -49,8 +49,7 @@ namespace GPW.CORE.WRKLOG.Components.Pages int.TryParse(monthConf.valore, out intVal); numMesi = intVal > 0 ? intVal : numMesi; } - // fix iniziale date... - // setup periodo (da rivedere in funzione eventi cambio mese dei controlli?!?) + // fix iniziale date... setup periodo (da rivedere in funzione eventi cambio mese dei controlli?!?) DateTime oggi = DateTime.Today; dtMin = new DateTime(oggi.Year - 1, 1, 1); dtMax = dtMin.AddYears(3); @@ -67,14 +66,17 @@ namespace GPW.CORE.WRKLOG.Components.Pages #region Private Properties + private List ListFermateAzienda { get; set; } = new List(); + + private List ListMalattie { get; set; } = new List(); + + private List ListRichiesteDip { get; set; } = new List(); + /// /// Elenco eventi formato originale (EventDTO) /// private List SchedEvList { get; set; } = new List(); - private List ListFermateAzienda { get; set; } = new List(); - private List ListMalattie { get; set; } = new List(); - private List ListRichiesteDip { get; set; } = new List(); private bool showMalattie { get; set; } = false; private SelectGlobalToggle ToggleData { get; set; } = new SelectGlobalToggle(); @@ -94,15 +96,22 @@ namespace GPW.CORE.WRKLOG.Components.Pages await ReloadData(); } - - - private async Task SetMonth(int newNum) + private void initToggler() { - if (numMesi != newNum) + ToggleData = new SelectGlobalToggle() { - numMesi = newNum; - } - await ReloadData(); + leftString = "Malattie", + rightString = "Ferie e Permessi", + placardCss = "bg-light border-light text-dark", + }; + } + + private async Task ReloadData() + { + isLoading = true; + // recupero direttamente da oggetto DB + SchedEvList = await DataService.EventListPeriodo(idxDipendente, dtMin, dtMax); + isLoading = false; } private async Task SetDate(DateTime newDate) @@ -122,94 +131,14 @@ namespace GPW.CORE.WRKLOG.Components.Pages await ReloadData(); } } - private void initToggler() + + private async Task SetMonth(int newNum) { - ToggleData = new SelectGlobalToggle() + if (numMesi != newNum) { - leftString = "Malattie", - rightString = "Ferie e Permessi", - placardCss = "bg-light border-light text-dark", - }; - } - - private async Task ReloadData() - { - isLoading = true; - - - // Reset poi recupero e converto i dati in EventDTO - SchedEvList = new List(); - - // recupero le fermate aziendali - ListFermateAzienda = await DataService.CalFestFeriePeriodo(dtMin, dtMax); - if (ListFermateAzienda.Count > 0) - { - // conversione fermate in EvDTO... - var evAzienda = ListFermateAzienda.Select(x => new EventDTO - { - DtStart = x.data, - DtEnd = x.data.AddDays(1), - CodTipo = x.codGiust, - IdxDipendente = 0, - Titolo = x.descrizione, - Descrizione = x.descrizione, - Note = x.descrizione, - IsDraggable = false, - IsCompany = true, - Conf = true, - Tooltip = $"{x.codGiust} | {x.descrizione}", - }).ToList(); - SchedEvList.AddRange(evAzienda); + numMesi = newNum; } - - // recupero e converto le richieste dipendente... - ListRichiesteDip = await DataService.RegRichiesteGetByDip(0, dtMin, dtMax); - if (ListRichiesteDip.Count > 0) - { - // conversione fermate in elenco task x calendario... - var evDip = ListRichiesteDip.Select(x => new EventDTO - { - DtStart = x.DtStart, - DtEnd = x.DtEnd, - CodTipo = x.CodGiust, //$"{x.CodGiust} | {x.DipNav.Abbrev}", - Titolo = x.DipNav.Abbrev, - IdxDipendente = x.IdxDipendente, - Abbrev = x.DipNav.Abbrev, - CognomeNome = $"{x.DipNav.Cognome} {x.DipNav.Nome}", - Descrizione = $"{x.CodGiust} | {x.DipNav.Abbrev} | {EventDTO.DateForm(x.CodGiust, x.DtStart)} → {EventDTO.DateForm(x.CodGiust, x.DtEnd)}", - //Descrizione = x.CodGiust == "PERM" ? $"{x.CodGiust} | {x.DipNav.Abbrev} | {x.DtStart:HH:mm}--> {x.DtEnd:HH:mm}" : $"{x.CodGiust} | {x.DipNav.Abbrev} | {x.DtStart:yyyy/MM/dd} -> {x.DtEnd:yyyy/MM/dd}", - Note = x.Note, - IsDraggable = x.IdxDipendente == idxDipendente && !x.Conf, - IsCompany = false, - Conf = x.Conf, - Tooltip = $"{x.CodGiust} | {x.DipNav.Abbrev} | {EventDTO.DateForm(x.CodGiust, x.DtStart)} → {EventDTO.DateForm(x.CodGiust, x.DtEnd)}", - }).ToList(); - SchedEvList.AddRange(evDip); - } - // recupero e converto le malattie... - ListMalattie = await DataService.RegMalattieGetAll(100); - if (ListMalattie.Count > 0) - { - // conversione fermate in elenco task x calendario... - var evDip = ListMalattie.Select(x => new EventDTO - { - DtStart = x.DtInizio, - DtEnd = x.DtInizio.AddDays(x.NumGG - 1), - CodTipo = "MAL", - Titolo = x.DipNav.Abbrev, - IdxDipendente = x.IdxDipendente, - Abbrev = x.DipNav.Abbrev, - CognomeNome = $"{x.DipNav.Cognome} {x.DipNav.Nome}", - Descrizione = $"MAL | {x.DipNav.Abbrev} {x.DtInizio:yyyy/MM/dd} -> {x.DtInizio.AddDays(x.NumGG - 1):yyyy/MM/dd}", - Note = x.CodCert, - IsDraggable = x.IdxDipendente == idxDipendente && !x.Conf, - IsCompany = false, - Conf = x.Conf, - Tooltip = $"MAL | {x.DipNav.Abbrev} {x.DtInizio:yyyy/MM/dd} -> {x.DtInizio.AddDays(x.NumGG - 1):yyyy/MM/dd}" - }).ToList(); - SchedEvList.AddRange(evDip); - } - isLoading = false; + await ReloadData(); } #endregion Private Methods diff --git a/GPW.CORE.WRKLOG/Data/GpwDataService.cs b/GPW.CORE.WRKLOG/Data/GpwDataService.cs index e4cd2e3..6594e09 100644 --- a/GPW.CORE.WRKLOG/Data/GpwDataService.cs +++ b/GPW.CORE.WRKLOG/Data/GpwDataService.cs @@ -43,7 +43,7 @@ namespace GPW.CORE.WRKLOG.Data var strVeto = _configuration["VetoIns"]; _ = bool.TryParse(strVeto, out VetoInsert); // Conf DB - string connStr = _configuration.GetConnectionString("GPW.DB")?? "Server=W2019-SQL-STEAM;Database=GPW; integrated security=True; App=GPW.CORE.WRKLOG; TrustServerCertificate=True;"; + string connStr = _configuration.GetConnectionString("GPW.DB") ?? "Server=W2019-SQL-STEAM;Database=GPW; integrated security=True; App=GPW.CORE.WRKLOG; TrustServerCertificate=True;"; if (string.IsNullOrEmpty(connStr)) { _logger.LogError("ConnString empty!"); @@ -769,51 +769,6 @@ namespace GPW.CORE.WRKLOG.Data return dbResult; } - - /// - /// Recupera l'elenco delle ultime attività inserite da un dipendente - /// - /// Dipendente interessato - /// Num record da recuperare - /// - public async Task> UserLastRec(int idxDipendente, int numRec) - { - string source = "DB"; - DateTime oggi = DateTime.Today; - List? dbResult = new List(); - string currKey = $"{rKeyLastRegAtt}:{idxDipendente}:{oggi.ToString("yyyy-MM-dd")}:{numRec}"; - 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.UserLastRec(idxDipendente, numRec); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, FastCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"UserLastRec | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - /// /// Recupera l'elenco dei dettagli giornalieri attività di un dipendente, dato periodo riferimento /// @@ -909,7 +864,119 @@ namespace GPW.CORE.WRKLOG.Data public string EncriptData(string rawData) { - return EgwCoreLib.Utils.SteamCrypto.EncryptString(rawData, passPhrase); + return SteamCrypto.EncryptString(rawData, passPhrase); + } + + /// + /// Lista Eventi dato periodo (TUTTI!) + /// + /// + /// + /// + public async Task> EventListPeriodo(int idxDipendente, DateTime dtStart, DateTime dtEnd) + { + string source = "DB"; + List? SchedEvList = new List(); + string currKey = $"{rKeyEventListDip}:{idxDipendente}:{dtStart:yyyyMMdd}:{dtEnd:yyyyMMdd}"; + 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) + { + SchedEvList = new List(); + } + else + { + SchedEvList = tempResult; + } + } + else + { + // recupero le fermate aziendali + var ListFermateAzienda = await CalFestFeriePeriodo(dtStart, dtEnd); + if (ListFermateAzienda.Count > 0) + { + // conversione fermate in EvDTO... + var evAzienda = ListFermateAzienda.Select(x => new EventDTO + { + DtStart = x.data, + DtEnd = x.data.AddDays(1), + CodTipo = x.codGiust, + IdxDipendente = 0, + Titolo = x.descrizione, + Descrizione = x.descrizione, + Note = x.descrizione, + IsDraggable = false, + IsCompany = true, + Conf = true, + Tooltip = $"{x.codGiust} | {x.descrizione}", + }).ToList(); + SchedEvList.AddRange(evAzienda); + } + + // recupero e converto le richieste dipendente... + var ListRichiesteDip = await RegRichiesteGetByDip(0, dtStart, dtEnd); + if (ListRichiesteDip.Count > 0) + { + // conversione fermate in elenco task x calendario... + var evDip = ListRichiesteDip.Select(x => new EventDTO + { + DtStart = x.DtStart, + DtEnd = x.DtEnd, + CodTipo = x.CodGiust, //$"{x.CodGiust} | {x.DipNav.Abbrev}", + Titolo = x.DipNav.Abbrev, + IdxDipendente = x.IdxDipendente, + Abbrev = x.DipNav.Abbrev, + CognomeNome = $"{x.DipNav.Cognome} {x.DipNav.Nome}", + Descrizione = $"{x.CodGiust} | {x.DipNav.Abbrev} | {EventDTO.DateForm(x.CodGiust, x.DtStart)} → {EventDTO.DateForm(x.CodGiust, x.DtEnd)}", + //Descrizione = x.CodGiust == "PERM" ? $"{x.CodGiust} | {x.DipNav.Abbrev} | {x.DtStart:HH:mm}--> {x.DtEnd:HH:mm}" : $"{x.CodGiust} | {x.DipNav.Abbrev} | {x.DtStart:yyyy/MM/dd} -> {x.DtEnd:yyyy/MM/dd}", + Note = x.Note, + IsDraggable = x.IdxDipendente == idxDipendente && !x.Conf, + IsCompany = false, + Conf = x.Conf, + Tooltip = $"{x.CodGiust} | {x.DipNav.Abbrev} | {EventDTO.DateForm(x.CodGiust, x.DtStart)} → {EventDTO.DateForm(x.CodGiust, x.DtEnd)}", + }).ToList(); + SchedEvList.AddRange(evDip); + } + + // recupero e converto le malattie... + var ListMalattie = await RegMalattieGetByPeriod(dtStart, dtEnd); + if (ListMalattie.Count > 0) + { + // conversione fermate in elenco task x calendario... + var evDip = ListMalattie.Select(x => new EventDTO + { + DtStart = x.DtInizio, + DtEnd = x.DtInizio.AddDays(x.NumGG - 1), + CodTipo = "MAL", + Titolo = x.DipNav.Abbrev, + IdxDipendente = x.IdxDipendente, + Abbrev = x.DipNav.Abbrev, + CognomeNome = $"{x.DipNav.Cognome} {x.DipNav.Nome}", + Descrizione = $"MAL | {x.DipNav.Abbrev} {x.DtInizio:yyyy/MM/dd} -> {x.DtInizio.AddDays(x.NumGG - 1):yyyy/MM/dd}", + Note = x.CodCert, + IsDraggable = x.IdxDipendente == idxDipendente && !x.Conf, + IsCompany = false, + Conf = x.Conf, + Tooltip = $"MAL | {x.DipNav.Abbrev} {x.DtInizio:yyyy/MM/dd} -> {x.DtInizio.AddDays(x.NumGG - 1):yyyy/MM/dd}" + }).ToList(); + SchedEvList.AddRange(evDip); + } + rawData = JsonConvert.SerializeObject(SchedEvList, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (SchedEvList == null) + { + SchedEvList = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"EventListPeriodo | {source} in: {ts.TotalMilliseconds} ms"); + return SchedEvList; } public async Task FlushRedisCache() @@ -1162,7 +1229,7 @@ namespace GPW.CORE.WRKLOG.Data { string source = "DB"; List? dbResult = new List(); - string currKey = $"{rKeyDipendenti}:ALL:RegMal:{maxRecord}"; + string currKey = $"{rKeyDipendenti}:ALL:RegMalLast:{maxRecord}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); @@ -1238,6 +1305,49 @@ namespace GPW.CORE.WRKLOG.Data return dbResult; } + /// + /// Recupera elenco reg malattie dato periodo + /// + /// + /// + /// + public async Task> RegMalattieGetByPeriod(DateTime DtFrom, DateTime DtTo) + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyDipendenti}:ALL:RegMal:{DtFrom:yyyyMMdd}:{DtTo:yyyyMMdd}"; + 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.RegMalattieGetByPeriod(DtFrom, DtTo); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"RegMalattieGetByPeriod | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Registra o aggiorna record registro malattie /// @@ -1625,6 +1735,50 @@ namespace GPW.CORE.WRKLOG.Data return answ; } + /// + /// Recupera l'elenco delle ultime attività inserite da un dipendente + /// + /// Dipendente interessato + /// Num record da recuperare + /// + public async Task> UserLastRec(int idxDipendente, int numRec) + { + string source = "DB"; + DateTime oggi = DateTime.Today; + List? dbResult = new List(); + string currKey = $"{rKeyLastRegAtt}:{idxDipendente}:{oggi.ToString("yyyy-MM-dd")}:{numRec}"; + 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.UserLastRec(idxDipendente, numRec); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"UserLastRec | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + #endregion Public Methods #region Protected Fields @@ -1644,27 +1798,17 @@ namespace GPW.CORE.WRKLOG.Data protected const string rKeyCalendari = $"{redisBaseAddr}:Cache:Calendari"; protected const string rKeyCliAll = $"{redisBaseAddr}:Cache:CliAll"; - protected const string rKeyConfig = $"{redisBaseAddr}:Cache:Config"; - protected const string rKeyDailyData = $"{redisBaseAddr}:Cache:DailyData"; - - protected const string rKeyLastRegAtt = $"{redisBaseAddr}:Cache:LastRegAtt"; - 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 rKeyGiust = $"{redisBaseAddr}:Cache:Giustif"; - protected const string rKeyGrpAll = $"{redisBaseAddr}:Cache:GrpAll"; - protected const string rKeyGrpUser = $"{redisBaseAddr}:Cache:GrpUser"; - + protected const string rKeyLastRegAtt = $"{redisBaseAddr}:Cache:LastRegAtt"; protected const string rKeyParetoRegAtt = $"{redisBaseAddr}:Cache:ParetoRegAtt"; protected const string rKeyProjAll = $"{redisBaseAddr}:Cache:ProjAll"; @@ -1748,12 +1892,12 @@ namespace GPW.CORE.WRKLOG.Data private readonly IEmailSender _emailSender; /// - /// Durata cache lunga IN SECONDI + /// Durata cache lunga IN SECONDI (5 min std) /// private int cacheTtlLong = 60 * 5; /// - /// Durata cache breve IN SECONDI + /// Durata cache breve IN SECONDI (1 min) /// private int cacheTtlShort = 60 * 1; diff --git a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj index 7fedbfc..fd31bfb 100644 --- a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj +++ b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 4.1.2409.0619 + 4.1.2409.0710 diff --git a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user index 98604bd..a347929 100644 --- a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user +++ b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAw3dMMgC4FUywyOTV2xvCRgAAAAACAAAAAAADZgAAwAAAABAAAADrbAogtj/xpZqylbgs9Hb3AAAAAASAAACgAAAAEAAAAFm1lcdH7oj+NFy4QgZ7q18YAAAAROPsyRR12dhPTKfMEQ5yNCAZJ5K7C4pvFAAAAEFBVTwItjyYP2BlOTsuK1g9myQ8 - True|2024-09-06T16:20:28.3994458Z||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; + True|2024-09-06T17:01:32.2132061Z||;True|2024-09-06T18:20:28.3994458+02:00||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS01.pubxml.user b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS01.pubxml.user index ad5cffe..04a9365 100644 --- a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS01.pubxml.user +++ b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS01.pubxml.user @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAw3dMMgC4FUywyOTV2xvCRgAAAAACAAAAAAADZgAAwAAAABAAAACGzXDK3zvXrM23DG9mcGE7AAAAAASAAACgAAAAEAAAAGyTdpfrCO34B/zMyya7+GAYAAAA0bmIiJbto8OwHhtlJG6RVMBv+aGxPm7pFAAAAF/Yr6uOS9vHRpx6NybbZsJ0uMXC - True|2024-09-06T16:19:44.1573989Z||;True|2024-09-05T10:44:09.9210584+02:00||;True|2024-09-05T10:25:37.0910150+02:00||;True|2024-09-05T10:22:08.9121789+02:00||;True|2024-09-05T09:25:44.4904558+02:00||;True|2024-09-04T18:03:12.0806897+02:00||;True|2023-04-27T16:41:43.3590124+02:00||;True|2023-04-27T16:40:30.4059588+02:00||;True|2023-03-24T19:29:18.9230558+01:00||;True|2022-04-21T18:35:38.6752750+02:00||;False|2022-04-21T18:33:27.2112658+02:00||; + True|2024-09-06T17:02:31.7174140Z||;True|2024-09-06T18:19:44.1573989+02:00||;True|2024-09-05T10:44:09.9210584+02:00||;True|2024-09-05T10:25:37.0910150+02:00||;True|2024-09-05T10:22:08.9121789+02:00||;True|2024-09-05T09:25:44.4904558+02:00||;True|2024-09-04T18:03:12.0806897+02:00||;True|2023-04-27T16:41:43.3590124+02:00||;True|2023-04-27T16:40:30.4059588+02:00||;True|2023-03-24T19:29:18.9230558+01:00||;True|2022-04-21T18:35:38.6752750+02:00||;False|2022-04-21T18:33:27.2112658+02:00||; \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index f6a0491..639fd50 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web - Versione: 4.1.2409.0619 + Versione: 4.1.2409.0710 Note di rilascio: diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index d5e058d..9f4d969 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -4.1.2409.0619 +4.1.2409.0710 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 7996772..29178de 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 4.1.2409.0619 + 4.1.2409.0710 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false