Merge branch 'release/FixLogDep01'

This commit is contained in:
Samuele Locatelli
2023-09-13 16:54:11 +02:00
30 changed files with 5962 additions and 5347 deletions
+956 -929
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -56,10 +56,10 @@
<HintPath>..\packages\MongoDB.Libmongocrypt.1.3.0\lib\netstandard2.0\MongoDB.Libmongocrypt.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.15\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.4\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.2\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
+1289 -1247
View File
File diff suppressed because it is too large Load Diff
+39 -32
View File
@@ -1,5 +1,7 @@
using MongoDB.Driver;
using Newtonsoft.Json;
using NLog.Fluent;
using NLog;
using StackExchange.Redis;
using SteamWare.Logger;
using System;
@@ -89,11 +91,16 @@ namespace SteamWare.IO
#region Protected Constructors
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// classe gestione accessi a Session, cache, viewstate, configuration...
/// </summary>
protected memLayer()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
// istanzia il conf setting reader...
configAppSetReader = new AppSettingsReader();
// avvio e configuro TA
@@ -304,7 +311,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Errore in lettura valore maxAgeAppConf_min{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Errore in lettura valore maxAgeAppConf_min{0}{1}", Environment.NewLine, exc));
}
return maxAge * 60;
}
@@ -380,7 +387,7 @@ namespace SteamWare.IO
catch (Exception exc)
{
answ = new Dictionary<string, string>();
Logging.Instance.Error(string.Format("Eccezzione in tabelleInCache{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in tabelleInCache{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -486,7 +493,7 @@ namespace SteamWare.IO
catch (Exception exc)
{
numTry--;
Logging.Instance.Error($"Errore procedura nML.taConfig.GetData(), numTry = {numTry}, now {waitMs}ms wait{Environment.NewLine}{exc}");
Log.Error($"Errore procedura nML.taConfig.GetData(), numTry = {numTry}, now {waitMs}ms wait{Environment.NewLine}{exc}");
Thread.Sleep(waitMs);
}
} while (numTry > 0 && tabDati == null);
@@ -501,11 +508,11 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Errore procedura ricaricaAppConf per kvp: {0} / {1}{2}{3}", riga.chiave, riga.valore, Environment.NewLine, exc));
Log.Error(string.Format("Errore procedura ricaricaAppConf per kvp: {0} / {1}{2}{3}", riga.chiave, riga.valore, Environment.NewLine, exc));
}
}
// log ricarica
Logging.Instance.Info(string.Format("Effettuata procedura ricaricaAppConf per {0} records", answ.Count));
Log.Info(string.Format("Effettuata procedura ricaricaAppConf per {0} records", answ.Count));
}
return answ;
}
@@ -559,17 +566,17 @@ namespace SteamWare.IO
}
// salvo in redis valori (con TTL)
redSaveHash(ACBH, valori, maxAgeAppConf);
Logging.Instance.Info("Completato procedura startupAppConf");
Log.Info("Completato procedura startupAppConf");
}
else
{
Logging.Instance.Error("Errore in procedura startupAppConf, ritornato insieme vuoto");
Log.Error("Errore in procedura startupAppConf, ritornato insieme vuoto");
}
}
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Errore in startupAppConf:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Errore in startupAppConf:{0}{1}", Environment.NewLine, exc));
}
}
}
@@ -707,12 +714,12 @@ namespace SteamWare.IO
bool fatto = bool.TryParse(sVal, out answ);
if (!fatto)
{
Logging.Instance.Error($"Errore in lettura chiave [{chiave}] durante cdvb: ricevuto {sVal}");
Log.Error($"Errore in lettura chiave [{chiave}] durante cdvb: ricevuto {sVal}");
}
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezzione in lettura chiave [{chiave}] durante cdvb{Environment.NewLine}{exc}");
Log.Error($"Eccezzione in lettura chiave [{chiave}] durante cdvb{Environment.NewLine}{exc}");
}
}
return answ;
@@ -735,12 +742,12 @@ namespace SteamWare.IO
bool fatto = int.TryParse(sVal, out answ);
if (!fatto)
{
Logging.Instance.Error($"Errore in lettura chiave [{chiave}] durante cdvi: ricevuto {sVal}");
Log.Error($"Errore in lettura chiave [{chiave}] durante cdvi: ricevuto {sVal}");
}
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezzione in lettura chiave [{chiave}] durante cdvi{Environment.NewLine}{exc}");
Log.Error($"Eccezzione in lettura chiave [{chiave}] durante cdvi{Environment.NewLine}{exc}");
}
}
return answ;
@@ -793,7 +800,7 @@ namespace SteamWare.IO
// controllo SE in redis ci sia ancora il valore, altrimenti rileggo...
if (!redKeyPresent(ACBH))
{
Logging.Instance.Info(string.Format("Manca HASH in redis --> rileggo da DB --> REDIS --> Memoria | {0} | {1}", ACBH, chiave));
Log.Info(string.Format("Manca HASH in redis --> rileggo da DB --> REDIS --> Memoria | {0} | {1}", ACBH, chiave));
resetAppConf();
}
// provo a leggere da DICT
@@ -805,7 +812,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Errore in lettura AppConf[{0}] durante configDbVal{1}{2}", chiave, Environment.NewLine, exc));
Log.Error(string.Format("Errore in lettura AppConf[{0}] durante configDbVal{1}{2}", chiave, Environment.NewLine, exc));
}
}
}
@@ -1152,7 +1159,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in getRSV:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezione in getRSV:{0}{1}", Environment.NewLine, exc));
}
return answInt;
}
@@ -1193,7 +1200,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in getRKeys:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezione in getRKeys:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -1212,7 +1219,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Log.Error($"Eccezione in getRSV:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -1283,7 +1290,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in verifica isInCacheObject REDIS per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in verifica isInCacheObject REDIS per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc));
}
}
else
@@ -1302,7 +1309,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in verifica isInCacheObject per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in verifica isInCacheObject per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc));
}
}
return answ;
@@ -1491,7 +1498,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezione in redCountKey:{Environment.NewLine}{exc}");
Log.Error($"Eccezione in redCountKey:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -1542,7 +1549,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezione in redFlushKey{Environment.NewLine}{exc}");
Log.Error($"Eccezione in redFlushKey{Environment.NewLine}{exc}");
}
return answ;
}
@@ -1577,7 +1584,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezione in redGetCounterByKey{Environment.NewLine}{exc}");
Log.Error($"Eccezione in redGetCounterByKey{Environment.NewLine}{exc}");
}
// ora recupero valori!
var valori = getRKeys(chiavi);
@@ -1719,7 +1726,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in redHashPresent per la key {2}{0}{1}", Environment.NewLine, exc, key));
Log.Error(string.Format("Eccezione in redHashPresent per la key {2}{0}{1}", Environment.NewLine, exc, key));
}
return answ;
}
@@ -1757,7 +1764,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in redKeyPresent per la key {2}:{0}{1}", Environment.NewLine, exc, key));
Log.Error(string.Format("Eccezione in redKeyPresent per la key {2}:{0}{1}", Environment.NewLine, exc, key));
}
return answ;
}
@@ -1940,7 +1947,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error($"redServInfo:{Environment.NewLine}{exc}");
Log.Error($"redServInfo:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -1968,7 +1975,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in resetRCnt:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezione in resetRCnt:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -2091,7 +2098,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in setRCD:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in setRCD:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -2110,7 +2117,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in setRCI:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in setRCI:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -2130,7 +2137,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezione in setRKeys:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezione in setRKeys:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
@@ -2153,12 +2160,12 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc));
}
}
else
{
Logging.Instance.Error("Errore: chiave non valida (vuota) in setRSV");
Log.Error("Errore: chiave non valida (vuota) in setRSV");
}
return answ;
}
@@ -2182,7 +2189,7 @@ namespace SteamWare.IO
}
catch (Exception exc)
{
Logging.Instance.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc));
Log.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc));
}
return answ;
}
+2 -2
View File
@@ -6,8 +6,8 @@
<package id="MongoDB.Driver" version="2.15.0" targetFramework="net462" />
<package id="MongoDB.Driver.Core" version="2.15.0" targetFramework="net462" />
<package id="MongoDB.Libmongocrypt" version="1.3.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
<package id="NLog" version="4.7.15" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
<package id="NLog" version="5.2.4" targetFramework="net462" />
<package id="Pipelines.Sockets.Unofficial" version="2.2.2" targetFramework="net462" />
<package id="SharpCompress" version="0.31.0" targetFramework="net462" />
<package id="SharpZipLib" version="1.3.3" targetFramework="net462" />
+2 -2
View File
@@ -31,8 +31,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.15\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.4\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.7.15" targetFramework="net462" />
<package id="NLog" version="5.2.4" targetFramework="net462" />
</packages>
-12
View File
@@ -1,12 +0,0 @@
---------------------------------------------------------------
------- SteamWare SDK -------
---------------------------------------------------------------
Libreria di utility base di SteamWare.
Le dipendenze inserite sono necessarie al funzionamento dell'SDK.
Sono inclusi a titolo di esempio vari files di conf:
* example-NLog.config
Attenzione a configurare correttamente il file NLog.xml includendo il rule per la classe, vedere ad esempio il file example-NLog.config allegato.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

