using LiMan.DB.DBModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//
// This is here so CodeMaid doesn't reorganize this document
//
namespace LiMan.DB.DTO
{
///
/// Resoconto informazioni per statistiche installazioni
///
public class InstallStatusDTO
{
///
/// Elenco delle licenze degli applicativi abilitati alla gestione verifica update
///
public List UpdaterList { get; set; } = new List();
///
/// Elenco chiamate con conteggio x CodApp
///
public Dictionary ReqCountApp { get; set; } = new Dictionary();
///
/// Lista delle ultime richieste registrate (TargetUrl like '%release%') come conteggio orario (tipicamente 15 gg)
///
public Dictionary ReqCountHour { get; set; } = new Dictionary();
///
/// Lista delle ultime richieste registrate (TargetUrl like '%release%') come conteggio giornaliero (tipicamente 1 anno)
///
public Dictionary ReqCountDay { get; set; } = new Dictionary();
///
/// Lista delle Releases Installate x le applicazioni gestite
///
public List InstallRelList { get; set; } = new List();
///
/// Statistica aggregata status applicativi
///
public List InstallStatus { get; set; } = new List();
///
/// Dizionario record Impiego/dati device
///
public Dictionary InstDevices { get; set; } = new Dictionary();
[NotMapped]
public int LastCallHour
{
get => ReqCountHour != null && ReqCountHour.Count > 0 ? ReqCountHour.Last().Value : 0;
}
[NotMapped]
public int LastCallDay
{
get => ReqCountDay != null && ReqCountDay.Count > 0 ? ReqCountDay.Last().Value : 0;
}
[NotMapped]
public int TotalUpdaterAct
{
get
{
return UpdaterList.Sum(x => x.NumLicenzeAttive);
}
}
[NotMapped]
public double GlobalUpdateScore
{
get
{
return InstallStatus.Sum(x => x.UpdateScore * x.NumInst) / (InstallStatus.Sum(x => x.NumInst));
}
}
///
/// Conteggio totale di tutte le applicazioni gestite, come somma CONTEGGIO degli applicativi diversi gestiti (per cliente)
///
[NotMapped]
public int TotalManagedCount
{
get
{
return UpdaterList.Count + InstallRelList.Count;
}
}
///
/// Conteggio totale di tutte le applicazioni gestite, come somma NumImpieghi di tutti gli applicativi + conteggio updater
///
[NotMapped]
public int TotalManagedNum
{
get
{
return UpdaterList.Sum(x => x.NumLicenzeAttive) + InstallRelList.Sum(x => x.NumImp);
}
}
///
/// Data Ora ultimo aggiornamento informazioni
///
public DateTime LastUpdated { get; set; } = DateTime.Now;
}
}