FIOX MP/IO: aggiunti metodi getCurrOdlStart e getCurrOdlRow

This commit is contained in:
Samuele E. Locatelli
2019-10-19 10:30:19 +02:00
parent 0f6938b810
commit 9dad20e641
4 changed files with 134 additions and 105 deletions
Vendored
+3 -3
View File
@@ -18,9 +18,9 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=1238']) {
// env.versionNumber = VersionNumber(versionNumberString : '6.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '6.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
withEnv(['NEXT_BUILD_NUMBER=1239']) {
// env.versionNumber = VersionNumber(versionNumberString : '6.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '6.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO'
}
}
+47 -1
View File
@@ -172,7 +172,53 @@ namespace MP_IO.Controllers
}
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 DateTime getCurrOdlStart(string id)
{
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;
}
/// <summary>
/// Restituisce intera riga dell'odl correntemente in lavorazione sulla macchina...
/// es: http://url_site/MP/IO/IOB/getCurrOdlRow/SIMUL_01
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public string getCurrOdlRow(string id)
{
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>
/// Recupera DATI correnti x macchina:
///
+68 -95
View File
@@ -1,6 +1,8 @@
using SteamWare;
using Newtonsoft.Json;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Reflection;
@@ -241,6 +243,40 @@ namespace MapoDb
}
}
public static List<T> DataTableToList<T>(DataTable dt) where T : class, new()
{
List<T> lstItems = new List<T>();
if (dt != null && dt.Rows.Count > 0)
foreach (DataRow row in dt.Rows)
lstItems.Add(ConvertDataRowToGenericType<T>(row));
else
lstItems = null;
return lstItems;
}
private static T ConvertDataRowToGenericType<T>(DataRow row) where T : class, new()
{
Type entityType = typeof(T);
T objEntity = new T();
foreach (DataColumn column in row.Table.Columns)
{
object value = row[column.ColumnName];
if (value == DBNull.Value) value = null;
PropertyInfo property = entityType.GetProperty(column.ColumnName, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Public);
try
{
if (property != null && property.CanWrite)
property.SetValue(objEntity, value, null);
}
catch (Exception ex)
{
throw ex;
}
}
return objEntity;
}
#endregion
#region utility public esposte
@@ -945,17 +981,7 @@ namespace MapoDb
// registro conteggio impiego chiamate REDIS
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:saveCurrODL"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("saveCurrODL: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:saveCurrODL"));
}
saveCallRec("saveCurrODL");
}
string answ = "";
// inizio processing vero e proprio INPUT...
@@ -1052,6 +1078,15 @@ namespace MapoDb
return mHash(string.Format("CurrODL:{0}", idxMacchina));
}
/// <summary>
/// Hash dati Current ODL ROW x la macchina specificata
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
public static string currOdlRowHash(string idxMacchina)
{
return mHash(string.Format("CurrOdlRow:{0}", idxMacchina));
}
/// <summary>
/// Hash dati LIVE x la macchina specificata
/// </summary>
/// <param name="idxMacchina"></param>
@@ -1369,17 +1404,7 @@ namespace MapoDb
bool answ = false;
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:insEnabled"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("insEnabled: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:insEnabled"));
}
saveCallRec("insEnabled");
try
{
answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled"));
@@ -1409,36 +1434,39 @@ namespace MapoDb
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
public static DS_ProdTempi.ODLRow currODLRow(string idxMacchina)
public static DS_ProdTempi.ODLDataTable currODLRowTab(string idxMacchina)
{
DS_ProdTempi.ODLRow answ = null;
DS_ProdTempi.ODLDataTable answTab = null;
string rCall = "";
if (memLayer.ML.CRB("IOB_RedEnab"))
{
saveCallRec("hasODL_row");
try
{
rCall = memLayer.ML.getRSV(currODLHash(idxMacchina));
if (rCall != null && rCall != "")
rCall = memLayer.ML.getRSV(currOdlRowHash(idxMacchina));
if (!string.IsNullOrEmpty(rCall))
{
answ = rCall;
answTab = JsonConvert.DeserializeObject<DS_ProdTempi.ODLDataTable>(rCall);
}
else
{
answ = MapoDb.obj.currODLRow(idxMacchina);
answTab = MapoDb.obj.currODLTab(idxMacchina);
// salvo in redis...
saveCurrODL(idxMacchina, answ);
rCall = JsonConvert.SerializeObject(answTab);
int currOdlRowCacheDur = memLayer.ML.CRI("currOdlRowCacheDur");
memLayer.ML.setRSV(currOdlRowHash(idxMacchina), rCall, currOdlRowCacheDur);
}
}
catch
{ }
catch (Exception exc)
{
logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
}
}
else
{
answ = MapoDb.obj.currODLRow(idxMacchina);
answTab = MapoDb.obj.currODLTab(idxMacchina);
}
return answ;
return answTab;
}
/// <summary>
@@ -1452,18 +1480,7 @@ namespace MapoDb
string rCall = "";
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:hasODL"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("IOB {1} | hasODL: effettuate {0} call", nCall, idxMacchina), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:hasODL"));
}
saveCallRec("hasODL");
try
{
rCall = memLayer.ML.getRSV(currODLHash(idxMacchina));
@@ -1525,18 +1542,7 @@ namespace MapoDb
bool answ = false;
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:sLogEnabled"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("sLogEnabled: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:sLogEnabled"));
}
saveCallRec("sLogEnabled");
try
{
answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled"));
@@ -1562,18 +1568,7 @@ namespace MapoDb
int answ = -1;
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:getCounterTC"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("pzCounterTC: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:getCounterTC"));
}
saveCallRec("getCounterTC");
}
// variabile x controllo dati recuperati
DS_ProdTempi.StatoProdDataTable datiProdAct = null;
@@ -1663,18 +1658,7 @@ namespace MapoDb
string rCall = "";
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:getCounter"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("pzCounter: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:getCounter"));
}
saveCallRec("getCounter");
try
{
rCall = memLayer.ML.getRSV(pzCountHash(idxMacchina));
@@ -1704,18 +1688,7 @@ namespace MapoDb
bool answ = false;
if (memLayer.ML.CRB("IOB_RedEnab"))
{
// conto la richiesta nel contatore REDIS
long nCall = memLayer.ML.setRCntI(mHash("COUNT:pCall:isMulti"));
//... se == nCall2Log scrivo su log e resetto
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
if (nCall >= nCall2Log)
{
// loggo
logger.lg.scriviLog(string.Format("isMulti: effettuate {0} call", nCall), tipoLog.INFO);
// resetto!
memLayer.ML.resetRCnt(mHash("COUNT:pCall:isMulti"));
}
saveCallRec("isMulti");
try
{
answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Multi") == "1");
+16 -6
View File
@@ -449,28 +449,38 @@ namespace MapoDb
return answ;
}
/// <summary>
/// restituisce RIGA dell'ODL attivo (iniziato e NON concluso)
/// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso)
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
public DS_ProdTempi.ODLRow currODLRow(string idxMacchina)
public DS_ProdTempi.ODLDataTable currODLTab(string idxMacchina)
{
DS_ProdTempi.ODLRow answ = null;
logger.lg.scriviLog("Recupero currODLRow da DB!", tipoLog.INFO);
DS_ProdTempi.ODLDataTable answ = null;
logger.lg.scriviLog("Recupero currODLTab da DB!", tipoLog.INFO);
try
{
answ = DataLayer.obj.taODL.getByMacchina(idxMacchina);
}
catch (Exception exc)
{
logger.lg.scriviLog($"Eccezione in recupero currODLTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
}
// recupero con stored NUOVA...
#if false
DS_ProdTempi.ODLDataTable tabOdl = DataLayer.obj.taODL.getByMacchina(idxMacchina);
if (tabOdl.Rows.Count > 0)
{
// solo SE ho idxODL (altrimenti loggo errore)
if (tabOdl[0].IdxODL > 0)
{
answ = tabOdl[0];
answ = tabOdl;
}
else
{
logger.lg.scriviLog($"Errore in currODLRow x idxMacchina {idxMacchina}: IdxODL = 0", tipoLog.ERROR);
}
}
}
#endif
// restituisco!
return answ;
}