using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using EgwControlCenter.Core.DTO; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace EgwControlCenter.Core.Models { public class TargetStatus { #region Public Properties /// /// Nome applicazione /// public string CodApp { get; set; } = ""; /// /// Tipo applicazione da monitorare /// [JsonConverter(typeof(StringEnumConverter))] public CoreEnum.AppType ApplicationType { get; set; } = CoreEnum.AppType.None; /// /// Release locale (es Macchine: come letta da file *.mlde) /// public ReleaseDTO CurrLocal { get; set; } = new ReleaseDTO(); /// /// DataOra ultima verifica locale /// public DateTime LastUpdateLoc { get; set; } = DateTime.Now; /// /// DataOra ultima verifica remota /// public DateTime LastUpdateRem { get; set; } = DateTime.Now; /// /// Elenco release remote da REST service /// public List ListRemote { get; set; } = new List(); #endregion Public Properties #region Public Methods public ReleaseDTO CurrRemote { get { ReleaseDTO answ = new ReleaseDTO(); if (ListRemote != null && ListRemote.Count() > 0) { answ = ListRemote .OrderByDescending(x => x.VersVal) .ThenByDescending(x => x.ReleaseDate) .FirstOrDefault() ?? new ReleaseDTO(); } return answ; } } /// /// Calcolo condizione "ci sono update": /// - almeno 1 rel remota /// - la rel remota "+ recente" / + alta > rel locale /// /// public bool HasUpdate() { bool answ = false; if (ListRemote != null && ListRemote.Count > 0) { // prendo max release var lastRemote = ListRemote.OrderByDescending(x => x.VersVal).FirstOrDefault(); //devo averla trovata... if (lastRemote != null) { answ = lastRemote.VersVal > CurrLocal.VersVal; } } return answ; } #endregion Public Methods } }