Aggiunta gestione vet x ping server quando non rispondesse...

This commit is contained in:
Samuele E. Locatelli
2019-01-10 18:47:13 +01:00
parent e5c86cccff
commit a7a079e2f6
2 changed files with 52 additions and 40 deletions
+51 -39
View File
@@ -15,6 +15,10 @@ namespace IOB_WIN
{
#region variabili ed oggetti base
/// <summary>
/// Indicazione VETO invio a server sino alla data-ora indicata
/// </summary>
public static DateTime dtVetoPing = DateTime.Now;
/// <summary>
/// Contapezzi attuale
/// </summary>
@@ -328,10 +332,6 @@ namespace IOB_WIN
/// </summary>
protected bool needRefresh = true;
/// <summary>
/// Indicazione VETO invio a server sino alla data-ora indicata
/// </summary>
public DateTime dtVetoSend = DateTime.Now;
/// <summary>
/// inizializzo l'oggetto sulla form SULLA BASE DEL FILE DI CONFIGURAZIONE letto
/// </summary>
/// <param name="caller"></param>
@@ -1389,46 +1389,58 @@ namespace IOB_WIN
get
{
bool answ = false;
if (DemoOut)
// controllo se ho un VETO all'invio...
if (dtVetoPing < DateTime.Now)
{
answ = false;
}
else
{
IPStatus pingStatus = testPingServer();
// se passa il ping faccio il resto...
if (pingStatus == IPStatus.Success)
if (DemoOut)
{
try
{
// chiamo URL, se restituisce "OK" è alive!
answ = (callUrl(urlAlive) == "OK");
}
catch (Exception exc)
{
lgError("Errore in checkServerAlive:{0}{1}", Environment.NewLine, exc);
}
// verifico SE è variato stato online/offline...
if (MPOnline != answ)
{
// se ORA sono online riporto...
if (answ)
{
lgInfo("SERVER ONLINE");
parentForm.commSrvActive = 1;
}
else
{
lgInfo("SERVER OFFLINE");
parentForm.commSrvActive = 0;
}
// salvo nuovo status...
MPOnline = answ;
}
answ = false;
}
else
{
lgInfo("SERVER NOT RESPONDING (PING)");
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");
}
catch (Exception exc)
{
lgError("Errore in checkServerAlive:{0}{1}", Environment.NewLine, exc);
}
// verifico SE è variato stato online/offline...
if (MPOnline != answ)
{
// se ORA sono online riporto...
if (answ)
{
lgInfo("SERVER ONLINE");
parentForm.commSrvActive = 1;
}
else
{
lgInfo("SERVER OFFLINE");
parentForm.commSrvActive = 0;
}
// salvo nuovo status...
MPOnline = answ;
}
}
else
{
lgInfo("SERVER NOT RESPONDING (PING)");
// imposto un veto per pauseSendMSec
int pauseSendMSec = utils.CRI("pauseSendMSec");
// aggiungo NOISE... +/- 33%
Random rnd = new Random();
int noise = rnd.Next(1, pauseSendMSec / 3);
pauseSendMSec += noise - (pauseSendMSec / 6);
// imposto veto
dtVetoPing = DateTime.Now.AddMilliseconds(pauseSendMSec);
}
}
}
return answ;
Vendored
+1 -1
View File
@@ -16,7 +16,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=334']) {
withEnv(['NEXT_BUILD_NUMBER=335']) {
// env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'