Aggiunta progetto logger (iniziale) come nuovo nuget
This commit is contained in:
@@ -0,0 +1,316 @@
|
||||
using System;
|
||||
|
||||
namespace SteamWare.Log
|
||||
{
|
||||
/// <summary>
|
||||
/// classe gestione logging esteso di eventi e note utente (correlabili)
|
||||
/// </summary>
|
||||
public class log2note
|
||||
{
|
||||
#region area protected
|
||||
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla tabella anagrafica filtraggi
|
||||
/// </summary>
|
||||
protected DS_loggingTableAdapters.T_anagFiltroTableAdapter taAnagFilt;
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla tabella anagrafica record
|
||||
/// </summary>
|
||||
protected DS_loggingTableAdapters.T_anagRecordTableAdapter taAnagRec;
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla tabella logging record di eventi
|
||||
/// </summary>
|
||||
protected DS_loggingTableAdapters.T_logRecordsTableAdapter taLogRec;
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla tabella logging utente
|
||||
/// </summary>
|
||||
protected DS_loggingTableAdapters.T_logUtenteTableAdapter taLogUt;
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla vista logging eventi
|
||||
/// </summary>
|
||||
public DS_loggingTableAdapters.v_logRecordsTableAdapter ta_vLogRec;
|
||||
/// <summary>
|
||||
/// TableAdapter di accesso alla vista logging utente
|
||||
/// </summary>
|
||||
public DS_loggingTableAdapters.v_logUtenteTableAdapter ta_vLogUt;
|
||||
|
||||
/// <summary>
|
||||
/// effettua setup dei connection strings da web.config delal singola applicazione
|
||||
/// </summary>
|
||||
protected void setupConnectionString()
|
||||
{
|
||||
// cambio le connString
|
||||
string _connectionString = memLayer.ML.confReadString("LoggingConnectionString");
|
||||
taAnagFilt.Connection.ConnectionString = _connectionString;
|
||||
taAnagRec.Connection.ConnectionString = _connectionString;
|
||||
taLogRec.Connection.ConnectionString = _connectionString;
|
||||
taLogUt.Connection.ConnectionString = _connectionString;
|
||||
ta_vLogUt.Connection.ConnectionString = _connectionString;
|
||||
ta_vLogRec.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
/// <summary>
|
||||
/// avvio i tari tableAdapters
|
||||
/// </summary>
|
||||
private void setupTA()
|
||||
{
|
||||
taAnagFilt = new DS_loggingTableAdapters.T_anagFiltroTableAdapter();
|
||||
taAnagRec = new DS_loggingTableAdapters.T_anagRecordTableAdapter();
|
||||
taLogRec = new DS_loggingTableAdapters.T_logRecordsTableAdapter();
|
||||
taLogUt = new DS_loggingTableAdapters.T_logUtenteTableAdapter();
|
||||
ta_vLogRec = new DS_loggingTableAdapters.v_logRecordsTableAdapter();
|
||||
ta_vLogUt = new DS_loggingTableAdapters.v_logUtenteTableAdapter();
|
||||
}
|
||||
/// <summary>
|
||||
/// avvio della classe istanziando db e
|
||||
/// </summary>
|
||||
log2note()
|
||||
{
|
||||
setupTA();
|
||||
setupConnectionString();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region area public
|
||||
|
||||
/// <summary>
|
||||
/// oggetto statico di accesso ai metodi della classe...
|
||||
/// </summary>
|
||||
public static log2note l2n = new log2note();
|
||||
|
||||
#region area oggetti restituiti
|
||||
|
||||
/// <summary>
|
||||
/// tabella eventi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logRecordsDataTable tabLogEventi()
|
||||
{
|
||||
return ta_vLogRec.GetData();
|
||||
}
|
||||
/// <summary>
|
||||
/// tabella note
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logUtenteDataTable tabLogNote()
|
||||
{
|
||||
return ta_vLogUt.GetData();
|
||||
}
|
||||
/// <summary>
|
||||
/// tabella eventi secondo filtro
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro gestito come condizione "LIKE '%{0}%'" rispetto al filtro salvato con l'evento</param>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logRecordsDataTable tabLogEventi(string filtro)
|
||||
{
|
||||
return ta_vLogRec.getByFiltro(filtro);
|
||||
}
|
||||
/// <summary>
|
||||
/// tabella note secondo filtro
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro gestito come condizione "LIKE '%{0}%'" rispetto al filtro salvato con l'evento</param>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logUtenteDataTable tabLogNote(string filtro)
|
||||
{
|
||||
return ta_vLogUt.getByFiltro(filtro);
|
||||
}
|
||||
/// <summary>
|
||||
/// tabella eventi secondo filtro e condizione ulteriore WHERE esplicitata
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro gestito come condizione "LIKE '%{0}%'" rispetto al filtro salvato con l'evento</param>
|
||||
/// <param name="_where">ulteriore condizione WHERE per filtrare i dati (testo {0} della condizione "WHERE {0}" </param>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logRecordsDataTable tabLogEventi(string filtro, string _where)
|
||||
{
|
||||
DS_logging.v_logRecordsDataTable _tab = new DS_logging.v_logRecordsDataTable();
|
||||
foreach (DS_logging.v_logRecordsRow riga in ta_vLogRec.getByFiltro(filtro).Select(_where))
|
||||
{
|
||||
_tab.Addv_logRecordsRow(riga);
|
||||
}
|
||||
return _tab;
|
||||
}
|
||||
/// <summary>
|
||||
/// tabella note secondo filtro e condizione ulteriore WHERE esplicitata
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro gestito come condizione "LIKE '%{0}%'" rispetto al filtro salvato con l'evento</param>
|
||||
/// <param name="_where">ulteriore condizione WHERE per filtrare i dati (testo {0} della condizione "WHERE {0}" </param>
|
||||
/// <returns></returns>
|
||||
public DS_logging.v_logUtenteDataTable tabLogNote(string filtro, string _where)
|
||||
{
|
||||
DS_logging.v_logUtenteDataTable _tab = new DS_logging.v_logUtenteDataTable();
|
||||
foreach (DS_logging.v_logUtenteRow riga in ta_vLogUt.getByFiltro(filtro).Select(_where))
|
||||
{
|
||||
_tab.Addv_logUtenteRow(riga);
|
||||
}
|
||||
return _tab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// tabella note secondo filtro
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro gestito come condizione "LIKE '%{0}%'" rispetto al filtro salvato con l'evento</param>
|
||||
/// <returns></returns>
|
||||
public DS_logging.T_logUtenteDataTable tabLogUt(string filtro)
|
||||
{
|
||||
return taLogUt.getByFiltro(filtro);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region area insert valori
|
||||
|
||||
/// <summary>
|
||||
/// inserisce l'evento indicato dai parametri
|
||||
/// </summary>
|
||||
/// <param name="_userEv">user che ha generato l'evento</param>
|
||||
/// <param name="_pagina">pagina/form applicaizone in cui l'evento si è generato</param>
|
||||
/// <param name="_valOrig">valore originale(se c'è)</param>
|
||||
/// <param name="_valNew">valore nuovo/modificato</param>
|
||||
/// <param name="_evento">descrizione evento (poi gestita con anagrafica interna)</param>
|
||||
/// <param name="_filtro">filtro logico evento (poi gestita con anagrafica interna)</param>
|
||||
public void insEvento(string _userEv, string _pagina, string _valOrig, string _valNew, string _evento, string _filtro)
|
||||
{
|
||||
taLogRec.sp_insRecFull(_userEv, _pagina, _valOrig, _valNew, _evento, _filtro);
|
||||
}
|
||||
/// <summary>
|
||||
/// inserisce la nota utente indicata dai parametri, restituisce idx della nota creata...
|
||||
/// </summary>
|
||||
/// <param name="_userNota">user che ha inserito la nota</param>
|
||||
/// <param name="_nota">testo della nota</param>
|
||||
/// <param name="_val">valore ulteriore da associare alla nota (es: label, codice, versione, ...)</param>
|
||||
/// <param name="_filtro">filtro logico evento (poi gestita con anagrafica interna)</param>
|
||||
/// <returns>intero dell'idx della nota creata</returns>
|
||||
public int insNota(string _userNota, string _nota, string _val, string _filtro)
|
||||
{
|
||||
int? answ = 0;
|
||||
taLogUt.sp_insLogUtFull(_userNota, _nota, _val, _filtro, ref answ);
|
||||
return (int)answ;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region area gestione eventi (cestina, delete, associazione a note,...)
|
||||
|
||||
/// <summary>
|
||||
/// associa l'evento e la nota indicati
|
||||
/// </summary>
|
||||
/// <param name="idxRecord">idx del record da associare</param>
|
||||
/// <param name="_idxNota">idx chiave della nota da associare</param>
|
||||
public void associaEvento2Nota(int idxRecord, int _idxNota)
|
||||
{
|
||||
taLogRec.sp_setRec2nota(idxRecord, _idxNota);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// associa l'ultimo evento del filtro indicato alla nota
|
||||
/// </summary>
|
||||
/// <param name="filtro">filtro associato all'ultimo evento...</param>
|
||||
/// <param name="_idxNota">idx chiave della nota da associare</param>
|
||||
public void associaLastEvento2Nota(string filtro, int _idxNota)
|
||||
{
|
||||
taLogRec.sp_setLastRec2nota(filtro, _idxNota);
|
||||
}
|
||||
/// <summary>
|
||||
/// segna come cestinati tutti gli eventi dell'utente indicato non ancora associati o cestinati
|
||||
/// </summary>
|
||||
/// <param name="_userEv">utente generatore dell'evento</param>
|
||||
public void cestinaEventiUser(string _userEv)
|
||||
{
|
||||
taLogRec.sp_cestinaLogRecUt(_userEv);
|
||||
}
|
||||
/// <summary>
|
||||
/// segna come cestinati tutti gli eventi dell'utente indicato non ancora associati o cestinati
|
||||
/// </summary>
|
||||
/// <param name="_filtro">utente generatore dell'evento</param>
|
||||
public void cestinaEventiFiltro(string _filtro)
|
||||
{
|
||||
taLogRec.sp_cestinaLogRecFiltro(_filtro);
|
||||
}
|
||||
/// <summary>
|
||||
/// Elimina gli eventi cestinati generati dall'utente indicato
|
||||
/// </summary>
|
||||
/// <param name="_userEv">utente generatore dell'evento</param>
|
||||
public void eliminaEventiDaUser(string _userEv)
|
||||
{
|
||||
taLogRec.sp_deleteLogUser(_userEv);
|
||||
}
|
||||
/// <summary>
|
||||
/// Elimina gli eventi cestinati anteriori alla data selezionata
|
||||
/// </summary>
|
||||
/// <param name="_dataOra">dataOra dell'evento</param>
|
||||
public void associaEvento2Nota(DateTime _dataOra)
|
||||
{
|
||||
taLogRec.sp_deleteLogMaxData(_dataOra);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua la registrazione dell'evento in session
|
||||
/// </summary>
|
||||
public void registraEventi(string _userEv, string _pagina)
|
||||
{
|
||||
// controllo: loggin SOLO se la scheda ha logging abilitato nella riga del db...
|
||||
bool logEn = memLayer.ML.BoolSessionObj("logEn");
|
||||
memLayer.ML.emptySessionVal("logEn");
|
||||
if (logEn)
|
||||
{
|
||||
// leggo e svuoto info x logging
|
||||
string ev2log = memLayer.ML.StringSessionObj("ev2log");
|
||||
memLayer.ML.emptySessionVal("ev2log");
|
||||
string valOrig = memLayer.ML.StringSessionObj("valOrig");
|
||||
memLayer.ML.emptySessionVal("valOrig");
|
||||
string valNew = memLayer.ML.StringSessionObj("valNew");
|
||||
memLayer.ML.emptySessionVal("valNew");
|
||||
string filtEv = memLayer.ML.StringSessionObj("filtEv");
|
||||
memLayer.ML.emptySessionVal("filtEv");
|
||||
// effettuo logging evento
|
||||
l2n.insEvento(_userEv, _pagina, valOrig, valNew, ev2log, filtEv);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// metodo di comportamento del controllo di logging
|
||||
/// </summary>
|
||||
public enum logControlMode
|
||||
{
|
||||
/// <summary>
|
||||
/// nasconde pannello log
|
||||
/// </summary>
|
||||
hideLog,
|
||||
/// <summary>
|
||||
/// memorizza log inserito
|
||||
/// </summary>
|
||||
recordLog,
|
||||
/// <summary>
|
||||
/// mostra pannello log
|
||||
/// </summary>
|
||||
showLog
|
||||
}
|
||||
/// <summary>
|
||||
/// metodo di comportamento del controllo di logging
|
||||
/// </summary>
|
||||
public enum tipoApprovazione
|
||||
{
|
||||
/// <summary>
|
||||
/// indica il primo step del doppio livello di approvazione (completamento)
|
||||
/// </summary>
|
||||
completamento,
|
||||
/// <summary>
|
||||
/// SOLO con incremento indice di revisione dell'oggetto approvato
|
||||
/// </summary>
|
||||
revisione,
|
||||
/// <summary>
|
||||
/// SOLO mantenendo indice di revisione corrente
|
||||
/// </summary>
|
||||
semplice,
|
||||
/// <summary>
|
||||
/// permette SIA con revisione che senza (e anche rev -1)
|
||||
/// </summary>
|
||||
tutto
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user