Aggiunta metodo getTask2Exe con gestione async estesa
This commit is contained in:
+15
-4
@@ -1,7 +1,4 @@
|
||||
#if false
|
||||
using MP.Core.DbModels;
|
||||
#endif
|
||||
|
||||
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace MP.Core
|
||||
@@ -85,6 +82,9 @@ namespace MP.Core
|
||||
public const string redisKitTempl = redisBaseAddr + "Cache:Kit:Templ";
|
||||
public const string redisKitWip = redisBaseAddr + "Cache:Kit:Wip";
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Properties
|
||||
@@ -128,6 +128,17 @@ namespace MP.Core
|
||||
{
|
||||
return (RedisKey)$"{redisBaseAddr}DtMac:{idxMacchina}";
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati Task2Exe x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="baseAddr">Chiave override per i valori in caso di dati che accedono al dominio dati di un altra app (es: baseAddr x IO legacy)</param>
|
||||
/// <returns></returns>
|
||||
public static RedisKey taskMaccHash(string idxMacchina, string baseAddr = null)
|
||||
{
|
||||
var prefix = (baseAddr ?? redisBaseAddr).TrimEnd(':');
|
||||
return (RedisKey)$"{prefix}:ExeTask:{idxMacchina}";
|
||||
}
|
||||
|
||||
public static string FormDurata(double durataMinuti)
|
||||
{
|
||||
|
||||
@@ -140,12 +140,10 @@ namespace MP.IOC.Controllers
|
||||
|
||||
// Multi: gestione carattere "|" trasformato in "#"
|
||||
id = id.Replace("|", "#");
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
var odl = await DService.GetCurrOdlAsync(id);
|
||||
answ = $"{odl}";
|
||||
return Ok(answ);
|
||||
return Ok($"{odl}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -157,7 +155,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina:
|
||||
///
|
||||
/// GET: IOB/getOptPar/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -179,6 +176,30 @@ namespace MP.IOC.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina: ///
|
||||
/// GET: IOB/getTask2Exe/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Json contenente 1..n task da eseguire</returns>
|
||||
[HttpGet("getTask2Exe/{id}")]
|
||||
public async Task<IActionResult> GetTask2Exe(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
|
||||
|
||||
// Multi: gestione carattere "|" trasformato in "#"
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
id = id.Replace("|", "#");
|
||||
}
|
||||
string answ = "";
|
||||
DService.ScriviKeepAlive(id, DateTime.Now);
|
||||
// leggo da REDIS eventuale elenco task x macchina...
|
||||
Dictionary<string, string> valori = await DService.GetTask2ExeMacchinaAsync(id);
|
||||
answ = JsonConvert.SerializeObject(valori);
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
[HttpGet("version")]
|
||||
public IActionResult Version()
|
||||
{
|
||||
|
||||
@@ -26,13 +26,17 @@ namespace MP.IOC.Data
|
||||
redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
BroadastMsgPipe = new MessagePipe(redisConn, Constants.BROADCAST_M_PIPE);
|
||||
// leggo cache lungo periodo
|
||||
// leggo cache (lungo periodo e corto periodo)
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisShortTimeCache"), out redisShortTimeCache);
|
||||
|
||||
_logger.LogInformation("Redis INIT");
|
||||
// conf base x servizi condivisi IO/IOC
|
||||
MpIoNS = _configuration.GetValue<string>("ServerConf:MpIoNS") ?? "MP";
|
||||
|
||||
_logger.LogInformation($"Redis INIT | redisLongTimeCache: {redisLongTimeCache} min | redisShortTimeCache {redisShortTimeCache} min");
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
string connStr = _configuration.GetConnectionString("MP.Data") ?? "";
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
_logger.LogError("DbController: ConnString empty!");
|
||||
@@ -62,11 +66,8 @@ namespace MP.IOC.Data
|
||||
#region Public Properties
|
||||
|
||||
public static MP.Data.Controllers.MpIocController IocDbController { get; set; } = null!;
|
||||
|
||||
public static MP.Data.Controllers.MpMongoController mongoController { get; set; } = null!;
|
||||
|
||||
public static MP.Data.Controllers.MpSpecController SpecDbController { get; set; } = null!;
|
||||
|
||||
public MessagePipe BroadastMsgPipe { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
@@ -1116,6 +1117,49 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> mTaskMacchina(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
var currHash = Utils.taskMaccHash(idxMacchina, MpIoNS);
|
||||
answ = RedisGetHashDict(currHash);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info(string.Format("Errore in mTaskMacchina | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<string, string>> GetTask2ExeMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
var currHash = Utils.taskMaccHash(idxMacchina, MpIoNS);
|
||||
answ = RedisGetHashDict(currHash);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info(string.Format("Errore in GetTask2ExeMacchinaAsync | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL dato batch selezionato
|
||||
/// </summary>
|
||||
@@ -1730,6 +1774,14 @@ namespace MP.IOC.Data
|
||||
var result = rawData.Where(x => !x.Name.IsNull).ToDictionary(x => x.Name.ToString(), x => x.Value.ToString());
|
||||
return result;
|
||||
}
|
||||
public async Task<Dictionary<string, string>> RedisGetHashDictAsync(RedisKey hashKey)
|
||||
{
|
||||
HashEntry[] rawData = await redisDb.HashGetAllAsync(hashKey);
|
||||
var result = rawData
|
||||
.Where(x => !x.Name.IsNull)
|
||||
.ToDictionary(x => x.Name.ToString(), x => x.Value.ToString());
|
||||
return result;
|
||||
}
|
||||
|
||||
public string RedisGetHashField(RedisKey key, string hashField)
|
||||
{
|
||||
@@ -2208,10 +2260,9 @@ namespace MP.IOC.Data
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static ILogger<MpDataService> _logger = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto vocabolario x uso continuo traduzione
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>6.16.2604.1110</Version>
|
||||
<Version>6.16.2604.1112</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 6.16.2604.1110</h4>
|
||||
<h4>Versione: 6.16.2604.1112</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2604.1110
|
||||
6.16.2604.1112
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2604.1110</version>
|
||||
<version>6.16.2604.1112</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -80,10 +80,13 @@
|
||||
},
|
||||
"ServerConf": {
|
||||
"BaseUrl": "/MP/IOC/",
|
||||
"MpIoNS": "MoonPro:SQL2016DEV:MoonPro",
|
||||
"RedisBaseKey": "MP-IOC",
|
||||
"RedisWeight": true,
|
||||
"RoutePath": "/api/RIOB",
|
||||
"SafePages": "Index"
|
||||
"SafePages": "Index",
|
||||
"redisLongTimeCache": 15,
|
||||
"redisShortTimeCache": 3
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"MP.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; App=MP.IOC;",
|
||||
|
||||
Reference in New Issue
Block a user