fix merge
This commit is contained in:
Vendored
+3
-3
@@ -10,9 +10,9 @@ pipeline {
|
||||
steps {
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=626']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
withEnv(['NEXT_BUILD_NUMBER=631']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '3.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '3.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.APP_NAME = 'SteamWareLib'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace SteamWare
|
||||
// calcolo il secret...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string Secret = string.Format("{0}|{1}|{2}", email, DeviceName, adesso);
|
||||
string devSecret = SteamCrypto.EncryptString(Secret, passphrase(memLayer.ML.CRS("CodModulo"), UserAuthKey));
|
||||
string devSecret = SteamCrypto.EncryptString(Secret, passphrase(memLayer.ML.confReadString("CodModulo"), UserAuthKey));
|
||||
try
|
||||
{
|
||||
// registro chiave x il device
|
||||
|
||||
+122
-10
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace SteamWare
|
||||
{
|
||||
@@ -10,8 +11,6 @@ namespace SteamWare
|
||||
{
|
||||
#region dichiarazione variabili
|
||||
|
||||
#region altri dati
|
||||
|
||||
/// <summary>
|
||||
/// directory base x logs
|
||||
/// </summary>
|
||||
@@ -28,9 +27,14 @@ namespace SteamWare
|
||||
/// controlla se si debba mantenere sotto controllo la dimensioen della cartella logs
|
||||
/// </summary>
|
||||
protected bool _doShrinkFolder;
|
||||
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Ultima verifica directory (x shrink)
|
||||
/// </summary>
|
||||
private static DateTime lastDirCheck;
|
||||
/// <summary>
|
||||
/// metodo gestione wirteLock su file log
|
||||
/// </summary>
|
||||
private static ReaderWriterLockSlim _readWriteLock = new ReaderWriterLockSlim();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -48,7 +52,7 @@ namespace SteamWare
|
||||
{
|
||||
try
|
||||
{
|
||||
_logBaseDir = SteamwareStrings.getFilePath(memLayer.ML.CRS("_logDir"));
|
||||
_logBaseDir = SteamwareStrings.getFilePath(memLayer.ML.confReadString("_logDir"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -63,6 +67,8 @@ namespace SteamWare
|
||||
{
|
||||
_doShrinkFolder = true;
|
||||
}
|
||||
// all'avvio imposto ultimo check a 23 ore fa... così farà shrink DOPO 1 h da avvio
|
||||
lastDirCheck = DateTime.Now.AddHours(-23);
|
||||
}
|
||||
/// <summary>
|
||||
/// livello di log applicazione (da web.config, chiave '_logLevel')
|
||||
@@ -116,19 +122,95 @@ namespace SteamWare
|
||||
/// <returns></returns>
|
||||
public bool scriviLog(string _testoPre)
|
||||
{
|
||||
bool needWrite = false;
|
||||
bool fatto = false;
|
||||
// preparo hash redis
|
||||
string hKey = _testoPre.Replace(":", "_").Replace("/", "_").Replace("#", "_").Replace("|", "_").Replace(" ", "_").Replace("__", "_").Replace("__", "_").Replace("__", "_").Replace("__", "_");
|
||||
//se troppo lunga trimmo...
|
||||
if (hKey.Length > 100)
|
||||
{
|
||||
hKey = hKey.Substring(0, 100);
|
||||
}
|
||||
string hVetoErrore = memLayer.ML.redHash("Logger:Veto:" + hKey);
|
||||
string hCountErrore = memLayer.ML.redHash("Logger:Counter:" + hKey);
|
||||
bool redisEnabled = memLayer.ML.confReadBool("cacheOnRedis");
|
||||
// verifico mitigazione
|
||||
int logMitigSec = 30;
|
||||
try
|
||||
{
|
||||
if (memLayer.ML.confReadString("logMitigSec") != "")
|
||||
{
|
||||
logMitigSec = memLayer.ML.confReadInt("logMitigSec");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// verifico SE HO redis (in quel caso gli errori li loggo 1 volta poi metto un VETO ed un counter)
|
||||
if (redisEnabled)
|
||||
{
|
||||
// cerco se ho un veto precedente in redis
|
||||
string vetoPar = memLayer.ML.getRSV(hVetoErrore);
|
||||
if (vetoPar != null && vetoPar != "")
|
||||
{
|
||||
needWrite = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// metto veto per TTL default... (durata std = 30 sec)
|
||||
memLayer.ML.setRSV(hVetoErrore, DateTime.UtcNow.ToString(), logMitigSec);
|
||||
// abilito log...
|
||||
needWrite = true;
|
||||
}
|
||||
memLayer.ML.setRCntI(hCountErrore);
|
||||
}
|
||||
else
|
||||
{
|
||||
// altrimenti log direttamente
|
||||
needWrite = true;
|
||||
}
|
||||
// se devo DAVVERO scrivere
|
||||
if (needWrite)
|
||||
{
|
||||
if (redisEnabled)
|
||||
{
|
||||
int numRep = memLayer.ML.getRCnt(hCountErrore);
|
||||
if (numRep > 1)
|
||||
{
|
||||
// cambio messaggio con un inizio pari al num di ripetizioni...
|
||||
_testoPre = string.Format("{0} x {1}", numRep, _testoPre);
|
||||
}
|
||||
// reset counter
|
||||
memLayer.ML.resetRCnt(hCountErrore);
|
||||
}
|
||||
fatto = doScriviLog(_testoPre);
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Vera chiamata scrittura log x override con gestione REDIS di calmierazione
|
||||
/// </summary>
|
||||
/// <param name="_testoPre"></param>
|
||||
/// <returns></returns>
|
||||
private bool doScriviLog(string _testoPre)
|
||||
{
|
||||
bool fatto = false;
|
||||
// attenzione: rimpiazzo eventuali "</br>" con newline...
|
||||
string _testo = string.Format("{0:H:mm:ss ffff} \t{1}", DateTime.Now, _testoPre.Replace("<br>", Environment.NewLine).Replace("<br/>", Environment.NewLine).Replace("<br />", Environment.NewLine));
|
||||
|
||||
if (_doShrinkFolder)
|
||||
// se è configurato x shrink ed è passato almeno 1 gg da ultimo check...
|
||||
if (_doShrinkFolder && lastDirCheck.AddDays(1) < DateTime.Now)
|
||||
{
|
||||
// verifica dim directory ed eventualmente cancella... - opzionale
|
||||
shrinkDir();
|
||||
// salvo nuova ora di check
|
||||
lastDirCheck = DateTime.Now;
|
||||
}
|
||||
// (ri)genera il nome del file di log...
|
||||
newLogfileName();
|
||||
// scrivo thread safe
|
||||
fatto = WriteToFileThreadSafe(_logfileName, _testo);
|
||||
#if false
|
||||
// aggiunge in append...
|
||||
StreamWriter sw = new StreamWriter(_logfileName, true);
|
||||
bool fatto;
|
||||
try
|
||||
{
|
||||
sw.WriteLine(_testo);
|
||||
@@ -139,9 +221,39 @@ namespace SteamWare
|
||||
catch
|
||||
{
|
||||
fatto = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esecuzione scrittura ThreadSafe
|
||||
/// </summary>
|
||||
/// <param name="text2write"></param>
|
||||
/// <param name="logPath"></param>
|
||||
public bool WriteToFileThreadSafe(string logPath, string text2write)
|
||||
{
|
||||
bool answ = false;
|
||||
// Set Status to Locked
|
||||
_readWriteLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
// Append text to the file
|
||||
using (StreamWriter sw = File.AppendText(logPath))
|
||||
{
|
||||
sw.WriteLine(text2write);
|
||||
sw.Close();
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Release lock
|
||||
_readWriteLock.ExitWriteLock();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scrive un messaggio di log con etichetta pre
|
||||
/// </summary>
|
||||
|
||||
@@ -162,6 +162,7 @@ namespace SteamWare
|
||||
}
|
||||
redSaveHash(ACBH, valori);
|
||||
lastUpdateAppConf = DateTime.Now;
|
||||
logger.lg.scriviLog("Completato procedura startupAppConf ", tipoLog.INFO);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -196,8 +197,17 @@ namespace SteamWare
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
foreach (DS_Utility.ConfigRow riga in taConfig.GetData())
|
||||
{
|
||||
answ.Add(riga.chiave, riga.valore);
|
||||
try
|
||||
{
|
||||
answ.Add(riga.chiave, riga.valore);
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore procedura ricaricaAppConf per kvp: {0} / {1}", riga.chiave, riga.valore), tipoLog.INFO);
|
||||
}
|
||||
}
|
||||
// log ricarica
|
||||
logger.lg.scriviLog(string.Format("Effettuata procedura ricaricaAppConf per {0} records", answ.Count), tipoLog.INFO);
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -238,7 +248,7 @@ namespace SteamWare
|
||||
}
|
||||
if (AppConf != null)
|
||||
{
|
||||
// controllo se ho dati (sennò rileggo)
|
||||
// controllo se ho dati (senn� rileggo)
|
||||
if (AppConf.Count == 0)
|
||||
{
|
||||
resetAppConf();
|
||||
@@ -251,9 +261,9 @@ namespace SteamWare
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog("Errore configDbVal: " + exc.ToString(), tipoLog.EXCEPTION);
|
||||
logger.lg.scriviLog(string.Format("Errore in lettura chiave [{0}] durante configDbVal{1}{2}", chiave, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
// controllo SE è passato più di 5 minuti, nel caso faccio refresh...
|
||||
// controllo SE � passato pi� di 5 minuti, nel caso faccio refresh...
|
||||
if (DateTime.Now.Subtract(lastUpdateAppConf).TotalMinutes > maxAge)
|
||||
{
|
||||
resetAppConf();
|
||||
@@ -292,7 +302,7 @@ namespace SteamWare
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog("Errore in cdvb x chiave [" + chiave + "]: " + exc.ToString(), tipoLog.EXCEPTION);
|
||||
logger.lg.scriviLog(string.Format("Errore in lettura chiave [{0}] durante cdvb{1}{2}", chiave, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -310,7 +320,7 @@ namespace SteamWare
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog("Errore in cdvi x chiave [" + chiave + "]: " + exc.ToString(), tipoLog.EXCEPTION);
|
||||
logger.lg.scriviLog(string.Format("Errore in lettura chiave [{0}] durante cdvi{1}{2}", chiave, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -801,7 +811,7 @@ namespace SteamWare
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce true se è presente in session l'oggetto richiesto
|
||||
/// restituisce true se � presente in session l'oggetto richiesto
|
||||
/// </summary>
|
||||
/// <param name="nomeVar"></param>
|
||||
/// <returns></returns>
|
||||
@@ -1095,7 +1105,7 @@ namespace SteamWare
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce true se è presente in cache l'oggetto richiesto
|
||||
/// restituisce true se � presente in cache l'oggetto richiesto
|
||||
/// </summary>
|
||||
/// <param name="nomeVar"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Reference in New Issue
Block a user