using MP.Core.Objects;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace MP.Data.DTO
{
public class IobDTO
{
#region Public Constructors
///
/// Costruttore da dati completi x Macchine
///
///
///
///
public IobDTO(DbModels.MacchineModel recMacc, IOB_data iobInfo, Dictionary macInfo)
{
this.IdxMacchina = recMacc.IdxMacchina;
this.CodMacchina = recMacc.CodMacchina;
this.Nome = recMacc.Nome;
this.Descrizione = recMacc.Descrizione;
this.Note = recMacc.Note ?? "";
this.Locazione = recMacc.locazione ?? "";
this.OS = $"{iobInfo.iType}";
this.IobName = iobInfo.name;
this.IobIpv4 = iobInfo.IP;
this.IobMac = "";
if (macInfo != null && macInfo.Count > 0)
{
this.AdapName = macInfo.ContainsKey("IobExe") ? macInfo["IobExe"] : "";
this.AdapType = macInfo.ContainsKey("IobType") ? macInfo["IobType"] : "";
this.AdapVers = macInfo.ContainsKey("IobVersion") ? macInfo["IobVersion"] : "";
this.TargetIp = macInfo.ContainsKey("MachIp") ? macInfo["MachIp"] : "";
this.TargetPort = macInfo.ContainsKey("MachPort") ? macInfo["MachPort"] : "";
}
this.IsMachine = true;
}
///
/// Costruttore empty di default
///
public IobDTO()
{ }
///
/// Costruttore da dati RemoteRebootLog e info incomplete
///
///
///
///
public IobDTO(DbModels.RemoteRebootLogModel recRRL, IOB_data iobInfo, Dictionary macInfo)
{
this.IdxMacchina = recRRL.IdxMacchina;
this.Locazione = "NA";
this.OS = $"{iobInfo.iType}";
this.IobName = recRRL.Agent;
this.IobIpv4 = recRRL.IPv4;
this.IobMac = recRRL.MacAddr;
if (macInfo != null && macInfo.Count > 0)
{
this.AdapName = macInfo.ContainsKey("IobExe") ? macInfo["IobExe"] : "";
this.AdapType = macInfo.ContainsKey("IobType") ? macInfo["IobType"] : "";
this.AdapVers = macInfo.ContainsKey("IobVersion") ? macInfo["IobVersion"] : "";
this.TargetIp = macInfo.ContainsKey("MachIp") ? macInfo["MachIp"] : "";
this.TargetPort = macInfo.ContainsKey("MachPort") ? macInfo["MachPort"] : "";
}
this.IsMachine = false;
}
#endregion Public Constructors
#region Public Properties
///
/// Nome Adapter
///
public string AdapName { get; set; } = "";
///
/// Sottotipo Adapter
///
public string AdapType { get; set; } = "";
///
/// Versione Adapter
///
public string AdapVers { get; set; } = "";
///
/// Cod macchina
///
public string CodMacchina { get; set; } = "";
///
/// Descrizione macchina
///
public string Descrizione { get; set; } = "";
[Key]
public string IdxMacchina { get; set; } = "";
///
/// IP v4 PC Iob
///
public string IobIpv4 { get; set; } = "";
///
/// Mac address IOB
///
public string IobMac { get; set; } = "";
///
/// Nome PC Iob
///
public string IobName { get; set; } = "";
///
/// Indica se sia una macchina effettiva vs Extra da RemoteRebootLog (es PING, ENR, ...)
///
public bool IsMachine { get; set; } = true;
///
/// Locazione (usata per nascondere in SITE/Tab)
///
public string Locazione { get; set; } = "";
///
/// Nome macchina
///
public string Nome { get; set; } = "";
///
/// Descrizione macchina
///
public string Note { get; set; } = "";
///
/// Tipo di IOB (Win / rPi / Python)
///
public string OS { get; set; } = "";
///
/// IP del target CNC/PLC
///
public string TargetIp { get; set; } = "";
///
/// Porta del target CNC/PLC
///
public string TargetPort { get; set; } = "";
#endregion Public Properties
}
}