Update x gestione dati extra da RRL x IOB
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Core.DTO
|
||||
{
|
||||
public class IobDTO
|
||||
{
|
||||
|
||||
[Key]
|
||||
/// <summary>
|
||||
/// Idx macchina
|
||||
/// </summary>
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Cod macchina
|
||||
/// </summary>
|
||||
public string CodMacchina { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Nome macchina
|
||||
/// </summary>
|
||||
public string Nome { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Descrizione { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di IOB (Win / rPi / Python)
|
||||
/// </summary>
|
||||
public string OS { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome PC Iob
|
||||
/// </summary>
|
||||
public string IobName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// IP v4 PC Iob
|
||||
/// </summary>
|
||||
public string IobIpv4 { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Mac address IOB
|
||||
/// </summary>
|
||||
public string IobMac { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome Adapter
|
||||
/// </summary>
|
||||
public string AdaptName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Sottotipo Adapter
|
||||
/// </summary>
|
||||
public string AdapType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Versione Adapter
|
||||
/// </summary>
|
||||
public string AdapVers { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// IP del target CNC/PLC
|
||||
/// </summary>
|
||||
public string TargetIp { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Porta del target CNC/PLC
|
||||
/// </summary>
|
||||
public string TargetPort { get; set; } = "";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,22 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera tutti i record di RemoteRebootLog
|
||||
/// </summary>
|
||||
@@ -109,6 +125,24 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera ultimo record x ogni IdxMacchina x avere ultimo attivo per impianti EXTRA (=no record Macchine)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RemoteRebootLogModel> RemRebootLogGetLastNoMacc()
|
||||
{
|
||||
List<RemoteRebootLogModel> dbResult = new List<RemoteRebootLogModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetRemRebLog
|
||||
.FromSqlRaw("EXEC stp_RRL_GetLastNoMachine")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
using MP.Core.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.DTO
|
||||
{
|
||||
public class IobDTO
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Costruttore da dati completi x Macchine
|
||||
/// </summary>
|
||||
/// <param name="recMacc"></param>
|
||||
/// <param name="iobInfo"></param>
|
||||
/// <param name="macInfo"></param>
|
||||
public IobDTO(DbModels.MacchineModel recMacc, IOB_data iobInfo, Dictionary<string, string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Costruttore empty di default
|
||||
/// </summary>
|
||||
public IobDTO()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Costruttore da dati RemoteRebootLog e info incomplete
|
||||
/// </summary>
|
||||
/// <param name="recRRL"></param>
|
||||
/// <param name="iobInfo"></param>
|
||||
/// <param name="macInfo"></param>
|
||||
public IobDTO(DbModels.RemoteRebootLogModel recRRL, IOB_data iobInfo, Dictionary<string, string> macInfo)
|
||||
{
|
||||
this.IdxMacchina = recRRL.IdxMacchina;
|
||||
this.Locazione = "NA";
|
||||
this.OS = $"{iobInfo.iType}";
|
||||
this.IobName = iobInfo.name;
|
||||
this.IobIpv4 = iobInfo.IP;
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Nome Adapter
|
||||
/// </summary>
|
||||
public string AdapName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Sottotipo Adapter
|
||||
/// </summary>
|
||||
public string AdapType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Versione Adapter
|
||||
/// </summary>
|
||||
public string AdapVers { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Cod macchina
|
||||
/// </summary>
|
||||
public string CodMacchina { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Descrizione { get; set; } = "";
|
||||
|
||||
[Key]
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// IP v4 PC Iob
|
||||
/// </summary>
|
||||
public string IobIpv4 { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Mac address IOB
|
||||
/// </summary>
|
||||
public string IobMac { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome PC Iob
|
||||
/// </summary>
|
||||
public string IobName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica se sia una macchina effettiva vs Extra da RemoteRebootLog (es PING, ENR, ...)
|
||||
/// </summary>
|
||||
public bool IsMachine { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Locazione (usata per nascondere in SITE/Tab)
|
||||
/// </summary>
|
||||
public string Locazione { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome macchina
|
||||
/// </summary>
|
||||
public string Nome { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di IOB (Win / rPi / Python)
|
||||
/// </summary>
|
||||
public string OS { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// IP del target CNC/PLC
|
||||
/// </summary>
|
||||
public string TargetIp { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Porta del target CNC/PLC
|
||||
/// </summary>
|
||||
public string TargetPort { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,10 @@ namespace MP.Data.DbModels
|
||||
/// </summary>
|
||||
public string Descrizione { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Note macchina
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Patch del file json di configurazione di una ricetta
|
||||
/// </summary>
|
||||
public string RecipePath { get; set; } = "";
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MP.Core.Objects;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -22,13 +27,130 @@ namespace MP.Data.Services
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
|
||||
// recupero conf speciali
|
||||
MpIoNS = _configuration.GetValue<string>("ServerConf:MpIoNS");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public IOB_data IobInfo(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<IOB_data>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore: non trovato valore <IOB_data> valido in REDIS | key: {currKey}");
|
||||
Log.Info($"REDIS | conf: {redisConn.Configuration}");
|
||||
Log.Info($" --> Valore trovato:{Environment.NewLine}{rawData}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new IOB_data();
|
||||
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> MachIobConf(string IdxMacchina)
|
||||
{
|
||||
string source = "NA";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// cerco in redis...
|
||||
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
|
||||
try
|
||||
{
|
||||
result = redisDb
|
||||
.HashGetAll(currKey)
|
||||
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
|
||||
source = "REDIS";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in MachIobConf{Environment.NewLine}{exc}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new Dictionary<string, string>();
|
||||
Log.Debug($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MachIobConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero Conf Yaml Machine-IOB
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public string MachIobYamlConf(string IdxMacchina)
|
||||
{
|
||||
string source = "NA";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string result = "";
|
||||
// cerco in redis...
|
||||
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:ConfYaml");
|
||||
try
|
||||
{
|
||||
result = redisDb.StringGet(currKey);
|
||||
source = "REDIS";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in MachIobYamlConf{Environment.NewLine}{exc}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = "";
|
||||
Log.Debug($"Init valore default MachIobYamlConf | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MachIobYamlConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static IConfiguration _configuration = null!;
|
||||
protected JsonSerializerSettings? JSSettings;
|
||||
protected string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
@@ -79,8 +201,29 @@ namespace MP.Data.Services
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string RedHashMpIO(string keyName)
|
||||
{
|
||||
string result = keyName;
|
||||
try
|
||||
{
|
||||
result = $"{MpIoNS}:{keyName}".Replace("\\", "_");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in RedHashMpIO{Environment.NewLine}{exc}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
@@ -91,7 +234,6 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
//private string redisBaseKey = "MP:BASE:Cache";
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.AppAuth.Controllers;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.DTO;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
@@ -45,6 +47,59 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco INFO IOB da tab Macchine gestite + RemoteRebootLog
|
||||
/// </summary>
|
||||
/// <param name="UserName"></param>
|
||||
/// <returns></returns>
|
||||
public List<IobDTO> IobListAll()
|
||||
{
|
||||
string source = "DB";
|
||||
List<IobDTO>? dbResult = new List<IobDTO>();
|
||||
string currKey = $"{redisBaseKey}:IobList";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string? rawData = redisDb.StringGet(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2)
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<IobDTO>>(rawData);
|
||||
dbResult = tempResult ?? new List<IobDTO>();
|
||||
}
|
||||
else
|
||||
{
|
||||
// recupero RRL missing
|
||||
var listRRl = dbController.RemRebootLogGetLast();
|
||||
var listRRlAdd = dbController.RemRebootLogGetLastNoMacc();
|
||||
// recupero lista macchine
|
||||
var ListMacch = dbController.MacchineGetAll();
|
||||
// ...converto in DTO
|
||||
dbResult = ListMacch
|
||||
.Select(x => new IobDTO(x, IobInfo(x.IdxMacchina), MachIobConf(x.IdxMacchina)))
|
||||
.ToList();
|
||||
// completo con RRL i mac address...
|
||||
|
||||
// recupero record RemoteRebootLog mancanti e accodo
|
||||
var listExtra = listRRlAdd.Select(x => new IobDTO(x, IobInfo(x.IdxMacchina), MachIobConf(x.IdxMacchina)))
|
||||
.ToList();
|
||||
dbResult.AddRange(listExtra);
|
||||
|
||||
//ordino x idxmacchina...
|
||||
dbResult = dbResult.OrderBy(x => x.IdxMacchina).ToList();
|
||||
|
||||
// serializzo in cache redis
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<IobDTO>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobListAll | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera tutti i record di RemoteRebootLog
|
||||
/// </summary>
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using EgwCoreLib.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Asn1.IsisMtt.Ocsp;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -18,10 +15,6 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MongoDB.Driver.Core.Operations;
|
||||
using MP.Data.Controllers;
|
||||
using DnsClient.Protocol;
|
||||
using MP.AppAuth.Controllers;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -60,7 +53,9 @@ namespace MP.Data.Services
|
||||
// sistemo i parametri x redHas...
|
||||
CodModulo = _configuration.GetValue<string>("SpecialConf:CodModulo");
|
||||
CodModuloParam = _configuration.GetValue<string>("SpecialConf:CodModuloParam");
|
||||
#if false
|
||||
MpIoNS = _configuration.GetValue<string>("ServerConf:MpIoNS");
|
||||
#endif
|
||||
var cstringArray = ConnStr.Split(";");
|
||||
foreach (var item in cstringArray)
|
||||
{
|
||||
@@ -1241,6 +1236,7 @@ namespace MP.Data.Services
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
/// </summary>
|
||||
@@ -1253,7 +1249,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
@@ -1276,6 +1272,7 @@ namespace MP.Data.Services
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
@@ -1289,7 +1286,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
@@ -1524,7 +1521,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
List<ObjItemDTO>? result = new List<ObjItemDTO>();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"CurrentParameters:{idxMacchina}");
|
||||
string currKey = RedHashMpIO($"CurrentParameters:{idxMacchina}");
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue && rawData.Length() > 2)
|
||||
{
|
||||
@@ -1626,12 +1623,13 @@ namespace MP.Data.Services
|
||||
}
|
||||
// serializzo e salvo
|
||||
string serVal = JsonConvert.SerializeObject(innovations);
|
||||
string currKey = redHashMpIO($"CurrentParameters:{idxMacchina}");
|
||||
string currKey = RedHashMpIO($"CurrentParameters:{idxMacchina}");
|
||||
RedisValue rawData = redisDb.StringSet(currKey, serVal);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupero info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO)
|
||||
/// </summary>
|
||||
@@ -1644,7 +1642,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
|
||||
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
|
||||
try
|
||||
{
|
||||
result = redisDb
|
||||
@@ -1678,7 +1676,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
string result = "";
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"IOB:{IdxMacchina}:ConfYaml");
|
||||
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:ConfYaml");
|
||||
try
|
||||
{
|
||||
result = redisDb.StringGet(currKey);
|
||||
@@ -1697,6 +1695,7 @@ namespace MP.Data.Services
|
||||
Log.Debug($"MachIobYamlConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato
|
||||
@@ -3967,6 +3966,8 @@ namespace MP.Data.Services
|
||||
|
||||
protected int expMinutes = 1;
|
||||
|
||||
protected string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
@@ -4021,8 +4022,6 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
private ExecStatsCollector esCollect = new ExecStatsCollector();
|
||||
|
||||
private string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// numero minimo di record per cui iniziare fase di log
|
||||
/// </summary>
|
||||
@@ -4114,7 +4113,7 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
private string exeTaskHash(string idxMacchina)
|
||||
{
|
||||
return redHashMpIO($"ExeTask:{idxMacchina}");
|
||||
return RedHashMpIO($"ExeTask:{idxMacchina}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4154,7 +4153,8 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
private string redHashMpIO(string keyName)
|
||||
#if false
|
||||
protected string RedHashMpIO(string keyName)
|
||||
{
|
||||
string result = keyName;
|
||||
try
|
||||
@@ -4163,11 +4163,12 @@ namespace MP.Data.Services
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in redHashMpIO{Environment.NewLine}{exc}");
|
||||
Log.Error($"Errore in RedHashMpIO{Environment.NewLine}{exc}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
private string redHashParam(string keyName)
|
||||
{
|
||||
@@ -4292,7 +4293,7 @@ namespace MP.Data.Services
|
||||
/// <returns></returns>
|
||||
private string savedTaskHash(string idxMacchina)
|
||||
{
|
||||
return redHashMpIO($"SavedTask:{idxMacchina}");
|
||||
return RedHashMpIO($"SavedTask:{idxMacchina}");
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Land</RootNamespace>
|
||||
<Version>6.16.2507.0108</Version>
|
||||
<Version>6.16.2507.0111</Version>
|
||||
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
|
||||
|
||||
+38
-22
@@ -79,17 +79,16 @@
|
||||
{
|
||||
<th>Descr <Sorter ParamName="Descr" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
}
|
||||
<th>OS</th>
|
||||
<th><i class="fa-solid fa-computer"></i> PC IOB</th>
|
||||
<th><i class="fa-solid fa-laptop-code"></i> Software</th>
|
||||
<th><i class="fa-solid fa-network-wired"></i> CNC/PLC</th>
|
||||
<th>OS <Sorter ParamName="OS" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th><i class="fa-solid fa-computer"></i> PC IOB <Sorter ParamName="IobName" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th><i class="fa-solid fa-laptop-code"></i> Adapter <Sorter ParamName="AdapName" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th><i class="fa-solid fa-network-wired"></i> CNC/PLC <Sorter ParamName="TargetIp" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Conf</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
var cIobInfo = CurrIobInfo(item.IdxMacchina);
|
||||
<tr class="@checkSelect(item)">
|
||||
<td class="fs-4 fw-bold">@item.IdxMacchina</td>
|
||||
<td>
|
||||
@@ -111,30 +110,47 @@
|
||||
</div>
|
||||
</td>
|
||||
}
|
||||
<td>@cIobInfo.iType</td>
|
||||
<td>@item.OS</td>
|
||||
<td>
|
||||
<div class="fw-bold">
|
||||
@cIobInfo.name
|
||||
</div>
|
||||
<div class="small">@cIobInfo.IP</div>
|
||||
</td>
|
||||
<td>
|
||||
@if (MacIobConf(item.IdxMacchina, "IobVersion").Length > 1)
|
||||
@if (!string.IsNullOrEmpty(item.IobName))
|
||||
{
|
||||
<div class="fw-bold">
|
||||
@* @MacIobConf(item.IdxMacchina, "IobExe") *@
|
||||
@IobExeTrim(item.IdxMacchina)
|
||||
</div>
|
||||
<div class="small">
|
||||
<span><i class="fa-solid fa-arrow-right"></i> @MacIobConf(item.IdxMacchina, "IobType")</span> | @MacIobConf(item.IdxMacchina, "IobVersion")
|
||||
@item.IobName
|
||||
</div>
|
||||
<div class="small">@item.IobIpv4</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>-</div>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<b>@MacIobConf(item.IdxMacchina, "MachIp")</b>
|
||||
<div class="small">
|
||||
port: @MacIobConf(item.IdxMacchina, "MachPort")
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(item.AdapName))
|
||||
{
|
||||
<div class="fw-bold">
|
||||
@item.AdapName
|
||||
</div>
|
||||
<div class="small">
|
||||
<span><i class="fa-solid fa-arrow-right"></i> @item.AdapType</span> | @item.AdapVers
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>-</div>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (!string.IsNullOrEmpty(item.TargetIp))
|
||||
{
|
||||
<b>@item.TargetIp</b>
|
||||
<div class="small">
|
||||
port: @item.TargetPort
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>-</div>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm" target="_blank" href="@($"ConfDetail?idxMacc={item.IdxMacchina}")"><i class="fa-solid fa-gear"></i></a>
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.AppAuth.Models;
|
||||
using MP.AppAuth.Services;
|
||||
using MP.Data.DTO;
|
||||
using MP.Data.Services;
|
||||
using MP.Land.Data;
|
||||
using NLog;
|
||||
@@ -26,6 +27,7 @@ namespace MP.Land.Pages
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
#if false
|
||||
public string MacIobConf(string idxMacc, string kReq)
|
||||
{
|
||||
string answ = "-";
|
||||
@@ -38,15 +40,18 @@ namespace MP.Land.Pages
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
#if false
|
||||
protected Dictionary<string, Core.Objects.IOB_data> DictIobInfo = new Dictionary<string, Core.Objects.IOB_data>();
|
||||
|
||||
protected Dictionary<string, Dictionary<string, string>> DictMachData = new Dictionary<string, Dictionary<string, string>>();
|
||||
protected Dictionary<string, Dictionary<string, string>> DictMachData = new Dictionary<string, Dictionary<string, string>>();
|
||||
#endif
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
@@ -55,6 +60,9 @@ namespace MP.Land.Pages
|
||||
[Inject]
|
||||
protected AppAuthService AppDService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected LandDataService LDService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected LMessageService AppMService { get; set; }
|
||||
|
||||
@@ -147,7 +155,7 @@ namespace MP.Land.Pages
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string checkSelect(MacchineModel IdxODL)
|
||||
protected string checkSelect(IobDTO IdxODL)
|
||||
{
|
||||
string answ = "";
|
||||
#if false
|
||||
@@ -164,6 +172,7 @@ namespace MP.Land.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
protected Core.Objects.IOB_data CurrIobInfo(string idxMacc)
|
||||
{
|
||||
Core.Objects.IOB_data answ = new Core.Objects.IOB_data();
|
||||
@@ -172,13 +181,17 @@ namespace MP.Land.Pages
|
||||
answ = DictIobInfo[idxMacc];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected void DataInit()
|
||||
{
|
||||
isLoading = true;
|
||||
// importante altrimenti NON mostra update UI
|
||||
AllRecords = AppDService.MacchineGetAll();
|
||||
// recupero TUTTI i dati IobList già completi anche on i RemoteRebootLog
|
||||
AllRecords = LDService.IobListAll();
|
||||
|
||||
|
||||
#if false
|
||||
// leggo i remoteRebootLog e cerco IdxMacc NON presenti, aggiungendo...
|
||||
|
||||
// fare!!! FixMe ToDo: aggiungere modello RRL, e query specifica x recuperare record con idxMacchina non presenti in tab Macchine..
|
||||
@@ -188,6 +201,7 @@ namespace MP.Land.Pages
|
||||
// leggo le info IOB x ogni record trovato...
|
||||
DictIobInfo = AllRecords.ToDictionary(x => x.IdxMacchina, x => TabSrv.IobInfo(x.IdxMacchina));
|
||||
DictMachData = AllRecords.ToDictionary(x => x.IdxMacchina, x => TabSrv.MachIobConf(x.IdxMacchina));
|
||||
#endif
|
||||
RefreshDisplay();
|
||||
isLoading = false;
|
||||
}
|
||||
@@ -204,6 +218,7 @@ namespace MP.Land.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
protected string IobExeTrim(string IdxMacchina)
|
||||
{
|
||||
string answ = MacIobConf(IdxMacchina, "IobExe");
|
||||
@@ -212,7 +227,8 @@ namespace MP.Land.Pages
|
||||
answ = answ.Substring(0, answ.IndexOf(','));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -261,12 +277,12 @@ namespace MP.Land.Pages
|
||||
/// </summary>
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private List<MacchineModel> AllRecords = new List<MacchineModel>();
|
||||
private List<IobDTO> AllRecords = new List<IobDTO>();
|
||||
private int currPage = 1;
|
||||
private bool isLoading = false;
|
||||
private List<MacchineModel> ListRecords = new List<MacchineModel>();
|
||||
private List<IobDTO> ListRecords = new List<IobDTO>();
|
||||
private int numRecord = 10;
|
||||
private List<MacchineModel> SearchRecords = new List<MacchineModel>();
|
||||
private List<IobDTO> SearchRecords = new List<IobDTO>();
|
||||
private string searchVal = "";
|
||||
|
||||
/// <summary>
|
||||
@@ -300,8 +316,9 @@ namespace MP.Land.Pages
|
||||
// in primis filtro conddizioni da selettori...
|
||||
SearchRecords = AllRecords
|
||||
.Where(x => (!string.IsNullOrEmpty(x.Locazione) || showEmptyLoc)
|
||||
&& (showMulti || !x.IdxMacchina.Contains("#")))
|
||||
.ToList();
|
||||
&& (showMulti || !x.IdxMacchina.Contains("#"))
|
||||
&& (showExtra || x.IsMachine)
|
||||
).ToList();
|
||||
|
||||
// se ho ricerca filtro...
|
||||
if (!string.IsNullOrEmpty(searchVal))
|
||||
@@ -356,8 +373,53 @@ namespace MP.Land.Pages
|
||||
}
|
||||
break;
|
||||
|
||||
case "OS":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.OS).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.OS).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "IobName":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.IobName).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.IobName).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "AdapName":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.AdapName).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.AdapName).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "TargetIp":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.TargetIp).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.TargetIp).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.IdxMacchina).ToList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo Tablet MAPO - DotNet6</i>
|
||||
<h4>Versione: 6.16.2507.0108</h4>
|
||||
<h4>Versione: 6.16.2507.0111</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2507.0108
|
||||
6.16.2507.0111
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2507.0108</version>
|
||||
<version>6.16.2507.0111</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user