84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
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;
|
|
|
|
namespace EgwControlCenter.Core.Models
|
|
{
|
|
public class TargetStatus
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Nome applicazione
|
|
/// </summary>
|
|
public string CodApp { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Release locale (es Macchine: come letta da file *.mlde)
|
|
/// </summary>
|
|
public ReleaseDTO CurrLocal { get; set; } = new ReleaseDTO();
|
|
|
|
/// <summary>
|
|
/// DataOra ultima verifica locale
|
|
/// </summary>
|
|
public DateTime LastUpdateLoc { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// DataOra ultima verifica remota
|
|
/// </summary>
|
|
public DateTime LastUpdateRem { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// Elenco release remote da REST service
|
|
/// </summary>
|
|
public List<ReleaseDTO> ListRemote { get; set; } = new List<ReleaseDTO>();
|
|
|
|
#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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calcolo condizione "ci sono update":
|
|
/// - almeno 1 rel remota
|
|
/// - la rel remota "+ recente" / + alta > rel locale
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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
|
|
}
|
|
} |