completato prima revisione x far redirezionare alle chiamate MVC le pagine enabled/alive/inputIOB con gestione chiamate da metodi MapoDb... da testare!
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using MapoDb;
|
||||
using SteamWare;
|
||||
|
||||
namespace MP_IO.Controllers
|
||||
{
|
||||
@@ -69,18 +70,18 @@ namespace MP_IO.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
// GET: IOB/input/5
|
||||
public string input(int? id)
|
||||
// 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 = "OK " + id.ToString();
|
||||
// controllo se sia da fare rilettura da DB dello stato macchina ( SE non c'è il valore oppure se il valore "maxAgeSec" è stato superato )
|
||||
|
||||
|
||||
// verifico se sia abilitato INSERT x una data macchina
|
||||
|
||||
// cerco prima in cache memory (altrimenti la popolo da DB)
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
answ = DataLayer.processInput(id, valore, dtEve, dtCurr, cnt);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-77
@@ -19,6 +19,8 @@ namespace MP_IO
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect(string.Format("IOB/input/{0}?valore={1}&dtEve={2}&dtCurr={3}&cnt={4}", Request.QueryString["idxMacchina"], Request.QueryString["valore"], Request.QueryString["dtEve"], Request.QueryString["dtCurr"], Request.QueryString["cnt"]));
|
||||
#if false
|
||||
// legge i get x processare la seriale
|
||||
string idxMacchina = "";
|
||||
string valore = "";
|
||||
@@ -42,86 +44,12 @@ namespace MP_IO
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// controllo: se ho valori dt x evento e orario DIVERSI per acquisitore IOB calcolo dataOraEvento corretto
|
||||
if (dtEve != dtCurr)
|
||||
{
|
||||
Int64 delta = 0;
|
||||
try
|
||||
{
|
||||
delta = Convert.ToInt64(dtCurr) - Convert.ToInt64(dtEve);
|
||||
// se meno di 60'000 ms ...
|
||||
if (delta < 59999)
|
||||
{
|
||||
dataOraEvento = dataOraEvento.AddMilliseconds(-delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
// in questo caso elimino i MS dalle stringhe e converto i datetime....
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
string format = "yyyyMMddHHmmssfff";
|
||||
DateTime dtEvento = DateTime.ParseExact(dtEve, format, provider);
|
||||
DateTime dtCorrente = DateTime.ParseExact(dtCurr, format, provider);
|
||||
Int64 tiks = dtCorrente.Ticks - dtEvento.Ticks;
|
||||
dataOraEvento = dataOraEvento.AddTicks(-tiks);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore calcolo ms evento/ora corrente da device remoto:{0}dtEve: {1}{0}dtCurr: {2}{0}{3}", Environment.NewLine, dtEve, dtCurr, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
//
|
||||
if (idxMacchina != null && valore != null)
|
||||
{
|
||||
if (idxMacchina != "" && valore != "")
|
||||
{
|
||||
// 2016.12.23 modifica x recording catena di input...
|
||||
// se abilitato registro evento sul DB
|
||||
int idxMacc = 0;
|
||||
try
|
||||
{
|
||||
idxMacc = Convert.ToInt32(idxMacchina);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (idxMacc > 0 && MapoDb.MapoDb.obj.sLogEnabled(idxMacc))
|
||||
{
|
||||
MapoDb.MapoDb.obj.saveSigLog(idxMacchina, valore, dataOraEvento, contatore);
|
||||
}
|
||||
// continuo col resto
|
||||
try
|
||||
{
|
||||
// ora processo e salvo il valore del microstato...
|
||||
MapoDb.MapoDb.obj.checkMicroStato(idxMacchina, valore, dataOraEvento, contatore);
|
||||
answ = "OK"; // registro in risposta che è andato tutto bene...
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (memLayer.ML.confReadInt("_logLevel") > 5)
|
||||
{
|
||||
string errore = string.Format("Errore: {0}{1}", Environment.NewLine, exc);
|
||||
logger.lg.scriviLog(errore, tipoLog.EXCEPTION);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: parametri macchina/valore vuoti";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: mancano parametri macchina/valore";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
answ = DataLayer.processInput(idxMacchina, valore, dtEve, dtCurr, contatore);
|
||||
// ripulisco pagina restituita e tolgo html (solo codice ok/NO)
|
||||
Response.Clear();
|
||||
Response.Write(answ);
|
||||
Context.Response.End();
|
||||
Context.Response.End();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using SteamWare;
|
||||
using System.Reflection;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
@@ -396,6 +397,98 @@ namespace MapoDb
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Processa input da IOB eventualmente registrando i segnali inviati
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="valore"></param>
|
||||
/// <param name="dtEve"></param>
|
||||
/// <param name="dtCurr"></param>
|
||||
/// <param name="contatore"></param>
|
||||
/// <returns></returns>
|
||||
public static string processInput(string idxMacchina, string valore, string dtEve, string dtCurr, string contatore)
|
||||
{
|
||||
|
||||
string answ = "";
|
||||
DateTime dataOraEvento = DateTime.Now;
|
||||
// controllo: se ho valori dt x evento e orario DIVERSI per acquisitore IOB calcolo dataOraEvento corretto
|
||||
if (dtEve != dtCurr)
|
||||
{
|
||||
Int64 delta = 0;
|
||||
try
|
||||
{
|
||||
delta = Convert.ToInt64(dtCurr) - Convert.ToInt64(dtEve);
|
||||
// se meno di 60'000 ms ...
|
||||
if (delta < 59999)
|
||||
{
|
||||
dataOraEvento = dataOraEvento.AddMilliseconds(-delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
// in questo caso elimino i MS dalle stringhe e converto i datetime....
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
string format = "yyyyMMddHHmmssfff";
|
||||
DateTime dtEvento = DateTime.ParseExact(dtEve, format, provider);
|
||||
DateTime dtCorrente = DateTime.ParseExact(dtCurr, format, provider);
|
||||
Int64 tiks = dtCorrente.Ticks - dtEvento.Ticks;
|
||||
dataOraEvento = dataOraEvento.AddTicks(-tiks);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore calcolo ms evento/ora corrente da device remoto:{0}dtEve: {1}{0}dtCurr: {2}{0}{3}", Environment.NewLine, dtEve, dtCurr, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
//
|
||||
if (idxMacchina != null && valore != null)
|
||||
{
|
||||
if (idxMacchina != "" && valore != "")
|
||||
{
|
||||
// 2016.12.23 modifica x recording catena di input...
|
||||
// se abilitato registro evento sul DB
|
||||
int idxMacc = 0;
|
||||
try
|
||||
{
|
||||
idxMacc = Convert.ToInt32(idxMacchina);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (idxMacc > 0 && MapoDb.obj.sLogEnabled(idxMacc))
|
||||
{
|
||||
MapoDb.obj.saveSigLog(idxMacchina, valore, dataOraEvento, contatore);
|
||||
}
|
||||
// continuo col resto
|
||||
try
|
||||
{
|
||||
// ora processo e salvo il valore del microstato...
|
||||
MapoDb.obj.checkMicroStato(idxMacchina, valore, dataOraEvento, contatore);
|
||||
answ = "OK"; // registro in risposta che è andato tutto bene...
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (memLayer.ML.confReadInt("_logLevel") > 5)
|
||||
{
|
||||
string errore = string.Format("Errore: {0}{1}", Environment.NewLine, exc);
|
||||
logger.lg.scriviLog(errore, tipoLog.EXCEPTION);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: parametri macchina/valore vuoti";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: mancano parametri macchina/valore";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user