|
|
|
@@ -189,6 +189,42 @@ namespace GWMS.UI.Data
|
|
|
|
|
{
|
|
|
|
|
return mHash(string.Format("ExeTask:{0}", idxMacchina));
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Hash dati SAVED (EXE) TASK x la macchina specificata x poter ripristinare in caso di perdita valore WRITE
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string savedTaskHash(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
return mHash(string.Format("SavedTask:{0}", idxMacchina));
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Hash dati CurrentParameters x la macchina specificata
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string currParametersHash(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
return mHash(string.Format("CurrentParameters:{0}", idxMacchina));
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Hash dati Parametri Macchina
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected static string paramHash(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
return mHash(string.Format("MachineParam:{0}", idxMacchina));
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Hash dati OPT PARAMETERS x la macchina specificata
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string optParHash(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
return mHash(string.Format("OptPar:{0}", idxMacchina));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// FUnzione verifica eventuale creazione NUOVI ordini di consegna
|
|
|
|
@@ -228,7 +264,7 @@ namespace GWMS.UI.Data
|
|
|
|
|
transporterId = 1;
|
|
|
|
|
}
|
|
|
|
|
// stacco un NUOVO ordine di quantità finita
|
|
|
|
|
NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantCode}{adesso:yyMMddHHmm}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId });
|
|
|
|
|
NewOrders.Add(new OrderModel() { DtOrder = adesso, DtETA = adesso.AddDays(1), OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantCode}{adesso:yyMMddHHmm}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (NewOrders.Count > 0)
|
|
|
|
@@ -514,18 +550,111 @@ namespace GWMS.UI.Data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
|
|
|
|
/// Restitusice elenco PARAMETRI (da passare a IOB-WIN) per l'impianto indicato
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina">Impianto richiesto</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Dictionary<string, string>> TaskMacchinaGet(string idxMacchina)
|
|
|
|
|
public async Task<List<objItem>> getCurrObjItems(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
List<objItem> answ = new List<objItem>();
|
|
|
|
|
// ORA recupero da memoria redis...
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string cacheKey = paramHash(idxMacchina);
|
|
|
|
|
string rawData;
|
|
|
|
|
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
|
|
|
|
if (redisDataList != null)
|
|
|
|
|
{
|
|
|
|
|
rawData = Encoding.UTF8.GetString(redisDataList);
|
|
|
|
|
answ = JsonConvert.DeserializeObject<List<objItem>>(rawData);
|
|
|
|
|
// ordino!
|
|
|
|
|
answ.Sort((a, b) => (a.name.CompareTo(b.name)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"Errore in recupero ParametriMacchinaGet | idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// SET elenco parametri correnti x IOB
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="currValues"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> setCurrObjItems(string idxMacchina, List<objItem> currValues)
|
|
|
|
|
{
|
|
|
|
|
bool answ = false;
|
|
|
|
|
if (currValues != null)
|
|
|
|
|
{
|
|
|
|
|
string currHash = currParametersHash(idxMacchina);
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
string rawData = JsonConvert.SerializeObject(currValues);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
// controllo se ha valori write...
|
|
|
|
|
foreach (var item in currValues)
|
|
|
|
|
{
|
|
|
|
|
// se fosse un valore WRITE e mi ha dato un valore vuoto --> mando un fix x riscrittura
|
|
|
|
|
if (item.writable && string.IsNullOrEmpty(item.value))
|
|
|
|
|
{
|
|
|
|
|
taskType currTask = (taskType)Enum.Parse(typeof(taskType), item.uid);
|
|
|
|
|
await addCheckTask4Machine(idxMacchina, currTask, item.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// verifica se sia da reinviare un task alla macchina dall'elenco di quelli salvati (in modalità upsert) se non scaduti
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="taskKey"></param>
|
|
|
|
|
/// <param name="taskVal"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> addCheckTask4Machine(string idxMacchina, taskType taskKey, string taskVal)
|
|
|
|
|
{
|
|
|
|
|
bool answ = false;
|
|
|
|
|
string currHash = exeTaskHash(idxMacchina);
|
|
|
|
|
Log.Info($"addCheckTask4Machine idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> savedTask = await mSavedTaskMacchina(idxMacchina);
|
|
|
|
|
// cerco valore saved
|
|
|
|
|
string savedVal = savedTask[taskKey.ToString()];
|
|
|
|
|
// se ho un valore != "" --> rimetto in coda di invio...
|
|
|
|
|
if (!string.IsNullOrEmpty(savedVal) && (savedVal != taskVal))
|
|
|
|
|
{
|
|
|
|
|
// leggo task attuali...
|
|
|
|
|
Dictionary<string, string> currTasks = await mTaskMacchina(idxMacchina);
|
|
|
|
|
// rimetto in task da eseguire...
|
|
|
|
|
currTasks[taskKey.ToString()] = savedVal;
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
string rawData = JsonConvert.SerializeObject(currTasks);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
Log.Info($"Re-issued task4machine | idxMacchina: {idxMacchina} | taskKey: {taskKey} | savedVal: {savedVal}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"Errore in addCheckTask4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Dictionary<string, string>> mSavedTaskMacchina(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
// hard coded dimensione vettore DatiMacchine
|
|
|
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
|
|
|
// ORA recupero da memoria redis...
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string cacheKey = exeTaskHash(idxMacchina);
|
|
|
|
|
string cacheKey = savedTaskHash(idxMacchina);
|
|
|
|
|
string rawData;
|
|
|
|
|
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
|
|
|
|
if (redisDataList != null)
|
|
|
|
@@ -536,77 +665,299 @@ namespace GWMS.UI.Data
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"Errore in recupero dati EXE TASK x Redis mTaskMacchina - idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
Log.Error($"Errore in recupero dati SAVED TASK x Redis mSavedTaskMacchina | idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Aggiunge ad elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina">Impianto richiesto</param>
|
|
|
|
|
/// <param name="taskName">Nome del Task da aggiungere</param>
|
|
|
|
|
/// <param name="taskVal">Valore del Task da aggiungere</param>
|
|
|
|
|
/// <returns>Restituisce elenco attuale</returns>
|
|
|
|
|
public async Task<Dictionary<string, string>> TaskMacchinaAdd(string idxMacchina, string taskName, string taskVal)
|
|
|
|
|
/// Aggiunge un task all'elenco di quelli salvati (in modalità upsert)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="taskKey"></param>
|
|
|
|
|
/// <param name="taskVal"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> addTask4Machine(string idxMacchina, taskType taskKey, string taskVal)
|
|
|
|
|
{
|
|
|
|
|
// hard coded dimensione vettore DatiMacchine
|
|
|
|
|
Dictionary<string, string> currTasks = await TaskMacchinaGet(idxMacchina);
|
|
|
|
|
bool answ = false;
|
|
|
|
|
string rawData = "";
|
|
|
|
|
string currHash = exeTaskHash(idxMacchina);
|
|
|
|
|
string currSavedParHash = savedTaskHash(idxMacchina);
|
|
|
|
|
Dictionary<string, string> currTasks = new Dictionary<string, string>();
|
|
|
|
|
Dictionary<string, string> savedTask = new Dictionary<string, string>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// cerco se chiave esiste -_> sostituisco
|
|
|
|
|
if (currTasks.ContainsKey(taskName))
|
|
|
|
|
Log.Info($"Request: idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}");
|
|
|
|
|
// leggo task attuali...
|
|
|
|
|
currTasks = await mTaskMacchina(idxMacchina);
|
|
|
|
|
if (currTasks.ContainsKey($"{taskKey}"))
|
|
|
|
|
{
|
|
|
|
|
currTasks[taskName] = taskVal;
|
|
|
|
|
currTasks[$"{taskKey}"] = taskVal;
|
|
|
|
|
}
|
|
|
|
|
// altrimenti aggiungo
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currTasks.Add(taskName, taskVal);
|
|
|
|
|
currTasks.Add($"{taskKey}", taskVal);
|
|
|
|
|
}
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
string cacheKey = exeTaskHash(idxMacchina);
|
|
|
|
|
string rawData = JsonConvert.SerializeObject(currTasks);
|
|
|
|
|
var redisData = Encoding.UTF8.GetBytes(rawData);
|
|
|
|
|
await distributedCache.SetAsync(cacheKey, redisData);
|
|
|
|
|
rawData = JsonConvert.SerializeObject(currTasks);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
Log.Info($"Task ADD | idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"Errore in TaskMacchinaAdd | idxMacchina: {idxMacchina} | taskName: {taskName} | taskVal: {taskVal}{Environment.NewLine}{exc}");
|
|
|
|
|
Log.Error($"Errore in remTask4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return currTasks;
|
|
|
|
|
// verifico in base al tipo di task se fare backup...
|
|
|
|
|
switch (taskKey)
|
|
|
|
|
{
|
|
|
|
|
case taskType.setArt:
|
|
|
|
|
case taskType.setComm:
|
|
|
|
|
case taskType.setPzComm:
|
|
|
|
|
case taskType.setProg:
|
|
|
|
|
// leggo task SALVATI attuali...
|
|
|
|
|
savedTask = await mSavedTaskMacchina(idxMacchina);
|
|
|
|
|
savedTask[$"{taskKey}"] = taskVal;
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
rawData = JsonConvert.SerializeObject(savedTask);
|
|
|
|
|
await distributedCache.SetAsync(currSavedParHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case taskType.endProd:
|
|
|
|
|
// salvo un DICT vuoto x resettare
|
|
|
|
|
savedTask = new Dictionary<string, string>();
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
rawData = JsonConvert.SerializeObject(savedTask);
|
|
|
|
|
await distributedCache.SetAsync(currSavedParHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rimuove da elenco KVP il TASK indicato (se presente)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina">Impianto richiesto</param>
|
|
|
|
|
/// <param name="taskName">Nome del Task da aggiungere</param>
|
|
|
|
|
/// <returns>Restituisce elenco attuale</returns>
|
|
|
|
|
public async Task<Dictionary<string, string>> TaskMacchinaRem(string idxMacchina, string taskName)
|
|
|
|
|
/// Aggiornamento parametro per macchina
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="Original_uid">Parametro macchina come definito in file json</param>
|
|
|
|
|
/// <param name="reqValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> updateMachineParameter(string idxMacchina, string Original_uid, string reqValue)
|
|
|
|
|
{
|
|
|
|
|
// hard coded dimensione vettore DatiMacchine
|
|
|
|
|
Dictionary<string, string> currTasks = await TaskMacchinaGet(idxMacchina);
|
|
|
|
|
bool answ = false;
|
|
|
|
|
// recupero items...
|
|
|
|
|
List<objItem> dcList = await getCurrObjItems(idxMacchina);
|
|
|
|
|
List<objItem> list2Update = new List<objItem>();
|
|
|
|
|
// cerco quello da aggiornare
|
|
|
|
|
objItem trovato = dcList.Find(obj => obj.uid == Original_uid);
|
|
|
|
|
// se non trova --> crea ed aggiunge...
|
|
|
|
|
if (trovato == null)
|
|
|
|
|
{
|
|
|
|
|
dcList.Add(new objItem() { uid = Original_uid });
|
|
|
|
|
trovato = dcList.Find(obj => obj.uid == Original_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// se trovato procedo
|
|
|
|
|
if (trovato != null)
|
|
|
|
|
{
|
|
|
|
|
// aggiorno valore richiesto + dt richiesta
|
|
|
|
|
trovato.reqValue = reqValue;
|
|
|
|
|
trovato.lastRequest = DateTime.Now;
|
|
|
|
|
list2Update.Add(trovato);
|
|
|
|
|
await upsertCurrObjItems(idxMacchina, list2Update);
|
|
|
|
|
// accodo in Task2Exe la richiesta di processing
|
|
|
|
|
await addTask4Machine(idxMacchina, taskType.setParameter, trovato.uid);
|
|
|
|
|
|
|
|
|
|
// salvo ANCHE il valore di setup ASSOCIATO...
|
|
|
|
|
taskType currTask = (taskType)Enum.Parse(typeof(taskType), trovato.uid);
|
|
|
|
|
await addTask4Machine(idxMacchina, currTask, reqValue);
|
|
|
|
|
|
|
|
|
|
answ = true;
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="innovations"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> upsertCurrObjItems(string idxMacchina, List<objItem> innovations)
|
|
|
|
|
{
|
|
|
|
|
bool answ = false;
|
|
|
|
|
if (innovations != null)
|
|
|
|
|
{
|
|
|
|
|
// leggo i valori attuali...
|
|
|
|
|
List<objItem> actValues = await getCurrObjItems(idxMacchina);
|
|
|
|
|
string currHash = currParametersHash(idxMacchina);
|
|
|
|
|
// per ogni valore passatomi faccio insert o update
|
|
|
|
|
foreach (var item in actValues)
|
|
|
|
|
{
|
|
|
|
|
// cerco nelle innovazioni SE CI SIA un valore act
|
|
|
|
|
objItem trovato = innovations.Find(obj => obj.uid == item.uid);
|
|
|
|
|
// se non trovato...
|
|
|
|
|
if (trovato == null)
|
|
|
|
|
{
|
|
|
|
|
// aggiungo
|
|
|
|
|
innovations.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// serializzo e salvo
|
|
|
|
|
string serVal = JsonConvert.SerializeObject(innovations);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(serVal));
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Restitusice elenco PARAMETRI che richiedono una WRITE x IOB
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina">Impianto richiesto</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<objItem>> getCurrObjItemsPendigWrite(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
List<objItem> actValues = new List<objItem>();
|
|
|
|
|
List<objItem> writeValues = new List<objItem>();
|
|
|
|
|
// ORA recupero da memoria redis...
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// cerco se chiave esiste -_> sostituisco
|
|
|
|
|
if (currTasks.ContainsKey(taskName))
|
|
|
|
|
string cacheKey = paramHash(idxMacchina);
|
|
|
|
|
string rawData;
|
|
|
|
|
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
|
|
|
|
if (redisDataList != null)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
rawData = Encoding.UTF8.GetString(redisDataList);
|
|
|
|
|
actValues = JsonConvert.DeserializeObject<List<objItem>>(rawData);
|
|
|
|
|
// cerco e rimuovo parametri sola lettura o SENZA richieste scrittura
|
|
|
|
|
foreach (var item in actValues)
|
|
|
|
|
{
|
|
|
|
|
if (item.writable && !string.IsNullOrEmpty(item.reqValue))
|
|
|
|
|
{
|
|
|
|
|
writeValues.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"Errore in TaskMacchinaRem | idxMacchina: {idxMacchina} | taskName: {taskName}{Environment.NewLine}{exc}");
|
|
|
|
|
Log.Info($"Errore in recupero ParametriMacchinaWriteGet | idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return currTasks;
|
|
|
|
|
return writeValues;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// RIMUOVE un PARAMETRO OPZIONALE dall'elenco di quelli salvati
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="taskKey"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> remOptPar4Machine(string idxMacchina, string taskKey)
|
|
|
|
|
{
|
|
|
|
|
bool answ = false;
|
|
|
|
|
string currHash = optParHash(idxMacchina);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// leggo task attuali...
|
|
|
|
|
var currVal = await mOptParMacchina(idxMacchina);
|
|
|
|
|
currVal.Remove(taskKey);
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
string rawData = JsonConvert.SerializeObject(currVal);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
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>> mOptParMacchina(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
// hard coded dimensione vettore DatiMacchine
|
|
|
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
|
|
|
// ORA recupero da memoria redis...
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string currHash = optParHash(idxMacchina);
|
|
|
|
|
var redisDataList = await distributedCache.GetAsync(currHash);
|
|
|
|
|
if (redisDataList != null)
|
|
|
|
|
{
|
|
|
|
|
string rawData = Encoding.UTF8.GetString(redisDataList);
|
|
|
|
|
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"Errore in compilazione dati OPT PARAM mOptParMacchina | idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
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>> mTaskMacchina(string idxMacchina)
|
|
|
|
|
{
|
|
|
|
|
// hard coded dimensione vettore DatiMacchine
|
|
|
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
|
|
|
// ORA recupero da memoria redis...
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string cacheKey = exeTaskHash(idxMacchina);
|
|
|
|
|
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
|
|
|
|
if (redisDataList != null)
|
|
|
|
|
{
|
|
|
|
|
string rawData = Encoding.UTF8.GetString(redisDataList);
|
|
|
|
|
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"Errore in recupero dati EXE TASK x Redis mTaskMacchina | idxMacchina: {idxMacchina}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// RIMUOVE un task dall'elenco di quelli salvati
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idxMacchina"></param>
|
|
|
|
|
/// <param name="taskKey"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> remTask4Machine(string idxMacchina, taskType taskKey)
|
|
|
|
|
{
|
|
|
|
|
bool answ = false;
|
|
|
|
|
string currHash = exeTaskHash(idxMacchina);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// leggo task attuali...
|
|
|
|
|
var currTasks = await mTaskMacchina(idxMacchina);
|
|
|
|
|
// cerco se chiave esiste -_> sostituisco
|
|
|
|
|
if (currTasks.ContainsKey($"{taskKey}"))
|
|
|
|
|
{
|
|
|
|
|
currTasks.Remove($"{taskKey}");
|
|
|
|
|
// salvo in redis!
|
|
|
|
|
string rawData = JsonConvert.SerializeObject(currTasks);
|
|
|
|
|
await distributedCache.SetAsync(currHash, Encoding.UTF8.GetBytes(rawData));
|
|
|
|
|
Log.Info($"Task REM | idxMacchina: {idxMacchina} | taskKey: {taskKey}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"Errore in remTask4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey}{Environment.NewLine}{exc}");
|
|
|
|
|
}
|
|
|
|
|
return answ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cancellazione Ordine consegna GAS
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="currItem"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> OrderDelete(OrderModel currItem)
|
|
|
|
|
{
|
|
|
|
|
bool done = false;
|
|
|
|
|