diff --git a/GWMS.UI/Controllers/IOBController.cs b/GWMS.UI/Controllers/IOBController.cs
index ddeee13..e2d9297 100644
--- a/GWMS.UI/Controllers/IOBController.cs
+++ b/GWMS.UI/Controllers/IOBController.cs
@@ -85,10 +85,30 @@ namespace GWMS.UI.Controllers
///
///
[HttpGet("addTask2Exe/{id}")]
- public string addTask2Exe(string id, string taskName, string taskVal)
+ public async Task addTask2Exe(string id, string taskName, string taskVal)
{
- //Log.Debug($"Chiamata addTask2Exe | {id} | {taskName} | {taskVal}");
- return $"N.A. | {id} | {taskName} | {taskVal}";
+ string answ = "";
+ Dictionary valori = await _DataService.TaskMacchinaAdd(id, taskName, taskVal);
+ answ = JsonConvert.SerializeObject(valori);
+ return answ;
+ }
+
+
+ ///
+ /// ELIMINA TASK richiesto x macchina:
+ ///
+ /// GET: IOB/remTask2Exe/SIMUL_03?taskName=T180326160502
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("remTask2Exe/{id}")]
+ public async Task remTask2Exe(string id, string taskName)
+ {
+ string answ = "";
+ Dictionary valori = await _DataService.TaskMacchinaRem(id, taskName);
+ answ = JsonConvert.SerializeObject(valori);
+ return answ;
}
///
@@ -582,20 +602,13 @@ namespace GWMS.UI.Controllers
///
/// Json contenente 1..n task da eseguire
[HttpGet("getTask2Exe/{id}")]
- public string getTask2Exe(string id)
+ public async Task getTask2Exe(string id)
{
- //Log.Debug($"Chiamata getTask2Exe | {id}");
string answ = "";
-#if false
- // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
- MapoDb.MapoDb connDb = new MapoDb.MapoDb();
- DataLayer DataLayerObj = new DataLayer();
- connDb.scriviKeepAlive(id, DateTime.Now);
-#endif
try
{
// leggo da REDIS eventuale elenco task x macchina...
- Dictionary valori = _DataService.mTaskMacchina(id).Result;
+ Dictionary valori = await _DataService.TaskMacchinaGet(id);
answ = JsonConvert.SerializeObject(valori);
}
catch
@@ -831,40 +844,6 @@ namespace GWMS.UI.Controllers
return answ;
}
- ///
- /// ELIMINA TASK richiesto x macchina:
- ///
- /// GET: IOB/remTask2Exe/SIMUL_03?taskName=T180326160502
- ///
- ///
- ///
- ///
- public string remTask2Exe(string id, string taskName)
- {
- string answ = "";
- // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
- MapoDb.MapoDb connDb = new MapoDb.MapoDb();
- DataLayer DataLayerObj = new DataLayer();
- connDb.scriviKeepAlive(id, DateTime.Now);
- try
- {
- // converto stringa in tipo task...
- taskType tName = taskType.nihil;
- bool fatto = Enum.TryParse(taskName, out tName);
- if (fatto)
- {
- DataLayerObj.remTask4Machine(id, tName);
- }
- else
- {
- logger.lg.scriviLog($"remTask2Exe: impossibile riconoscere il comando {taskName} come uno deitipi ammessi, NON aggiunto", tipoLog.ERROR);
- }
- answ = getTask2Exe(id);
- }
- catch
- { }
- return answ;
- }
///
/// Effettua RESET dell'ODL corrente x macchina:
diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs
index 7a70432..d6bd71f 100644
--- a/GWMS.UI/Data/GWMSDataService.cs
+++ b/GWMS.UI/Data/GWMSDataService.cs
@@ -516,9 +516,9 @@ namespace GWMS.UI.Data
///
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
///
- ///
+ /// Impianto richiesto
///
- public async Task> mTaskMacchina(string idxMacchina)
+ public async Task> TaskMacchinaGet(string idxMacchina)
{
// hard coded dimensione vettore DatiMacchine
Dictionary answ = new Dictionary();
@@ -541,13 +541,79 @@ namespace GWMS.UI.Data
return answ;
}
+
+ ///
+ /// Aggiunge ad elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
+ ///
+ /// Impianto richiesto
+ /// Nome del Task da aggiungere
+ /// Valore del Task da aggiungere
+ /// Restituisce elenco attuale
+ public async Task> TaskMacchinaAdd(string idxMacchina, string taskName, string taskVal)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary currTasks = await TaskMacchinaGet(idxMacchina);
+ try
+ {
+ // cerco se chiave esiste -_> sostituisco
+ if (currTasks.ContainsKey(taskName))
+ {
+ currTasks[taskName] = taskVal;
+ }
+ // altrimenti aggiungo
+ else
+ {
+ currTasks.Add(taskName, taskVal);
+ }
+ // salvo in redis!
+ string cacheKey = exeTaskHash(idxMacchina);
+ string rawData = JsonConvert.SerializeObject(currTasks);
+ var redisData = Encoding.UTF8.GetBytes(rawData);
+ await distributedCache.SetAsync(cacheKey, redisData);
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore in TaskMacchinaAdd | idxMacchina: {idxMacchina} | taskName: {taskName} | taskVal: {taskVal}{Environment.NewLine}{exc}");
+ }
+ return currTasks;
+ }
+ ///
+ /// Rimuove da elenco KVP il TASK indicato (se presente)
+ ///
+ /// Impianto richiesto
+ /// Nome del Task da aggiungere
+ /// Restituisce elenco attuale
+ public async Task> TaskMacchinaRem(string idxMacchina, string taskName)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary currTasks = await TaskMacchinaGet(idxMacchina);
+ try
+ {
+ // cerco se chiave esiste -_> sostituisco
+ if (currTasks.ContainsKey(taskName))
+ {
+ currTasks.Remove(taskName);
+ // salvo in redis!
+ string cacheKey = exeTaskHash(idxMacchina);
+ string rawData = JsonConvert.SerializeObject(currTasks);
+ var redisData = Encoding.UTF8.GetBytes(rawData);
+ await distributedCache.SetAsync(cacheKey, redisData);
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore in TaskMacchinaRem | idxMacchina: {idxMacchina} | taskName: {taskName}{Environment.NewLine}{exc}");
+ }
+ return currTasks;
+ }
+
public async Task OrderDelete(OrderModel currItem)
{
bool done = false;
try
{
done = dbController.OrderDelete(currItem);
- InvalidateAllCache();
+ await InvalidateAllCache();
}
catch (Exception exc)
{
diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj
index 5183a99..be8c419 100644
--- a/GWMS.UI/GWMS.UI.csproj
+++ b/GWMS.UI/GWMS.UI.csproj
@@ -2,7 +2,7 @@
net5.0
- 1.0.2110.2208
+ 1.0.2110.2216
95c9f021-52d1-4390-a670-5810b7b777b0
true
true
diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 360fc36..c835c3b 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
GWMS - Gas Warehouse Management System
- Versione: 1.0.2110.2208
+ Versione: 1.0.2110.2216
Note di rilascio:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index bbe21cc..1761434 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-1.0.2110.2208
+1.0.2110.2216
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index b9dd38c..f8d50ba 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 1.0.2110.2208
+ 1.0.2110.2216
http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip
http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html
false