Corretta gestione con Dictionary e diventato OK metodo enabled e sLog
This commit is contained in:
@@ -195,7 +195,7 @@ namespace MP_IO.Controllers
|
||||
answ = "";
|
||||
try
|
||||
{
|
||||
KeyValuePair<string, string>[] valori = DataLayer.mDatiMacchine(idxMacch);
|
||||
Dictionary<string, string> valori = DataLayer.mDatiMacchine(idxMacch);
|
||||
foreach (var item in valori)
|
||||
{
|
||||
answ += string.Format("{0}|{1}<br/>", item.Key, item.Value);
|
||||
|
||||
@@ -29,19 +29,19 @@ namespace MP_IO.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
bool insEnabled = false;
|
||||
bool isEnabled = false;
|
||||
// verifico se sia abilitato INSERT x una data macchina... con REDIS se abilitato
|
||||
if (memLayer.ML.CRB("IOB_RedEnab"))
|
||||
{
|
||||
insEnabled = DataLayer.insEnab(idx);
|
||||
isEnabled = DataLayer.insEnab(idx);
|
||||
}
|
||||
// ...oppure dritto su DB
|
||||
else
|
||||
{
|
||||
insEnabled = MapoDb.MapoDb.obj.insEnabled(idx);
|
||||
isEnabled = MapoDb.MapoDb.obj.insEnabled(idx);
|
||||
}
|
||||
// salvo risposta!
|
||||
answ = insEnabled ? "OK" : "NO";
|
||||
answ = isEnabled ? "OK" : "NO";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -66,15 +66,19 @@ namespace MP_IO.Controllers
|
||||
Int32.TryParse(id.ToString(), out idx);
|
||||
try
|
||||
{
|
||||
// verifico se sia abilitato SignalLog x una data macchina
|
||||
if (MapoDb.MapoDb.obj.sLogEnabled(idx))
|
||||
bool isEnabled = false;
|
||||
// verifico se sia abilitato SignalLog x una data macchina... con REDIS se abilitato
|
||||
if (memLayer.ML.CRB("IOB_RedEnab"))
|
||||
{
|
||||
answ = "OK";
|
||||
isEnabled = DataLayer.sLogEnab(idx);
|
||||
}
|
||||
// ...oppure dritto su DB
|
||||
else
|
||||
{
|
||||
answ = "NO";
|
||||
isEnabled = MapoDb.MapoDb.obj.sLogEnabled(idx);
|
||||
}
|
||||
// salvo risposta!
|
||||
answ = isEnabled ? "OK" : "NO";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -158,6 +162,7 @@ namespace MP_IO.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#if false
|
||||
// GET: IOB/setredis/5
|
||||
public string setredis(int? id)
|
||||
{
|
||||
@@ -287,6 +292,7 @@ namespace MP_IO.Controllers
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+63
-41
@@ -555,19 +555,17 @@ namespace MapoDb
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyValuePair<string, string>[] mDatiMacchine(int idxMacchina)
|
||||
public static Dictionary<string,string> mDatiMacchine(int idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[1];
|
||||
// iniziualizzo con un valore... 0/0
|
||||
answ[0] = new KeyValuePair<string, string>("0", "0");
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
string currHash = dtMaccHash(idxMacchina);
|
||||
answ = memLayer.ML.redGetHash(currHash);
|
||||
answ = memLayer.ML.redGetHashDict(currHash);
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (answ.Length == 0)
|
||||
if (answ.Count == 0)
|
||||
{
|
||||
answ = resetDatiMacchina(idxMacchina);
|
||||
}
|
||||
@@ -583,46 +581,46 @@ namespace MapoDb
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyValuePair<string, string>[] resetDatiMacchina(int idxMacchina)
|
||||
public static Dictionary<string, string> resetDatiMacchina(int idxMacchina)
|
||||
{
|
||||
string currHash = dtMaccHash(idxMacchina);
|
||||
// inizio con un bel reset...
|
||||
memLayer.ML.redFlushKey(currHash);
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[18];
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
DS_applicazione.MSFDDataTable tabMSFD = MapoDb.obj.taMSFD.getByIdxMacc(idxMacchina.ToString());
|
||||
try
|
||||
{
|
||||
DS_applicazione.MSFDRow rigaMSFD = tabMSFD[0];
|
||||
// salvo 1:1 i valori...
|
||||
answ[0] = new KeyValuePair<string, string>("palletChange", rigaMSFD.palletChange.ToString());
|
||||
answ[1] = new KeyValuePair<string, string>("CodArticolo_A", rigaMSFD.CodArticolo_A);
|
||||
answ[2] = new KeyValuePair<string, string>("CodArticolo_B", rigaMSFD.CodArticolo_B);
|
||||
answ[3] = new KeyValuePair<string, string>("simplePallet", rigaMSFD.simplePallet.ToString());
|
||||
answ[4] = new KeyValuePair<string, string>("insEnabled", rigaMSFD.insEnabled.ToString());
|
||||
answ[5] = new KeyValuePair<string, string>("sLogEnabled", rigaMSFD.sLogEnabled.ToString());
|
||||
answ[6] = new KeyValuePair<string, string>("IdxStato", rigaMSFD.IdxStato.ToString());
|
||||
answ[7] = new KeyValuePair<string, string>("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString());
|
||||
answ[8] = new KeyValuePair<string, string>("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString());
|
||||
answ[9] = new KeyValuePair<string, string>("CodArticolo", rigaMSFD.CodArticolo);
|
||||
answ[10] = new KeyValuePair<string, string>("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
answ[11] = new KeyValuePair<string, string>("PzPalletProd", rigaMSFD.PzPalletProd.ToString());
|
||||
answ[12] = new KeyValuePair<string, string>("MatrOpr", rigaMSFD.MatrOpr.ToString());
|
||||
answ[13] = new KeyValuePair<string, string>("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString());
|
||||
answ[14] = new KeyValuePair<string, string>("pallet", rigaMSFD.pallet);
|
||||
answ[15] = new KeyValuePair<string, string>("lastVal", rigaMSFD.lastVal);
|
||||
answ[16] = new KeyValuePair<string, string>("TCBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
answ[17] = new KeyValuePair<string, string>("CodMacc", rigaMSFD.codmacchina);
|
||||
// salvo 1:1 i valori... STATO
|
||||
answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString());
|
||||
answ.Add("IdxStato", rigaMSFD.IdxStato.ToString());
|
||||
answ.Add("CodArticolo", rigaMSFD.CodArticolo);
|
||||
answ.Add("insEnabled", rigaMSFD.insEnabled.ToString());
|
||||
answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString());
|
||||
answ.Add("pallet", rigaMSFD.pallet);
|
||||
answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A);
|
||||
answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B);
|
||||
answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString());
|
||||
answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString());
|
||||
answ.Add("lastVal", rigaMSFD.lastVal);
|
||||
answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
|
||||
//...e SETUP
|
||||
answ.Add("CodMacc", rigaMSFD.codmacchina);
|
||||
answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString());
|
||||
answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString());
|
||||
answ.Add("simplePallet", rigaMSFD.simplePallet.ToString());
|
||||
answ.Add("palletChange", rigaMSFD.palletChange.ToString());
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// verifico il timeout che cambia a seconda che sia vero o falso insEnabled...
|
||||
int tOutShort = memLayer.ML.cdvi("TmOut.MS.S");
|
||||
int tOutLong = memLayer.ML.cdvi("TmOut.MS.L");
|
||||
int redDtMacTOut = (answ[4].Value.ToLower() == "true") ? tOutShort : tOutLong;
|
||||
|
||||
//int redDtMacTOut = (memLayer.ML.CRI("redDtMacTOut") <= 0) ? 60 : memLayer.ML.CRI("redDtMacTOut");
|
||||
int redDtMacTOut = (answ["insEnabled"].ToLower() == "true") ? tOutShort : tOutLong;
|
||||
// salvo in redis!
|
||||
memLayer.ML.redSaveHash(currHash, answ, redDtMacTOut);
|
||||
memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -706,6 +704,23 @@ namespace MapoDb
|
||||
return memLayer.ML.redGetHashField(currHash, field);
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce valore di una singola chiave del dizionario DatiMacchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="chiave"></param>
|
||||
/// <returns></returns>
|
||||
public static string mDatiMacchinaVal(int idxMacchina, string chiave)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = mDatiMacchine(idxMacchina)[chiave];
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce il valore booleano se la macchina sia abilitata all'input
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
@@ -713,18 +728,25 @@ namespace MapoDb
|
||||
public static bool insEnab(int idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
string currHash = dtMaccHash(idxMacchina);
|
||||
string field = "insEnabled";
|
||||
try
|
||||
{
|
||||
// verifico se ne ho altrimenti ricarico...
|
||||
bool trovato = memLayer.ML.redHashPresentSz(currHash);
|
||||
if (!trovato)
|
||||
{
|
||||
// ricarico tabella!
|
||||
KeyValuePair<string, string>[] valori = DataLayer.mDatiMacchine(idxMacchina);
|
||||
}
|
||||
answ = Convert.ToBoolean(memLayer.ML.redGetHashField(currHash, field));
|
||||
answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled"));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel Signal Log
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static bool sLogEnab(int idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled"));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
Reference in New Issue
Block a user