diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs
index 4310cc6b..7cc85daa 100644
--- a/MP.Core/Utils.cs
+++ b/MP.Core/Utils.cs
@@ -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}";
}
+ ///
+ /// Hash dati Task2Exe x la macchina specificata
+ ///
+ ///
+ /// Chiave override per i valori in caso di dati che accedono al dominio dati di un altra app (es: baseAddr x IO legacy)
+ ///
+ 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)
{
diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs
index f362f726..f63222cd 100644
--- a/MP.IOC/Controllers/IOBController.cs
+++ b/MP.IOC/Controllers/IOBController.cs
@@ -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
///
/// Recupera TASK richiesto x macchina:
- ///
/// GET: IOB/getOptPar/SIMUL_03
///
///
@@ -179,6 +176,30 @@ namespace MP.IOC.Controllers
return answ;
}
+ ///
+ /// Recupera TASK richiesto x macchina: ///
+ /// GET: IOB/getTask2Exe/SIMUL_03
+ ///
+ ///
+ /// Json contenente 1..n task da eseguire
+ [HttpGet("getTask2Exe/{id}")]
+ public async Task 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 valori = await DService.GetTask2ExeMacchinaAsync(id);
+ answ = JsonConvert.SerializeObject(valori);
+ return Ok(answ);
+ }
+
[HttpGet("version")]
public IActionResult Version()
{
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index d6141826..7ba10660 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -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("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
+ int.TryParse(_configuration.GetValue("ServerConf:redisShortTimeCache"), out redisShortTimeCache);
- _logger.LogInformation("Redis INIT");
+ // conf base x servizi condivisi IO/IOC
+ MpIoNS = _configuration.GetValue("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!;
///
@@ -1116,6 +1117,49 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
+ ///
+ ///
+ ///
+ public Dictionary mTaskMacchina(string idxMacchina)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary answ = new Dictionary();
+ // 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;
+ }
+ ///
+ /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
+ ///
+ ///
+ ///
+ public async Task> GetTask2ExeMacchinaAsync(string idxMacchina)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary answ = new Dictionary();
+ // 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;
+ }
+
///
/// Elenco ODL dato batch selezionato
///
@@ -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> 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 _logger = null!;
-
private static Logger Log = LogManager.GetCurrentClassLogger();
+ private string MpIoNS = "";
///
/// Oggetto vocabolario x uso continuo traduzione
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index 2f8e3daf..4996adf2 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.1110
+ 6.16.2604.1112
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 342f91b8..f7f7ba37 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.1110
+ Versione: 6.16.2604.1112
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 11ea92a2..ca517968 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.1110
+6.16.2604.1112
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index cc519a2f..f08a9e9e 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.1110
+ 6.16.2604.1112
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html
false
diff --git a/MP.IOC/appsettings.json b/MP.IOC/appsettings.json
index 22f9af38..bd6a61b3 100644
--- a/MP.IOC/appsettings.json
+++ b/MP.IOC/appsettings.json
@@ -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;",