OpAuth serializzabile!
This commit is contained in:
+140
-139
@@ -3,147 +3,148 @@ using System;
|
||||
|
||||
namespace GMW_data
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe gestione auth utente
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OpAuth
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe gestione auth utente
|
||||
/// CodSoggetto (univoco)
|
||||
/// </summary>
|
||||
public class OpAuth
|
||||
public string CodSoggetto { get; set; }
|
||||
/// <summary>
|
||||
/// Matricola OP (univoca)
|
||||
/// </summary>
|
||||
public int Matricola { get; set; }
|
||||
/// <summary>
|
||||
/// Cognome - Nome
|
||||
/// </summary>
|
||||
public string CognomeNome { get; set; }
|
||||
/// <summary>
|
||||
/// numero autorizzazioni ancora possibili
|
||||
/// </summary>
|
||||
public int remAuth { get; set; }
|
||||
/// <summary>
|
||||
/// scadenza massima auth
|
||||
/// </summary>
|
||||
public DateTime scadAuth { get; set; }
|
||||
/// <summary>
|
||||
/// inizializzazione componente, default da web.config MA CON AUTH
|
||||
/// </summary>
|
||||
protected OpAuth()
|
||||
{
|
||||
/// <summary>
|
||||
/// CodSoggetto (univoco)
|
||||
/// </summary>
|
||||
public string CodSoggetto { get; set; }
|
||||
/// <summary>
|
||||
/// Matricola OP (univoca)
|
||||
/// </summary>
|
||||
public int Matricola { get; set; }
|
||||
/// <summary>
|
||||
/// Cognome - Nome
|
||||
/// </summary>
|
||||
public string CognomeNome { get; set; }
|
||||
/// <summary>
|
||||
/// numero autorizzazioni ancora possibili
|
||||
/// </summary>
|
||||
public int remAuth { get; set; }
|
||||
/// <summary>
|
||||
/// scadenza massima auth
|
||||
/// </summary>
|
||||
public DateTime scadAuth { get; set; }
|
||||
/// <summary>
|
||||
/// inizializzazione componente, default da web.config MA CON AUTH
|
||||
/// </summary>
|
||||
protected OpAuth()
|
||||
{
|
||||
// imposto valori di default (scaduti...)
|
||||
CodSoggetto = "";
|
||||
Matricola = 0;
|
||||
CognomeNome = "NA";
|
||||
remAuth = memLayer.ML.CRI("defRemAuth");
|
||||
scadAuth = DateTime.Now.AddMinutes(memLayer.ML.CRI("defMinScad"));
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce un oggetto OpAuth popolato da CodSoggetto calcolando il resto + lettura default da web.config
|
||||
/// </summary>
|
||||
/// <param name="CodSoggetto"></param>
|
||||
/// <returns></returns>
|
||||
public static OpAuth startOpAuth(string CodSoggetto)
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
if (CodSoggetto != "")
|
||||
{
|
||||
answ.CodSoggetto = CodSoggetto;
|
||||
answ.CognomeNome = utils.obj.getOperatoreByCod(CodSoggetto);
|
||||
answ.Matricola = DataProxy.obj.taTrascSogg.getByKey(CodSoggetto, 0)[0].CodMatricola;
|
||||
}
|
||||
currAuth = answ;
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce un oggetto OpAuth popolato da Matricola calcolando il resto + lettura default da web.config
|
||||
/// </summary>
|
||||
/// <param name="Matricola"></param>
|
||||
/// <returns></returns>
|
||||
public static OpAuth startOpAuth(int Matricola)
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
if (Matricola > 0)
|
||||
{
|
||||
answ.CodSoggetto = DataProxy.obj.taTrascSogg.getByKey("", Matricola)[0].CodSoggetto;
|
||||
answ.CognomeNome = utils.obj.getOperatoreByCod(answ.CodSoggetto);
|
||||
answ.Matricola = Matricola;
|
||||
}
|
||||
currAuth = answ;
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// toglie auth utente
|
||||
/// </summary>
|
||||
public static void stopAuth()
|
||||
{
|
||||
memLayer.ML.emptySessionVal("OpAuth");
|
||||
}
|
||||
/// <summary>
|
||||
/// Auth Corrente x operazioni User
|
||||
/// </summary>
|
||||
public static OpAuth currAuth
|
||||
{
|
||||
get
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
// cerco in sessione...
|
||||
if (memLayer.ML.isInSessionObject("OpAuth"))
|
||||
{
|
||||
answ = (OpAuth)memLayer.ML.objSessionObj("OpAuth");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
memLayer.ML.setSessionVal("OpAuth", value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// definisce si sia valida auth operatività utente, ovvero
|
||||
/// - valori in sessione
|
||||
/// - num auth > 0
|
||||
/// - auth non scaduta
|
||||
/// </summary>
|
||||
public static bool isAuth
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
// se ho valori in sessione
|
||||
if (memLayer.ML.isInSessionObject("OpAuth"))
|
||||
{
|
||||
// se ho num auth > 0
|
||||
if (currAuth.remAuth > 0)
|
||||
{
|
||||
// se non è scaduta auth..
|
||||
if (currAuth.scadAuth > DateTime.Now)
|
||||
{
|
||||
// se ho un CodSoggetto VALIDO
|
||||
if (currAuth.CodSoggetto != "")
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// definisce se sia richiesta OpAuth
|
||||
/// </summary>
|
||||
public static bool opAuthReq
|
||||
{
|
||||
get
|
||||
{
|
||||
// verifico SE devo fare controllo OpAuth...
|
||||
return memLayer.ML.CRB("enableOpAuth");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// imposto valori di default (scaduti...)
|
||||
CodSoggetto = "";
|
||||
Matricola = 0;
|
||||
CognomeNome = "NA";
|
||||
remAuth = memLayer.ML.CRI("defRemAuth");
|
||||
scadAuth = DateTime.Now.AddMinutes(memLayer.ML.CRI("defMinScad"));
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce un oggetto OpAuth popolato da CodSoggetto calcolando il resto + lettura default da web.config
|
||||
/// </summary>
|
||||
/// <param name="CodSoggetto"></param>
|
||||
/// <returns></returns>
|
||||
public static OpAuth startOpAuth(string CodSoggetto)
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
if (CodSoggetto != "")
|
||||
{
|
||||
answ.CodSoggetto = CodSoggetto;
|
||||
answ.CognomeNome = utils.obj.getOperatoreByCod(CodSoggetto);
|
||||
answ.Matricola = DataProxy.obj.taTrascSogg.getByKey(CodSoggetto, 0)[0].CodMatricola;
|
||||
}
|
||||
currAuth = answ;
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce un oggetto OpAuth popolato da Matricola calcolando il resto + lettura default da web.config
|
||||
/// </summary>
|
||||
/// <param name="Matricola"></param>
|
||||
/// <returns></returns>
|
||||
public static OpAuth startOpAuth(int Matricola)
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
if (Matricola > 0)
|
||||
{
|
||||
answ.CodSoggetto = DataProxy.obj.taTrascSogg.getByKey("", Matricola)[0].CodSoggetto;
|
||||
answ.CognomeNome = utils.obj.getOperatoreByCod(answ.CodSoggetto);
|
||||
answ.Matricola = Matricola;
|
||||
}
|
||||
currAuth = answ;
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// toglie auth utente
|
||||
/// </summary>
|
||||
public static void stopAuth()
|
||||
{
|
||||
memLayer.ML.emptySessionVal("OpAuth");
|
||||
}
|
||||
/// <summary>
|
||||
/// Auth Corrente x operazioni User
|
||||
/// </summary>
|
||||
public static OpAuth currAuth
|
||||
{
|
||||
get
|
||||
{
|
||||
OpAuth answ = new OpAuth();
|
||||
// cerco in sessione...
|
||||
if (memLayer.ML.isInSessionObject("OpAuth"))
|
||||
{
|
||||
answ = (OpAuth)memLayer.ML.objSessionObj("OpAuth");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
memLayer.ML.setSessionVal("OpAuth", value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// definisce si sia valida auth operatività utente, ovvero
|
||||
/// - valori in sessione
|
||||
/// - num auth > 0
|
||||
/// - auth non scaduta
|
||||
/// </summary>
|
||||
public static bool isAuth
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
// se ho valori in sessione
|
||||
if (memLayer.ML.isInSessionObject("OpAuth"))
|
||||
{
|
||||
// se ho num auth > 0
|
||||
if (currAuth.remAuth > 0)
|
||||
{
|
||||
// se non è scaduta auth..
|
||||
if (currAuth.scadAuth > DateTime.Now)
|
||||
{
|
||||
// se ho un CodSoggetto VALIDO
|
||||
if (currAuth.CodSoggetto != "")
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// definisce se sia richiesta OpAuth
|
||||
/// </summary>
|
||||
public static bool opAuthReq
|
||||
{
|
||||
get
|
||||
{
|
||||
// verifico SE devo fare controllo OpAuth...
|
||||
return memLayer.ML.CRB("enableOpAuth");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user