From d377c1cc8665b26f67c1e04b20f89786db64e46b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 30 Jun 2025 08:57:05 +0200 Subject: [PATCH] Fix obj DataLayer x ricordione con MapoDb in loop x rebootLog track --- MP-IO/Controllers/IOBController.cs | 14 +++- MP-IO/MP-IO.csproj | 2 +- MP-IO/sendReboot.aspx.cs | 96 +++++++++++++------------- MapoDb/DataLayer.cs | 12 ++-- MapoDb/MapoDb.cs | 21 ++---- MapoDb/Properties/Settings.Designer.cs | 4 +- MapoDb/Properties/Settings.settings | 4 +- MapoDb/app.config | 31 ++++++--- MapoSDK/MapoSDK.csproj | 3 +- 9 files changed, 105 insertions(+), 82 deletions(-) diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 46dcb254..1c21f990 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -2126,9 +2126,21 @@ namespace MP_IO.Controllers { } try { + // uso datalayer che COMPRENDE MapoDb... + DataLayer DataLayerObj = new DataLayer(); + int num2keep = 5; + var rConf = DataLayerObj.ListConfig.Where(x => x.chiave == "").FirstOrDefault(); + if (rConf != null) + { + int.TryParse(rConf.valore, out num2keep); + } + // chiamo registrazione reboot + DataLayerObj.MapoDbObj.registraStartup(id, IPv4, agent, mac, num2keep); +#if false // ora salvo che la macchina è stata (ri)avviata... MapoDb.MapoDb MapoDbObj = new MapoDb.MapoDb(); - MapoDbObj.registraStartup(id, IPv4, agent, mac); + MapoDbObj.registraStartup(id, IPv4, agent, mac); +#endif answ = "OK"; } catch (Exception exc) diff --git a/MP-IO/MP-IO.csproj b/MP-IO/MP-IO.csproj index f4752eca..83299720 100644 --- a/MP-IO/MP-IO.csproj +++ b/MP-IO/MP-IO.csproj @@ -402,7 +402,7 @@ - {973245E4-02C0-4ED1-A81B-1727C5F4CA59} + {973245e4-02c0-4ed1-a81b-1727c5f4ca59} MagData diff --git a/MP-IO/sendReboot.aspx.cs b/MP-IO/sendReboot.aspx.cs index c8df3160..cba7f643 100644 --- a/MP-IO/sendReboot.aspx.cs +++ b/MP-IO/sendReboot.aspx.cs @@ -3,55 +3,57 @@ using System; namespace MP_IO { - public partial class sendReboot : System.Web.UI.Page - { - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) + public partial class sendReboot : System.Web.UI.Page { - // legge i get x registrare che una macchina è stata riavviata - string idxMacchina = ""; - string IPv4 = ""; - string agent = ""; - string macAddr = ""; - try - { - idxMacchina = Request.QueryString["idxMacchina"]; - } - catch - { } - try - { - macAddr = Request.QueryString["mac"]; // opzionale, mac address!!! - } - catch - { } - try - { - // recupero IP del client remoto - IPv4 = Request.UserHostName; - agent = Request.UserAgent; - } - catch - { } - try - { - // ora salvo che la macchina è stata (ri)avviata... - MapoDb.MapoDb MapoDbObj = new MapoDb.MapoDb(); - MapoDbObj.registraStartup(idxMacchina, IPv4, agent, macAddr); - } - catch (Exception exc) - { - if (memLayer.ML.CRI("_logLevel") > 5) + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) { - string errore = string.Format("Errore: {0}{1}", Environment.NewLine, exc); - logger.lg.scriviLog(errore, tipoLog.EXCEPTION); - lblOut.Text = errore; + // legge i get x registrare che una macchina è stata riavviata + string idxMacchina = ""; + string IPv4 = ""; + string agent = ""; + string macAddr = ""; + try + { + idxMacchina = Request.QueryString["idxMacchina"]; + } + catch + { } + try + { + macAddr = Request.QueryString["mac"]; // opzionale, mac address!!! + } + catch + { } + try + { + // recupero IP del client remoto + IPv4 = Request.UserHostName; + agent = Request.UserAgent; + } + catch + { } + try + { + // ora salvo che la macchina è stata (ri)avviata... + MapoDb.MapoDb MapoDbObj = new MapoDb.MapoDb(); + // hard coded num2keep valori reboot + int num2keep = 10; + MapoDbObj.registraStartup(idxMacchina, IPv4, agent, macAddr, num2keep); + } + catch (Exception exc) + { + if (memLayer.ML.CRI("_logLevel") > 5) + { + string errore = string.Format("Errore: {0}{1}", Environment.NewLine, exc); + logger.lg.scriviLog(errore, tipoLog.EXCEPTION); + lblOut.Text = errore; + } + } } - } } - } } \ No newline at end of file diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 86e13e06..fa50d152 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -20,6 +20,7 @@ namespace MapoDb /// public class DataLayer { + #region Public Fields /// @@ -110,11 +111,14 @@ namespace MapoDb // init oggetto MapoDb MapoDbObj = new MapoDb(); -#if false - // init message channel... - BroadastMsgPipe = new MessagePipe(connRedis, Constants.BROADCAST_M_PIPE); -#endif + // init config.. + ListConfig = taConfig.GetData(); } + /// + /// Valori config da tabella corrente + /// + public DS_Utility.ConfigDataTable ListConfig = new DS_Utility.ConfigDataTable(); + /// /// Init class diff --git a/MapoDb/MapoDb.cs b/MapoDb/MapoDb.cs index d1a47ae7..39e31380 100644 --- a/MapoDb/MapoDb.cs +++ b/MapoDb/MapoDb.cs @@ -47,14 +47,7 @@ namespace MapoDb public MapoDb() { AvviaTabAdapt(); - // aggiungo una copia dei valori config correnti... - DataLayer man = new DataLayer(); - listConfig = man.taConfig.GetData(); } - /// - /// Valori config da tabella corrente - /// - private DS_Utility.ConfigDataTable listConfig = new DS_Utility.ConfigDataTable(); #endregion Public Constructors @@ -570,8 +563,9 @@ namespace MapoDb /// /// /// mac address (inviato dalla macchina) + /// num record da mantenere x reboot /// - public inputComandoMapo registraStartup(string idxMacchina, string IPv4, string agent, string macAddr) + public inputComandoMapo registraStartup(string idxMacchina, string IPv4, string agent, string macAddr, int num2keep) { if (memLayer.ML.CRI("_logLevel") > 6) { @@ -580,7 +574,7 @@ namespace MapoDb // formatto output inputComandoMapo answ = new inputComandoMapo(); // scrivo remote reboot alive! - scriviRemoteReboot(idxMacchina, IPv4, agent, macAddr); + scriviRemoteReboot(idxMacchina, IPv4, agent, macAddr, num2keep); // scrivo PRIMO keep alive scriviPrimoKeepAlive(idxMacchina, DateTime.Now); @@ -671,17 +665,12 @@ namespace MapoDb /// /// /// + /// num record da mantenere x reboot /// - public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent, string macAddr) + public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent, string macAddr, int num2keep) { taRRL.Insert(IdxMacchina, IPv4, agent, DateTime.Now, macAddr); // chiama stored x ripulire dati - int num2keep = 5; - var rConf = listConfig.Where(x => x.chiave == "").FirstOrDefault(); - if (rConf != null) - { - int.TryParse(rConf.valore, out num2keep); - } taRRL.KeepLatest(num2keep); } diff --git a/MapoDb/Properties/Settings.Designer.cs b/MapoDb/Properties/Settings.Designer.cs index fb665dea..bb92a5d6 100644 --- a/MapoDb/Properties/Settings.Designer.cs +++ b/MapoDb/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace MapoDb.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -93,7 +93,7 @@ namespace MapoDb.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] [global::System.Configuration.DefaultSettingValueAttribute("Data Source=SQL2016DEV;Initial Catalog=MoonPro_FluxData;Persist Security Info=Tru" + - "e;User ID=sa;Password=keyhammer16;TrustServerCertificate=True")] + "e;User ID=sa;Password=keyhammer16;TrustServerCertificate=True;")] public string MoonPro_FluxDataConnectionString { get { return ((string)(this["MoonPro_FluxDataConnectionString"])); diff --git a/MapoDb/Properties/Settings.settings b/MapoDb/Properties/Settings.settings index 3afda9f2..d907681a 100644 --- a/MapoDb/Properties/Settings.settings +++ b/MapoDb/Properties/Settings.settings @@ -53,10 +53,10 @@ <?xml version="1.0" encoding="utf-16"?> <SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ConnectionString>Data Source=SQL2016DEV;Initial Catalog=MoonPro_FluxData;Persist Security Info=True;User ID=sa;Password=keyhammer16;TrustServerCertificate=True</ConnectionString> + <ConnectionString>Data Source=SQL2016DEV;Initial Catalog=MoonPro_FluxData;Persist Security Info=True;User ID=sa;Password=keyhammer16;TrustServerCertificate=True;</ConnectionString> <ProviderName>System.Data.SqlClient</ProviderName> </SerializableConnectionString> - Data Source=SQL2016DEV;Initial Catalog=MoonPro_FluxData;Persist Security Info=True;User ID=sa;Password=keyhammer16;TrustServerCertificate=True + Data Source=SQL2016DEV;Initial Catalog=MoonPro_FluxData;Persist Security Info=True;User ID=sa;Password=keyhammer16;TrustServerCertificate=True; \ No newline at end of file diff --git a/MapoDb/app.config b/MapoDb/app.config index 02bee836..d123208f 100644 --- a/MapoDb/app.config +++ b/MapoDb/app.config @@ -5,14 +5,29 @@
- - - - - - - - + + + + + + + + diff --git a/MapoSDK/MapoSDK.csproj b/MapoSDK/MapoSDK.csproj index 5ebb6997..2dde5d0f 100644 --- a/MapoSDK/MapoSDK.csproj +++ b/MapoSDK/MapoSDK.csproj @@ -9,7 +9,7 @@ Properties MapoSDK MapoSDK - v4.6.2 + v4.0 Samuele E. Locatelli EgalWare SDK for MAPO solutions @@ -19,6 +19,7 @@ true + true