diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs
index f4284443..bd5080e6 100644
--- a/MP-IO/Controllers/IOBController.cs
+++ b/MP-IO/Controllers/IOBController.cs
@@ -13,15 +13,11 @@ namespace MP_IO.Controllers
{
#region Public Methods
- ///
- /// SALVA x macchina KVP parametro/valore:
+ /// SALVA x macchina KVP parametro/valore:
///
/// GET: IOB/addOptPar/SIMUL_03?pName=PZREQ&pValue=1000
///
- ///
- ///
- ///
- ///
+ ///
public string addOptPar(string id, string pName, string pValue)
{
string answ = "";
@@ -39,8 +35,7 @@ namespace MP_IO.Controllers
return answ;
}
- ///
- /// AGGIUNGE TASK richiesto x macchina:
+ /// AGGIUNGE TASK richiesto x macchina:
///
/// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512
/// GET: IOB/addTask2Exe/3010?taskName=stopSetup&taskVal=T190406101512
@@ -48,10 +43,7 @@ namespace MP_IO.Controllers
/// GET: IOB/addTask2Exe/SIMUL_03?taskName=setComm&taskVal=ODL_0000123
/// GET: IOB/addTask2Exe/SIMUL_03?taskName=setArt&taskVal=ART_0000321
///
- ///
- ///
- ///
- ///
+ ///
public string addTask2Exe(string id, string taskName, string taskVal)
{
string answ = "";
@@ -79,7 +71,6 @@ namespace MP_IO.Controllers
return answ;
}
-
// GET: IOB/enabled/SIMUL_03
public string enabled(string id)
{
@@ -106,90 +97,6 @@ namespace MP_IO.Controllers
return answ;
}
- ///
- /// Processa una chiamata POST per l'invio di un array Json di oggetti rawTransfer (generiche info da deserializzare)
- /// POST: IOB/rawTransfJson/SIMUL_03
- ///
- /// ID dell'IOB
- ///
- [HttpPost]
- public string rawTransfJson(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 != "")
- {
- DataLayer DataLayerObj = new DataLayer();
- // deserializzo come un dictionary generico di oggetti rawDataType/string
- List receivedData = new List();
- // procedo a deserializzare in blocco l'oggetto...
- try
- {
- // deserializzo.
- receivedData = JsonConvert.DeserializeObject>(content);
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Errore in fase deserializzazione rawTransfJson{Environment.NewLine}{exc}");
- answ = "NO";
- }
- // se ho qualcosa da processare...
- if (receivedData != null)
- {
- try
- {
- foreach (var item in receivedData)
- {
-
- // per ora salvo su REDIS ultimo x tipo
- DataLayerObj.lastRawTrasfData = JsonConvert.SerializeObject(item.mesContent);
- //DataLayerObj.lastRawTrasfData = item.mesContent;
-
- // !!! FixMe ToDo fare
- // deserializzazione e salvataggio su MongoDB
- // salvataggio su tab RawTrasf su DB IS
-
- // in base al tipo processo...
- switch (item.mesType)
- {
- case rawTransfType.ND:
- break;
- case rawTransfType.IcoelBatch:
- break;
- case rawTransfType.IcoelVarInfo:
- break;
- default:
- break;
- }
- insDone++;
- }
- // se vuoto --> OK!
- if (string.IsNullOrEmpty(answ))
- {
- answ = $"OK {insDone} processed";
- }
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Errore in fase invio valori rawTransfJson{Environment.NewLine}{exc}");
- answ = "NO";
- }
- }
- }
- return answ;
- }
-
///
/// Processa una chiamata POST per l'invio di un array Json di oggetti input (EVENTI)
/// POST: IOB/evListJson/SIMUL_03
@@ -353,7 +260,8 @@ namespace MP_IO.Controllers
try
{
List currParams = DataLayerObj.getCurrObjItems(id);
- // ora per ogni valore RICEVUTO costruisco un oggetto in innovazioni da inviare...x salvare in stato parametri...
+ // ora per ogni valore RICEVUTO costruisco un oggetto in innovazioni da
+ // inviare...x salvare in stato parametri...
List innovazioni = new List();
foreach (var item in receivedData.fluxData)
{
@@ -365,7 +273,8 @@ namespace MP_IO.Controllers
// aggiorno valore e data
trovato.value = item.valore;
trovato.lastRead = DateTime.Now;
- // se fosse un valore WRITE e mi ha dato un valore vuoto --> mando un fix x riscrittura
+ // se fosse un valore WRITE e mi ha dato un valore vuoto --> mando
+ // un fix x riscrittura
if (trovato.writable && string.IsNullOrEmpty(item.valore))
{
logger.lg.scriviLog($"flogJson | verifica parametri | {trovato.uid} | reqVal: {trovato.reqValue}");
@@ -401,136 +310,36 @@ namespace MP_IO.Controllers
return answ;
}
-
- // GET: IOB/ulog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999&matrOpr=0=0&label=&valNum
- public string ulog(string id, string flux, string valore, string dtEve, string dtCurr, string cnt, string matrOpr, string label, string valNum)
- {
- 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($"ulog | Valori letti: idxMacchina: {id} | flux: {flux} valore: {valore} | matrOpr: {matrOpr} | label: {label} | valNum: {valNum}", tipoLog.INFO);
- }
- try
- {
- DataLayer DataLayerObj = new DataLayer();
- int count = 0;
- int nMatrOpr = 0;
- int nValNum = 0;
- Int32.TryParse(cnt, out count);
- Int32.TryParse(matrOpr, out nMatrOpr);
- Int32.TryParse(valNum, out nValNum);
- answ = DataLayerObj.processUserLog(id, flux, valore, dtEve, dtCurr, count, nMatrOpr, label, nValNum);
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Errore in ulog{Environment.NewLine}{exc}");
- answ = "NO";
- }
- return answ;
- }
///
- /// Processa una chiamata POST per l'invio di una List Json 1+ UserAction (contiene controlli, scarti, dichiarazioni)
- /// POST: IOB/ulogJson/SIMUL_03
- ///
- /// ID dell'IOB
- ///
- [HttpPost]
- public string ulogJson(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 != "")
- {
- DataLayer DataLayerObj = new DataLayer();
- // procedo a deserializzare in blocco l'oggetto...
- ulogJsonPayload receivedData = new ulogJsonPayload();
- try
- {
- // deserializzo.
- receivedData = JsonConvert.DeserializeObject(content);
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Errore in fase deserializzazione ulogJson{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 = DataLayerObj.processUserLog(id, item.flux, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt, item.matrOpr, item.label, item.valNum);
- }
- // se vuoto --> OK!
- if (string.IsNullOrEmpty(answ))
- {
- answ = $"OK {insDone} processed";
- }
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Errore in fase invio valori ulogJson{Environment.NewLine}{exc}");
- answ = "NO";
- }
- }
- }
- return answ;
-
- }
-
- ///
- /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE), e CONFERMA produzione...
+ /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE),
+ /// e CONFERMA produzione...
///
/// GET: IOB/forceSplitOdl/SIMUL_03
- ///
///
///
/// Esito chiamata (OK/vuoto)
public string forceSplitOdl(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il
+ // carattere "|" che poi trasformiamo ora in "#"
id = id.Replace("|", "#");
DataLayer DataLayerObj = new DataLayer();
return DataLayerObj.AutoStartOdl(id, true, true, 100, "");
}
- ///
- /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE), e CONFERMA produzione...
+ /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità
+ /// RIMANENTE), e CONFERMA produzione...
///
/// GET: IOB/forceSplitOdl/SIMUL_03?doConfirm=true&qtyFromLast=true&roundStep=150&extOrderCode=ABCDE1234
///
- ///
- /// id impianto
- ///
- ///
- ///
- /// Cod esterno da legare all'ODL x tracciare lotti prod
+ /// id impianto Cod esterno da legare all'ODL x tracciare lotti prod
/// Esito chiamata (OK/vuoto)
public string forceSplitOdlFull(string id, bool doConfirm, bool qtyFromLast, int? roundStep, string keyRichiesta = "")
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il
+ // carattere "|" che poi trasformiamo ora in "#"
id = id.Replace("|", "#");
DataLayer DataLayerObj = new DataLayer();
if (roundStep == null)
@@ -544,7 +353,6 @@ namespace MP_IO.Controllers
/// Recupera COUNTER x macchina:
///
/// GET: IOB/getCounter/5
- ///
///
///
///
@@ -568,7 +376,6 @@ namespace MP_IO.Controllers
/// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
///
/// GET: IOB/getCounterTCRec/5
- ///
///
///
///
@@ -592,13 +399,13 @@ namespace MP_IO.Controllers
/// Recupera DATI correnti x macchina:
///
/// GET: IOB/getCurrData/SIMUL_03
- ///
///
///
/// Json contenente la riga di stato macchina
public string getCurrData(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // 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...)
@@ -620,13 +427,13 @@ namespace MP_IO.Controllers
/// Recupera ODL corrente x macchina:
///
/// GET: IOB/getCurrODL/SIMUL_03
- ///
///
///
///
public string getCurrODL(string id)
{
- // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // carattere "|" che poi trasformiamo ora in "#"
id = id.Replace("|", "#");
string answ = "";
try
@@ -650,7 +457,8 @@ namespace MP_IO.Controllers
///
public string getCurrOdlRow(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // 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;
@@ -676,7 +484,8 @@ namespace MP_IO.Controllers
///
public string getCurrOdlStart(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // 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...
@@ -705,7 +514,8 @@ namespace MP_IO.Controllers
///
public string getCurrStatoRow(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // 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;
@@ -764,14 +574,16 @@ namespace MP_IO.Controllers
}
///
- /// Restituisce il valore dello stato di IDLE della macchina, quindi SOLO SE NON é in lavoro e già convertito in minuti...
+ /// 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
///
///
///
public int getIdlePeriod(string id)
{
- // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#"
+ // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il
+ // carattere "|" che poi trasformiamo ora in "#"
id = id.Replace("|", "#");
int answ = 0;
DataLayer DataLayerObj = new DataLayer();
@@ -801,7 +613,8 @@ namespace MP_IO.Controllers
}
///
- /// Restituisce il (primo) codice IOB da dover gestire (se un IOBMAN chiede di gestirne uno in +...)
+ /// Restituisce il (primo) codice IOB da dover gestire (se un IOBMAN chiede di gestirne uno
+ /// in +...)
///
/// IP del Gateway
///
@@ -809,7 +622,8 @@ namespace MP_IO.Controllers
{
string answ = "";
- // !!!FARE!!! temporanemanete genera a caso vuoto o 3000 x permettere test... altrimenti gestisce VERA coda... secondi pari...
+ // !!!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)
@@ -888,7 +702,8 @@ namespace MP_IO.Controllers
}
///
- /// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di oggetti objItem
+ /// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di
+ /// oggetti objItem
/// GET: IOB/getObjItems2Write/SIMUL_03
///
/// ID dell'IOB
@@ -928,7 +743,6 @@ namespace MP_IO.Controllers
/// Recupera TASK richiesto x macchina:
///
/// GET: IOB/getOptPar/SIMUL_03
- ///
///
///
/// Json contenente 1..n task da eseguire
@@ -954,7 +768,6 @@ namespace MP_IO.Controllers
/// Recupera TASK richiesto x macchina:
///
/// GET: IOB/getTask2Exe/SIMUL_03
- ///
///
///
/// Json contenente 1..n task da eseguire
@@ -1087,11 +900,96 @@ namespace MP_IO.Controllers
return answ;
}
+ ///
+ /// Processa una chiamata POST per l'invio di un array Json di oggetti rawTransfer
+ /// (generiche info da deserializzare)
+ /// POST: IOB/rawTransfJson/SIMUL_03
+ ///
+ /// ID dell'IOB
+ ///
+ [HttpPost]
+ public string rawTransfJson(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 != "")
+ {
+ DataLayer DataLayerObj = new DataLayer();
+ // deserializzo come un dictionary generico di oggetti rawDataType/string
+ List receivedData = new List();
+ // procedo a deserializzare in blocco l'oggetto...
+ try
+ {
+ // deserializzo.
+ receivedData = JsonConvert.DeserializeObject>(content);
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Errore in fase deserializzazione rawTransfJson{Environment.NewLine}{exc}");
+ answ = "NO";
+ }
+ // se ho qualcosa da processare...
+ if (receivedData != null)
+ {
+ try
+ {
+ foreach (var item in receivedData)
+ {
+ // per ora salvo su REDIS ultimo x tipo
+ DataLayerObj.lastRawTrasfData = JsonConvert.SerializeObject(item.mesContent);
+ //DataLayerObj.lastRawTrasfData = item.mesContent;
+
+ // !!! FixMe ToDo fare deserializzazione e salvataggio su MongoDB
+ // salvataggio su tab RawTrasf su DB IS
+
+ // in base al tipo processo...
+ switch (item.mesType)
+ {
+ case rawTransfType.ND:
+ break;
+
+ case rawTransfType.IcoelBatch:
+ break;
+
+ case rawTransfType.IcoelVarInfo:
+ break;
+
+ default:
+ break;
+ }
+ insDone++;
+ }
+ // se vuoto --> OK!
+ if (string.IsNullOrEmpty(answ))
+ {
+ answ = $"OK {insDone} processed";
+ }
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Errore in fase invio valori rawTransfJson{Environment.NewLine}{exc}");
+ answ = "NO";
+ }
+ }
+ }
+ return answ;
+ }
+
///
/// ELIMINA TASK richiesto x macchina:
///
/// GET: IOB/remOptPar/SIMUL_03?pName=PZREQ
- ///
///
///
///
@@ -1116,7 +1014,6 @@ namespace MP_IO.Controllers
/// ELIMINA TASK richiesto x macchina:
///
/// GET: IOB/remTask2Exe/SIMUL_03?taskName=T180326160502
- ///
///
///
///
@@ -1151,7 +1048,6 @@ namespace MP_IO.Controllers
/// Effettua RESET dell'ODL corrente x macchina:
///
/// GET: IOB/resetCurrODL/5
- ///
///
///
///
@@ -1177,7 +1073,8 @@ namespace MP_IO.Controllers
}
else
{
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // 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))
@@ -1207,7 +1104,8 @@ namespace MP_IO.Controllers
}
///
- /// Processa una chiamata POST per l'invio di un array Json di oggetti di conf DataItems (es per MTC)
+ /// Processa una chiamata POST per l'invio di un array Json di oggetti di conf DataItems (es
+ /// per MTC)
/// PUT: IOB/saveDataItems/SIMUL_03
///
/// ID dell'IOB
@@ -1223,7 +1121,8 @@ namespace MP_IO.Controllers
}
else
{
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // 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))
@@ -1256,10 +1155,10 @@ namespace MP_IO.Controllers
}
///
- /// SALVA in blocco un incremento pezzi x macchina restituendo il valore appena inviato o, se mancasse chaive redis, del valore da DB
+ /// SALVA in blocco un incremento pezzi x macchina restituendo il valore appena inviato o,
+ /// se mancasse chaive redis, del valore da DB
///
/// GET: IOB/savePzCountInc/5?qty=10
- ///
///
/// codice macchina
/// num peziz da salvare in blocco
@@ -1291,10 +1190,8 @@ namespace MP_IO.Controllers
///
///
[HttpPost]
- //public string sendAlarmBankUpdate(string id)
public string sendAlarmBankUpdate(string id, string memAddr, int index, int currStatus)
{
-
DataLayer DataLayerObj = new DataLayer();
// esempio valido x MAPO
string answ = "";
@@ -1305,7 +1202,8 @@ namespace MP_IO.Controllers
}
else
{
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // 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))
@@ -1340,16 +1238,11 @@ namespace MP_IO.Controllers
return answ;
// esempio GWMS
-
}
-
- ///
- /// Salva MAC adress + IP dopo il reboot
- /// GET: IOB/sendReboot?idxMacchina=5&mac=18:C0:4D:37:3C:8C
- ///
- /// IP del Gateway
- ///
+ /// Salva MAC adress + IP dopo il reboot
+ /// GET: IOB/sendReboot?idxMacchina=5&mac=18:C0:4D:37:3C:8C IP
+ /// del Gateway
public string sendReboot(string idxMacchina, string mac)
{
string answ = "NO";
@@ -1396,10 +1289,10 @@ namespace MP_IO.Controllers
}
///
- /// SALVA Counter x macchina restituendo il valore appena inviato o, se mancasse chiave redis, del valore da DB
+ /// SALVA Counter x macchina restituendo il valore appena inviato o, se mancasse chiave
+ /// redis, del valore da DB
///
/// GET: IOB/setCounter/5?counter=10
- ///
///
/// cod macchina
/// contapezzi da salvare
@@ -1490,7 +1383,8 @@ namespace MP_IO.Controllers
}
else
{
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // 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))
@@ -1548,6 +1442,105 @@ namespace MP_IO.Controllers
return answ;
}
+ // GET: IOB/ulog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999&matrOpr=0=0&label=&valNum
+ public string ulog(string id, string flux, string valore, string dtEve, string dtCurr, string cnt, string matrOpr, string label, string valNum)
+ {
+ 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($"ulog | Valori letti: idxMacchina: {id} | flux: {flux} valore: {valore} | matrOpr: {matrOpr} | label: {label} | valNum: {valNum}", tipoLog.INFO);
+ }
+ try
+ {
+ DataLayer DataLayerObj = new DataLayer();
+ int count = 0;
+ int nMatrOpr = 0;
+ int nValNum = 0;
+ Int32.TryParse(cnt, out count);
+ Int32.TryParse(matrOpr, out nMatrOpr);
+ Int32.TryParse(valNum, out nValNum);
+ answ = DataLayerObj.processUserLog(id, flux, valore, dtEve, dtCurr, count, nMatrOpr, label, nValNum);
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Errore in ulog{Environment.NewLine}{exc}");
+ answ = "NO";
+ }
+ return answ;
+ }
+
+ ///
+ /// Processa una chiamata POST per l'invio di una List Json 1+ UserAction (contiene
+ /// controlli, scarti, dichiarazioni)
+ /// POST: IOB/ulogJson/SIMUL_03
+ ///
+ /// ID dell'IOB
+ ///
+ [HttpPost]
+ public string ulogJson(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 != "")
+ {
+ DataLayer DataLayerObj = new DataLayer();
+ // procedo a deserializzare in blocco l'oggetto...
+ ulogJsonPayload receivedData = new ulogJsonPayload();
+ try
+ {
+ // deserializzo.
+ receivedData = JsonConvert.DeserializeObject(content);
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Errore in fase deserializzazione ulogJson{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 = DataLayerObj.processUserLog(id, item.flux, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt, item.matrOpr, item.label, item.valNum);
+ }
+ // se vuoto --> OK!
+ if (string.IsNullOrEmpty(answ))
+ {
+ answ = $"OK {insDone} processed";
+ }
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Errore in fase invio valori ulogJson{Environment.NewLine}{exc}");
+ answ = "NO";
+ }
+ }
+ }
+ return answ;
+ }
+
///
/// 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
@@ -1608,7 +1601,8 @@ namespace MP_IO.Controllers
}
else
{
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // 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))
@@ -1641,7 +1635,6 @@ namespace MP_IO.Controllers
return answ;
}
-
#endregion Public Methods
}
}
\ No newline at end of file