Fix catena init in CACHE (messo gestione redis serialization)
This commit is contained in:
@@ -163,6 +163,9 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.ReportViewer.WinForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
@@ -356,6 +359,7 @@
|
||||
<DependentUpon>DS_Utility.xsd</DependentUpon>
|
||||
</None>
|
||||
<None Include="GMW_vs_SP_GMWTest.scmp" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
|
||||
</packages>
|
||||
+20
-125
@@ -1,4 +1,5 @@
|
||||
using SteamWare;
|
||||
using Newtonsoft.Json;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
@@ -160,12 +161,27 @@ namespace GMW_data
|
||||
{
|
||||
if (memLayer.ML.isInCacheObject("elOperatori"))
|
||||
{
|
||||
elOperatori = (Dictionary<string, string>)memLayer.ML.objCacheObj("elOperatori");
|
||||
if (memLayer.ML.cacheOnRedis)
|
||||
{
|
||||
elOperatori = JsonConvert.DeserializeObject<Dictionary<string, string>>(memLayer.ML.objCacheObj("elOperatori").ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
elOperatori = (Dictionary<string, string>)memLayer.ML.objCacheObj("elOperatori");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elOperatori = ricaricaElOperatori();
|
||||
memLayer.ML.setCacheVal("elOperatori", elOperatori, false);
|
||||
if (memLayer.ML.cacheOnRedis)
|
||||
{
|
||||
string serVal = JsonConvert.SerializeObject(elOperatori);
|
||||
memLayer.ML.setCacheVal("dictVocabolario", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
memLayer.ML.setCacheVal("elOperatori", elOperatori, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -196,128 +212,7 @@ namespace GMW_data
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region area gestione rPI
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="CodMacchina"></param>
|
||||
/// <param name="IPv4"></param>
|
||||
/// <param name="agent"></param>
|
||||
/// <returns></returns>
|
||||
public inputComando registraStartup(string CodMacchina, string IPv4, string agent)
|
||||
{
|
||||
if (memLayer.ML.confReadInt("_logLevel") > 6)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("{0}---------------------------{0}Richiesta registrazione (ri)avvio Macchina {1}", Environment.NewLine, CodMacchina), tipoLog.INFO);
|
||||
}
|
||||
// formatto output
|
||||
inputComando answ = new inputComando();
|
||||
// scrivo remote reboot alive!
|
||||
scriviRemoteReboot(CodMacchina, IPv4, agent);
|
||||
// scrivo PRIMO keep alive
|
||||
scriviPrimoKeepAlive(CodMacchina, DateTime.Now);
|
||||
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scrive un evento di keepalive sulla tabella
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="oraMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public void scriviKeepAlive(string IdxMacchina, DateTime oraMacchina)
|
||||
{
|
||||
#if false
|
||||
// salvo in variabile boolean se registrare keep alive su db o meno
|
||||
bool doWrite = false;
|
||||
string nomeVar = string.Format("KA{0}", IdxMacchina);
|
||||
// in primis controllo se in cache c'è oggetto keep alive x macchina... formato KA{ID-MACCHINA}
|
||||
if (memLayer.ML.isInCacheObject(nomeVar))
|
||||
{
|
||||
// leggo data ora, se è + vecchia di corrente - kaMinUpdSec segno da aggiornare
|
||||
DateTime adesso = DateTime.Now;
|
||||
DateTime lastKA = DateTime.Now;
|
||||
try
|
||||
{
|
||||
lastKA = (DateTime)memLayer.ML.objCacheObj(nomeVar);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (adesso.AddSeconds(-memLayer.ML.CRI("kaMinUpdSec")) > lastKA)
|
||||
{
|
||||
doWrite = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// non c'è in sessione, lo salvo
|
||||
memLayer.ML.setCacheVal(nomeVar, oraMacchina);
|
||||
// indico di fare refresh
|
||||
doWrite = true;
|
||||
}
|
||||
if (doWrite)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (memLayer.ML.confReadBool("forceResetKeepAlive"))
|
||||
{
|
||||
taKeepAlive.Connection.Close();
|
||||
taKeepAlive.Connection.Open();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (taKeepAlive.Connection.State == ConnectionState.Closed)
|
||||
{
|
||||
taKeepAlive.Connection.Open();
|
||||
}
|
||||
}
|
||||
taKeepAlive.UpdateQueryNoStartTime(DateTime.Now, oraMacchina, IdxMacchina);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in scrittura keep alive!{0}oraMacchina:{1} - IdxMacchina:{2}{0}{3}", Environment.NewLine, oraMacchina, IdxMacchina, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// scrive un evento di start di keepalive sulla tabella
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="oraMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public void scriviPrimoKeepAlive(string IdxMacchina, DateTime oraMacchina)
|
||||
{
|
||||
#if false
|
||||
// se non c'è riga macchina insert...
|
||||
if (taKeepAlive.GetData().FindByIdxMacchina(IdxMacchina) == null)
|
||||
{
|
||||
taKeepAlive.Insert(IdxMacchina, DateTime.Now, oraMacchina, DateTime.Now);
|
||||
}
|
||||
else // altrimenti update!
|
||||
{
|
||||
taKeepAlive.UpdateQuery(DateTime.Now, oraMacchina, DateTime.Now, IdxMacchina);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// Registra un evento di RemoteReboot sulla tabella
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="IPv4"></param>
|
||||
/// <param name="agent"></param>
|
||||
/// <returns></returns>
|
||||
public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent)
|
||||
{
|
||||
taRRL.Insert(IdxMacchina, IPv4, agent, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user