100 lines
2.6 KiB
C#
100 lines
2.6 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.Mvc;
|
|
|
|
namespace MP_IO.Controllers
|
|
{
|
|
public class IOBController : Controller
|
|
{
|
|
// GET: IOB (è un check alive)
|
|
public string Index()
|
|
{
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
// conto la richiesta nel contatore REDIS
|
|
long nCall = memLayer.ML.setRCntI(DataLayer.mHash("COUNT:IOB_INDEX"));
|
|
//... se == nCall2Log scrivo su log e resetto
|
|
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
|
|
if (nCall >= nCall2Log)
|
|
{
|
|
// loggo
|
|
logger.lg.scriviLog(string.Format("IOB_INDEX: effettuate {0} call", nCall), tipoLog.INFO);
|
|
// resetto!
|
|
memLayer.ML.resetRCnt(DataLayer.mHash("COUNT:IOB_INDEX"));
|
|
}
|
|
}
|
|
return "OK";
|
|
}
|
|
|
|
// GET: IOB/enabled/5
|
|
public string enabled(string id)
|
|
{
|
|
string answ = "ND";
|
|
// se id nullo --> KO!
|
|
if (id == null)
|
|
{
|
|
answ = "KO";
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
// salvo risposta!
|
|
answ = DataLayer.insEnab(id) ? "OK" : "NO";
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in enabled{0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
// GET: IOB/slog/5
|
|
public string slog(string id)
|
|
{
|
|
string answ = "ND";
|
|
// se id nullo --> KO!
|
|
if (id == null)
|
|
{
|
|
answ = "KO";
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
answ = DataLayer.sLogEnab(id) ? "OK" : "NO";
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in sLog{0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
// GET: IOB/input/5?valore=3&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999
|
|
public string input(string id, string valore, string dtEve, string dtCurr, string cnt)
|
|
{
|
|
string answ = "";
|
|
// formato yyyymmddHHMMSSnnn ovvero da anno a millisecondi
|
|
if (cnt == null) cnt = "0";
|
|
DateTime dataOraEvento = DateTime.Now;
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Valori letti:{0}idxMacchina: {1}{0}valore: {2}{0}dtEve: {3}{0}dtCurr: {4}{0}cnt: {5}", Environment.NewLine, id, valore, dtEve, dtCurr, cnt), tipoLog.INFO);
|
|
}
|
|
try
|
|
{
|
|
answ = DataLayer.processInput(id, valore, dtEve, dtCurr, cnt);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in input{0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
} |