using SteamWare; using System; namespace GPW_data { public class licenzeGPW { /// /// numero di utenti attivi /// public static int utentiAttivi { get { int answ = DataProxy.DP.taDipendenti.getAttivi().Count; return answ; } } /// /// numero di licenze attive sul sw (SE CONFORMI A CHIAVE) altrimenti da dll steamware /// 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; } } /// /// numero di licenze attive su DB (NON verificate!) /// public static int licenzeDb { get { int answ = 0; // controllo su db... try { answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valInt; } catch { } return answ; } } /// /// chaive licenza /// public static string authKey { get { string answ = ""; // controllo su db... try { answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString; } catch { } return answ; } } /// /// nome installazione sw /// 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; } } /// /// modalità applicazione (pagina test.aspx) /// 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; } } /// /// nome applicazione sw /// public static string applicazione { get { string answ = memLayer.ML.confReadString("appName"); return answ; } } /// /// verifica se numero licenze copre utenti attivi... /// 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; } } /// /// scadenza licenze x applicativo /// 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; } } } }