Files
2023-04-11 10:08:17 +02:00

122 lines
4.2 KiB
C#

using GPW.CORE.Data.DbModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GPW.CORE.Data.DTO
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
public class DailyDataDTO
{
public int IdxDipendente { get; set; } = 0;
public DateTime DtRif { get; set; } = DateTime.Today;
public List<RegAttivitaModel>? ListRA { get; set; } = null;
public List<TimbratureModel>? ListTimbr { get; set; } = null;
public TimbratureExplModel? TimbrExpl { get; set; } = null;
public List<RilievoTempModel>? ListRilTemp { get; set; } = null;
public List<CheckVc19Model>? ListCheckC19 { get; set; } = null;
public List<CalFesteFerieModel>? ListFermateAzienda { get; set; } = null;
public List<RegMalattieModel>? ListMalattie { get; set; } = null;
public List<RegRichiesteModel>? ListFerieDip { get; set; } = null;
public List<RegRichiesteModel>? ListRichiesteDip { get; set; } = null;
public DateTime DtInizio
{
get
{
DateTime answ = DtRif;
if (ListTimbr != null && ListTimbr.Count > 0)
{
answ = ListTimbr
.OrderBy(x => x.DataOra)
.Take(1)
.Select(x => x.DataOra)
.FirstOrDefault();
}
return answ;
}
}
public double OreComm
{
get
{
double answ = 0;
if (ListRA != null && ListRA.Count > 0)
{
answ = (double)ListRA.Sum(x => x.OreTot ?? 0);
}
// fix arrotondamento ai 5 minuti straight
TimeSpan tSpan = Utils.TSpanRounded(TimeSpan.FromHours(answ), 5);
answ = tSpan.TotalHours;
return answ;
}
}
public double OreLav
{
get
{
double answ = 0;
if (TimbrExpl != null && TimbrExpl.HLav != null)
{
answ = (double)TimbrExpl.HLav;
if (DtRif == DateTime.Today)
{
if (ListTimbr != null)
{
// aggiungo ultima timb fino ad adesso...
var lastIn = ListTimbr.Where(x => x.Entrata == true).OrderByDescending(x => x.DataOra).FirstOrDefault();
var lastOut = ListTimbr.Where(x => x.Entrata == false).OrderByDescending(x => x.DataOra).FirstOrDefault();
// se MANCA timb uscita finale...
if (lastIn != null)
{
if (lastOut == null || lastOut.DataOra < lastIn.DataOra)
{
DateTime adesso = DateTime.Now;
answ += adesso.Subtract(lastIn.DataOra).TotalHours;
}
}
}
}
}
// fix arrotondamento ai 5 minuti x difetto
TimeSpan tSpan = Utils.TSpanRounded(TimeSpan.FromHours(answ), 5, true);
answ = tSpan.TotalHours;
return answ;
}
}
public int MinComm
{
get => (int)Math.Round(OreComm * 60);
}
public int MinLav
{
get => (int)Math.Round(OreLav * 60);
}
public string OreMinLav
{
get
{
TimeSpan durTs = TimeSpan.FromHours(OreLav);
return $"{durTs.Hours}:{durTs.Minutes:00}";
}
}
public string OreMinComm
{
get
{
TimeSpan durTs = TimeSpan.FromHours(OreComm);
return $"{durTs.Hours}:{durTs.Minutes:00}";
}
}
}
}