1261 lines
40 KiB
C#
1261 lines
40 KiB
C#
using MapoDb;
|
|
using MapoSDK;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Web.Mvc;
|
|
|
|
namespace MP_IO.Controllers
|
|
{
|
|
public class IOBController : Controller
|
|
{
|
|
// GET: IOB (è un check alive del server)
|
|
public string Index()
|
|
{
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
// conto la richiesta nel contatore REDIS
|
|
long nCall = memLayer.ML.setRCntI(DataLayer.mHash("COUNT:pCall: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:pCall:IOB_INDEX"));
|
|
}
|
|
}
|
|
return "OK";
|
|
}
|
|
|
|
// GET: IOB/enabled/SIMUL_03
|
|
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/SIMUL_03
|
|
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/SIMUL_03?valore=3&dtEve=20181206180600000&dtCurr=20181206180600000&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 processInput{0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un array Json di oggetti input (EVENTI)
|
|
/// PUT: IOB/evListJson/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string evListJson(string id)
|
|
{
|
|
int insDone = 0;
|
|
string answ = "-";
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(
|
|
Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// se ho dati...
|
|
if (content != "")
|
|
{
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
evJsonPayload receivedData = new evJsonPayload();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
receivedData = JsonConvert.DeserializeObject<evJsonPayload>(content);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in fase deserializzazione inputJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
// se ho qualcosa da processare...
|
|
if (receivedData != null)
|
|
{
|
|
// per ogni valore --> processo!
|
|
try
|
|
{
|
|
foreach (var item in receivedData.eventList)
|
|
{
|
|
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, item.valore, item.dtEve, item.dtCurr, item.cnt), tipoLog.INFO);
|
|
}
|
|
|
|
// formato datetime come yyyyMMddHHmmssfff -->es: 20181223180600000
|
|
answ = DataLayer.processInput(id, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt.ToString());
|
|
insDone++;
|
|
}
|
|
// se vuoto --> OK!
|
|
if (string.IsNullOrEmpty(answ))
|
|
{
|
|
answ = $"OK {insDone} processed";
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in fase invio valori inputJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
// GET: IOB/flog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999
|
|
public string flog(string id, string flux, 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}flux: {6}{0}valore: {2}{0}dtEve: {3}{0}dtCurr: {4}{0}cnt: {5}", Environment.NewLine, id, valore, dtEve, dtCurr, cnt, flux), tipoLog.INFO);
|
|
}
|
|
try
|
|
{
|
|
int count = 0;
|
|
Int32.TryParse(cnt, out count);
|
|
answ = DataLayer.processFluxLog(id, flux, valore, dtEve, dtCurr, count);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in flog{0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un array Json di oggetti fluxLog
|
|
/// PUT: IOB/flogJson/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string flogJson(string id)
|
|
{
|
|
int insDone = 0;
|
|
string answ = "-";
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(
|
|
Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// se ho dati...
|
|
if (content != "")
|
|
{
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
flogJsonPayload receivedData = new flogJsonPayload();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
receivedData = JsonConvert.DeserializeObject<flogJsonPayload>(content);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in fase deserializzazione flogJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
// se ho qualcosa da processare...
|
|
if (receivedData != null)
|
|
{
|
|
// per ogni valore --> salvo!
|
|
try
|
|
{
|
|
foreach (var item in receivedData.fluxData)
|
|
{
|
|
// formato datetime come yyyyMMddHHmmssfff -->es: 20181223180600000
|
|
answ = DataLayer.processFluxLog(id, item.flux, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt);
|
|
}
|
|
// se vuoto --> OK!
|
|
if (string.IsNullOrEmpty(answ))
|
|
{
|
|
answ = $"OK {insDone} processed";
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in fase invio valori flogJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
// leggo parametri correnti...
|
|
try
|
|
{
|
|
List<objItem> currParams = DataLayer.getCurrObjItems(id);
|
|
// ora per ogni valore RICEVUTO costruisco un oggetto in innnovazioni da inviare...x salvare in stato parametri...
|
|
List<objItem> innovazioni = new List<objItem>();
|
|
foreach (var item in receivedData.fluxData)
|
|
{
|
|
// flux = uuid del parametro
|
|
objItem trovato = currParams.Find(obj => obj.uid == item.flux);
|
|
// se lo trovo aggiorno...
|
|
if (trovato != null)
|
|
{
|
|
// aggiorno valore e data
|
|
trovato.value = item.valore;
|
|
trovato.lastRead = DateTime.Now;
|
|
}
|
|
// altrimenti AGGIUNGO (READ ONLY)...
|
|
else
|
|
{
|
|
trovato = new objItem
|
|
{
|
|
uid = item.flux,
|
|
name = item.flux,
|
|
value = item.valore,
|
|
lastRead = DateTime.Now,
|
|
writable = false
|
|
};
|
|
}
|
|
// lo carico in innovation
|
|
innovazioni.Add(trovato);
|
|
}
|
|
// faccio upsert innovations!
|
|
DataLayer.upsertCurrObjItems(id, innovazioni);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in fase salvataggio innovazioni parametri correnti da flogJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un array Json di oggetti LIVE REC
|
|
/// PUT: IOB/liveJson/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string liveJson(string id)
|
|
{
|
|
string answ = "-";
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(
|
|
Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
try
|
|
{
|
|
// deserializzo.
|
|
liveIOB receivedData = JsonConvert.DeserializeObject<liveIOB>(content);
|
|
answ = DataLayer.processLiveJson(id, receivedData);
|
|
// se vuoto --> OK!
|
|
if (string.IsNullOrEmpty(answ))
|
|
{
|
|
answ = "OK 1 done";
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in liveJson{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un SET di file "a nome" di un IOB, formato MapoSDK.fileEmbed
|
|
/// PUT: IOB/uploadFile/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string uploadFile(string id)
|
|
{
|
|
string answ = "";
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
try
|
|
{
|
|
// deserializzo.
|
|
fileEmbed receivedData = JsonConvert.DeserializeObject<fileEmbed>(content);
|
|
// salvo nella cartella di Upload...
|
|
string basePath = Server.MapPath(memLayer.ML.CRS("uploadFileDir"));
|
|
string dirPath = $"{basePath}\\{id}";
|
|
// fix directory...
|
|
Directory.CreateDirectory(dirPath);
|
|
foreach (var item in receivedData.fileList)
|
|
{
|
|
// scrivo!
|
|
System.IO.File.WriteAllText($"{dirPath}\\{item.fileName}", item.content);
|
|
}
|
|
answ = "OK";
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in uploadFile{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un array JSon di files di una IOB
|
|
/// PUT: IOB/getFiles/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns>Oggetto Json in formato MapoSDK.fileEmbed</returns>
|
|
public string getFiles(string id)
|
|
{
|
|
string answ = "";
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
try
|
|
{
|
|
// recupero TUTTI i files della folder dell'IOB richiesta
|
|
string basePath = Server.MapPath(memLayer.ML.CRS("uploadFileDir"));
|
|
string dirPath = $"{basePath}\\{id}";
|
|
var fileList = fileMover.obj.elencoFilesDir(dirPath);
|
|
fileEmbed objFiles = new fileEmbed();
|
|
smallFile currFile = null;
|
|
string fileContent = "";
|
|
foreach (var item in fileList)
|
|
{
|
|
fileContent = System.IO.File.ReadAllText($"{dirPath}\\{item.Nome}");
|
|
currFile = new smallFile()
|
|
{
|
|
fileName = item.Nome,
|
|
content = fileContent.Replace("\r\n", Environment.NewLine)
|
|
};
|
|
objFiles.fileList.Add(currFile);
|
|
}
|
|
// serializzo
|
|
answ = JsonConvert.SerializeObject(objFiles);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in uploadFile{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un array Json di oggetti plcMemConf
|
|
/// PUT: IOB/saveConf/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string saveConf(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
plcMemMap currMemMap = null;
|
|
try
|
|
{
|
|
// deserializzo.
|
|
currMemMap = JsonConvert.DeserializeObject<plcMemMap>(content);
|
|
// se != null --> salvo!
|
|
if (currMemMap != null)
|
|
{
|
|
DataLayer.setIobMemMap(id, currMemMap);
|
|
answ = "OK";
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di un array Json di oggetti di conf DataItems (es per MTC)
|
|
/// PUT: IOB/saveDataItems/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string saveDataItems(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
// Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
List<machDataItem> dataItems = null;
|
|
try
|
|
{
|
|
// deserializzo.
|
|
dataItems = JsonConvert.DeserializeObject<List<machDataItem>>(content);
|
|
// se != null --> salvo!
|
|
if (dataItems != null)
|
|
{
|
|
// chiamo metodo update direttamente!
|
|
MtcDataModelArchive.man.saveMachineDataItems(id, dataItems);
|
|
answ = "OK";
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce elenco parametri correnti come una List Json di oggetti objItem
|
|
/// GET: IOB/getObjItems/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
public string getObjItems(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// procedo a recuperare l'oggetto...
|
|
List<objItem> currParams = new List<objItem>();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
currParams = DataLayer.getCurrObjItems(id);
|
|
// se != null --> salvo!
|
|
if (currParams != null)
|
|
{
|
|
answ = JsonConvert.SerializeObject(currParams);
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in getCurrParams{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di oggetti objItem
|
|
/// GET: IOB/getObjItems2Write/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
public string getObjItems2Write(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// procedo a recuperare l'oggetto...
|
|
List<objItem> currParams = new List<objItem>();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
currParams = DataLayer.getCurrObjItemsPendigWrite(id);
|
|
// se != null --> salvo!
|
|
if (currParams != null)
|
|
{
|
|
answ = JsonConvert.SerializeObject(currParams);
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in getCurrParams{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di una List Json di oggetti objItem
|
|
/// POST: IOB/setObjItems/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string setObjItems(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
List<objItem> currParams = new List<objItem>();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
currParams = JsonConvert.DeserializeObject<List<objItem>>(content);
|
|
// se != null --> salvo!
|
|
if (currParams != null)
|
|
{
|
|
DataLayer.setCurrObjItems(id, currParams);
|
|
answ = "OK";
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in setCurrParams{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Processa una chiamata POST per l'invio di una List Json di UNO O PIU' oggetti objItem
|
|
/// POST: IOB/upsertObjItems/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id">ID dell'IOB</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public string upsertObjItems(string id)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
answ = "Missing IOB";
|
|
}
|
|
else
|
|
{
|
|
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
|
string content = "";
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
|
{
|
|
content = reader.ReadToEnd();
|
|
}
|
|
//Rest
|
|
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
|
// procedo a deserializzare in blocco l'oggetto...
|
|
List<objItem> innovazioni = new List<objItem>();
|
|
try
|
|
{
|
|
// deserializzo.
|
|
innovazioni = JsonConvert.DeserializeObject<List<objItem>>(content);
|
|
// se != null --> salvo!
|
|
if (innovazioni != null)
|
|
{
|
|
// salvo
|
|
DataLayer.upsertCurrObjItems(id, innovazioni);
|
|
answ = "OK";
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in setCurrParams{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
// GET: IOB/liveRec/SIMUL_03?&liveData=chiave1|valore1#chiave2|valore#|chiave3|valore3
|
|
public string liveRec(string id, string liveData)
|
|
{
|
|
string answ = "";
|
|
DateTime dataOraEvento = DateTime.Now;
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog($"Valori Live:{Environment.NewLine}idxMacchina: {id}{Environment.NewLine}liveData: {liveData}", tipoLog.INFO);
|
|
}
|
|
try
|
|
{
|
|
answ = DataLayer.processLiveRec(id, liveData);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in liveRec{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Recupera ODL corrente x macchina:
|
|
///
|
|
/// GET: IOB/getCurrODL/SIMUL_03
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCurrODL(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = DataLayer.currODL(id).ToString();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in currODL (get){0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce data-ora inizio dell'odl correntemente in lavorazione sulla macchina...
|
|
/// es: http://url_site/MP/IO/IOB/getCurrOdlStart/SIMUL_03
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCurrOdlStart(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
DateTime answ = new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
// chiamo metodo redis/db...
|
|
try
|
|
{
|
|
DS_ProdTempi.ODLDataTable currTab = DataLayer.currODLRowTab(id);
|
|
if (currTab.Count > 0)
|
|
{
|
|
DS_ProdTempi.ODLRow odlRow = currTab[0];
|
|
answ = odlRow.DataInizio;
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero getCurrOdlStart{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
return answ.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
/// <summary>
|
|
/// Restituisce intera riga dell'odl correntemente in lavorazione sulla macchina...
|
|
/// GET: IOB/getCurrOdlRow/SIMUL_01
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCurrOdlRow(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
string answ = "";
|
|
DS_ProdTempi.ODLDataTable currData = null;
|
|
// chiamo metodo redis/db...
|
|
try
|
|
{
|
|
currData = DataLayer.currODLRowTab(id);
|
|
answ = JsonConvert.SerializeObject(currData);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero getCurrOdlRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce intera riga dello stato di macchina...
|
|
/// GET: IOB/getCurrStatoRow/SIMUL_01
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCurrStatoRow(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
string answ = "";
|
|
DS_applicazione.StatoMacchineDataTable currData = null;
|
|
// chiamo metodo redis/db...
|
|
try
|
|
{
|
|
currData = DataLayer.currSMTab(id);
|
|
answ = JsonConvert.SerializeObject(currData);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero getCurrStatoRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce il valore dello stato di IDLE della macchina, quindi SOLO SE NON é in lavoro e già convertito in minuti...
|
|
/// GET: IOB/getIdlePeriod/SIMUL_01
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public int getIdlePeriod(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
int answ = 0;
|
|
DS_applicazione.StatoMacchineDataTable currData = null;
|
|
// chiamo metodo redis/db...
|
|
try
|
|
{
|
|
currData = DataLayer.currSMTab(id);
|
|
if (currData.Count > 0)
|
|
{
|
|
// recupero da redis elenco stati
|
|
DS_applicazione.AnagraficaStatiDataTable anagStati = DataLayer.AnagraficaStati();
|
|
DS_applicazione.AnagraficaStatiRow currStato = anagStati.FindByIdxStato(currData[0].IdxStato);
|
|
// calcolo SE sia idle... OVVERO SEMAFORO NON VERDE!!!
|
|
if (currStato.Semaforo != "sVe")
|
|
{
|
|
// calcolo durata...
|
|
answ = (int)DateTime.Now.Subtract(currData[0].InizioStato).TotalMinutes;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero getIdlePeriod{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Recupera DATI correnti x macchina:
|
|
///
|
|
/// GET: IOB/getCurrData/SIMUL_03
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns>Json contenente la riga di stato macchina</returns>
|
|
public string getCurrData(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
// recupero dati macchina...
|
|
Dictionary<string, string> valori = DataLayer.mDatiMacchine(id);
|
|
answ = JsonConvert.SerializeObject(valori);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Chiude ODL precedente ed avvia uno nuovo (duplicandolo)
|
|
///
|
|
/// GET: IOB/forceSplitOdl/SIMUL_03
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns>Json contenente la riga di stato macchina</returns>
|
|
public string forceSplitOdl(string id)
|
|
{
|
|
// attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
|
|
id = id.Replace("|", "#");
|
|
return DataLayer.forceSplitOdl(id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera TASK richiesto x macchina:
|
|
///
|
|
/// GET: IOB/getTask2Exe/SIMUL_03
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns>Json contenente 1..n task da eseguire</returns>
|
|
public string getTask2Exe(string id)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
// leggo da REDIS eventuale elenco task x macchina...
|
|
Dictionary<string, string> valori = DataLayer.mTaskMacchina(id);
|
|
answ = JsonConvert.SerializeObject(valori);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// AGGIUNGE TASK richiesto x macchina:
|
|
///
|
|
/// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512
|
|
/// GET: IOB/addTask2Exe/3010?taskName=stopSetup&taskVal=T190406101512
|
|
/// GET: IOB/addTask2Exe/SIMUL_03?taskName=setProg&taskVal=P00000001
|
|
/// GET: IOB/addTask2Exe/SIMUL_03?taskName=setComm&taskVal=ODL_0000123
|
|
/// GET: IOB/addTask2Exe/SIMUL_03?taskName=setArt&taskVal=ART_0000321
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="taskName"></param>
|
|
/// <param name="taskVal"></param>
|
|
public string addTask2Exe(string id, string taskName, string taskVal)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
// converto stringa in tipo task...
|
|
taskType tName = taskType.nihil;
|
|
bool fatto = Enum.TryParse(taskName, out tName);
|
|
if (fatto)
|
|
{
|
|
DataLayer.addTask4Machine(id, tName, taskVal);
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog($"addTask2Exe: impossibile riconoscere il comando {taskName} come uno deitipi ammessi, NON aggiunto", tipoLog.ERROR);
|
|
}
|
|
answ = getTask2Exe(id);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// ELIMINA TASK richiesto x macchina:
|
|
///
|
|
/// GET: IOB/remTask2Exe/SIMUL_03?taskName=T180326160502
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="taskName"></param>
|
|
public string remTask2Exe(string id, string taskName)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
// converto stringa in tipo task...
|
|
taskType tName = taskType.nihil;
|
|
bool fatto = Enum.TryParse(taskName, out tName);
|
|
if (fatto)
|
|
{
|
|
DataLayer.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;
|
|
}
|
|
/// <summary>
|
|
/// Recupera TASK richiesto x macchina:
|
|
///
|
|
/// GET: IOB/getOptPar/SIMUL_03
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns>Json contenente 1..n task da eseguire</returns>
|
|
public string getOptPar(string id)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
// leggo da REDIS eventuale elenco task x macchina...
|
|
Dictionary<string, string> valori = DataLayer.mOptParMacchina(id);
|
|
answ = JsonConvert.SerializeObject(valori);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// SALVA x macchina KVP parametro/valore:
|
|
///
|
|
/// GET: IOB/addOptPar/SIMUL_03?pName=PZREQ&pValue=1000
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="pName"></param>
|
|
/// <param name="pValue"></param>
|
|
public string addOptPar(string id, string pName, string pValue)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
DataLayer.addOptPar4Machine(id, pName, pValue);
|
|
answ = getOptPar(id);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// ELIMINA TASK richiesto x macchina:
|
|
///
|
|
/// GET: IOB/remOptPar/SIMUL_03?pName=PZREQ
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="pName"></param>
|
|
public string remOptPar(string id, string pName)
|
|
{
|
|
string answ = "";
|
|
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
|
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
|
connDb.scriviKeepAlive(id, DateTime.Now);
|
|
try
|
|
{
|
|
DataLayer.remOptPar4Machine(id, pName);
|
|
answ = getOptPar(id);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Effettua RESET dell'ODL corrente x macchina:
|
|
///
|
|
/// GET: IOB/resetCurrODL/5
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string resetCurrODL(string id)
|
|
{
|
|
return DataLayer.emptyCurrODL(id);
|
|
}
|
|
/// <summary>
|
|
/// Recupera COUNTER x macchina:
|
|
///
|
|
/// GET: IOB/getCounter/5
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCounter(string id)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = DataLayer.pzCounter(id).ToString();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in counter (get){0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
|
|
///
|
|
/// GET: IOB/getCounterTCRec/5
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public string getCounterTCRec(string id)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = DataLayer.pzCounterTC(id).ToString();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in counter TC (get){0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// SALVA Counter x macchina:
|
|
///
|
|
/// GET: IOB/setCounter/5?counter=10
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="counter"></param>
|
|
/// <returns></returns>
|
|
public string setCounter(string id, string counter)
|
|
{
|
|
string answ = "";
|
|
DateTime dataOraEvento = DateTime.Now;
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Salvataggio counter:{0}idxMacchina: {1}{0}conteggio: {2}", Environment.NewLine, id, counter), tipoLog.INFO);
|
|
}
|
|
try
|
|
{
|
|
answ = DataLayer.saveCounter(id, counter);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in counter (set){0}{1}", Environment.NewLine, exc));
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// SALVA in blocco un incremento pezzi x macchina:
|
|
///
|
|
/// GET: IOB/savePzCountInc/5?qty=10
|
|
///
|
|
/// </summary>
|
|
/// <param name="id">codice macchina</param>
|
|
/// <param name="qty">num peziz da salvare in blocco</param>
|
|
/// <returns></returns>
|
|
public string savePzCountInc(string id, string qty)
|
|
{
|
|
string answ = "";
|
|
DateTime dataOraEvento = DateTime.Now;
|
|
// salvo SEMPRE log x questo tipo di dati!
|
|
logger.lg.scriviLog($"Salvataggio incremento contapezzi:{Environment.NewLine}idxMacchina: {id}{Environment.NewLine}pezzi: {qty}", tipoLog.INFO);
|
|
try
|
|
{
|
|
answ = DataLayer.saveCaricoPezzi(id, qty);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Errore in savePzCountInc{Environment.NewLine}{exc}");
|
|
answ = "NO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Salva associazione tra macchina, device IOB chiamante e sue info
|
|
/// </summary>
|
|
/// <param name="id">Id della macchina</param>
|
|
/// <param name="IOB_name">Nome dell'IOB di acquisizione della macchina</param>
|
|
/// <returns></returns>
|
|
public string setM2IOB(string id, string IOB_name)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
// recupero IP del client remoto
|
|
string IPv4 = Request.UserHostName;
|
|
string agent = Request.UserAgent;
|
|
// creo oggetto IOB_data...
|
|
IOB_data m2IOB = new IOB_data
|
|
{
|
|
name = IOB_name,
|
|
IP = IPv4,
|
|
iType = IobType.ND,
|
|
typeCss = "fa fa-question-circle-o",
|
|
CNC_Counter = false
|
|
};
|
|
// imposto tipo ed icona come windows/linux secondo UserAgent...
|
|
if (agent.IndexOf("WIN") >= 0)
|
|
{
|
|
m2IOB.iType = IobType.WIN;
|
|
m2IOB.typeCss = "fa fa-windows";
|
|
m2IOB.CNC_Counter = true;
|
|
}
|
|
else if (agent.IndexOf("Python") >= 0)
|
|
{
|
|
m2IOB.iType = IobType.rPi;
|
|
m2IOB.typeCss = "fa fa-linux";
|
|
}
|
|
// serializzo...
|
|
string dataSer = JsonConvert.SerializeObject(m2IOB);
|
|
// salvo in redis...
|
|
string hM2IOB = DataLayer.hM2IOB(id);
|
|
memLayer.ML.setRSV(hM2IOB, dataSer);
|
|
// salvo tutto OK
|
|
answ = "OK";
|
|
}
|
|
catch
|
|
{
|
|
answ = "KO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce dati di associazione tra macchina, device IOB chiamante e sue info
|
|
/// </summary>
|
|
/// <param name="id">Id della macchina</param>
|
|
/// <returns></returns>
|
|
public string getM2IOB(string id)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
// recupero da redis...
|
|
string hM2IOB = DataLayer.hM2IOB(id);
|
|
string dataSer = memLayer.ML.getRSV(hM2IOB);
|
|
if (dataSer != "" && dataSer != null)
|
|
{
|
|
// restituisco Json
|
|
answ = dataSer;
|
|
}
|
|
else
|
|
{
|
|
answ = "NO";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
answ = "KO";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce il (primo) codice IOB da dover gestire (se un IOBMAN chiede di gestirne uno in +...)
|
|
/// </summary>
|
|
/// <param name="GWIP">IP del Gateway</param>
|
|
/// <returns></returns>
|
|
public string getIob2call(string GWIP)
|
|
{
|
|
string answ = "";
|
|
|
|
// !!!FARE!!! temporanemanete genera a caso vuoto o 3000 x permettere test... altrimenti gestisce VERA coda... secondi pari...
|
|
int resto = 0;
|
|
Math.DivRem(DateTime.Now.Second, 2, out resto);
|
|
if (resto == 0)
|
|
{
|
|
answ = "3000";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Salva IP del gateway dopo il reboot
|
|
/// </summary>
|
|
/// <param name="GWIP">IP del Gateway</param>
|
|
/// <returns></returns>
|
|
public string sendRebootGateway(string GWIP)
|
|
{
|
|
string answ = "OK";
|
|
|
|
// !!!FARE!!! deve salvare il riavvio dell'applicazione GATEWAY multiclient
|
|
|
|
return answ;
|
|
}
|
|
|
|
}
|
|
} |