diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs
index 21ff1646..df5f8ec3 100644
--- a/MP.Core/Utils.cs
+++ b/MP.Core/Utils.cs
@@ -19,6 +19,7 @@ namespace MP.Core
public const string redisBaseAddr = "MP:";
+ public const string redisConfFlux = redisBaseAddr + "Cache:ConfFlux";
public const string redisConfKey = redisBaseAddr + "Cache:Config";
public const string redisDecNumArtKey = redisBaseAddr + "Cache:DecNumArt";
@@ -30,8 +31,6 @@ namespace MP.Core
public const string redisFluxByMac = redisBaseAddr + "Cache:FluxByMac";
public const string redisFluxByMacFirst = redisBaseAddr + "Cache:FluxByMacFirst";
- public const string redisConfFlux = redisBaseAddr + "Cache:ConfFlux";
-
public const string redisFluxLogFilt = redisBaseAddr + "Cache:FluxLogFilt";
public const string redisGiacenzaList = redisBaseAddr + "Cache:GiacenzaList";
@@ -166,17 +165,6 @@ namespace MP.Core
return endRounded;
}
- ///
- /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato
- /// dafunzionalita' DbConfig) + idxMacchina richiesto...
- ///
- ///
- ///
- public static RedisKey OptParHash(string idxMacchina)
- {
- return (RedisKey)$"{redisBaseAddr}OpPar:{idxMacchina}";
- }
-
///
/// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da
/// funzionalita' DbConfig) + idxMacchina richiesto...
@@ -291,6 +279,18 @@ namespace MP.Core
return (RedisKey)$"{prefix}:hMSMI:{idxMacchina}";
}
+ ///
+ /// Key variabile OptPar calcolata x idxMacchina (ex optParHash)
+ ///
+ ///
+ /// 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 RedKeyOptPar(string idxMacchina, string baseAddr = null)
+ {
+ var prefix = (baseAddr ?? redisBaseAddr).TrimEnd(':');
+ return (RedisKey)$"{prefix}:OptPar:{idxMacchina}";
+ }
+
///
/// Hash dati countapezzi macchina
///
diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs
index 72eadbe1..5a21b239 100644
--- a/MP.IOC/Controllers/IOBController.cs
+++ b/MP.IOC/Controllers/IOBController.cs
@@ -26,7 +26,8 @@ namespace MP.IOC.Controllers
#region Public Methods
- /// SALVA x macchina KVP parametro/valore:
+ ///
+ /// SALVA x macchina KVP parametro/valore:
/// GET: api/IOB/addOptPar/SIMUL_03?pName=PZREQ&pValue=1000
///
[HttpGet("addOptPar/{id}")]
@@ -1284,87 +1285,6 @@ namespace MP.IOC.Controllers
return Ok(answ);
}
- ///
- /// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di
- /// oggetti objItem
- /// GET: IOB/getObjItems2Write/SIMUL_03
- ///
- /// ID dell'IOB
- ///
- ///
- /// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL)
- ///
- /// GET: IOB/getPOdlNext/SIMUL_03
- ///
- /// id macchina, se "" mostra tutto
- /// Json contenente lista oggetti PODL serializzati
-#if false
- ///
- /// Recupera DATI PODL x macchina e codice PODL:
- ///
- /// GET: IOB/getPODL/SIMUL_03?idxPODL=123
- ///
- ///
- /// idx del PDL da avviare
- /// Json contenente lista oggetti PODL serializzati
- public string getPODL(string id, int idxPODL)
- {
- // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
- // carattere "|" che poi trasformiamo ora in "#"
- if (!string.IsNullOrEmpty(id))
- {
- id = id.Replace("|", "#");
- }
- string answ = "";
-
- // init obj DataLayer
- DataLayer DataLayerObj = new DataLayer();
- try
- {
- // recupero dati da chaive, ignorando info macchina...
- var elencoOdl = DataLayerObj.taPODL.getByKey(idxPODL);
- answ = JsonConvert.SerializeObject(elencoOdl);
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina:
- ///
- /// GET: IOB/getPOdlAct/SIMUL_03
- ///
- /// id macchina, se "" mostra tutto
- /// Json contenente lista 1 oggetto PODL serializzato, se presente
- public string getPOdlAct(string id)
- {
- // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
- // carattere "|" che poi trasformiamo ora in "#"
- if (!string.IsNullOrEmpty(id))
- {
- id = id.Replace("|", "#");
- }
- string answ = "";
-
- // init obj DataLayer
- DataLayer DataLayerObj = new DataLayer();
- try
- {
- // recupero IdxOdl corrente
- string sIdxOdl = DataLayerObj.currODL(id);
- int IdxOdl = 0;
- int.TryParse(sIdxOdl, out IdxOdl);
- // recupero Podl running x macchina ...
- DS_ProdTempi.PromesseODLDataTable elencoOdl = DataLayerObj.taPODL.getByIdxOdl(IdxOdl);
- answ = JsonConvert.SerializeObject(elencoOdl);
- }
- catch
- { }
- return answ;
- }
-#endif
-
///
/// Processa una chiamata GET x salvare UserLog
/// GET: IOB/ulog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999&matrOpr=0=0&label=&valNum
@@ -1646,7 +1566,7 @@ namespace MP.IOC.Controllers
innovazioni.Add(trovato);
}
// faccio upsert innovations!
- DService.UpsertCurrObjItems(idxMacc, innovazioni);
+ DService.UpsertCurrObjItemsAsync(idxMacc, innovazioni);
Log.Info($"processFLogJsonAsync | {idxMacc} | Updated {innovazioni.Count} par");
}
catch (Exception exc)
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index d96f350b..d140c18a 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -177,12 +177,20 @@ namespace MP.IOC.Data
public bool AddOptPar4Machine(string idxMacchina, string taskKey, string taskVal)
{
bool answ = false;
- RedisKey currHash = Utils.OptParHash(idxMacchina);
+ RedisKey currHash = Utils.RedKeyOptPar(idxMacchina, MpIoNS);
try
{
// leggo tName attuali...
var currVal = mOptParMacchina(idxMacchina);
- currVal[taskKey] = taskVal;
+ // verifico se esista o se vada aggiunto...
+ if (currVal.ContainsKey(taskKey))
+ {
+ currVal[taskKey] = taskVal;
+ }
+ else
+ {
+ currVal.Add(taskKey, taskVal);
+ }
RedisSetHashDict(currHash, currVal);
answ = true;
}
@@ -2173,20 +2181,6 @@ namespace MP.IOC.Data
return result;
}
- ///
- /// Esegue aggiornamento MachineParamList (ex CurrObjItems)
- ///
- ///
- ///
- ///
- public bool MachineParamListSet(string idxMacchina, List currData)
- {
- string serVal = JsonConvert.SerializeObject(currData);
- var currKey = Utils.RedKeyCurrObjItems(idxMacchina, MpIoNS);
- bool fatto = redisDb.StringSet(currKey, serVal);
- return fatto;
- }
-
///
/// Esegue aggiornamento MachineParamList (ex CurrObjItems) Async
///
@@ -2201,46 +2195,6 @@ namespace MP.IOC.Data
return fatto;
}
- ///
- /// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD)
- ///
- ///
- ///
- ///
- public bool MachineParamUpsert(string idxMacchina, List innovations)
- {
- bool answ = false;
- if (innovations != null)
- {
- Log.Info($"upsertCurrObjItems | idxMacchina: {idxMacchina} | {innovations.Count} innovations");
- // leggo i valori attuali...
- List actValues = MachineParamList(idxMacchina);
- // per ogni valore passatomi faccio insert o update rispetto elenco valori correnti
- // in REDIS
- foreach (var item in actValues)
- {
- // cerco nelle innovazioni SE CI SIA il valore...
- var trovato = innovations.Find(obj => obj.uid == item.uid);
- // se non trovato nelle innovazioni...
- if (trovato == null)
- {
- // lo ri-aggiungo x non perderlo
- innovations.Add(item);
- Log.Trace($"innovations | add | item.uid: {item.uid} | item.value: {item.value}");
- }
- // altrimenti aggiorno campo (non trasmesso) name e tengo il resto...
- else
- {
- trovato.name = item.name;
- Log.Info($"innovations | update | item.uid: {item.uid} | item.value: {item.value} --> {trovato.value} ");
- }
- }
- // serializzo e salvo
- answ = MachineParamListSet(idxMacchina, innovations);
- }
- return answ;
- }
-
///
/// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD)
///
@@ -2276,56 +2230,11 @@ namespace MP.IOC.Data
}
}
// serializzo e salvo
- answ = MachineParamListSet(idxMacchina, innovations);
+ answ = await MachineParamListSetAsync(idxMacchina, innovations);
}
return answ;
}
-#if false
- ///
- /// Restituisce valore di una singola chiave del dizionario DatiMacchina
- ///
- ///
- ///
- ///
- public string mDatiMacchinaVal(string idxMacchina, string chiave)
- {
- string answ = "";
- try
- {
- answ = mDatiMacchine(idxMacchina)[chiave];
- }
- catch { }
- return answ;
- }
-
- ///
- /// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
- ///
- ///
- ///
- public Dictionary mDatiMacchine(string idxMacchina)
- {
- // hard coded dimensione vettore DatiMacchine
- Dictionary answ = new Dictionary();
- // ORA recupero da memoria redis...
- try
- {
- var currHash = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
- answ = RedisGetHashDict(currHash);
- // se è vuoto... leggo da DB e popolo!
- if (answ.Count == 0)
- {
- answ = ResetDatiMacchina(idxMacchina);
- }
- }
- catch (Exception exc)
- {
- Log.Error($"Errore in compilazione dati Macchine x Redis - idxMacchina {idxMacchina}:{Environment.NewLine}{exc}");
- }
- return answ;
- }
-#endif
///
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
@@ -2364,15 +2273,8 @@ namespace MP.IOC.Data
// hard coded dimensione vettore DatiMacchine
Dictionary answ = new Dictionary();
// ORA recupero da memoria redis...
- try
- {
- RedisKey currHash = Utils.OptParHash(idxMacchina);
- answ = RedisGetHashDict(currHash);
- }
- catch (Exception exc)
- {
- Log.Error($"Errore in compilazione dati OPT PARAM x Redis - idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
- }
+ RedisKey currHash = Utils.RedKeyOptPar(idxMacchina, MpIoNS);
+ answ = RedisGetHashDict(currHash);
return answ;
}
@@ -4123,7 +4025,7 @@ namespace MP.IOC.Data
///
///
///
- public bool UpsertCurrObjItems(string idxMacchina, List innovations)
+ public async Task UpsertCurrObjItemsAsync(string idxMacchina, List innovations)
{
bool answ = false;
if (innovations != null)
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index 560fffd0..971bdd3a 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.2219
+ 6.16.2604.2308
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index bc29cdd2..bd1e5671 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.2219
+ Versione: 6.16.2604.2308
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 24856547..3d97dba4 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.2219
+6.16.2604.2308
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index b4b60577..e826cd0a 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.2219
+ 6.16.2604.2308
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