Files
GPW/GPW_Data/licenzeGPW.cs
T
Samuele E. Locatelli ffd3ea1edc Aggiunto progetto GPW_Data
2016-11-09 15:04:25 +01:00

163 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamWare;
namespace GPW_data
{
public class licenzeGPW
{
/// <summary>
/// numero di utenti attivi
/// </summary>
public static int utentiAttivi
{
get
{
int answ = DataProxy.DP.taDipendenti.getAttivi().Count;
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 = SteamWare.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>
/// 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>
/// 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>
/// 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>
/// nome applicazione sw
/// </summary>
public static string applicazione
{
get
{
string answ = memLayer.ML.confReadString("appName");
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>
/// 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;
}
}
}
}