From c2865dfd2b45257ee3fd66915141233cb2b0dc23 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 22 Oct 2019 18:00:02 +0200 Subject: [PATCH] Revisione test pingServer --- IOB-WIN/IobGeneric.cs | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs index 84a0834f..2f2c9181 100644 --- a/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IobGeneric.cs @@ -16,6 +16,11 @@ namespace IOB_WIN { #region variabili ed oggetti base + /// + /// TImeout x ping al server + /// + protected int pingServerMsTimeout = utils.CRI("pingMsTimeout"); + /// /// Indicazione VETO invio a server sino alla data-ora indicata /// @@ -1746,19 +1751,21 @@ namespace IOB_WIN /// test ping all'indirizzo impostato nei parametri /// /// - private IPStatus testPingServer() + private IPStatus testPingServer { - IPStatus answ = IPStatus.Unknown; ; - IPAddress address; - PingReply reply; - Ping pingSender = new Ping(); - address = IPAddress.Loopback; - string ipAdrr = cIobConf.serverData.MPIP.Replace("http://", "").Replace("https://", ""); - IPAddress.TryParse(ipAdrr, out address); - int pingMsTimeout = utils.CRI("pingMsTimeout"); - reply = pingSender.Send(address, pingMsTimeout); - answ = reply.Status; - return answ; + get + { + IPStatus answ = IPStatus.Unknown; ; + IPAddress address; + PingReply reply; + Ping pingSender = new Ping(); + address = IPAddress.Loopback; + string ipAdrr = cIobConf.serverData.MPIP.Replace("http://", "").Replace("https://", ""); + IPAddress.TryParse(ipAdrr, out address); + reply = pingSender.Send(address, pingServerMsTimeout); + answ = reply.Status; + return answ; + } } /// /// Verifica se il server sia ALIVE (tramite PING) @@ -1777,14 +1784,15 @@ namespace IOB_WIN } else { - IPStatus pingStatus = testPingServer(); + IPStatus pingStatus = testPingServer; // se passa il ping faccio il resto... if (pingStatus == IPStatus.Success) { try { // chiamo URL, se restituisce "OK" รจ alive! - answ = (callUrl(urlAlive) == "OK"); + string callResp = callUrl(urlAlive); + answ = (callResp == "OK"); } catch (Exception exc) {