+58 -39
View File
@@ -1,3 +1,6 @@
using NLog;
using System;
namespace SteamWare
{
/// <summary>
@@ -5,43 +8,22 @@ namespace SteamWare
/// </summary>
public class ApplicationSimplePage : System.Web.UI.Page
{
#region Public Constructors
/// <summary>
/// Iniziazlizzazione void (non fa nulla)
/// </summary>
protected ApplicationSimplePage()
{ }
#region area public
#endregion
#region flusso creazione pagina =c=
/// <summary>
/// Metodo MAIN: viene eseguita al caricamento ed effettua delle routines per il controllo utente e istanzia l'oggetto memLayer
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void Page_Load(object sender, System.EventArgs e)
public ApplicationSimplePage()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
#endregion Public Constructors
#endregion
#region utility =c=
/// <summary>
/// rimanda alla pagina di Work In Progress salvando in session un titolo ed una descrizione che al pagina wip poi mostrerà all'utente
/// </summary>
/// <param name="titoloWIP">titolo da mostrare nella pagina WIP</param>
/// <param name="descrizioneWIP">descrizione da mostrare nella pagina WIP</param>
protected void paginaWIP(string titoloWIP, string descrizioneWIP)
{
Session["titoloWIP"] = titoloWIP;
Session["descrizioneWIP"] = descrizioneWIP;
Response.Redirect("WIP.aspx");
}
#region Public Methods
/// <summary>
/// wrapper per log con salvataggio dell'IP del chiamante
@@ -56,11 +38,14 @@ namespace SteamWare
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + _testoPre);
catch (Exception exc)
{
Log.Error($"Eccezione in httpLog01{Environment.NewLine}{exc}");
}
Log.Info(postazione_IP + _testoPre);
return answ;
}
/// <summary>
/// wrapper per log con salvataggio dell'IP del chiamante
/// </summary>
@@ -75,13 +60,47 @@ namespace SteamWare
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + testoLog, tipo);
catch (Exception exc)
{
Log.Error($"Eccezione in httpLog02{Environment.NewLine}{exc}");
}
Log.Info(postazione_IP + testoLog, tipo);
return answ;
}
#endregion
#endregion Public Methods
#region Protected Methods
/// <summary>
/// Metodo MAIN: viene eseguita al caricamento ed effettua delle routines per il controllo
/// utente e istanzia l'oggetto memLayer
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void Page_Load(object sender, System.EventArgs e)
{
}
/// <summary>
/// rimanda alla pagina di Work In Progress salvando in session un titolo ed una descrizione
/// che al pagina wip poi mostrerà all'utente
/// </summary>
/// <param name="titoloWIP">titolo da mostrare nella pagina WIP</param>
/// <param name="descrizioneWIP">descrizione da mostrare nella pagina WIP</param>
protected void paginaWIP(string titoloWIP, string descrizioneWIP)
{
Session["titoloWIP"] = titoloWIP;
Session["descrizioneWIP"] = descrizioneWIP;
Response.Redirect("WIP.aspx");
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
}
+70 -38
View File
@@ -1,3 +1,4 @@
using NLog;
using System;
using System.Collections.Generic;
using System.Data;
@@ -8,16 +9,17 @@ namespace SteamWare
/// <summary>
/// Base class for every user control in the application, containing some common behaviour and
/// utility methods. It is not meant to be be used directly.
/// * Definizioni generali:
/// * SteamWare: codice scritto manualmente da SteamWare
/// * webForm: codice autogenerato da VisualStudio
/// * =c= : codice costante(non serve modifica)
/// * >c> : codice variabile(va modificato x ogni controllo / pagina)
///
/// * Notazione
/// * _ : se posto all'inizio del nome indica una variabile/oggetto caricato in memoria da input pagina e/o session
/// * MAIUS : le procedure / metodi con prima lettera in MAIUSCOLO indicano codice COSTANTE
/// * minus : le procedure / metodi con prima lettera in minuscolo indicano codice variabile da verificare////modificare
/// * Definizioni generali:
/// * SteamWare: codice scritto manualmente da SteamWare
/// * webForm: codice autogenerato da VisualStudio
/// * =c= : codice costante(non serve modifica)
/// * &gt;c&gt; : codice variabile(va modificato x ogni controllo / pagina)
///
/// * Notazione
/// * _ : se posto all'inizio del nome indica una variabile/oggetto caricato in memoria da input
/// pagina e/o session
/// * MAIUS : le procedure / metodi con prima lettera in MAIUSCOLO indicano codice COSTANTE
/// * minus : le procedure / metodi con prima lettera in minuscolo indicano codice variabile da verificare////modificare
/// </summary>
public class ApplicationUserControl : System.Web.UI.UserControl
{
@@ -41,7 +43,12 @@ namespace SteamWare
/// tipo id controllo con classi di base comune da cui derivare gli *.asmx
/// </summary>
public ApplicationUserControl()
{ }
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
#endregion Public Constructors
@@ -170,8 +177,10 @@ namespace SteamWare
answ = righe.Length;
}
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in setLogValueToSession:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -203,8 +212,10 @@ namespace SteamWare
string[] righe = confrontoValori.obj.valNew.Split('<');
answ = righe.Length;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in setLogValueToSession4del:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -241,8 +252,9 @@ namespace SteamWare
string data = val.ToString();
dataFormattata = data.Substring(0, 4) + "-" + data.Substring(4, 2) + "-" + data.Substring(6, 2);
}
catch
catch (Exception exc)
{
Log.Error($"Errore in data2IsoString:{Environment.NewLine}{exc}");
}
return dataFormattata;
}
@@ -260,8 +272,9 @@ namespace SteamWare
string data = val.ToString();
dataFormattata = data.Substring(6, 2) + "/" + data.Substring(4, 2) + "/" + data.Substring(0, 4);
}
catch
catch (Exception exc)
{
Log.Error($"Errore in data2string:{Environment.NewLine}{exc}");
}
return dataFormattata;
}
@@ -307,8 +320,10 @@ namespace SteamWare
{
label = (DataWrap.DW.taCdc.getByCdc(val.ToString())[0]).DESCRIZIONE;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in descrCdcDaId:{Environment.NewLine}{exc}");
}
return label;
}
@@ -325,9 +340,11 @@ namespace SteamWare
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + _testoPre);
catch (Exception exc)
{
Log.Error($"Errore in httpLog01:{Environment.NewLine}{exc}");
}
Log.Info(postazione_IP + _testoPre);
return answ;
}
@@ -345,9 +362,11 @@ namespace SteamWare
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + testoLog, tipo);
catch (Exception exc)
{
Log.Error($"Errore in httpLog02:{Environment.NewLine}{exc}");
}
Log.Info(postazione_IP + testoLog, tipo);
return answ;
}
@@ -576,7 +595,7 @@ namespace SteamWare
}
/// <summary>
/// calcola come percentuale la radio dividendo/divisore
/// calcola come percentuale la ratio dividendo/divisore
/// </summary>
/// <param name="dividendo"></param>
/// <param name="divisore"></param>
@@ -588,10 +607,12 @@ namespace SteamWare
double _divisore = Convert.ToDouble(divisore);
try
{
answ = string.Format("{0:p}", _dividendo / _divisore);
answ = $"{_dividendo / _divisore:p}";
}
catch (Exception exc)
{
Log.Error($"Errore in percentuale:{Environment.NewLine}{exc}");
}
catch
{ }
return answ;
}
@@ -645,8 +666,10 @@ namespace SteamWare
DataLayer_AnagGen.UTENTERow riga = DataWrap.DW.taUtente.getByUserName(utenteWin)[0];
sigla = riga.SIGLA;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in siglaDaUserWin:{Environment.NewLine}{exc}");
}
return sigla;
}
@@ -819,7 +842,7 @@ namespace SteamWare
int filtLenght = filtroCompleto.Length;
int currLenght = 0;
// workaround: separo la ricerca in + tranches, andando a prendere solo (circa) 2000
// char alla volta...
// char alla volta...
if (filtroCompleto.Length < 2000)
{
// uso il filtro completo...
@@ -1040,9 +1063,10 @@ namespace SteamWare
_dataFrom = "01/01/1900";
}
}
catch
catch (Exception exc)
{
_dataFrom = "01/01/1900";
Log.Error($"Errore in dataFilter / conv _dataFrom:{Environment.NewLine}{exc}");
}
try
{
@@ -1052,9 +1076,10 @@ namespace SteamWare
_dataTo = "01/01/2200";
}
}
catch
catch (Exception exc)
{
_dataTo = "01/01/2200";
Log.Error($"Errore in dataFilter / conv _dataTo:{Environment.NewLine}{exc}");
}
switch (_tipoPeriodo)
{
@@ -1096,9 +1121,10 @@ namespace SteamWare
_data = "01/01/1900";
}
}
catch
catch (Exception exc)
{
_data = "01/01/1900";
Log.Error($"Errore in dataFilter / conv _data:{Environment.NewLine}{exc}");
}
switch (_tipoPeriodo)
{
@@ -1153,7 +1179,7 @@ namespace SteamWare
DataLayer_AnagGen.CDCDataTable tblCdc = DataWrap.DW.taCdc.GetTopCdC(user_std.UtSn.utente, user_std.UtSn.dominio, user_std.UtSn.modulo);
if (tblCdc.Rows.Count == 0 && _safePages.IndexOf(_paginaCorrente) == -1)
{
logger.lg.scriviLog(string.Format("Errore in filtroPosizioneCdC: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
Log.Info(string.Format("Errore in filtroPosizioneCdC: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
Response.Redirect("~/unauthorized.aspx");
}
foreach (DataLayer_AnagGen.CDCRow riga in tblCdc)
@@ -1347,7 +1373,7 @@ namespace SteamWare
/// <summary>
/// MAIN: esecuzione al caricamento del modulo delle routines di controllo utente e
/// creazione pagina
/// creazione pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -1427,7 +1453,7 @@ namespace SteamWare
// una common page...
if (!user_std.UtSn.isPageEnabled(_paginaCorrente) && _commonPages.IndexOf(_paginaCorrente) == -1)
{
logger.lg.scriviLog(string.Format("Errore in SetUpByUserRight: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
Log.Info(string.Format("Errore in SetUpByUserRight: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
Response.Redirect("~/unauthorized.aspx");
}
}
@@ -1467,6 +1493,12 @@ namespace SteamWare
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Methods
/// <summary>
+81 -47
View File
@@ -1,4 +1,6 @@
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Generic;
namespace SteamWare
@@ -94,6 +96,10 @@ namespace SteamWare
/// </summary>
public DataWrap()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
// inizializzo i table adapters
avvioTableAdaptersBase();
setupConnectionStringBase();
@@ -159,6 +165,32 @@ namespace SteamWare
#endregion Public Properties
#region Public Methods
/// <summary>
/// crea nel db corrente il lemma richiesto e lo valorizza come "--{0}--"
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public void creaNuovoLemmaVoc(string lemma)
{
foreach (DataLayer_generic.LingueRow rigaLingua in taLingue.GetData())
{
taVocabolario.Insert(rigaLingua.Lingua, lemma, string.Format("--{0}--", lemma));
}
}
/// <summary>
/// resetta il vocabolario rileggendo i dati...
/// </summary>
public void resetVocabolario()
{
memLayer.ML.emptyCacheVal("dictVocabolario");
setupVocabolario();
}
#endregion Public Methods
#region Protected Methods
/// <summary>
@@ -196,19 +228,18 @@ namespace SteamWare
{
// continuo
Dictionary<string, string> answ = new Dictionary<string, string>();
DataLayer_generic.VocabolarioDataTable vocData = new DataLayer_generic.VocabolarioDataTable();
if (taVocabolario == null)
{
foreach (DataLayer_generic.VocabolarioRow riga in DW.taVocabolario.GetData())
{
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
}
vocData = DW.taVocabolario.GetData();
}
else
{
foreach (DataLayer_generic.VocabolarioRow riga in taVocabolario.GetData())
{
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
}
vocData = taVocabolario.GetData();
}
foreach (DataLayer_generic.VocabolarioRow riga in vocData)
{
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
}
return answ;
}
@@ -219,6 +250,10 @@ namespace SteamWare
protected virtual void setupConnectionStringBase()
{
string connStr = memLayer.ML.confReadString("VocabolarioConnectionString");
if (string.IsNullOrEmpty(connStr))
{
Log.Error($"ERRORE | DataWrap.setupConnectionStringBase | VocabolarioConnectionString EMPTY");
}
// connections del db vocabolario
taLingue.Connection.ConnectionString = connStr;
taVocabolario.Connection.ConnectionString = connStr;
@@ -231,7 +266,15 @@ namespace SteamWare
protected virtual void setupConnectionStringSpec()
{
string connStrUt = memLayer.ML.confReadString("UtenteCdcConnectionString");
if (string.IsNullOrEmpty(connStrUt))
{
Log.Error($"ERRORE | DataWrap.setupConnectionStringSpec | UtenteCdcConnectionString EMPTY");
}
string connStrPerm = memLayer.ML.confReadString("PermessiConnectionString");
if (string.IsNullOrEmpty(connStrPerm))
{
Log.Error($"ERRORE | DataWrap.setupConnectionStringSpec | PermessiConnectionString EMPTY");
}
// cambio le connString - db anagrafica principale
taCdc.Connection.ConnectionString = connStrUt;
taDiritti.Connection.ConnectionString = connStrUt;
@@ -251,60 +294,51 @@ namespace SteamWare
/// </summary>
protected void setupVocabolario()
{
if (memLayer.ML.isInCacheObject("dictVocabolario"))
string source = "DB";
try
{
if (memLayer.ML.cacheOnRedis)
if (memLayer.ML.isInCacheObject("dictVocabolario"))
{
dictVocabolario = JsonConvert.DeserializeObject<Dictionary<string, string>>(memLayer.ML.objCacheObj("dictVocabolario").ToString());
if (memLayer.ML.cacheOnRedis)
{
dictVocabolario = JsonConvert.DeserializeObject<Dictionary<string, string>>(memLayer.ML.objCacheObj("dictVocabolario").ToString());
source = "REDIS";
}
else
{
dictVocabolario = (Dictionary<string, string>)memLayer.ML.objCacheObj("dictVocabolario");
source = "CACHE";
}
}
else
{
dictVocabolario = (Dictionary<string, string>)memLayer.ML.objCacheObj("dictVocabolario");
dictVocabolario = ricaricaDictVocabolario();
if (memLayer.ML.cacheOnRedis)
{
string serVal = JsonConvert.SerializeObject(dictVocabolario);
memLayer.ML.setCacheVal("dictVocabolario", serVal, true);
}
else
{
memLayer.ML.setCacheVal("dictVocabolario", dictVocabolario, true);
}
}
}
else
catch (Exception exc)
{
dictVocabolario = ricaricaDictVocabolario();
if (memLayer.ML.cacheOnRedis)
{
string serVal = JsonConvert.SerializeObject(dictVocabolario);
memLayer.ML.setCacheVal("dictVocabolario", serVal, true);
}
else
{
memLayer.ML.setCacheVal("dictVocabolario", dictVocabolario, true);
}
Log.Error($"Eccezione 01 durante setupVocabolario:{Environment.NewLine}{exc}");
dictVocabolario = new Dictionary<string, string>();
}
// scrivo quanti lemmi ha caricato!
logger.lg.scriviLog(string.Format("Caricati {0} lemmi!", dictVocabolario.Count));
Log.Info($"setupVocabolario | {source} | Caricati {dictVocabolario.Count} lemmi");
}
#endregion Protected Methods
#region Public Methods
#region Private Fields
/// <summary>
/// crea nel db corrente il lemma richiesto e lo valorizza come "--{0}--"
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public void creaNuovoLemmaVoc(string lemma)
{
foreach (DataLayer_generic.LingueRow rigaLingua in taLingue.GetData())
{
taVocabolario.Insert(rigaLingua.Lingua, lemma, string.Format("--{0}--", lemma));
}
}
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// resetta il vocabolario rileggendo i dati...
/// </summary>
public void resetVocabolario()
{
memLayer.ML.emptyCacheVal("dictVocabolario");
setupVocabolario();
}
#endregion Public Methods
#endregion Private Fields
}
}
+63 -51
View File
@@ -1,6 +1,6 @@
using Microsoft.VisualBasic.Devices;
using NLog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
@@ -13,15 +13,6 @@ namespace SteamWare
/// </summary>
public class HwSwInfo
{
#region Protected Fields
/// <summary>
/// Assembly di base
/// </summary>
protected Assembly assembly = Assembly.GetExecutingAssembly();
#endregion Protected Fields
#region Public Constructors
/// <summary>
@@ -29,8 +20,13 @@ namespace SteamWare
/// </summary>
public HwSwInfo()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
assembly = Assembly.GetExecutingAssembly();
}
/// <summary>
/// Info hw/sw del server
/// </summary>
@@ -42,13 +38,6 @@ namespace SteamWare
#endregion Public Constructors
#if false
/// <summary>
/// Singleton!
/// </summary>
public static HwSwInfo man = new HwSwInfo();
#endif
#region Public Properties
/// <summary>
@@ -87,8 +76,10 @@ namespace SteamWare
answ += referencedAssemblyName.FullName + Environment.NewLine;
}
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Eccezione librariesVers{Environment.NewLine}{exc}");
}
return answ;
}
}
@@ -105,8 +96,10 @@ namespace SteamWare
{
answ = assembly.FullName;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Eccezione mainAssembly{Environment.NewLine}{exc}");
}
return answ;
}
}
@@ -127,8 +120,10 @@ namespace SteamWare
numLib++;
}
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Eccezione numLibraries{Environment.NewLine}{exc}");
}
return numLib;
}
}
@@ -202,7 +197,7 @@ namespace SteamWare
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in redisServersData{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Log.Error($"Eccezione redisServersData{Environment.NewLine}{exc}");
}
return sb.ToString();
}
@@ -220,8 +215,10 @@ namespace SteamWare
{
answ = assembly.ImageRuntimeVersion;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Eccezione runtimeImg{Environment.NewLine}{exc}");
}
return answ;
}
}
@@ -260,7 +257,7 @@ namespace SteamWare
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in ServerStats{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Log.Error($"Eccezione ServerStats{Environment.NewLine}{exc}");
}
return sb.ToString();
}
@@ -268,28 +265,6 @@ namespace SteamWare
#endregion Public Properties
#region Private Methods
private static string getBrowserData(string redPattern)
{
StringBuilder sb = new StringBuilder();
int numRec = memLayer.ML.redCountKey(redPattern);
var redKeys = memLayer.ML.redGetKeys(redPattern);
// riordino elenco
sb.AppendLine(string.Format("Trovate {0} combinazioni", numRec));
string currKey = "";
string currVal = "";
foreach (var item in redKeys)
{
currKey = item.ToString().Replace(memLayer.ML.redHash(redPattern.Replace(":*", ":")), "");
currVal = memLayer.ML.getRSV(item);
sb.AppendLine($"{currKey}: {currVal}");
}
return sb.ToString();
}
#endregion Private Methods
#region Public Methods
/// <summary>
@@ -316,8 +291,8 @@ namespace SteamWare
rawSize = rawSize / 1024;
}
// Adjust the format string to your preferences. For example "{0:0.#}{1}" would
// show a single decimal place, and no space.
// Adjust the format string to your preferences. For example "{0:0.#}{1}" would show a
// single decimal place, and no space.
return String.Format("{0:0.##} {1}", rawSize, sizes[order]);
}
@@ -332,5 +307,42 @@ namespace SteamWare
}
#endregion Public Methods
#region Protected Fields
/// <summary>
/// Assembly di base
/// </summary>
protected Assembly assembly = Assembly.GetExecutingAssembly();
#endregion Protected Fields
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Methods
private static string getBrowserData(string redPattern)
{
StringBuilder sb = new StringBuilder();
int numRec = memLayer.ML.redCountKey(redPattern);
var redKeys = memLayer.ML.redGetKeys(redPattern);
// riordino elenco
sb.AppendLine(string.Format("Trovate {0} combinazioni", numRec));
string currKey = "";
string currVal = "";
foreach (var item in redKeys)
{
currKey = item.ToString().Replace(memLayer.ML.redHash(redPattern.Replace(":*", ":")), "");
currVal = memLayer.ML.getRSV(item);
sb.AppendLine($"{currKey}: {currVal}");
}
return sb.ToString();
}
#endregion Private Methods
}
}
+3 -8
View File
@@ -98,10 +98,10 @@
<HintPath>..\packages\MongoDB.Libmongocrypt.1.3.0\lib\netstandard2.0\MongoDB.Libmongocrypt.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.15\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.4\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="PdfSharp, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll</HintPath>
@@ -118,9 +118,6 @@
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.2.5.61\lib\net461\StackExchange.Redis.dll</HintPath>
</Reference>
<Reference Include="SteamWare.Logger, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SteamWare.Logger.5.2.2204.2910\lib\net462\SteamWare.Logger.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll</HintPath>
</Reference>
@@ -315,9 +312,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Readme\README_SteamWare.txt" />
<Content Include="App_Readme\SteamWare_demo\example-config-table.txt" />
<Content Include="App_Readme\SteamWare_demo\example-favicon.ico" />
<Content Include="App_Readme\SteamWare_demo\example-NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+42 -29
View File
@@ -1,50 +1,47 @@
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace SteamWare
{
/// <summary>
/// Object of this class gives you all the details about the update useful in handling the update logic yourself.
/// Object of this class gives you all the details about the update useful in handling the
/// update logic yourself.
/// </summary>
public class UpdateInfoEventArgs : EventArgs
{
#region Public Properties
/// <summary>
/// URL of the webpage specifying changes in the new update.
/// URL of the webpage specifying changes in the new update.
/// </summary>
public string ChangelogURL { get; set; }
/// <summary>
/// Returns newest version of the application available to download.
/// Returns newest version of the application available to download.
/// </summary>
public Version CurrentVersion { get; set; }
/// <summary>
/// Download URL of the update file.
/// Download URL of the update file.
/// </summary>
public string DownloadURL { get; set; }
/// <summary>
/// Returns version of the application currently installed on the user's PC.
/// Returns version of the application currently installed on the user's PC.
/// </summary>
public Version InstalledVersion { get; set; }
/// <summary>
/// If new update is available then returns true otherwise false.
/// If new update is available then returns true otherwise false.
/// </summary>
public bool IsUpdateAvailable { get; set; }
/// <summary>
/// Shows if the update is required or optional.
/// Shows if the update is required or optional.
/// </summary>
public bool Mandatory { get; set; }
@@ -71,7 +68,12 @@ namespace SteamWare
/// Init classe
/// </summary>
public UpdateMan()
{ }
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
/// <summary>
/// Init classe
@@ -80,25 +82,16 @@ namespace SteamWare
/// <param name="pwd"></param>
public UpdateMan(string user, string pwd)
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
userName = user;
passwd = pwd;
}
#endregion Public Constructors
#region Protected Properties
/// <summary>
/// password
/// </summary>
protected string passwd { get; set; } = "";
/// <summary>
/// Username
/// </summary>
protected string userName { get; set; } = "";
#endregion Protected Properties
#region Public Methods
/// <summary>
@@ -150,7 +143,7 @@ namespace SteamWare
//var myReader = data.Content.ReadAsStreamAsync();
if (data.StatusCode != HttpStatusCode.OK)
{
logger.lg.scriviLog($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
}
else
{
@@ -220,7 +213,7 @@ namespace SteamWare
var myReader = data.Content.ReadAsStreamAsync();
if (data.StatusCode != HttpStatusCode.OK)
{
logger.lg.scriviLog($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
}
else
{
@@ -249,7 +242,7 @@ namespace SteamWare
}
catch (Exception exc)
{
logger.lg.scriviLog($"Eccezione in getUpdateInfo:{Environment.NewLine}{exc}");
Log.Error($"Eccezione in getUpdateInfo:{Environment.NewLine}{exc}");
// metto versione = 0 + errore...
args.IsUpdateAvailable = false;
args.CurrentVersion = new Version("0.0.0.0");
@@ -258,5 +251,25 @@ namespace SteamWare
}
#endregion Public Methods
#region Protected Properties
/// <summary>
/// password
/// </summary>
protected string passwd { get; set; } = "";
/// <summary>
/// Username
/// </summary>
protected string userName { get; set; } = "";
#endregion Protected Properties
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
+423 -336
View File
@@ -1,352 +1,439 @@
using System;
using NLog;
using System;
using System.Web.UI.WebControls;
namespace SteamWare
{
/// <summary>
/// Base class for every user control in the application, containing some common
/// behaviour and utility methods.
/// It is not meant to be be used directly.
/// </summary>
public class UserControl : System.Web.UI.UserControl
{
/// <summary>
/// UID formattato con "_"
/// Base class for every user control in the application, containing some common behaviour and
/// utility methods. It is not meant to be be used directly.
/// </summary>
public string uid
public class UserControl : System.Web.UI.UserControl
{
get
{
return this.UniqueID.Replace("$", "_").Replace("-", "_");
}
}
/// <summary>
/// event handler generico
/// </summary>
public event EventHandler eh_ucev;
/// <summary>
/// sollevo evento selezione
/// </summary>
protected void raiseEvent(ucEvType evType)
{
// sollevo evento nuovo valore...
if (eh_ucev != null)
{
ucEvent evento = new ucEvent(evType);
eh_ucev(this, evento);
}
}
/// <summary>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(object lemma)
{
string answ = "";
if (lemma != null)
{
if (lemma.ToString() != "")
{
answ = user_std.UtSn.Traduci(lemma.ToString());
}
}
else
{
answ = "--";
}
return answ;
}
/// <summary>
/// modalità operativa controllo
/// </summary>
public ucMode modoContr { get; set; }
#region Public Constructors
/// <summary>
/// escape dei parametri input dell'ODS
/// </summary>
/// <param name="e"></param>
public static void escapeInputParam(ObjectDataSourceMethodEventArgs e)
{
// escape GENERALE!!!
for (int i = 0; i < e.InputParameters.Count; i++)
{
try
/// <summary>
/// init classe
/// </summary>
public UserControl()
{
e.InputParameters[i] = e.InputParameters[i].ToString().Replace("'", "''");
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
catch
{ }
}
}
/// <summary>
/// indica se i caratteri vadano forzati a maiuscoli
/// </summary>
public bool forceUppercase
{
get
{
bool answ = false;
try
{
answ = memLayer.ML.CRB("forceUppercase");
}
catch
{ }
return answ;
}
}
/// <summary>
/// determina se l'utente sia abilitato a scrivere nella pagina corrente (quindi modificare e cancellare...)
/// </summary>
public bool isWriteEnabled
{
get
{
bool answ = false;
try
{
answ = devicesAuthProxy.stObj.isPageWriteEnabled(titolo);
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore isWriteEnabled{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
return answ;
}
}
/// <summary>
/// determina se l'utente sia abilitato alla pagina corrente (di base visualizzazione...)
/// </summary>
public bool isPageEnabled
{
get
{
return devicesAuthProxy.stObj.isPageEnabled(titolo);
}
}
/// <summary>
/// titolo pagina
/// </summary>
public string titolo
{
get
{
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
}
}
/// <summary>
/// evento standard agganciabile da grView x aggiunta doppio click e singolo click (x edit e select)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void grView_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView grView = (GridView)sender;
if (e.Row.RowType == DataControlRowType.DataRow)
{
// single click --> edit
e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(grView, "Edit$" + e.Row.RowIndex);
e.Row.Attributes["style"] = "cursor:pointer";
}
}
/// <summary>
/// evento andata in editing del controllo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void grView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView grView = (GridView)sender;
if (grView.EditIndex >= 0)
{
grView.UpdateRow(grView.EditIndex, false);
}
}
#endregion Public Constructors
/// <summary>
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
/// </summary>
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
/// <returns></returns>
public string imgPath(tipoImg _tipo, dimImg _dimensione)
{
return imgPath(_tipo, _dimensione, tipoFileImg.png);
}
#region Public Events
/// <summary>
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
/// </summary>
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
/// <param name="_tipoFile">tipo del file richiesto..."</param>
/// <returns></returns>
public string imgPath(tipoImg _tipo, dimImg _dimensione, tipoFileImg _tipoFile)
{
string _imgName = "unknown";
string _imgDim = "_s";
string _imgType = "png";
switch (_tipo)
{
case tipoImg.annulla:
_imgName = "cancel";
break;
case tipoImg.approva:
_imgName = "approva";
break;
case tipoImg.barcode:
_imgName = "barcode_white";
break;
case tipoImg.barcodeArancio:
_imgName = "barcode_orange";
break;
case tipoImg.clona:
_imgName = "clonaObj";
break;
case tipoImg.conferma:
_imgName = "apply";
break;
case tipoImg.elimina:
_imgName = "elimina";
break;
case tipoImg.modifica:
_imgName = "edit";
break;
case tipoImg.notepad:
_imgName = "notepad";
break;
case tipoImg.notepadPdf:
_imgName = "notepadPdf";
break;
case tipoImg.nuovo:
_imgName = "new";
break;
case tipoImg.seleziona:
_imgName = "view";
break;
case tipoImg.semaforoGiallo:
_imgName = "semaGiallo";
break;
case tipoImg.semaforoRosso:
_imgName = "semaRosso";
break;
case tipoImg.semaforoVerde:
_imgName = "semaVerde";
break;
case tipoImg.stampa:
_imgName = "print";
break;
default:
break;
}
switch (_dimensione)
{
case dimImg.small:
_imgDim = "_s";
break;
case dimImg.medium:
_imgDim = "_m";
break;
case dimImg.large:
_imgDim = "_l";
break;
default:
break;
}
switch (_tipoFile)
{
case tipoFileImg.gif:
_imgType = "gif";
break;
case tipoFileImg.jpg:
_imgType = "jpg";
break;
case tipoFileImg.png:
_imgType = "png";
break;
default:
break;
}
return string.Format("~/images/{0}{1}.{2}", _imgName, _imgDim, _imgType);
}
/// <summary>
/// Classe help email x SteamWare.UserControl
/// </summary>
public class email
{
/// <summary>
/// Email dell'account admin applicativo
/// </summary>
public static string adminEmail
{
get
/// <summary>
/// event handler generico
/// </summary>
public event EventHandler eh_ucev;
#endregion Public Events
#region Public Properties
/// <summary>
/// indica se i caratteri vadano forzati a maiuscoli
/// </summary>
public bool forceUppercase
{
return memLayer.ML.CRS("_adminEmail");
get
{
bool answ = false;
try
{
answ = memLayer.ML.CRB("forceUppercase");
}
catch (Exception exc)
{
Log.Error($"Eccezione forceUppercase{Environment.NewLine}{exc}");
}
return answ;
}
}
}
/// <summary>
/// Email dell'account sender applicativo
/// </summary>
public static string senderEmail
{
get
{
return memLayer.ML.CRS("_fromEmail");
}
}
}
/// <summary>
/// Numero Righe standard
/// </summary>
public int righeDataGrid
{
get
{
return memLayer.ML.CRI("_righeDataGrid");
}
}
/// <summary>
/// Numero Righe standard ANAGR
/// </summary>
public int righeDataGridAnagr
{
get
{
return memLayer.ML.CRI("_righeDataGridAnagr");
}
}
/// <summary>
/// Numero Righe standard LONG
/// </summary>
public int righeDataGridLong
{
get
{
return memLayer.ML.CRI("_righeDataGridLong");
}
}
/// <summary>
/// Numero Righe standard MED
/// </summary>
public int righeDataGridMed
{
get
{
return memLayer.ML.CRI("_righeDataGridMed");
}
}
/// <summary>
/// Numero Righe standard SHORT
/// </summary>
public int righeDataGridShort
{
get
{
return memLayer.ML.CRI("_righeDataGridShort");
}
}
}
}
/// <summary>
/// determina se l'utente sia abilitato alla pagina corrente (di base visualizzazione...)
/// </summary>
public bool isPageEnabled
{
get
{
return devicesAuthProxy.stObj.isPageEnabled(titolo);
}
}
/// <summary>
/// determina se l'utente sia abilitato a scrivere nella pagina corrente (quindi modificare
/// e cancellare...)
/// </summary>
public bool isWriteEnabled
{
get
{
bool answ = false;
try
{
answ = devicesAuthProxy.stObj.isPageWriteEnabled(titolo);
}
catch (Exception exc)
{
Log.Error($"Eccezione isWriteEnabled{Environment.NewLine}{exc}");
}
return answ;
}
}
/// <summary>
/// modalità operativa controllo
/// </summary>
public ucMode modoContr { get; set; }
/// <summary>
/// Numero Righe standard
/// </summary>
public int righeDataGrid
{
get
{
return memLayer.ML.CRI("_righeDataGrid");
}
}
/// <summary>
/// Numero Righe standard ANAGR
/// </summary>
public int righeDataGridAnagr
{
get
{
return memLayer.ML.CRI("_righeDataGridAnagr");
}
}
/// <summary>
/// Numero Righe standard LONG
/// </summary>
public int righeDataGridLong
{
get
{
return memLayer.ML.CRI("_righeDataGridLong");
}
}
/// <summary>
/// Numero Righe standard MED
/// </summary>
public int righeDataGridMed
{
get
{
return memLayer.ML.CRI("_righeDataGridMed");
}
}
/// <summary>
/// Numero Righe standard SHORT
/// </summary>
public int righeDataGridShort
{
get
{
return memLayer.ML.CRI("_righeDataGridShort");
}
}
/// <summary>
/// titolo pagina
/// </summary>
public string titolo
{
get
{
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
}
}
/// <summary>
/// UID formattato con "_"
/// </summary>
public string uid
{
get
{
return this.UniqueID.Replace("$", "_").Replace("-", "_");
}
}
#endregion Public Properties
#region Public Methods
/// <summary>
/// escape dei parametri input dell'ODS
/// </summary>
/// <param name="e"></param>
public static void escapeInputParam(ObjectDataSourceMethodEventArgs e)
{
// escape GENERALE!!!
for (int i = 0; i < e.InputParameters.Count; i++)
{
try
{
e.InputParameters[i] = e.InputParameters[i].ToString().Replace("'", "''");
}
catch (Exception exc)
{
Log.Error($"Eccezione escapeInputParam{Environment.NewLine}{exc}");
}
}
}
/// <summary>
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
/// </summary>
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
/// <returns></returns>
public string imgPath(tipoImg _tipo, dimImg _dimensione)
{
return imgPath(_tipo, _dimensione, tipoFileImg.png);
}
/// <summary>
/// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
/// </summary>
/// <param name="_tipo">verrà usato x posizione {0}, tipo "view"</param>
/// <param name="_dimensione">verrà usato x posizione {1}, tipo "_s.png"</param>
/// <param name="_tipoFile">tipo del file richiesto..."</param>
/// <returns></returns>
public string imgPath(tipoImg _tipo, dimImg _dimensione, tipoFileImg _tipoFile)
{
string _imgName = "unknown";
string _imgDim = "_s";
string _imgType = "png";
switch (_tipo)
{
case tipoImg.annulla:
_imgName = "cancel";
break;
case tipoImg.approva:
_imgName = "approva";
break;
case tipoImg.barcode:
_imgName = "barcode_white";
break;
case tipoImg.barcodeArancio:
_imgName = "barcode_orange";
break;
case tipoImg.clona:
_imgName = "clonaObj";
break;
case tipoImg.conferma:
_imgName = "apply";
break;
case tipoImg.elimina:
_imgName = "elimina";
break;
case tipoImg.modifica:
_imgName = "edit";
break;
case tipoImg.notepad:
_imgName = "notepad";
break;
case tipoImg.notepadPdf:
_imgName = "notepadPdf";
break;
case tipoImg.nuovo:
_imgName = "new";
break;
case tipoImg.seleziona:
_imgName = "view";
break;
case tipoImg.semaforoGiallo:
_imgName = "semaGiallo";
break;
case tipoImg.semaforoRosso:
_imgName = "semaRosso";
break;
case tipoImg.semaforoVerde:
_imgName = "semaVerde";
break;
case tipoImg.stampa:
_imgName = "print";
break;
default:
break;
}
switch (_dimensione)
{
case dimImg.small:
_imgDim = "_s";
break;
case dimImg.medium:
_imgDim = "_m";
break;
case dimImg.large:
_imgDim = "_l";
break;
default:
break;
}
switch (_tipoFile)
{
case tipoFileImg.gif:
_imgType = "gif";
break;
case tipoFileImg.jpg:
_imgType = "jpg";
break;
case tipoFileImg.png:
_imgType = "png";
break;
default:
break;
}
return string.Format("~/images/{0}{1}.{2}", _imgName, _imgDim, _imgType);
}
/// <summary>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(object lemma)
{
string answ = "";
if (lemma != null)
{
if (lemma.ToString() != "")
{
answ = user_std.UtSn.Traduci(lemma.ToString());
}
}
else
{
answ = "--";
}
return answ;
}
#endregion Public Methods
#region Public Classes
/// <summary>
/// Classe help email x SteamWare.UserControl
/// </summary>
public class email
{
#region Public Properties
/// <summary>
/// Email dell'account admin applicativo
/// </summary>
public static string adminEmail
{
get
{
return memLayer.ML.CRS("_adminEmail");
}
}
/// <summary>
/// Email dell'account sender applicativo
/// </summary>
public static string senderEmail
{
get
{
return memLayer.ML.CRS("_fromEmail");
}
}
#endregion Public Properties
}
#endregion Public Classes
#region Protected Methods
/// <summary>
/// evento standard agganciabile da grView x aggiunta doppio click e singolo click (x edit e select)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void grView_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView grView = (GridView)sender;
if (e.Row.RowType == DataControlRowType.DataRow)
{
// single click --> edit
e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(grView, "Edit$" + e.Row.RowIndex);
e.Row.Attributes["style"] = "cursor:pointer";
}
}
/// <summary>
/// evento andata in editing del controllo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void grView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView grView = (GridView)sender;
if (grView.EditIndex >= 0)
{
grView.UpdateRow(grView.EditIndex, false);
}
}
/// <summary>
/// sollevo evento selezione
/// </summary>
protected void raiseEvent(ucEvType evType)
{
// sollevo evento nuovo valore...
if (eh_ucev != null)
{
ucEvent evento = new ucEvent(evType);
eh_ucev(this, evento);
}
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
+4
View File
@@ -97,6 +97,10 @@
<assemblyIdentity name="DnsClient" publicKeyToken="4574bb5573c51424" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.0.0" newVersion="1.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+144 -106
View File
@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
namespace SteamWare
{
@@ -7,100 +8,22 @@ namespace SteamWare
/// </summary>
public class authProxy
{
#region area table adapters
#region Public Fields
/// <summary>
/// The ta anag dev
/// </summary>
public DS_devicesTableAdapters.AnagDevicesTableAdapter taAnagDev;
/// <summary>
/// init dei table adapters
/// </summary>
protected void initTA()
{
taAnagDev = new DS_devicesTableAdapters.AnagDevicesTableAdapter();
}
/// <summary>
/// effettua setup dei connection strings da web.config della singola applicazione
/// </summary>
protected virtual void setupConnectionStringBase()
{
// connections del db
string connString = memLayer.ML.confReadString("DevicesConnectionString");
taAnagDev.Connection.ConnectionString = connString;
}
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="authProxy"/> class.
/// </summary>
protected authProxy()
{
initTA();
setupConnectionStringBase();
}
/// <summary>
/// Singleton accesso a authProxy
/// </summary>
public static authProxy AP = new authProxy();
/// <summary>
/// Tenta autologin con autoriconoscimento Dominio/username by cookie
/// The ta anag dev
/// </summary>
/// <param name="cookieName"></param>
/// <returns></returns>
public static bool tryAuthByCookie(string cookieName)
{
logger.lg.scriviLog(String.Format(string.Format("Richiesta login da cookie {0}", cookieName)), tipoLog.INFO);
string devSecret = memLayer.ML.getCookieVal(cookieName);
bool answ = false;
DS_devices.AnagDevicesRow device = null;
if (devSecret != "" && devSecret != null)
{
// cerco il device...ogni dipendente può averne + di 1 registrato a suo nome...
string Dominio = "";
string UsrName = "";
try
{
device = DataWrap.DW.taAnagDev.getByDeviceSecret(devSecret)[0];
Dominio = device.Dominio;
UsrName = device.User_Name;
}
catch (Exception exc)
{
logger.lg.scriviLog(String.Format("Errore recupero dati da devSecret {0}:{1}{2}", devSecret, Environment.NewLine, exc), tipoLog.ERROR);
}
if (Dominio != "" && UsrName != "")
{
answ = true;
try
{
// avvio l'utente (in sessione)
user_std.UtSn.startUpUtente(Dominio, UsrName);
logger.lg.scriviLog(String.Format("Effettuata login da cookie per l'utente {0}/{1}", Dominio, UsrName), tipoLog.INFO);
}
catch
{ }
}
}
return answ;
}
/// <summary>
/// formatta il secret code
/// </summary>
/// <param name="Dominio"></param>
/// <param name="UsrName"></param>
/// <param name="matrOpr"></param>
/// <param name="DeviceName"></param>
/// <param name="adesso"></param>
/// <returns></returns>
public static string getSecret(string Dominio, string UsrName, int matrOpr, string DeviceName, DateTime adesso)
{
return string.Format("{0}|{1}|{2}|{3}|{4}", Dominio, UsrName, DeviceName, matrOpr, adesso);
}
public DS_devicesTableAdapters.AnagDevicesTableAdapter taAnagDev;
#endregion Public Fields
#region Public Methods
/// <summary>
/// crea un nuovo record device e salva un nuovo cookie su db x il dispositivo e l'utente richiesti
/// </summary>
@@ -126,33 +49,31 @@ namespace SteamWare
DataWrap.DW.taAnagDev.insertQuery(devSecret, Dominio, UsrName, matrOpr, DeviceName, Description, adesso, IPv4);
// salvo il cookie nel browser
memLayer.ML.setCookieVal(cookieName, devSecret, expDate);
logger.lg.scriviLog(String.Format("Salvato login da cookie per l'utente {0}/{1} - matr {2}", Dominio, UsrName, matrOpr), tipoLog.INFO);
Log.Info($"Salvato login da cookie per l'utente {Dominio}/{UsrName} | matr {matrOpr}");
// indico come fatto
answ = true;
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in salvataggio cookie su db/dispositivo:{0}dominio:{1} | userName:{2} | matr:{6} | deviceName:{3} | ip:{4}{0}{5}", Environment.NewLine, Dominio, UsrName, DeviceName, IPv4, exc, matrOpr));
Log.Error($"Errore in salvataggio cookie su db/dispositivo:{Environment.NewLine}dom/usr: {Dominio}/{UsrName} | matr:{matrOpr} | deviceName:{DeviceName} | ip:{IPv4}{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// rimuove device da DB e toglie il cookie
/// formatta il secret code
/// </summary>
/// <param name="DeviceSecret">secret associata al device</param>
/// <param name="Dominio"></param>
/// <param name="UsrName"></param>
/// <param name="matrOpr"></param>
/// <param name="DeviceName"></param>
/// <param name="adesso"></param>
/// <returns></returns>
public static bool removeDeviceByDevSec(string DeviceSecret)
public static string getSecret(string Dominio, string UsrName, int matrOpr, string DeviceName, DateTime adesso)
{
bool answ = false;
try
{
DataWrap.DW.taAnagDev.delByDeviceSecret(DeviceSecret);
answ = true;
}
catch
{ }
return answ;
return $"{Dominio}|{UsrName}|{DeviceName}|{matrOpr}|{adesso}";
}
/// <summary>
/// rimuove device da DB e toglie il cookie
/// </summary>
@@ -166,10 +87,33 @@ namespace SteamWare
DataWrap.DW.taAnagDev.delByDeviceName(DeviceName);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in removeDeviceByDevName:{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// rimuove device da DB e toglie il cookie
/// </summary>
/// <param name="DeviceSecret">secret associata al device</param>
/// <returns></returns>
public static bool removeDeviceByDevSec(string DeviceSecret)
{
bool answ = false;
try
{
DataWrap.DW.taAnagDev.delByDeviceSecret(DeviceSecret);
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in removeDeviceByDevSec:{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// imuove device da DB e toglie il cookie
/// </summary>
@@ -184,9 +128,103 @@ namespace SteamWare
DataWrap.DW.taAnagDev.delByDominioUser(Dominio, UsrName);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Log.Error($"Errore in removeDeviceByUserDominio:{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// Tenta autologin con autoriconoscimento Dominio/username by cookie
/// </summary>
/// <param name="cookieName"></param>
/// <returns></returns>
public static bool tryAuthByCookie(string cookieName)
{
Log.Info($"Richiesta login da cookie {cookieName}");
string devSecret = memLayer.ML.getCookieVal(cookieName);
bool answ = false;
DS_devices.AnagDevicesRow device = null;
if (devSecret != "" && devSecret != null)
{
// cerco il device...ogni dipendente può averne + di 1 registrato a suo nome...
string Dominio = "";
string UsrName = "";
try
{
device = DataWrap.DW.taAnagDev.getByDeviceSecret(devSecret)[0];
Dominio = device.Dominio;
UsrName = device.User_Name;
}
catch (Exception exc)
{
Log.Error($"tryAuthByCookie | Errore recupero dati da devSecret {devSecret}:{Environment.NewLine}{exc}");
}
if (Dominio != "" && UsrName != "")
{
answ = true;
try
{
// avvio l'utente (in sessione)
user_std.UtSn.startUpUtente(Dominio, UsrName);
Log.Info($"Effettuata login da cookie per l'utente {Dominio}/{UsrName}");
}
catch (Exception exc)
{
Log.Error($"tryAuthByCookie | Errore check dominio {Environment.NewLine}{exc}");
}
}
}
return answ;
}
#endregion Public Methods
#region Protected Constructors
/// <summary>
/// Initializes a new instance of the <see cref="authProxy" /> class.
/// </summary>
protected authProxy()
{
// fix log
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
initTA();
setupConnectionStringBase();
}
#endregion Protected Constructors
#region Protected Methods
/// <summary>
/// init dei table adapters
/// </summary>
protected void initTA()
{
taAnagDev = new DS_devicesTableAdapters.AnagDevicesTableAdapter();
}
/// <summary>
/// effettua setup dei connection strings da web.config della singola applicazione
/// </summary>
protected virtual void setupConnectionStringBase()
{
// connections del db
string connString = memLayer.ML.confReadString("DevicesConnectionString");
taAnagDev.Connection.ConnectionString = connString;
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
}
+76 -49
View File
@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
using System.Data.SqlClient;
namespace SteamWare
@@ -8,27 +9,17 @@ namespace SteamWare
/// </summary>
public class dbUpdateManager
{
/// <summary>
/// oggetto connessione
/// </summary>
protected SqlConnection conn = null;
/// <summary>
/// stringa di connessione
/// </summary>
protected string _connString;
/// <summary>
/// dir che contiene gli script da eseguire...
/// </summary>
protected string _sqlScriptDir;
/// <summary>
/// formato del file SQL impiegato (nel senso di formato come iFormat del tipo "App_{0:0000}.sql" --> da App_0001.sql ad App_9999.sql)
/// </summary>
protected string _sqlFileFormat;
#region Public Constructors
/// <summary>
/// avvio protected della classe
/// </summary>
public dbUpdateManager(string connectionString, string sqlDir, string sqlFileFormat)
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
// salvo valori di avvio
_sqlFileFormat = sqlFileFormat;
_connString = connectionString;
@@ -40,8 +31,38 @@ namespace SteamWare
{
_sqlScriptDir = sqlDir;
}
//logger.lg.scriviLog(_sqlScriptDir, tipoLog.INFO);
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// verifica se il db indicato esiste o meno...
/// </summary>
/// <param name="dbname"></param>
/// <param name="connectionString"></param>
/// <returns></returns>
public bool checkDbExisting(string dbname, string connectionString)
{
bool answ = false;
// !!!FARE!!!
return answ;
}
/// <summary>
/// crea il db indicato con i parametri di connessione specificati
/// </summary>
/// <param name="dbname"></param>
/// <param name="connectionString"></param>
/// <returns></returns>
public bool createDb(string dbname, string connectionString)
{
bool answ = false;
// !!!FARE!!! per ora non c'è creazione ma SOLO fasi di update...
return answ;
}
/// <summary>
/// esegue gli script di sql di update dal file richiesto
/// </summary>
@@ -61,7 +82,7 @@ namespace SteamWare
// apro connessione
conn.Open();
// creo e popolo comando
logger.lg.scriviLog(string.Format("Inizio esecuzione comandl SQL del file {0}", nomeFile), tipoLog.INFO);
Log.Info(string.Format("Inizio esecuzione comandl SQL del file {0}", nomeFile), tipoLog.INFO);
DateTime inizio = DateTime.Now;
SqlCommand comando = conn.CreateCommand();
// eseguo un comando alla volta (fino al GO...)
@@ -81,13 +102,13 @@ namespace SteamWare
// ricaolco posizione prox GO...
i_GO = sqlCmd.IndexOf("GO\r\n");
}
logger.lg.scriviLog(string.Format("Completata esecuzione SQL {0} in {1} msec", nomeFile, DateTime.Now.Subtract(inizio).TotalMilliseconds), tipoLog.INFO);
Log.Info(string.Format("Completata esecuzione SQL {0} in {1} msec", nomeFile, DateTime.Now.Subtract(inizio).TotalMilliseconds), tipoLog.INFO);
// segno come fatto
answ = true;
}
catch (Exception e)
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore durante l'esecuzione SQL {0}, errore \n\r {1}", nomeFile, e), tipoLog.EXCEPTION);
Log.Error($"Eccezione durante l'esecuzione SQL {nomeFile}{Environment.NewLine}{exc}");
}
finally
{
@@ -99,19 +120,20 @@ namespace SteamWare
conn.Close();
conn.Dispose();
}
catch (Exception e)
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore durante la chiusura della connessione, errore:\n\r {0}", e), tipoLog.EXCEPTION);
Log.Error($"Eccezione durante la chiusura della connessione{Environment.NewLine}{exc}");
}
}
}
return answ;
}
/// <summary>
/// Aggiorna il db eseguendo gli script dalla versione di partenza a quella di arrivo
///
/// NB: per definizione rev 0 = resetta svuotando DB, rev 1 crea tabelle iniziali, rev 2 inserisce i valori di default
///
/// NB: per definizione rev 0 = resetta svuotando DB, rev 1 crea tabelle iniziali, rev 2
/// inserisce i valori di default
/// </summary>
/// <param name="nomeDB">nome DB di cui cercare script</param>
/// <param name="revFrom">revisione di partenza</param>
@@ -128,33 +150,38 @@ namespace SteamWare
}
return answ;
}
#endregion Public Methods
#region Protected Fields
/// <summary>
/// verifica se il db indicato esiste o meno...
/// stringa di connessione
/// </summary>
/// <param name="dbname"></param>
/// <param name="connectionString"></param>
/// <returns></returns>
public bool checkDbExisting(string dbname, string connectionString)
{
bool answ = false;
protected string _connString;
// !!!FARE!!!
return answ;
}
/// <summary>
/// crea il db indicato con i parametri di connessione specificati
/// formato del file SQL impiegato (nel senso di formato come iFormat del tipo
/// "App_{0:0000}.sql" --&gt; da App_0001.sql ad App_9999.sql)
/// </summary>
/// <param name="dbname"></param>
/// <param name="connectionString"></param>
/// <returns></returns>
public bool createDb(string dbname, string connectionString)
{
bool answ = false;
protected string _sqlFileFormat;
// !!!FARE!!! per ora non c'è creazione ma SOLO fasi di update...
/// <summary>
/// dir che contiene gli script da eseguire...
/// </summary>
protected string _sqlScriptDir;
return answ;
}
/// <summary>
/// oggetto connessione
/// </summary>
protected SqlConnection conn = null;
#endregion Protected Fields
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
}
+1147 -1077
View File
File diff suppressed because it is too large Load Diff
+976 -936
View File
File diff suppressed because it is too large Load Diff
+108 -80
View File
@@ -1,89 +1,117 @@
using System;
using NLog;
using System;
namespace SteamWare
{
/// <summary>
/// gestione licenze applicativi
/// </summary>
public class licenseMan
{
/// <summary>
/// numero di licenze attive per cliente/applicativo
/// gestione licenze applicativi
/// </summary>
/// <param name="cliente"></param>
/// <param name="applicativo"></param>
/// <returns></returns>
public static int getLicenseNum(string cliente, string applicativo)
public class licenseMan
{
// !!!FARE!!! chiamata a webservice 1/mese
int answ = 1;
// molto hard-coded e discutibile... licenze "perenni"
switch (cliente)
{
case "SteamWare":
answ = 50;
break;
case "ETS":
if (applicativo == "GPW")
{
answ = 35;
}
break;
case "SPS":
if (applicativo == "GPW")
{
answ = 11;
}
break;
default:
answ = 1;
break;
}
#region Public Constructors
return answ;
}
/// <summary>
/// Fornisce chiave MD5 x un cliente/applicativo/expiryDate
/// </summary>
/// <param name="cliente"></param>
/// <param name="applicativo"></param>
/// <param name="licenze"></param>
/// <param name="expiryDate"></param>
/// <returns></returns>
public static string getAuthKey(string cliente, string applicativo, int licenze, DateTime expiryDate)
{
string answ = "";
// algoritmo MD5 formato cliente#applicativo#expDate, via SQLdiventa
// SELECT CONVERT(VARCHAR(32), HashBytes('MD5', 'ETS#GPW#2013/12/31'), 2)
string plainAuthKey = string.Format("{0}#{1}-{2}%{3}%", cliente, applicativo.PadLeft(20, '-'), expiryDate.ToString("yyyy/MM/dd"), licenze);
string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
answ = SteamCrypto.EncryptString(plainAuthKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
return answ;
}
/// <summary>
/// restituisce data decodificata da authKey + applicazione + cliente...
/// </summary>
/// <param name="cliente">The cliente.</param>
/// <param name="applicativo">The applicativo.</param>
/// <param name="licenze">The licenze.</param>
/// <param name="authKey">The authentication key.</param>
/// <returns></returns>
public static DateTime expiryDateByAuthKey(string cliente, string applicativo, int licenze, string authKey)
{
DateTime answ = DateTime.Today.AddYears(-10);
public licenseMan()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
string plainAuthKey = "";
try
{
string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
plainAuthKey = SteamCrypto.DecryptString(authKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
answ = Convert.ToDateTime(plainAuthKey.Replace(string.Format("{0}#{1}-", cliente, applicativo.PadLeft(20, '-')), "").Replace(string.Format("%{0}%", licenze), ""));
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore decodifica auth key:{0}AuthKey: {1}{0}cliente:{2}{0}applicativo:{3}{0}errore:{4}", Environment.NewLine, authKey, cliente, applicativo, exc), tipoLog.EXCEPTION);
}
return answ;
#endregion Public Constructors
#region Public Methods
/// <summary>
/// restituisce data decodificata da authKey + applicazione + cliente...
/// </summary>
/// <param name="cliente">The cliente.</param>
/// <param name="applicativo">The applicativo.</param>
/// <param name="licenze">The licenze.</param>
/// <param name="authKey">The authentication key.</param>
/// <returns></returns>
public static DateTime expiryDateByAuthKey(string cliente, string applicativo, int licenze, string authKey)
{
DateTime answ = DateTime.Today.AddYears(-10);
string plainAuthKey = "";
try
{
string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
plainAuthKey = SteamCrypto.DecryptString(authKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
answ = Convert.ToDateTime(plainAuthKey.Replace(string.Format("{0}#{1}-", cliente, applicativo.PadLeft(20, '-')), "").Replace(string.Format("%{0}%", licenze), ""));
}
catch (Exception exc)
{
Log.Error($"Eccezione expiryDateByAuthKey | AuthKey: {authKey} | cliente:{cliente} | applicativo: {applicativo}{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// Fornisce chiave MD5 x un cliente/applicativo/expiryDate
/// </summary>
/// <param name="cliente"></param>
/// <param name="applicativo"></param>
/// <param name="licenze"></param>
/// <param name="expiryDate"></param>
/// <returns></returns>
public static string getAuthKey(string cliente, string applicativo, int licenze, DateTime expiryDate)
{
string answ = "";
// algoritmo MD5 formato cliente#applicativo#expDate, via SQLdiventa SELECT
// CONVERT(VARCHAR(32), HashBytes('MD5', 'ETS#GPW#2013/12/31'), 2)
string plainAuthKey = string.Format("{0}#{1}-{2}%{3}%", cliente, applicativo.PadLeft(20, '-'), expiryDate.ToString("yyyy/MM/dd"), licenze);
string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
answ = SteamCrypto.EncryptString(plainAuthKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
return answ;
}
/// <summary>
/// numero di licenze attive per cliente/applicativo
/// </summary>
/// <param name="cliente"></param>
/// <param name="applicativo"></param>
/// <returns></returns>
public static int getLicenseNum(string cliente, string applicativo)
{
// !!!FARE!!! chiamata a webservice 1/mese
int answ = 1;
// molto hard-coded e discutibile... licenze "perenni"
switch (cliente)
{
case "SteamWare":
answ = 50;
break;
case "ETS":
if (applicativo == "GPW")
{
answ = 35;
}
break;
case "SPS":
if (applicativo == "GPW")
{
answ = 11;
}
break;
default:
answ = 1;
break;
}
return answ;
}
#endregion Public Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
}
}
+2 -3
View File
@@ -10,14 +10,13 @@
<package id="MongoDB.Driver.Core" version="2.15.0" targetFramework="net462" />
<package id="MongoDB.Libmongocrypt" version="1.3.0" targetFramework="net462" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
<package id="NLog" version="4.7.15" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
<package id="NLog" version="5.2.4" targetFramework="net462" />
<package id="PDFsharp" version="1.50.5147" targetFramework="net462" />
<package id="Pipelines.Sockets.Unofficial" version="2.2.2" targetFramework="net462" />
<package id="SharpCompress" version="0.31.0" targetFramework="net462" />
<package id="SharpZipLib" version="1.3.3" targetFramework="net462" />
<package id="StackExchange.Redis" version="2.5.61" targetFramework="net462" />
<package id="SteamWare.Logger" version="5.2.2204.2910" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Diagnostics.PerformanceCounter" version="6.0.1" targetFramework="net462" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net462" />
+318 -300
View File
@@ -1,5 +1,5 @@
using AegisImplicitMail;
using System.Net.Mail;
using NLog;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -8,6 +8,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
@@ -39,20 +40,6 @@ namespace SteamWare
/// </summary>
public class CSplitter
{
#region Private Fields
/// <summary>
/// Delimiter con cui splittare
/// </summary>
private static string m_Delimiter;
/// <summary>
/// stringa da splittare
/// </summary>
private static string m_Expression;
#endregion Private Fields
#region Public Constructors
/// <summary>
@@ -65,74 +52,6 @@ namespace SteamWare
#endregion Public Constructors
#region Private Methods
/// <summary>
/// comparatore case sensitive
/// </summary>
/// <param name="StringIndex"></param>
/// <param name="DelimiterIndex"></param>
/// <returns></returns>
private static bool isValidDelimiterBinary(int StringIndex, int DelimiterIndex)
{
if (DelimiterIndex == m_Delimiter.Length)
{
return true;
}
if (StringIndex == m_Expression.Length)
{
return false;
}
//If the current character of the expression matches
//the current character of the Delimiter,
//then go to next character
if (m_Expression[StringIndex] ==
m_Delimiter[DelimiterIndex])
{
return isValidDelimiterBinary(StringIndex + 1,
DelimiterIndex + 1);
}
else
{
return false;
}
}
/// <summary>
/// comparatore case insensitive
/// </summary>
/// <param name="StringIndex"></param>
/// <param name="DelimiterIndex"></param>
/// <returns></returns>
private static bool isValidDelimiterText(int StringIndex, int DelimiterIndex)
{
if (DelimiterIndex == m_Delimiter.Length)
{
return true;
}
if (StringIndex == m_Expression.Length)
{
return false;
}
//If the current character of the expression
//matches the current character of the Delimiter,
//then go to next character
if (Char.ToLower(m_Expression[StringIndex])
== Char.ToLower(m_Delimiter[DelimiterIndex]))
{
return isValidDelimiterText(StringIndex + 1,
DelimiterIndex + 1);
}
else
{
return false;
}
}
#endregion Private Methods
#region Public Methods
/// <summary>
@@ -140,9 +59,12 @@ namespace SteamWare
/// </summary>
/// <param name="Expression">stringa da splittare</param>
/// <param name="Delimiter">delimitatore ricercato</param>
/// <param name="SingleSeparator">true=il delimiter un blocco unico, false=qualsiasi oggetto del delimiter fa split (come split base)</param>
/// <param name="SingleSeparator">
/// true=il delimiter un blocco unico, false=qualsiasi oggetto del delimiter fa split
/// (come split base)
/// </param>
/// <param name="Count"></param>
/// <param name="Compare">0 -> Binary=CaseSensitive, 1 -> Text=case insensitive</param>
/// <param name="Compare">0 -&gt; Binary=CaseSensitive, 1 -&gt; Text=case insensitive</param>
/// <returns></returns>
public static string[] Split(string Expression, string Delimiter, bool SingleSeparator, int Count, ComparisonMethod Compare)
{
@@ -270,6 +192,88 @@ namespace SteamWare
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// Delimiter con cui splittare
/// </summary>
private static string m_Delimiter;
/// <summary>
/// stringa da splittare
/// </summary>
private static string m_Expression;
#endregion Private Fields
#region Private Methods
/// <summary>
/// comparatore case sensitive
/// </summary>
/// <param name="StringIndex"></param>
/// <param name="DelimiterIndex"></param>
/// <returns></returns>
private static bool isValidDelimiterBinary(int StringIndex, int DelimiterIndex)
{
if (DelimiterIndex == m_Delimiter.Length)
{
return true;
}
if (StringIndex == m_Expression.Length)
{
return false;
}
//If the current character of the expression matches
//the current character of the Delimiter,
//then go to next character
if (m_Expression[StringIndex] ==
m_Delimiter[DelimiterIndex])
{
return isValidDelimiterBinary(StringIndex + 1,
DelimiterIndex + 1);
}
else
{
return false;
}
}
/// <summary>
/// comparatore case insensitive
/// </summary>
/// <param name="StringIndex"></param>
/// <param name="DelimiterIndex"></param>
/// <returns></returns>
private static bool isValidDelimiterText(int StringIndex, int DelimiterIndex)
{
if (DelimiterIndex == m_Delimiter.Length)
{
return true;
}
if (StringIndex == m_Expression.Length)
{
return false;
}
//If the current character of the expression
//matches the current character of the Delimiter,
//then go to next character
if (Char.ToLower(m_Expression[StringIndex])
== Char.ToLower(m_Delimiter[DelimiterIndex]))
{
return isValidDelimiterText(StringIndex + 1,
DelimiterIndex + 1);
}
else
{
return false;
}
}
#endregion Private Methods
}
}
@@ -296,7 +300,7 @@ namespace SteamWare
#region Public Properties
/// <summary>
/// indica se sia valido il dato, ovvero inizio e fine > 0 e FINE >= INIZIO
/// indica se sia valido il dato, ovvero inizio e fine &gt; 0 e FINE &gt;= INIZIO
/// </summary>
public bool isValid
{
@@ -360,49 +364,37 @@ namespace SteamWare
/// <summary>
/// Gets or sets the cod turno.
/// </summary>
/// <value>
/// The cod turno.
/// </value>
/// <value>The cod turno.</value>
public string codTurno { get; set; }
/// <summary>
/// Gets or sets the durata minuti.
/// </summary>
/// <value>
/// The durata minuti.
/// </value>
/// <value>The durata minuti.</value>
public int durataMinuti { get; set; }
/// <summary>
/// Gets or sets the fine.
/// </summary>
/// <value>
/// The fine.
/// </value>
/// <value>The fine.</value>
public DateTime fine { get; set; }
/// <summary>
/// Gets or sets the inizio.
/// </summary>
/// <value>
/// The inizio.
/// </value>
/// <value>The inizio.</value>
public DateTime inizio { get; set; }
/// <summary>
/// Gets or sets the periodo.
/// </summary>
/// <value>
/// The periodo.
/// </value>
/// <value>The periodo.</value>
public intervalloDate periodo { get; set; }
/// <summary>
/// Gets or sets the t number.
/// </summary>
/// <value>
/// The t number.
/// </value>
/// <value>The t number.</value>
public int TNum { get; set; }
#endregion Public Properties
@@ -411,8 +403,8 @@ namespace SteamWare
/// <summary>
/// Helper methods e funzioni x gestione conversione dataset tipizzati e non
/// </summary>
/// <typeparam name="T">A strongly type DataTable.
/// A DataTable of type T will be returned from the DataSet.
/// <typeparam name="T">
/// A strongly type DataTable. A DataTable of type T will be returned from the DataSet.
/// </typeparam>
public static class DataSetAdapter<T>
where T : DataTable, new()
@@ -420,8 +412,7 @@ namespace SteamWare
#region Public Methods
/// <summary>
/// Convert the first DataTable from a DataSet to a
/// strongly-typed data table.
/// Convert the first DataTable from a DataSet to a strongly-typed data table.
/// </summary>
public static T convert(DataSet dataSet)
{
@@ -440,8 +431,7 @@ namespace SteamWare
}
/// <summary>
/// Convert an ordinary DataTable to a strongly-typed
/// data table.
/// Convert an ordinary DataTable to a strongly-typed data table.
/// </summary>
public static T convert(DataTable dataTable)
{
@@ -451,8 +441,7 @@ namespace SteamWare
}
T stronglyTyped = new T();
// add data from the regular DataTable to the
// strongly typed DataTable.
// add data from the regular DataTable to the strongly typed DataTable.
stronglyTyped.Merge(dataTable, true, MissingSchemaAction.Ignore);
return stronglyTyped;
}
@@ -528,6 +517,10 @@ namespace SteamWare
/// </summary>
public datario()
{
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
}
#endregion Public Constructors
@@ -578,14 +571,14 @@ namespace SteamWare
CultureInfo cInfo = new CultureInfo(culture);
if (doLog)
{
logger.lg.scriviLog(string.Format("Valore txt:{1}", Environment.NewLine, dataOra), tipoLog.INFO);
Log.Info(string.Format("Valore txt:{1}", Environment.NewLine, dataOra), tipoLog.INFO);
}
bool fatto = false;
fatto = DateTime.TryParseExact(dataOra, formato, cInfo, DateTimeStyles.None, out answ);
if (doLog)
{
logger.lg.scriviLog(string.Format("{0}Valore txt:{1}{0}Valore conv:{2}", Environment.NewLine, dataOra, answ), tipoLog.INFO);
Log.Info(string.Format("{0}Valore txt:{1}{0}Valore conv:{2}", Environment.NewLine, dataOra, answ), tipoLog.INFO);
}
if (!fatto)
@@ -594,7 +587,7 @@ namespace SteamWare
}
if (doLog)
{
logger.lg.scriviLog(string.Format("{0}Valore txt:{1}{0}Valore conv BIS:{2}", Environment.NewLine, dataOra, answ), tipoLog.INFO);
Log.Info(string.Format("{0}Valore txt:{1}{0}Valore conv BIS:{2}", Environment.NewLine, dataOra, answ), tipoLog.INFO);
}
return answ;
@@ -677,7 +670,8 @@ namespace SteamWare
}
/// <summary>
/// effettua l'operazione di intersezione tra 2 intervali di date restituendo ulteriore intervallo: NB se sono intervali disgiunti restituisce 9/9/9999 x inizio e fine
/// effettua l'operazione di intersezione tra 2 intervali di date restituendo ulteriore
/// intervallo: NB se sono intervali disgiunti restituisce 9/9/9999 x inizio e fine
/// </summary>
/// <param name="interv1"></param>
/// <param name="interv2"></param>
@@ -793,7 +787,8 @@ namespace SteamWare
}
/// <summary>
/// restituisce l'intervallo dell'anno corrente per la data indicata (dal giorno 1 all'indomani della data indicata)
/// restituisce l'intervallo dell'anno corrente per la data indicata (dal giorno 1
/// all'indomani della data indicata)
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
@@ -806,7 +801,8 @@ namespace SteamWare
}
/// <summary>
/// restituisce l'intervallo del mese corrente per la data indicata (dal giorno 1 all'indomani della data indicata)
/// restituisce l'intervallo del mese corrente per la data indicata (dal giorno 1
/// all'indomani della data indicata)
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
@@ -877,6 +873,12 @@ namespace SteamWare
}
#endregion Public Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
/// <summary>
@@ -985,25 +987,6 @@ namespace SteamWare
/// </summary>
public class gestEmail
{
#region Protected Fields
/// <summary>
/// stringa pwd x server SMTP
/// </summary>
protected string _password;
/// <summary>
/// stringa del nome DNS o dell'ip del server SMTP
/// </summary>
protected string _smtpCli;
/// <summary>
/// stringa username x server SMTP
/// </summary>
protected string _username;
#endregion Protected Fields
#region Public Fields
/// <summary>
@@ -1026,7 +1009,11 @@ namespace SteamWare
/// <param name="smtpCli"></param>
public gestEmail(string smtpCli)
{
logger.lg.scriviLog(string.Format("[Modulo gestEmail]: avviato con parametro smtp {0} - SENZA USER/PWD", smtpCli), tipoLog.STARTUP);
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
Log.Info($"[Modulo gestEmail]: avviato con parametro smtp {smtpCli} - SENZA USER/PWD");
_smtpCli = smtpCli;
_username = "";
_password = "";
@@ -1040,7 +1027,11 @@ namespace SteamWare
/// <param name="pwd"></param>
public gestEmail(string smtpCli, string user, string pwd)
{
logger.lg.scriviLog(string.Format("[Modulo gestEmail]: avviato con parametro smtp {0} ed utente {1}", smtpCli, user), tipoLog.STARTUP);
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
Log.Info($"[Modulo gestEmail]: avviato con parametro smtp {smtpCli} ed utente {user}");
_smtpCli = smtpCli;
_username = user;
_password = pwd;
@@ -1053,7 +1044,11 @@ namespace SteamWare
/// <param name="logDir"></param>
public gestEmail(string smtpCli, string logDir)
{
logger.lg.scriviLog(string.Format("[Modulo gestEmail]: avviato con parametro smtp {0} e logdir", smtpCli), tipoLog.STARTUP);
if (Log == null)
{
Log = LogManager.GetCurrentClassLogger();
}
Log.Info($"[Modulo gestEmail]: avviato con parametro smtp {smtpCli} e logdir {logDir}");
_smtpCli = smtpCli;
_username = "";
_password = "";
@@ -1061,6 +1056,168 @@ namespace SteamWare
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Decode in Base64
/// </summary>
/// <param name="base64EncodedData"></param>
/// <returns></returns>
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
/// <summary>
/// Encode in Base64
/// </summary>
/// <param name="plainText"></param>
/// <returns></returns>
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
/// <summary>
/// procedura invio email + scrittura in log!
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
public bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
{
bool fatto = false;
//manda email...
try
{
fatto = mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
Log.Info(string.Format("Email inviata" +
"{0}------------------------------------{0}" +
"destinatario: {1}{0}" +
"oggetto: {2}{0}" +
"------------------------------------------------------------------------{0}" +
"{3}" +
"{0}------------------------------------------------------------------------{0}{0}", Environment.NewLine, _mailTo, _oggetto, _corpo), tipoLog.INFO);
}
catch (Exception e)
{
Log.Info(string.Format("ERRORE! Email NON INVIATA!oggetto: {0} corpo: {1} eccezione:{2}{3}", _oggetto, _corpo, Environment.NewLine, e), tipoLog.EXCEPTION);
}
return fatto;
}
/// <summary>
/// procedura invio email + scrittura in log!
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
/// <param name="_allegati">allegati del messaggio</param>
public bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati)
{
bool fatto = false;
// setup numero tentativi (default 3)
var reqRetry = memLayer.ML.CRI("_smtpMaxRetry");
int numTry = reqRetry > 0 ? reqRetry : 3;
// ciclo fino a che non viene inviato con successo...
while (!fatto || numTry > 0)
{
numTry--;
//manda email...
try
{
fatto = mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
Log.Info(string.Format("Email inviata: oggetto: {0}, corpo:{1}{1}{2}", _oggetto, Environment.NewLine, _corpo), tipoLog.INFO);
}
catch (Exception e)
{
Log.Info(string.Format("ERRORE! Email NON INVIATA!oggetto: {0} corpo: {1} eccezione:{2}{3}", _oggetto, _corpo, Environment.NewLine, e), tipoLog.EXCEPTION);
fatto = false;
}
// se non inviato pausa 250-750 msec...
if (!fatto)
{
Random rnd = new Random();
int nextWait = 250 + rnd.Next(500);
Log.Info($"Errore email non inviata, attesa di {nextWait}ms prima di riprovare, restano {numTry} tentativi");
Thread.Sleep(nextWait);
}
}
return fatto;
}
/// <summary>
/// procedura invio email
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
/// <param name="_allegati">allegati del messaggio</param>
public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati)
{
bool answ = false;
// sostituisco eventuali a capo nel corpo messaggio...
_corpo = _corpo.Replace("\r", "<br />");
_corpo = _corpo.Replace("\n", "<br />");
//_useAIMSmtp
if (memLayer.ML.CRB("_useAIMSmtp"))
{
answ = sendWithAIMClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
}
else
{
answ = sendWithNetClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
}
return answ;
}
/// <summary>
/// procedura invio email
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
{
// chiamo procedura con alelgati nulli...
return mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo, null);
}
#endregion Public Methods
#region Protected Fields
/// <summary>
/// stringa pwd x server SMTP
/// </summary>
protected string _password;
/// <summary>
/// stringa del nome DNS o dell'ip del server SMTP
/// </summary>
protected string _smtpCli;
/// <summary>
/// stringa username x server SMTP
/// </summary>
protected string _username;
#endregion Protected Fields
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Methods
/// <summary>
@@ -1072,24 +1229,23 @@ namespace SteamWare
{
if (e.UserState != null)
{
logger.lg.scriviLog(e.UserState.ToString());
Log.Info(e.UserState.ToString());
}
if (e.Cancelled)
{
logger.lg.scriviLog("Invio cancellato");
Log.Info("Invio cancellato");
}
Console.Out.WriteLine("is it canceled? " + e.Cancelled);
if (e.Error != null)
{
logger.lg.scriviLog("Invio con errori: " + e.Error.Message);
Log.Info("Invio con errori: " + e.Error.Message);
}
}
/// <summary>
/// Invia con metodo del client AIM x compatilbiiltà SSL implicito and co
/// https://sourceforge.net/projects/netimplicitssl/
/// Invia con metodo del client AIM x compatilbiiltà SSL implicito and co https://sourceforge.net/projects/netimplicitssl/
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
@@ -1220,149 +1376,12 @@ namespace SteamWare
Console.WriteLine("{0}", esmtp.Message);
Console.WriteLine("Here is the full error message output");
Console.Write("{0}", esmtp.ToString());
logger.lg.scriviLog(string.Format("{0}\r\n full error message\r\n {1}", esmtp.Message, esmtp.ToString()), tipoLog.EXCEPTION);
Log.Info(string.Format("{0}\r\n full error message\r\n {1}", esmtp.Message, esmtp.ToString()), tipoLog.EXCEPTION);
return false;
}
}
#endregion Private Methods
#region Public Methods
/// <summary>
/// Decode in Base64
/// </summary>
/// <param name="base64EncodedData"></param>
/// <returns></returns>
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
/// <summary>
/// Encode in Base64
/// </summary>
/// <param name="plainText"></param>
/// <returns></returns>
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
/// <summary>
/// procedura invio email + scrittura in log!
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
public bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
{
bool fatto = false;
//manda email...
try
{
fatto = mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
logger.lg.scriviLog(string.Format("Email inviata" +
"{0}------------------------------------{0}" +
"destinatario: {1}{0}" +
"oggetto: {2}{0}" +
"------------------------------------------------------------------------{0}" +
"{3}" +
"{0}------------------------------------------------------------------------{0}{0}", Environment.NewLine, _mailTo, _oggetto, _corpo), tipoLog.INFO);
}
catch (Exception e)
{
logger.lg.scriviLog(string.Format("ERRORE! Email NON INVIATA!oggetto: {0} corpo: {1} eccezione:{2}{3}", _oggetto, _corpo, Environment.NewLine, e), tipoLog.EXCEPTION);
}
return fatto;
}
/// <summary>
/// procedura invio email + scrittura in log!
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
/// <param name="_allegati">allegati del messaggio</param>
public bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati)
{
bool fatto = false;
// setup numero tentativi (default 3)
var reqRetry = memLayer.ML.CRI("_smtpMaxRetry");
int numTry = reqRetry > 0 ? reqRetry : 3;
// ciclo fino a che non viene inviato con successo...
while (!fatto || numTry > 0)
{
numTry--;
//manda email...
try
{
fatto = mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
logger.lg.scriviLog(string.Format("Email inviata: oggetto: {0}, corpo:{1}{1}{2}", _oggetto, Environment.NewLine, _corpo), tipoLog.INFO);
}
catch (Exception e)
{
logger.lg.scriviLog(string.Format("ERRORE! Email NON INVIATA!oggetto: {0} corpo: {1} eccezione:{2}{3}", _oggetto, _corpo, Environment.NewLine, e), tipoLog.EXCEPTION);
fatto = false;
}
// se non inviato pausa 250-750 msec...
if (!fatto)
{
Random rnd = new Random();
int nextWait = 250 + rnd.Next(500);
logger.lg.scriviLog($"Errore email non inviata, attesa di {nextWait}ms prima di riprovare, restano {numTry} tentativi");
Thread.Sleep(nextWait);
}
}
return fatto;
}
/// <summary>
/// procedura invio email
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
/// <param name="_allegati">allegati del messaggio</param>
public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati)
{
bool answ = false;
// sostituisco eventuali a capo nel corpo messaggio...
_corpo = _corpo.Replace("\r", "<br />");
_corpo = _corpo.Replace("\n", "<br />");
//_useAIMSmtp
if (memLayer.ML.CRB("_useAIMSmtp"))
{
answ = sendWithAIMClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
}
else
{
answ = sendWithNetClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati);
}
return answ;
}
/// <summary>
/// procedura invio email
/// </summary>
/// <param name="_mailFrom">email mittente</param>
/// <param name="_mailTo">email destinatario</param>
/// <param name="_oggetto">oggetto dell'email</param>
/// <param name="_corpo">corpo del messaggio</param>
public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
{
// chiamo procedura con alelgati nulli...
return mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo, null);
}
#endregion Public Methods
}
/// <summary>
@@ -1373,7 +1392,8 @@ namespace SteamWare
#region Public Methods
/// <summary>
/// restituisce la stringa di codice javascript x conferma client comprensiva di messaggio tradotto specifico
/// restituisce la stringa di codice javascript x conferma client comprensiva di messaggio
/// tradotto specifico
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
@@ -1383,7 +1403,8 @@ namespace SteamWare
}
/// <summary>
/// restituisce la stringa di codice javascript x conferma client comprensiva di messaggio tradotto specifico
/// restituisce la stringa di codice javascript x conferma client comprensiva di messaggio
/// tradotto specifico
/// </summary>
/// <param name="lemma"></param>
/// <param name="doTranslate"></param>
@@ -1414,7 +1435,7 @@ namespace SteamWare
#region Public Methods
/// <summary>
/// converte da numero a percentuale (es 0.053 --> 5,3%)
/// converte da numero a percentuale (es 0.053 --&gt; 5,3%)
/// </summary>
/// <param name="originalVal"></param>
/// <returns></returns>
@@ -1434,7 +1455,7 @@ namespace SteamWare
}
/// <summary>
/// converte da percentuale a numero (es 5,3% --> 0.053)
/// converte da percentuale a numero (es 5,3% --&gt; 0.053)
/// </summary>
/// <param name="originalVal"></param>
/// <returns></returns>
@@ -1466,7 +1487,8 @@ namespace SteamWare
#region Public Methods
/// <summary>
/// Effettua il calcolo del rapporto numeratore/denominatore come DECIMAL con gestione denominatore != 0
/// Effettua il calcolo del rapporto numeratore/denominatore come DECIMAL con gestione
/// denominatore != 0
/// </summary>
/// <param name="numVal">numeratore</param>
/// <param name="denVal">denominatore</param>
@@ -1506,9 +1528,8 @@ namespace SteamWare
byte[] Results = null;
UTF8Encoding UTF8 = new UTF8Encoding();
// Step 1. We hash the passphrase using MD5
// We use the MD5 hash generator as the result is a 128 bit byte array
// which is a valid length for the TripleDES encoder we use below
// Step 1. We hash the passphrase using MD5 We use the MD5 hash generator as the result
// is a 128 bit byte array which is a valid length for the TripleDES encoder we use below
MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
@@ -1560,9 +1581,8 @@ namespace SteamWare
byte[] Results;
UTF8Encoding UTF8 = new UTF8Encoding();
// Step 1. We hash the passphrase using MD5
// We use the MD5 hash generator as the result is a 128 bit byte array
// which is a valid length for the TripleDES encoder we use below
// Step 1. We hash the passphrase using MD5 We use the MD5 hash generator as the result
// is a 128 bit byte array which is a valid length for the TripleDES encoder we use below
MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
@@ -1621,12 +1641,10 @@ namespace SteamWare
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
// Create a new Stringbuilder to collect the bytes
// and create a string.
// Create a new Stringbuilder to collect the bytes and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
// Loop through each byte of the hashed data and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
@@ -1672,7 +1690,7 @@ namespace SteamWare
#region Public Methods
/// <summary>
/// conversione da tempo minuti centesimali a minuti/secondi
/// conversione da tempo minuti centesimali a minuti/secondi
/// </summary>
/// <param name="valore"></param>
/// <returns></returns>
@@ -1737,7 +1755,7 @@ namespace SteamWare
}
/// <summary>
/// classi helper gestione URL
/// classi helper gestione URL
/// </summary>
public class urlUtils
{
+8 -1
View File
@@ -14,7 +14,10 @@
<add key="vetoRedisPausePurge" value="10" />
<add key="vetoRedisPurgeMax" value="300" />
<add key="codModulo" value="TestBench" />
<add key="DbConfConnectionString" value="Data Source=SQL2016DEV;Initial Catalog=TestBench;Persist Security Info=True;User ID=sa;Password=keyhammer16;" />
<add key="DbConfConnectionString" value="Data Source=SQL2016DEV;Initial Catalog=TestBench;Persist Security Info=True;User ID=sa;Password=keyhammer16;" />
<add key="PermessiConnectionString" value="Data Source=SQL2016DEV;Initial Catalog=MoonPro;Persist Security Info=True;User ID=sa;Password=keyhammer16;" />
<add key="UtenteCdcConnectionString" value="Data Source=SQL2016DEV;Initial Catalog=MoonPro_Anagrafica;Persist Security Info=True;User ID=sa;Password=keyhammer16;" />
<add key="VocabolarioConnectionString" value="Data Source=SQL2016DEV;Initial Catalog=MoonPro;Persist Security Info=True;User ID=sa;Password=keyhammer16;" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@@ -62,6 +65,10 @@
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+84 -19
View File
@@ -91,6 +91,7 @@
this.txtUser = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.tabPage8 = new System.Windows.Forms.TabPage();
this.lblChannelLog = new System.Windows.Forms.Label();
this.btnStartSub = new System.Windows.Forms.Button();
this.txtMessaggio = new System.Windows.Forms.TextBox();
this.btnSendMessage = new System.Windows.Forms.Button();
@@ -98,7 +99,11 @@
this.label12 = new System.Windows.Forms.Label();
this.clockTimer = new System.Windows.Forms.Timer(this.components);
this.LogTimer = new System.Windows.Forms.Timer(this.components);
this.lblChannelLog = new System.Windows.Forms.Label();
this.tabPage9 = new System.Windows.Forms.TabPage();
this.txtMatr = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.btnTestUserLoad = new System.Windows.Forms.Button();
this.lblOutTestMatr = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
@@ -113,6 +118,7 @@
this.groupBox2.SuspendLayout();
this.tabPage7.SuspendLayout();
this.tabPage8.SuspendLayout();
this.tabPage9.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
@@ -287,6 +293,7 @@
this.tabControl1.Controls.Add(this.tabPage6);
this.tabControl1.Controls.Add(this.tabPage7);
this.tabControl1.Controls.Add(this.tabPage8);
this.tabControl1.Controls.Add(this.tabPage9);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@@ -300,7 +307,7 @@
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(768, 353);
this.tabPage1.Size = new System.Drawing.Size(768, 366);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "File IO test";
this.tabPage1.UseVisualStyleBackColor = true;
@@ -313,7 +320,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(768, 353);
this.tabPage2.Size = new System.Drawing.Size(768, 366);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "PDF test";
this.tabPage2.UseVisualStyleBackColor = true;
@@ -330,7 +337,7 @@
this.tabPage3.Controls.Add(this.button2);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(768, 353);
this.tabPage3.Size = new System.Drawing.Size(768, 366);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Redis test";
this.tabPage3.UseVisualStyleBackColor = true;
@@ -402,7 +409,7 @@
this.tabPage4.Controls.Add(this.lblHwSwData);
this.tabPage4.Location = new System.Drawing.Point(4, 22);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(768, 353);
this.tabPage4.Size = new System.Drawing.Size(768, 366);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "Hw Sw pages";
this.tabPage4.UseVisualStyleBackColor = true;
@@ -424,7 +431,7 @@
this.tabPage5.Margin = new System.Windows.Forms.Padding(2);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(2);
this.tabPage5.Size = new System.Drawing.Size(768, 353);
this.tabPage5.Size = new System.Drawing.Size(768, 366);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "Scheduler";
this.tabPage5.UseVisualStyleBackColor = true;
@@ -546,7 +553,7 @@
this.tabPage6.Location = new System.Drawing.Point(4, 22);
this.tabPage6.Margin = new System.Windows.Forms.Padding(2);
this.tabPage6.Name = "tabPage6";
this.tabPage6.Size = new System.Drawing.Size(768, 353);
this.tabPage6.Size = new System.Drawing.Size(768, 366);
this.tabPage6.TabIndex = 5;
this.tabPage6.Text = "MessageQueue";
this.tabPage6.UseVisualStyleBackColor = true;
@@ -691,7 +698,7 @@
this.tabPage7.Location = new System.Drawing.Point(4, 22);
this.tabPage7.Name = "tabPage7";
this.tabPage7.Padding = new System.Windows.Forms.Padding(3);
this.tabPage7.Size = new System.Drawing.Size(768, 353);
this.tabPage7.Size = new System.Drawing.Size(768, 366);
this.tabPage7.TabIndex = 6;
this.tabPage7.Text = "Update Man";
this.tabPage7.UseVisualStyleBackColor = true;
@@ -792,6 +799,19 @@
this.tabPage8.Text = "PubSub (REDIS)";
this.tabPage8.UseVisualStyleBackColor = true;
//
// lblChannelLog
//
this.lblChannelLog.AutoSize = true;
this.lblChannelLog.BackColor = System.Drawing.Color.Black;
this.lblChannelLog.ForeColor = System.Drawing.Color.Yellow;
this.lblChannelLog.Location = new System.Drawing.Point(378, 65);
this.lblChannelLog.MaximumSize = new System.Drawing.Size(400, 300);
this.lblChannelLog.MinimumSize = new System.Drawing.Size(400, 300);
this.lblChannelLog.Name = "lblChannelLog";
this.lblChannelLog.Size = new System.Drawing.Size(400, 300);
this.lblChannelLog.TabIndex = 9;
this.lblChannelLog.Text = "log";
//
// btnStartSub
//
this.btnStartSub.Location = new System.Drawing.Point(619, 12);
@@ -850,18 +870,56 @@
this.LogTimer.Interval = 10;
this.LogTimer.Tick += new System.EventHandler(this.LogTimer_Tick);
//
// lblChannelLog
// tabPage9
//
this.lblChannelLog.AutoSize = true;
this.lblChannelLog.BackColor = System.Drawing.Color.Black;
this.lblChannelLog.ForeColor = System.Drawing.Color.Yellow;
this.lblChannelLog.Location = new System.Drawing.Point(378, 65);
this.lblChannelLog.MaximumSize = new System.Drawing.Size(400, 300);
this.lblChannelLog.MinimumSize = new System.Drawing.Size(400, 300);
this.lblChannelLog.Name = "lblChannelLog";
this.lblChannelLog.Size = new System.Drawing.Size(400, 300);
this.lblChannelLog.TabIndex = 9;
this.lblChannelLog.Text = "log";
this.tabPage9.Controls.Add(this.lblOutTestMatr);
this.tabPage9.Controls.Add(this.btnTestUserLoad);
this.tabPage9.Controls.Add(this.label13);
this.tabPage9.Controls.Add(this.txtMatr);
this.tabPage9.Location = new System.Drawing.Point(4, 22);
this.tabPage9.Name = "tabPage9";
this.tabPage9.Padding = new System.Windows.Forms.Padding(3);
this.tabPage9.Size = new System.Drawing.Size(768, 366);
this.tabPage9.TabIndex = 8;
this.tabPage9.Text = "Test Vari";
this.tabPage9.UseVisualStyleBackColor = true;
//
// txtMatr
//
this.txtMatr.Location = new System.Drawing.Point(41, 11);
this.txtMatr.Name = "txtMatr";
this.txtMatr.Size = new System.Drawing.Size(69, 20);
this.txtMatr.TabIndex = 0;
this.txtMatr.Text = "102";
this.txtMatr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(8, 14);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(27, 13);
this.label13.TabIndex = 1;
this.label13.Text = "matr";
//
// btnTestUserLoad
//
this.btnTestUserLoad.Location = new System.Drawing.Point(126, 11);
this.btnTestUserLoad.Name = "btnTestUserLoad";
this.btnTestUserLoad.Size = new System.Drawing.Size(75, 23);
this.btnTestUserLoad.TabIndex = 2;
this.btnTestUserLoad.Text = "load user";
this.btnTestUserLoad.UseVisualStyleBackColor = true;
this.btnTestUserLoad.Click += new System.EventHandler(this.btnTestUserLoad_Click);
//
// lblOutTestMatr
//
this.lblOutTestMatr.AutoSize = true;
this.lblOutTestMatr.Location = new System.Drawing.Point(218, 14);
this.lblOutTestMatr.Name = "lblOutTestMatr";
this.lblOutTestMatr.Size = new System.Drawing.Size(16, 13);
this.lblOutTestMatr.TabIndex = 3;
this.lblOutTestMatr.Text = "---";
//
// MainForm
//
@@ -898,6 +956,8 @@
this.tabPage7.PerformLayout();
this.tabPage8.ResumeLayout(false);
this.tabPage8.PerformLayout();
this.tabPage9.ResumeLayout(false);
this.tabPage9.PerformLayout();
this.ResumeLayout(false);
}
@@ -974,6 +1034,11 @@
private System.Windows.Forms.TextBox txtChannelName;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label lblChannelLog;
private System.Windows.Forms.TabPage tabPage9;
private System.Windows.Forms.Label lblOutTestMatr;
private System.Windows.Forms.Button btnTestUserLoad;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox txtMatr;
}
}
+23
View File
@@ -7,6 +7,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NLog;
namespace TestBench
{
@@ -399,5 +400,27 @@ namespace TestBench
}
}
}
private void btnTestUserLoad_Click(object sender, EventArgs e)
{
// test lettura dati utente
try
{
var rigaUt = user_std.UtSn.rigaUtenteDaMatricola(txtMatr.Text.Trim());
if (rigaUt != null)
{
lblOutTestMatr.Text = $"Test user | CN: {rigaUt.COGNOME} {rigaUt.NOME} | email: {rigaUt.EMAIL}";
}
else
{
lblOutTestMatr.Text = "Errore!";
}
}
catch (Exception exc)
{
Log.Error($"Test user_std fallito{Environment.NewLine}{exc}");
}
}
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
}
}
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<!-- optional, add some variabeles
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets async="true">
<target xsi:type="File"
name="SteamWare"
fileName="${basedir}/logs/${shortdate}-SteamWare.log"
layout="${longdate} ${uppercase:${level}} ${message}"
/>
</targets>
<rules>
<logger name="SteamWare.*" minlevel="Debug" writeTo="SteamWare" />
</rules>
</nlog>
+8
View File
@@ -36,6 +36,9 @@
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.4\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.2\lib\net472\Pipelines.Sockets.Unofficial.dll</HintPath>
</Reference>
@@ -46,6 +49,7 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.PerformanceCounter, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.PerformanceCounter.6.0.1\lib\net461\System.Diagnostics.PerformanceCounter.dll</HintPath>
@@ -68,12 +72,15 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Channels, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.6.0.0\lib\net461\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -109,6 +116,7 @@
<Content Include="logs\.placeholder.file">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="NLog.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net472" />
<package id="NLog" version="5.2.4" targetFramework="net472" />
<package id="Pipelines.Sockets.Unofficial" version="2.2.2" targetFramework="net472" />
<package id="StackExchange.Redis" version="2.5.61" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />