196 lines
5.5 KiB
C#
196 lines
5.5 KiB
C#
using SteamWare;
|
|
using System;
|
|
|
|
namespace GPW_data
|
|
{
|
|
public class licenzeGPW
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// nome applicazione sw
|
|
/// </summary>
|
|
public static string applicazione
|
|
{
|
|
get
|
|
{
|
|
string answ = memLayer.ML.confReadString("appName");
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// chaive licenza
|
|
/// </summary>
|
|
public static string authKey
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
// controllo su db...
|
|
try
|
|
{
|
|
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica se numero licenze copre utenti attivi...
|
|
/// </summary>
|
|
public static bool checkLicenze
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = utentiAttivi <= licenzeAttive;
|
|
if (!answ && memLayer.ML.confReadInt("_logLevel") > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("WARNING licenze: utenti attivi {0} / licenziati {1}", utentiAttivi, licenzeAttive), tipoLog.WARNING);
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica se il payload delle licenze attivate sia valido (con server online)
|
|
/// </summary>
|
|
public static bool checkPayload
|
|
{
|
|
get
|
|
{
|
|
bool answ = true;
|
|
|
|
// FIXME TODO !!!
|
|
|
|
//bool answ = false;
|
|
//try
|
|
//{
|
|
// answ = utentiAttivi <= licenzeAttive;
|
|
// if (!answ && memLayer.ML.confReadInt("_logLevel") > 5)
|
|
// {
|
|
// logger.lg.scriviLog(string.Format("WARNING licenze: utenti attivi {0} / licenziati {1}", utentiAttivi, licenzeAttive), tipoLog.WARNING);
|
|
// }
|
|
//}
|
|
//catch
|
|
//{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// nome installazione sw
|
|
/// </summary>
|
|
public static string installazione
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = DataProxy.DP.taAKV.getByKey("installazione")[0].valString;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore recupero chiave installazione da AKV: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// numero di licenze attive sul sw (SE CONFORMI A CHIAVE) altrimenti da dll steamware
|
|
/// </summary>
|
|
public static int licenzeAttive
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int licenzeMax = licenseMan.getLicenseNum(installazione, applicazione);
|
|
// verifico dato su DB sia valido... expiry date con quel numero sia > della data odierna!!!
|
|
if (scadenzaLicenza >= DateTime.Today)
|
|
{
|
|
answ = licenzeDb;
|
|
}
|
|
else
|
|
{
|
|
answ = licenzeMax;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// numero di licenze attive su DB (NON verificate!)
|
|
/// </summary>
|
|
public static int licenzeDb
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
// controllo su db...
|
|
try
|
|
{
|
|
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valInt;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// modalità applicazione (pagina test.aspx)
|
|
/// </summary>
|
|
public static string modApp
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = DataProxy.DP.taAKV.getByKey("appMode")[0].valString;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore recupero chiave appMode da AKV: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// scadenza licenze x applicativo
|
|
/// </summary>
|
|
public static DateTime scadenzaLicenza
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = licenseMan.expiryDateByAuthKey(installazione, applicazione, DataProxy.DP.taAKV.getByKey(installazione)[0].valInt, DataProxy.DP.taAKV.getByKey(installazione)[0].valString);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// numero di utenti attivi
|
|
/// </summary>
|
|
public static int utentiAttivi
|
|
{
|
|
get
|
|
{
|
|
int answ = DataProxy.DP.taDipendenti.getAttivi(false).Count;
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |