Continuo metodi x calcolo durata periodo IDLE (da finire!!!)
This commit is contained in:
@@ -220,6 +220,60 @@ namespace MP_IO.Controllers
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce intera riga dello stato di macchina...
|
||||
/// es: http://url_site/MP/IO/IOB/getCurrStatoRow/SIMUL_01
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public string getCurrStatoRow(string id)
|
||||
{
|
||||
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...
|
||||
/// es: http://url_site/MP/IO/IOB/getIdlePeriod/SIMUL_01
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int getIdlePeriod(string id)
|
||||
{
|
||||
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
|
||||
|
||||
// calcolo SE sia idle... !!!FIXME
|
||||
if (currData[0].IdxStato != 13)
|
||||
{
|
||||
// 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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MP_MON.Models;
|
||||
using MapoDb;
|
||||
using MP_MON.Models;
|
||||
using Newtonsoft.Json;
|
||||
using SteamWare;
|
||||
using System;
|
||||
@@ -26,13 +27,10 @@ namespace MP_MON.Controllers
|
||||
{
|
||||
int dataRefresh = 2000;
|
||||
string answ = "";
|
||||
answ = dataSer;
|
||||
if (answ == null || answ == "")
|
||||
answ = DataLayer.obj.currMSE;
|
||||
if (!string.IsNullOrEmpty(answ))
|
||||
{
|
||||
var dati = db.stp_MSE_getData(dataRefresh).ToList();
|
||||
// serializzo
|
||||
answ = JsonConvert.SerializeObject(dati);
|
||||
dataSer = answ;
|
||||
List<MappaStatoExpl> dati = getDbSaveRedis(dataRefresh);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -41,7 +39,7 @@ namespace MP_MON.Controllers
|
||||
{
|
||||
int dataRefresh = 2000;
|
||||
// salvo idxMacc in sessione se c'è...
|
||||
if (IdxMacchina != "" && IdxMacchina != null)
|
||||
if (!string.IsNullOrEmpty(IdxMacchina))
|
||||
{
|
||||
memLayer.ML.setSessionVal("IdxMacchina", IdxMacchina);
|
||||
}
|
||||
@@ -56,21 +54,22 @@ namespace MP_MON.Controllers
|
||||
catch
|
||||
{ }
|
||||
List<MappaStatoExpl> dati = new List<MappaStatoExpl>();
|
||||
if (dataSer != "" && dataSer != null)
|
||||
string currMse = DataLayer.obj.currMSE;
|
||||
if (!string.IsNullOrEmpty(currMse))
|
||||
{
|
||||
try
|
||||
{
|
||||
dati = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(dataSer);
|
||||
dati = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currMse);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
getDbSaveRedis(dataRefresh, hMSE, out dati);
|
||||
dati = getDbSaveRedis(dataRefresh);
|
||||
logger.lg.scriviLog(string.Format("Recuperata MSE da DB{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getDbSaveRedis(dataRefresh, hMSE, out dati);
|
||||
dati = getDbSaveRedis(dataRefresh);
|
||||
}
|
||||
// filtro dati SOLO PER la macchina che mi interessa... SE C'E'...
|
||||
string reqView = "_StatusMap";
|
||||
@@ -93,43 +92,18 @@ namespace MP_MON.Controllers
|
||||
return PartialView(reqView, dati);
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupera dati da DB e salva su REDIS
|
||||
/// Restituisce dati da DB (e li salva su REDIS...)
|
||||
/// </summary>
|
||||
/// <param name="dataRefresh"></param>
|
||||
/// <param name="hMSE"></param>
|
||||
/// <param name="dati"></param>
|
||||
private void getDbSaveRedis(int dataRefresh, string hMSE, out List<MappaStatoExpl> dati)
|
||||
/// <param name="dataRefresh">Parametro x procedura ricalcolo MSE</param>
|
||||
private List<MappaStatoExpl> getDbSaveRedis(int dataRefresh)
|
||||
{
|
||||
List<MappaStatoExpl> dati = new List<MappaStatoExpl>();
|
||||
// se non c'è rileggo...
|
||||
logger.lg.scriviLog("Recuperata MSE da DB");
|
||||
dati = db.stp_MSE_getData(dataRefresh).ToList();
|
||||
// serializzo
|
||||
dataSer = JsonConvert.SerializeObject(dati);
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash chaive dati MSE
|
||||
/// </summary>
|
||||
protected string hMSE
|
||||
{
|
||||
get
|
||||
{
|
||||
return MapoDb.DataLayer.hMSE();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Dati MSE serializzati in REDIS (get/set)
|
||||
/// </summary>
|
||||
protected string dataSer
|
||||
{
|
||||
get
|
||||
{
|
||||
logger.lg.scriviLog("Recuperata MSE da REDIS");
|
||||
return memLayer.ML.getRSV(hMSE);
|
||||
}
|
||||
set
|
||||
{
|
||||
memLayer.ML.setRSV(hMSE, value, memLayer.ML.CRI("MSE_cacheDuration"));
|
||||
}
|
||||
DataLayer.obj.currMSE = JsonConvert.SerializeObject(dati);
|
||||
return dati;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
+83
-4
@@ -1087,6 +1087,15 @@ namespace MapoDb
|
||||
return mHash(string.Format("CurrOdlRow:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati Current StatoMacchina x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static string currStatoMaccHash(string idxMacchina)
|
||||
{
|
||||
return mHash(string.Format("CurrStatoMacc:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati LIVE x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
@@ -1136,9 +1145,36 @@ namespace MapoDb
|
||||
/// Hash dati MSE
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string hMSE()
|
||||
public static string hMSE
|
||||
{
|
||||
return mHash(string.Format("hMSE_DATA"));
|
||||
get
|
||||
{
|
||||
return mHash(string.Format("hMSE_DATA"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione MSE
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Dati MSE serializzati in REDIS (get/set)
|
||||
/// </summary>
|
||||
public string currMSE
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
logger.lg.scriviLog("Richiesta MSE da REDIS");
|
||||
answ = memLayer.ML.getRSV(hMSE);
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
int MSE_cacheDuration = memLayer.ML.CRI("MSE_cacheDuration");
|
||||
memLayer.ML.setRSV(hMSE, value, MSE_cacheDuration);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1215,7 +1251,6 @@ namespace MapoDb
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region gestione OPT PARAMETERS macchina
|
||||
|
||||
/// <summary>
|
||||
@@ -1288,8 +1323,52 @@ namespace MapoDb
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione dati macchina
|
||||
#region gestione stato macchina
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore dell'intera RIGA stato macchina corrente (da redis o da DB se non trovata...)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static DS_applicazione.StatoMacchineDataTable currSMTab(string idxMacchina)
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable answTab = null;
|
||||
string rCall = "";
|
||||
if (memLayer.ML.CRB("IOB_RedEnab"))
|
||||
{
|
||||
saveCallRec("hasStatoMacc");
|
||||
try
|
||||
{
|
||||
rCall = memLayer.ML.getRSV(currStatoMaccHash(idxMacchina));
|
||||
if (!string.IsNullOrEmpty(rCall))
|
||||
{
|
||||
answTab = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(rCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
answTab = MapoDb.obj.currStatoMaccTab(idxMacchina);
|
||||
// salvo in redis...
|
||||
rCall = JsonConvert.SerializeObject(answTab);
|
||||
int currStatoMaccCacheDur = memLayer.ML.CRI("currStatoMaccCacheDur");
|
||||
memLayer.ML.setRSV(currStatoMaccHash(idxMacchina), rCall, currStatoMaccCacheDur);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
answTab = MapoDb.obj.currStatoMaccTab(idxMacchina);
|
||||
}
|
||||
return answTab;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione dati macchina
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
|
||||
|
||||
+19
-15
@@ -465,22 +465,26 @@ namespace MapoDb
|
||||
{
|
||||
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)
|
||||
// restituisco!
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public DS_applicazione.StatoMacchineDataTable currStatoMaccTab(string idxMacchina)
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable answ = null;
|
||||
logger.lg.scriviLog("Recupero currStatoMaccTab da DB!", tipoLog.INFO);
|
||||
try
|
||||
{
|
||||
// solo SE ho idxODL (altrimenti loggo errore)
|
||||
if (tabOdl[0].IdxODL > 0)
|
||||
{
|
||||
answ = tabOdl;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.lg.scriviLog($"Errore in currODLRow x idxMacchina {idxMacchina}: IdxODL = 0", tipoLog.ERROR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
answ = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog($"Eccezione in recupero currStatoMaccTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
}
|
||||
// restituisco!
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@
|
||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.ReportViewer.WinForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -68,11 +74,13 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
|
||||
+27
-2
@@ -1,12 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="MapoDb.Properties.Settings.MoonProConnectionString" connectionString="Data Source=SQL2016DEV;Initial Catalog=MoonPro;Persist Security Info=True;User ID=sa;Password=keyhammer16;" providerName="System.Data.SqlClient" />
|
||||
<add name="MapoDb.Properties.Settings.MoonPro_IS_ConnectionString" connectionString="Data Source=SQL2016DEV;Initial Catalog=MoonPro_IS_Donati;Persist Security Info=True;User ID=sa;Password=keyhammer16" providerName="System.Data.SqlClient" />
|
||||
<add name="MapoDb.Properties.Settings.C_TRACKConnectionString" connectionString="Data Source=SQL2016DEV;Initial Catalog=C_TRACK;Persist Security Info=True;User ID=sa;Password=keyhammer16" providerName="System.Data.SqlClient" />
|
||||
<add name="MapoDb.Properties.Settings.MoonPro_ES3ConnectionString" connectionString="Data Source=sql2016dev;Initial Catalog=MoonPro_ES3;Persist Security Info=True;User ID=sa;Password=keyhammer16" providerName="System.Data.SqlClient" />
|
||||
<add name="MapoModel" connectionString="data source=SQL2016DEV;initial catalog=MoonPro;persist security info=True;user id=sa;password=keyhammer16;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||
@@ -23,7 +26,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
@@ -35,8 +38,30 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Channels" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="mssqllocaldb" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net462" />
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net462" />
|
||||
<package id="EntityFramework.it" version="6.2.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net462" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net462" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user