diff --git a/SteamWare/App_Readme/SteamWare_demo/example-config-table.txt b/SteamWare/App_Readme/SteamWare_demo/example-config-table.txt
index dd0ab8e..62cd776 100644
--- a/SteamWare/App_Readme/SteamWare_demo/example-config-table.txt
+++ b/SteamWare/App_Readme/SteamWare_demo/example-config-table.txt
@@ -2,8 +2,10 @@
_adminEmail samuele@steamware.net,info@steamware.net samuele@steamware.net,info@steamware.net info@steamware.net
_allowForceUser true true abilita login forzato
_commonPages menu menu pagina comune
-_emailPwd drmfsls16 drmfsls16 drmfsls16
-_emailUser steamwarebot@gmail.com steamwarebot@gmail.com steamwarebot@gmail.com
+_emailPwd siamoInViaNazionale93 siamoInViaNazionale93 siamoInViaNazionale93
+_emailUser steamwarebot@outlook.it steamwarebot@outlook.it steamwarebot@outlook.it
+_smtpCli smtp-mail.outlook.com smtp-mail.outlook.com smtp-mail.outlook.com
+_fromEmail steamwarebot@outlook.it steamwarebot@outlook.it steamwarebot@outlook.it
_enableSSL true true true
_fromEmail webmaster@admodelling.org webmaster@admodelling.org email mittente eventuali msg
_righeDataGrid 30 30 Num righe datagrid std
diff --git a/SteamWare/ApplicationUserControl.cs b/SteamWare/ApplicationUserControl.cs
index 1b9ef8a..94ebb32 100644
--- a/SteamWare/ApplicationUserControl.cs
+++ b/SteamWare/ApplicationUserControl.cs
@@ -5,1456 +5,1504 @@ using System.IO;
namespace SteamWare
{
- ///
- /// Base class for every user control in the application, containing some common
- /// behaviour and utility methods.
- /// It is not meant to be be used directly.
- ///
- public class ApplicationUserControl : System.Web.UI.UserControl
- {
///
- /// tipo id controllo con classi di base comune da cui derivare gli *.asmx
+ /// Base class for every user control in the application, containing some common behaviour and
+ /// utility methods. It is not meant to be be used directly.
+ /// * Definizioni generali:
+ /// * SteamWare: codice scritto manualmente da SteamWare
+ /// * webForm: codice autogenerato da VisualStudio
+ /// * =c= : codice costante(non serve modifica)
+ /// * >c> : codice variabile(va modificato x ogni controllo / pagina)
+ ///
+ /// * Notazione
+ /// * _ : se posto all'inizio del nome indica una variabile/oggetto caricato in memoria da input pagina e/o session
+ /// * MAIUS : le procedure / metodi con prima lettera in MAIUSCOLO indicano codice COSTANTE
+ /// * minus : le procedure / metodi con prima lettera in minuscolo indicano codice variabile da verificare////modificare
///
- public ApplicationUserControl()
- { }
- /*
- * Definizioni generali:
- * SteamWare: codice scritto manualmente da SteamWare
- * webForm: codice autogenerato da VisualStudio
- * =c= : codice costante (non serve modifica)
- * : codice variabile (va modificato x ogni controllo / pagina)
- *
- * Notazione
- * _ : se posto all'inizio del nome indica una variabile/oggetto caricato in memoria da input pagina e/o session
- * MAIUS : le procedure / metodi con prima lettera in MAIUSCOLO indicano codice COSTANTE
- * minus : le procedure / metodi con prima lettera in minuscolo indicano codice variabile da verificare/modificare
- */
-
-
- ///
- /// imposto il tipo di anagrafica del controlloS
- ///
- public tipoAnagrafica TipoAnagControllo
+ public class ApplicationUserControl : System.Web.UI.UserControl
{
- get
- {
- return _tipoAnagrafica;
- }
- set
- {
- _tipoAnagrafica = value;
- }
- }
+ #region Public Fields
- #region dati utente e sessione =c=
+ ///
+ /// nome della pagina correntemente caricata
+ ///
+ public string _paginaCorrente;
- ///
- /// nome della pagina correntemente caricata
- ///
- public string _paginaCorrente;
- ///
- /// memorizza la pagina precedente (ovvero la corrente ma non da page-object ma in session...
- ///
- public string _paginaPrecedente;
- ///
- /// stringa con CDC in (...) dei cdc abilitati (da permesso gerarchicamente a discendere...)
- ///
- protected string _AuthCdC;
- ///
- /// stringa con elenco CDC abilitati (da permesso gerarchicamente a discendere...)
- ///
- protected string _CdCUser;
+ ///
+ /// memorizza la pagina precedente (ovvero la corrente ma non da page-object ma in session...
+ ///
+ public string _paginaPrecedente;
- #endregion
+ #endregion Public Fields
- #region tabelle dati
+ #region Public Constructors
- ///
- /// tabella diritti
- ///
- protected DataLayer_AnagGen.DIRITTIDataTable _Diritti;
- ///
- /// tabella di tutti i cdc
- ///
- protected DataLayer_AnagGen.CDCDataTable _allCdC;
+ ///
+ /// tipo id controllo con classi di base comune da cui derivare gli *.asmx
+ ///
+ public ApplicationUserControl()
+ { }
- #endregion
+ #endregion Public Constructors
- #region altri dati
+ #region Public Events
- ///
- /// tipo di anagrafica usata
- ///
- protected tipoAnagrafica _tipoAnagrafica = tipoAnagrafica.Standard;
- ///
- /// importo il tipo di vista del modulo
- ///
- protected tipoVistaMod _vistaModulo = tipoVistaMod.editing;
+ ///
+ /// event handler generico
+ ///
+ public event EventHandler eh_ucev;
- ///
- /// elenco testuale csv dei cdc accessibili all'utente (x filtri tipo IN(...))
- ///
- protected string _elencoCdC;
- ///
- /// numero di righe standard x i datagrid
- ///
- protected int _righeDataGrid;
- ///
- /// numero di righe standard x i datagrid di anagrafica
- ///
- protected int _righeDataGridAnagr;
- ///
- /// numero di righe standard x i datagrid lunghi
- ///
- protected int _righeDataGridLong;
- ///
- /// numero di righe standard x i datagrid medi
- ///
- protected int _righeDataGridMed;
- ///
- /// numero di righe standard x i datagrid su mezza pagina
- ///
- protected int _righeDataGridShort;
- ///
- /// numero di righe standard x i selettori popup
- ///
- protected int _righeSelettore;
- ///
- /// indirizzo email dell'admin applicativo cui vanno le email in caso di anomalie...
- ///
- protected string _adminEmail;
- ///
- /// indirizzo email dell'applicativo da cui partono le email in caso di anomalie...
- ///
- protected string _fromEmail;
- ///
- /// indirizzo server SMTP
- ///
- protected string _smtpCli;
- ///
- /// elenco delle pagine "safe" ovvero da non autorizzare - da web.config
- ///
- protected string _safePages;
- ///
- /// elenco delle pagine "common" ovvero da autorizzare ma senza bisogno diritti in anagrafica - da web.config
- ///
- protected string _commonPages;
- ///
- /// valore che determina se � possibile forzare impersonificazioen utente...
- ///
- protected bool _allowForceUser;
- ///
- /// livello di log (1-->5)
- ///
- protected int _logLevel;
- ///
- /// dir di logging
- ///
- protected string _logBaseDir;
+ #endregion Public Events
- #endregion
+ #region Public Properties
- #region flusso creazione pagina =c=
-
- ///
- /// MAIN: esecuzione al caricamento del modulo delle routines di controllo utente e creazione pagina
- ///
- ///
- ///
- protected virtual void Page_Load(object sender, System.EventArgs e)
- {
- // carico i dati...
- LoadUserData();
- SetUpByUserRight();
- loadSessionData();
- PredisponiDati();
- bindControlli();
- }
-
- ///
- /// predisposizione dati x pagina da cache/database a seconda della disponibilit� in cache o refresh (B.1.4)
- ///
- protected void PredisponiDati()
- {
- if (!datiDisponibili())
- {
- resetUpdate();
- forza_Update();
- }
- else
- {
- caricaDati();
- }
- }
-
- ///
- /// popola gli oggetti e le labels... (B.1.6)
- ///
- protected virtual void bindControlli()
- {
- // IsPostBack � TRUE se utilizzo javascript ovvero confermo cancellazioni o modifico i controlli...
- if (!IsPostBack)
- {
- DisegnaPagina();
- }
- }
-
- ///
- /// disegna la pagina: prima i controlli poi il datagrid
- ///
- protected void DisegnaPagina()
- {
- sistemaControlli();
- aggiungiLink();
- aggiornaControlliDataGL();
- traduciObj();
- }
- ///
- /// aggiunge i link x i selettori
- ///
- protected virtual void aggiungiLink()
- {
- }
-
- ///
- /// sistema i vari controlli della pagina
- ///
- protected virtual void sistemaControlli()
- { }
- ///
- /// aggiorna eventuali datalist e datagrid
- ///
- protected virtual void aggiornaControlliDataGL()
- {
- }
-
- ///
- /// sistema tutte le labels traducendo i lemmi nella lingua utente ed in inglese
- ///
- protected virtual void traduciObj()
- { }
-
-
-
- #endregion
-
- #region utility =c=
-
- ///
- /// calcola come percentuale la radio dividendo/divisore
- ///
- ///
- ///
- ///
- public string percentuale(object dividendo, object divisore)
- {
- string answ = "";
- double _dividendo = Convert.ToDouble(dividendo);
- double _divisore = Convert.ToDouble(divisore);
- try
- {
- answ = string.Format("{0:p}", _dividendo / _divisore);
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// limita una stringa al numero max di caratteri imposto
- ///
- ///
- ///
- ///
- public string limitString(string original, int maxChar)
- {
- string outString = original;
- if (outString.Length > maxChar)
- {
- outString = string.Format("{0}...", original.Substring(0, maxChar - 3));
- }
- return outString;
- }
-
- ///
- /// Reads data from a stream until the end is reached. The
- /// data is returned as a byte array. An IOException is
- /// thrown if any of the underlying IO calls fail.
- ///
- /// The stream to read data from
- /// The initial buffer length
- public static byte[] ReadFully(Stream stream, int initialLength)
- {
- // If we've been passed an unhelpful initial length, just
- // use 32K.
- if (initialLength < 1)
- {
- initialLength = 32768;
- }
-
- byte[] buffer = new byte[initialLength];
- int read = 0;
-
- int chunk;
- while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
- {
- read += chunk;
-
- // If we've reached the end of our buffer, check to see if there's
- // any more information
- if (read == buffer.Length)
+ ///
+ /// imposto il tipo di anagrafica del controlloS
+ ///
+ public tipoAnagrafica TipoAnagControllo
{
- int nextByte = stream.ReadByte();
-
- // End of stream? If so, we're done
- if (nextByte == -1)
- {
- return buffer;
- }
-
- // Nope. Resize the buffer, put in the byte we've just
- // read, and continue
- byte[] newBuffer = new byte[buffer.Length * 2];
- Array.Copy(buffer, newBuffer, buffer.Length);
- newBuffer[read] = (byte)nextByte;
- buffer = newBuffer;
- read++;
- }
- }
- // Buffer is now too big. Shrink it.
- byte[] ret = new byte[read];
- Array.Copy(buffer, ret, read);
- return ret;
- }
-
-
- ///
- /// converte una data in formato aaaammgg in stringa gg/mm/aaaa
- ///
- ///
- ///
- public string data2string(object val)
- {
- string dataFormattata = "";
- try
- {
- string data = val.ToString();
- dataFormattata = data.Substring(6, 2) + "/" + data.Substring(4, 2) + "/" + data.Substring(0, 4);
- }
- catch
- {
- }
- return dataFormattata;
- }
- ///
- /// converte una data in formato aaaammgg in stringa aaaa-mm-gg
- ///
- ///
- ///
- public string data2IsoString(object val)
- {
- string dataFormattata = "";
- try
- {
- string data = val.ToString();
- dataFormattata = data.Substring(0, 4) + "-" + data.Substring(4, 2) + "-" + data.Substring(6, 2);
- }
- catch
- {
- }
- return dataFormattata;
- }///
- /// converte una stringa in formato gg/mm/aaaa in stringa(intero data) in formato aaaammgg
- ///
- ///
- ///
- public string string2data(object val)
- {
- DateTime data = Convert.ToDateTime(val);
- return (data.Year).ToString() + (data.Month).ToString().PadLeft(2, '0') + (data.Day).ToString().PadLeft(2, '0');
- }
- ///
- /// converte una datetime in un intero tipo yyyymmddhhmmss
- ///
- ///
- ///
- public long datetime2int(DateTime _data)
- {
- long valore_data = 0;
- long valore_time = 0;
- long valore = 0;
- valore_data = (_data).Year * 10000 + (_data).Month * 100 + (_data).Day;
- valore_time = (_data).Hour * 10000 + (_data).Minute * 100 + (_data).Second;
- valore = valore_data * 1000000 + valore_time;
- return valore;
- }
- ///
- /// formatta la data in formato dateTime in una data formato italiano come stringa gg/mm/aaaa
- ///
- ///
- ///
- public string dataItaliana(DateTime dataRichiesta)
- {
- string dataFormattata;
- dataFormattata = dataRichiesta.Day.ToString().PadLeft(2, '0') + "/" + dataRichiesta.Month.ToString().PadLeft(2, '0') + "/" + dataRichiesta.Year.ToString();
- return dataFormattata;
- }
-
-
-
- ///
- /// invia un alert jscript con messaggio indicato...
- ///
- /// messaggio dell'alert da mandare
- public void mandaAlert(string _messaggio)
- {
- string comando = "";
- Response.Write(comando);
- }
- ///
- /// scrive immediatamente sulla pagina web il messaggio di avanzamento...
- ///
- ///
- public void scriviAvanzamento(string _messaggio)
- {
- Response.Write(_messaggio);
- Response.Flush();
- }
-
- ///
- /// restituisce una scringa formattata in testa e coda x essere un corretto comando javascript
- ///
- ///
- ///
- public string jscriptFormat(string comando)
- {
- return "";
- }
-
- #endregion
-
- #region gestione email & log...
-
- ///
- /// invio email senza log
- ///
- ///
- ///
- ///
- ///
- ///
- protected bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
- {
- bool answ = false;
- try
- {
- answ = SteamWare.gestEmail.ge.mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
- }
- catch { }
- return answ;
- }
- ///
- /// invio email con log
- ///
- ///
- ///
- ///
- ///
- ///
- protected bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
- {
- return SteamWare.gestEmail.ge.mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
- }
-
- #endregion
-
- #region gestione dati
-
- ///
- /// caricamento dati applicazione da sessione (B.1.3)
- ///
- protected virtual void loadSessionData()
- {
- }
- ///
- /// setup datamanagers...
- ///
- protected virtual void setupUserDataMan()
- {
- }
- ///
- /// reset update del modulo corrente
- ///
- protected virtual void resetUpdate()
- { }
- ///
- /// (ri)carica i dataset del modulo
- ///
- protected virtual void forza_Update()
- { }
- ///
- /// verifica se tutti i dataset richiesti sono disponibili i cache
- ///
- ///
- protected virtual bool datiDisponibili()
- {
- return true;
- }
- ///
- /// salva nella cache i dataset caricati
- ///
- protected virtual void salvaDati()
- { }
- ///
- /// carica dalla cache i dataset necessari
- ///
- protected virtual void caricaDati()
- { }
-
-
- #endregion
-
- #region lettura dataset standard
-
- ///
- /// legge i valori standard x dataset e parametri
- ///
- protected void StandardDataLoad()
- {
- try
- {
- loadAuthCdC();
- }
- catch
- { }
- }
- ///
- /// leggi i parametri di configurazione standard dell'applicativo
- ///
- protected void loadDefaultsWebConfig()
- {
- _righeDataGrid = memLayer.ML.CRI("_righeDataGrid");
- _righeDataGridAnagr = memLayer.ML.CRI("_righeDataGridAnagr");
- _righeDataGridLong = memLayer.ML.CRI("_righeDataGridLong");
- _righeDataGridMed = memLayer.ML.CRI("_righeDataGridMed");
- _righeDataGridShort = memLayer.ML.CRI("_righeDataGridShort");
- _adminEmail = memLayer.ML.CRS("_adminEmail");
- _fromEmail = memLayer.ML.CRS("_fromEmail");
- _smtpCli = memLayer.ML.CRS("_smtpCli");
- _logLevel = memLayer.ML.CRI("_logLevel");
- _safePages = memLayer.ML.CRS("_safePages");
- _commonPages = memLayer.ML.CRS("_commonPages");
- }
- ///
- /// genera la stringa dei cdc autorizzati dell'utente
- ///
- protected void loadAuthCdC()
- {
- if (!memLayer.ML.isInSessionObject("_AuthCdC"))
- {
- _CdCUser = elencoCdC;
- memLayer.ML.setSessionVal("_CdCUser", _CdCUser);
- _AuthCdC = string.Format(" COD_CDC IN ({0})", _CdCUser);
- memLayer.ML.setSessionVal("_AuthCdC", _AuthCdC);
- }
- else
- {
- _AuthCdC = memLayer.ML.StringSessionObj("_AuthCdC");
- }
- }
-
- ///
- /// legge il dataset dei CdC
- ///
- protected void loadAllCdC()
- {
- if (!memLayer.ML.isInCacheObject("_allCdC"))
- {
- _allCdC = DataWrap.DW.taCdc.GetData();
- //Cache["_allCdC"] = _allCdC;
- memLayer.ML.setCacheVal("_allCdC", _allCdC, true);
- }
- else
- {
- _allCdC = (DataLayer_AnagGen.CDCDataTable)Cache["_allCdC"];
- }
- }
-
- #endregion
-
- #region autenticazione / autorizzazione =c=
-
- ///
- /// caricamento dati user da sessione (B.1.1)
- ///
- protected void LoadUserData()
- {
- _paginaPrecedente = memLayer.ML.StringSessionObj("_paginaPrecedente");
- setupUserDataMan();
- loadDefaultsWebConfig();
- if (user_std.UtSn.utente != "")
- {
- StandardDataLoad();
- }
- }
-
- ///
- /// verifica che l'utente abbia almeno un permesso per la pagina corrente altrimenti redirect ad unauthorized
- ///
- protected virtual void SetUpByUserRight()
- {
- PagCorrente();
- // verifica la pagina NON sia di quelle "libere"
- if (_safePages.IndexOf(_paginaCorrente) == -1)
- {
- // verifica l'utente sia autorizzato (in session...)
- if (!user_std.UtSn.isAuth)
- {
- if (_paginaCorrente != "" && _paginaCorrente != "login.aspx")
- {
- Session["nextPage"] = _paginaCorrente;
- }
-
- Response.Redirect("login.aspx");
- }
- // verifica i permessi dell'utente per almeno vedere la pagina corrente SSE non � una common page...
- if (!user_std.UtSn.isPageEnabled(_paginaCorrente) && _commonPages.IndexOf(_paginaCorrente) == -1)
- {
- logger.lg.scriviLog(string.Format("Errore in SetUpByUserRight: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
- Response.Redirect("~/unauthorized.aspx");
- }
-
- }
- }
-
- ///
- /// salva in variabile pagina il nome della pagina corrente
- ///
- protected virtual void PagCorrente()
- {
- Uri MyUrl = Request.Url;
- string delimStr = "/";
- char[] delimiter = delimStr.ToCharArray();
- string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
- int n = finalUrl.Length;
- _paginaCorrente = finalUrl[n - 1].ToString();
- // tolgo .aspx!
- _paginaCorrente = _paginaCorrente.Replace(".aspx", "");
- if (string.IsNullOrEmpty(_paginaPrecedente) || _paginaPrecedente == null)
- {
- _paginaPrecedente = _paginaCorrente;
- memLayer.ML.setSessionVal("_paginaPrecedente", _paginaPrecedente);
- }
- if (_paginaCorrente != _paginaPrecedente)
- {
- // in questo caso tolgo i vari filtering e gli indici...
- memLayer.ML.emptySessionVal("_indexFilt");
- memLayer.ML.emptySessionVal("valoreCercato");
- _paginaPrecedente = _paginaCorrente;
- memLayer.ML.setSessionVal("_paginaPrecedente", _paginaPrecedente);
- }
- }
-
- ///
- /// selezione delle posizioni cdc autorizzate come stringa di filtraggio su POSIZIONE LIKE, se non ce ne fossero redirige su unauthorized.aspx
- ///
- ///
- protected string filtroPosizioneCdC()
- {
- string Filtraggio;
- Filtraggio = " (";
- DataLayer_AnagGen.CDCDataTable tblCdc = DataWrap.DW.taCdc.GetTopCdC(user_std.UtSn.utente, user_std.UtSn.dominio, user_std.UtSn.modulo);
- if (tblCdc.Rows.Count == 0 && _safePages.IndexOf(_paginaCorrente) == -1)
- {
- logger.lg.scriviLog(string.Format("Errore in filtroPosizioneCdC: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
- Response.Redirect("~/unauthorized.aspx");
- }
- foreach (DataLayer_AnagGen.CDCRow riga in tblCdc)
- {
- // aggiongo solo se non � contenuta la posizione...
- if (Filtraggio.IndexOf(riga.POSIZIONE) == -1)
- {
- // controllo se posizione termina col punto...
- if (riga.POSIZIONE.EndsWith("."))
- {
- Filtraggio += String.Format("(POSIZIONE LIKE '{0}%') OR ", riga.POSIZIONE);
- }
- else
- {
- Filtraggio += String.Format("(POSIZIONE LIKE '{0}.%') OR ", riga.POSIZIONE);
- }
- }
- }
- int lungFiltr = Filtraggio.Length;
- Filtraggio = Filtraggio.Remove(lungFiltr - 3, 3);
- Filtraggio += ") ";
- return Filtraggio;
- }
-
- ///
- /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione
- ///
- ///
- public bool isWritable()
- {
- bool answ = false;
- if (_paginaCorrente == null)
- {
- PagCorrente();
- }
- answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente);
- return answ;
- }
-
- #endregion
-
- #region funzioni x sorting & filtering =c=
-
- ///
- /// verifica la condizione booleana e formatta di conseguenza la stringa di filtraggio da accodare al filtro x CdC autorizzati
- ///
- /// condizione
- /// tipo di eguaglianza
- /// nome parametro
- /// valore parametro
- ///
- protected string condFilter(bool _condizione, string _tipoEqual, string _nomeParam, string _valParam)
- {
- string outFilter = "";
- if (_condizione && _valParam != "")
- {
- if (_tipoEqual == "=")
- {
- outFilter = " AND (" + _nomeParam.Replace("'", "''") + " = '" + _valParam.Replace("'", "''") + "')";
- }
- else if (_tipoEqual == "IN")
- {
- outFilter = String.Format(" AND ({0} IN ({1}))", _nomeParam.Replace("'", "''"), _valParam.Replace("'", "''"));
- }
-
- else
- {
- outFilter = " AND (" + _nomeParam.Replace("'", "''") + " LIKE '%" + _valParam.Replace("'", "''") + "%')";
- }
- }
- return outFilter;
- }
- ///
- /// crea la stringa di filtraggio x data secondo modalit� tipo inizio/fine/durante...
- ///
- ///
- protected string dataFilter(bool _condizione, string _tipoPeriodo, string _nomeFrom, string _dataFrom, string _nomeTo, string _dataTo)
- {
- string outFilter = "";
- if (_condizione)
- {
- // carica i valori dalle textbox... se non ci sono li imposta a:
- // start = 01/01/1900
- // end = 01/01/2200
- try
- {
- _dataFrom = _dataFrom.Replace(".", "/");
- if (string.IsNullOrEmpty(_dataFrom))
- {
- _dataFrom = "01/01/1900";
- }
- }
- catch
- {
- _dataFrom = "01/01/1900";
- }
- try
- {
- _dataTo = _dataTo.Replace(".", "/");
- if (string.IsNullOrEmpty(_dataTo))
- {
- _dataTo = "01/01/2200";
- }
- }
- catch
- {
- _dataTo = "01/01/2200";
- }
- switch (_tipoPeriodo)
- {
- case "1":
- // filtro su inizio
- outFilter += " AND (" + _nomeFrom + " >= '" + _dataFrom + "' AND " + _nomeFrom + " <= '" + _dataTo + "') ";
- break;
- case "2":
- // filtro su scadenza
- outFilter += " AND (" + _nomeTo + " >= '" + _dataFrom + "' AND " + _nomeTo + " <= '" + _dataTo + "') ";
- break;
- case "3":
- // filtro su "in corso"
- outFilter += " AND NOT (" + _nomeFrom + " > '" + _dataTo + "' OR " + _nomeTo + " < '" + _dataFrom + "') ";
- break;
- }
- }
- return outFilter;
- }
-
- ///
- /// crea la stringa di filtraggio x data secondo modalit� tipo minoreUguale / uguale / maggioreUguale...
- ///
- ///
- protected string dataFilter(bool _condizione, string _tipoPeriodo, string _nome, string _data)
- {
- string outFilter = "";
- if (_condizione)
- {
- // carica i valori dalle textbox... se non ci sono li imposta a:
- // start = 01/01/1900
- // end = 01/01/2200
- try
- {
- _data = _data.Replace(".", "/");
- if (string.IsNullOrEmpty(_data))
- {
- _data = "01/01/1900";
- }
- }
- catch
- {
- _data = "01/01/1900";
- }
- switch (_tipoPeriodo)
- {
- case "<=":
- // filtro su inizio
- outFilter += " AND (" + _nome + " <= '" + _data + "') ";
- break;
- case "=":
- // filtro su scadenza
- outFilter += " AND (" + _nome + " = '" + _data + "') ";
- break;
- case ">=":
- // filtro su "in corso"
- outFilter += " AND (" + _nome + " >= '" + _data + "') ";
- break;
- }
- }
- return outFilter;
- }
- ///
- /// verifica la condizione booleana e formatta di conseguenza la stringa di filtraggio tipo LIKE x i campi inseriti separati da # SE valParam !=""
- ///
- ///
- ///
- ///
- protected string likeFilter(string _elencoCampi, string _valParam)
- {
- string outFilter = "";
- if (_valParam != "")
- {
- outFilter = " AND ( ";
- string comandoCompleto = _elencoCampi;
- string[] comando = comandoCompleto.Split('#');
- int numCampi = comando.GetLength(0);
- for (int i = 1; i <= numCampi; i++)
- {
- outFilter += "(" + comando[i - 1] + " LIKE '%" + _valParam + "%')";
- outFilter += " OR ";
- }
- outFilter = outFilter.Remove(outFilter.Length - 3, 3);
- outFilter += " ) ";
- }
- return outFilter;
- }
-
- ///
- /// variabile salvata in view state x la stringa di sorting - dg 2
- ///
- protected string SortField2
- {
- //registra nella viewState la stringa di sorting
- //(nome campo + scritta desc o nulla che equivale ad ascending...)
- //si pu� impropriamente usare x + controlli... al max serve 1 click in +...
- get
- {
- object o = ViewState["SortField2"];
- if (o == null)
- {
- return String.Empty;
- }
- return (string)o;
- }
-
- set
- {
- if (value == SortField2)
- {
- // same as current sort file, toggle sort direction
- SortAscending = !SortAscending;
- }
- ViewState["SortField2"] = value;
- }
- }
-
- ///
- /// variabile salvata in view state x la stringa di sorting - dg 2
- ///
- protected string SortField
- {
- //registra nella viewState la stringa di sorting
- //(nome campo + scritta desc o nulla che equivale ad ascending...)
- //si pu� impropriamente usare x + controlli... al max serve 1 click in +...
- get
- {
- object o = ViewState["SortField"];
- if (o == null)
- {
- return String.Empty;
- }
- return (string)o;
- }
-
- set
- {
- if (value == SortField)
- {
- // same as current sort file, toggle sort direction
- SortAscending = !SortAscending;
- }
- ViewState["SortField"] = value;
- }
- }
- ///
- /// legge e scrive in viewState la stringa di filtraggio...
- ///
- protected string FiltString
- {
- get
- {
- object o = ViewState["FiltString"];
- if (o == null)
- {
- return String.Empty;
- }
- return (string)o;
- }
-
- set
- {
- ViewState["FiltString"] = value;
- }
- }
- ///
- /// variabile salvata in viewstate x la direzione del sorting
- ///
- protected bool SortAscending
- {
- //memorizza l'ultima direzione di sort x poterla invertire
- get
- {
- object o = ViewState["SortAscending"];
- if (o == null)
- {
- return true;
- }
- return (bool)o;
- }
-
- set
- {
- ViewState["SortAscending"] = value;
- }
- }
- ///
- /// genera la stringa filtro x i cdc autorizzati x l'user
- ///
- ///
- protected string elencoCdC
- {
- get
- {
- // messo qui caricamento dei cdc...
- loadAllCdC();
- //filtro sui CdC -- ATTENZIONE!!! possibile stack overflow se si supera un filtro con oltre 5000 char di posizioni... loop! vedi 647 mantis
- string filtroCompleto = filtroPosizioneCdC();
- string filtroCorrente = "";
- string Filtraggio;
- //dall'elenco dei CdC compone filtro x tabella corrente...
- Filtraggio = "";
- // setta a 0 il cdc precedente... poi inserisce il cdc SE E SOLO SE � diverso dal precedente: � distinct!!!
- string _cdcPrec = "000";
- string _cdcCurr = "";
- int currPos = 0;
- int filtLenght = filtroCompleto.Length;
- int currLenght = 0;
- // workaround: separo la ricerca in + tranches, andando a prendere solo (circa) 2000 char alla volta...
- if (filtroCompleto.Length < 2000)
- {
- // uso il filtro completo...
- Filtraggio = recuperaCdC_daFiltro(filtroCompleto, ref Filtraggio, ref _cdcPrec, ref _cdcCurr);
- }
- else
- {
- while (currPos < filtLenght)
- {
- // se non trova significa che siamo all'ultimo "tratto" da meno di 1900 char...
- if (filtLenght - currPos < 2100)
+ get
{
- currLenght = filtLenght - currPos;
+ return _tipoAnagrafica;
+ }
+ set
+ {
+ _tipoAnagrafica = value;
+ }
+ }
+
+ ///
+ /// tipo di vista del modulo
+ ///
+ public tipoVistaMod vistaModulo
+ {
+ get
+ {
+ return _vistaModulo;
+ }
+ set
+ {
+ _vistaModulo = value;
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ ///
+ /// Reads data from a stream until the end is reached. The data is returned as a byte array.
+ /// An IOException is thrown if any of the underlying IO calls fail.
+ ///
+ /// The stream to read data from
+ /// The initial buffer length
+ public static byte[] ReadFully(Stream stream, int initialLength)
+ {
+ // If we've been passed an unhelpful initial length, just use 32K.
+ if (initialLength < 1)
+ {
+ initialLength = 32768;
+ }
+
+ byte[] buffer = new byte[initialLength];
+ int read = 0;
+
+ int chunk;
+ while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
+ {
+ read += chunk;
+
+ // If we've reached the end of our buffer, check to see if there's any more information
+ if (read == buffer.Length)
+ {
+ int nextByte = stream.ReadByte();
+
+ // End of stream? If so, we're done
+ if (nextByte == -1)
+ {
+ return buffer;
+ }
+
+ // Nope. Resize the buffer, put in the byte we've just read, and continue
+ byte[] newBuffer = new byte[buffer.Length * 2];
+ Array.Copy(buffer, newBuffer, buffer.Length);
+ newBuffer[read] = (byte)nextByte;
+ buffer = newBuffer;
+ read++;
+ }
+ }
+ // Buffer is now too big. Shrink it.
+ byte[] ret = new byte[read];
+ Array.Copy(buffer, ret, read);
+ return ret;
+ }
+
+ ///
+ /// salva in sessione i valori indicati
+ ///
+ /// dictionary dei valori vecchi
+ /// dictionary dei valori nuovi
+ /// bool su abilitazione al log dell'oggetto
+ /// descrizione evento da loggare
+ /// filtro associato all'evento
+ /// restituisce il numero di elementi contenuti, -1 significa nessuna differenza...
+ public static int setLogValueToSession(Dictionary oldVal, Dictionary newVal, bool logEnabled, string ev2log, string filtroEv)
+ {
+ int answ = -1;
+ // salvo i valori x logging
+ confrontoValori.obj.paramOld = oldVal;
+ confrontoValori.obj.paramNew = newVal;
+ // faccio generare il diff...
+ confrontoValori.obj.doDiff();
+ // logging modifica
+ memLayer.ML.setSessionVal("ev2log", ev2log);
+ memLayer.ML.setSessionVal("logEn", logEnabled);
+ memLayer.ML.setSessionVal("filtEv", filtroEv);
+ memLayer.ML.setSessionVal("valOrig", confrontoValori.obj.valOld);
+ memLayer.ML.setSessionVal("valNew", confrontoValori.obj.valNew);
+ // se ci sono differenze allora restituisco posizione della prima differenza, cercando
+ //
nella stringa...
+ try
+ {
+ if (confrontoValori.obj.valNew != "")
+ {
+ string[] righe = confrontoValori.obj.valNew.Split('<');
+ answ = righe.Length;
+ }
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// salva in sessione i valori per un oggetto che sta x essere eliminato
+ ///
+ /// dictionary dei valori vecchi
+ /// bool su abilitazione al log dell'oggetto
+ /// descrizione evento da loggare
+ /// filtro associato all'evento
+ /// restituisce il numero di elementi contenuti, -1 significa nessuna differenza...
+ public static int setLogValueToSession4del(Dictionary oldVal, bool logEnabled, string ev2log, string filtroEv)
+ {
+ int answ = -1;
+ // salvo i valori x logging
+ confrontoValori.obj.paramOld = oldVal;
+ // faccio generare il diff...
+ confrontoValori.obj.calcOldVal();
+ // logging modifica
+ memLayer.ML.setSessionVal("ev2log", ev2log);
+ memLayer.ML.setSessionVal("logEn", logEnabled);
+ memLayer.ML.setSessionVal("filtEv", filtroEv);
+ memLayer.ML.setSessionVal("valOrig", confrontoValori.obj.valOld);
+ memLayer.ML.setSessionVal("valNew", "-");
+ // se ci sono differenze allora restituisco posizione della prima differenza, cercando
+ //
nella stringa...
+ try
+ {
+ string[] righe = confrontoValori.obj.valNew.Split('<');
+ answ = righe.Length;
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// restituisce il cdc dell'utente data la sua matricola
+ ///
+ ///
+ ///
+ public string cdcUtente(object val)
+ {
+ DataLayer_AnagGen.UTENTERow riga = DataWrap.DW.taUtente.getByMatricola(val.ToString())[0];
+ return riga.COD_CDC;
+ }
+
+ ///
+ /// invia la stringa jscript di conferma pre-cancellazione
+ ///
+ ///
+ public string confermaCancellazione()
+ {
+ return string.Format("return confirm(\"{0}\");", user_std.UtSn.Traduci("confermaDel"));
+ }
+
+ ///
+ /// converte una data in formato aaaammgg in stringa aaaa-mm-gg
+ ///
+ ///
+ ///
+ public string data2IsoString(object val)
+ {
+ string dataFormattata = "";
+ try
+ {
+ string data = val.ToString();
+ dataFormattata = data.Substring(0, 4) + "-" + data.Substring(4, 2) + "-" + data.Substring(6, 2);
+ }
+ catch
+ {
+ }
+ return dataFormattata;
+ }
+
+ ///
+ /// converte una data in formato aaaammgg in stringa gg/mm/aaaa
+ ///
+ ///
+ ///
+ public string data2string(object val)
+ {
+ string dataFormattata = "";
+ try
+ {
+ string data = val.ToString();
+ dataFormattata = data.Substring(6, 2) + "/" + data.Substring(4, 2) + "/" + data.Substring(0, 4);
+ }
+ catch
+ {
+ }
+ return dataFormattata;
+ }
+
+ ///
+ /// formatta la data in formato dateTime in una data formato italiano come stringa gg/mm/aaaa
+ ///
+ ///
+ ///
+ public string dataItaliana(DateTime dataRichiesta)
+ {
+ string dataFormattata;
+ dataFormattata = dataRichiesta.Day.ToString().PadLeft(2, '0') + "/" + dataRichiesta.Month.ToString().PadLeft(2, '0') + "/" + dataRichiesta.Year.ToString();
+ return dataFormattata;
+ }
+
+ ///
+ /// converte una datetime in un intero tipo yyyymmddhhmmss
+ ///
+ ///
+ ///
+ public long datetime2int(DateTime _data)
+ {
+ long valore_data = 0;
+ long valore_time = 0;
+ long valore = 0;
+ valore_data = (_data).Year * 10000 + (_data).Month * 100 + (_data).Day;
+ valore_time = (_data).Hour * 10000 + (_data).Minute * 100 + (_data).Second;
+ valore = valore_data * 1000000 + valore_time;
+ return valore;
+ }
+
+ ///
+ /// restituisce la descr del CdC
+ ///
+ ///
+ ///
+ public string descrCdcDaId(object val)
+ {
+ // cambio sena obj completo in cache
+ string label = "-";
+ try
+ {
+ label = (DataWrap.DW.taCdc.getByCdc(val.ToString())[0]).DESCRIZIONE;
+ }
+ catch
+ { }
+ return label;
+ }
+
+ ///
+ /// wrapper per log con salvataggio dell'IP del chiamante
+ ///
+ ///
+ ///
+ public bool httpLog(string _testoPre)
+ {
+ bool answ = false;
+ string postazione_IP = "";
+ try
+ {
+ postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
+ }
+ catch
+ { }
+ logger.lg.scriviLog(postazione_IP + _testoPre);
+ return answ;
+ }
+
+ ///
+ /// wrapper per log con salvataggio dell'IP del chiamante
+ ///
+ /// The testo log.
+ /// The tipo.
+ ///
+ public bool httpLog(string testoLog, tipoLog tipo)
+ {
+ bool answ = false;
+ string postazione_IP = "";
+ try
+ {
+ postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
+ }
+ catch
+ { }
+ logger.lg.scriviLog(postazione_IP + testoLog, tipo);
+ return answ;
+ }
+
+ ///
+ /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
+ ///
+ /// verr� usato x posizione {0}, tipo "view"
+ /// verr� usato x posizione {1}, tipo "_s.png"
+ ///
+ public string imgPath(tipoImg _tipo, dimImg _dimensione)
+ {
+ return imgPath(_tipo, _dimensione, tipoFileImg.png);
+ }
+
+ ///
+ /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
+ ///
+ /// verr� usato x posizione {0}, tipo "view"
+ /// verr� usato x posizione {1}, tipo "_s.png"
+ /// tipo del file richiesto..."
+ ///
+ public string imgPath(tipoImg _tipo, dimImg _dimensione, tipoFileImg _tipoFile)
+ {
+ string _imgName = "unknown";
+ string _imgDim = "_s";
+ string _imgType = "png";
+ switch (_tipo)
+ {
+ case tipoImg.annulla:
+ _imgName = "cancel";
+ break;
+
+ case tipoImg.approva:
+ _imgName = "approva";
+ break;
+
+ case tipoImg.barcode:
+ _imgName = "barcode_white";
+ break;
+
+ case tipoImg.barcodeArancio:
+ _imgName = "barcode_orange";
+ break;
+
+ case tipoImg.clona:
+ _imgName = "clonaObj";
+ break;
+
+ case tipoImg.conferma:
+ _imgName = "apply";
+ break;
+
+ case tipoImg.elimina:
+ _imgName = "elimina";
+ break;
+
+ case tipoImg.modifica:
+ _imgName = "edit";
+ break;
+
+ case tipoImg.notepad:
+ _imgName = "notepad";
+ break;
+
+ case tipoImg.notepadPdf:
+ _imgName = "notepadPdf";
+ break;
+
+ case tipoImg.nuovo:
+ _imgName = "new";
+ break;
+
+ case tipoImg.seleziona:
+ _imgName = "view";
+ break;
+
+ case tipoImg.semaforoGiallo:
+ _imgName = "semaGiallo";
+ break;
+
+ case tipoImg.semaforoRosso:
+ _imgName = "semaRosso";
+ break;
+
+ case tipoImg.semaforoVerde:
+ _imgName = "semaVerde";
+ break;
+
+ case tipoImg.stampa:
+ _imgName = "print";
+ break;
+
+ default:
+ break;
+ }
+ switch (_dimensione)
+ {
+ case dimImg.small:
+ _imgDim = "_s";
+ break;
+
+ case dimImg.medium:
+ _imgDim = "_m";
+ break;
+
+ case dimImg.large:
+ _imgDim = "_l";
+ break;
+
+ default:
+ break;
+ }
+ switch (_tipoFile)
+ {
+ case tipoFileImg.gif:
+ _imgType = "gif";
+ break;
+
+ case tipoFileImg.jpg:
+ _imgType = "jpg";
+ break;
+
+ case tipoFileImg.png:
+ _imgType = "png";
+ break;
+
+ default:
+ break;
+ }
+ return string.Format("~/images/{0}{1}.{2}", _imgName, _imgDim, _imgType);
+ }
+
+ ///
+ /// effettua l'inserimento vero e proprio dell'evento letto dai valori in session x l'utente corrente...
+ ///
+ /// evento da loggare
+ /// valori originali
+ /// nuovi valori
+ /// filtro associato
+ public virtual void insEvento(string ev2log, string valOrig, string valNew, string filtEv)
+ {
+ // effettuo logging evento
+ log2note.l2n.insEvento(user_std.UtSn.utente, _paginaCorrente, valOrig, valNew, ev2log, filtEv);
+ }
+
+ ///
+ /// definisce visibilit�
+ ///
+ ///
+ ///
+ public bool isVisible(object cosa)
+ {
+ bool visibile;
+ switch (cosa.ToString())
+ {
+ case "Select":
+ visibile = (_vistaModulo == tipoVistaMod.selezione);
+ break;
+
+ case "Edit":
+ visibile = (_vistaModulo == tipoVistaMod.editing);
+ break;
+
+ case "Delete":
+ visibile = (_vistaModulo == tipoVistaMod.editing);
+ break;
+
+ default:
+ visibile = false;
+ break;
+ }
+ return visibile;
+ }
+
+ ///
+ /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione
+ ///
+ ///
+ public bool isWritable()
+ {
+ bool answ = false;
+ if (_paginaCorrente == null)
+ {
+ PagCorrente();
+ }
+ answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente);
+ return answ;
+ }
+
+ ///
+ /// restituisce una scringa formattata in testa e coda x essere un corretto comando javascript
+ ///
+ ///
+ ///
+ public string jscriptFormat(string comando)
+ {
+ return "";
+ }
+
+ ///
+ /// limita una stringa al numero max di caratteri imposto
+ ///
+ ///
+ ///
+ ///
+ public string limitString(string original, int maxChar)
+ {
+ string outString = original;
+ if (outString.Length > maxChar)
+ {
+ outString = string.Format("{0}...", original.Substring(0, maxChar - 3));
+ }
+ return outString;
+ }
+
+ ///
+ /// invia un alert jscript con messaggio indicato...
+ ///
+ /// messaggio dell'alert da mandare
+ public void mandaAlert(string _messaggio)
+ {
+ string comando = "";
+ Response.Write(comando);
+ }
+
+ ///
+ /// calcola come percentuale la radio dividendo/divisore
+ ///
+ ///
+ ///
+ ///
+ public string percentuale(object dividendo, object divisore)
+ {
+ string answ = "";
+ double _dividendo = Convert.ToDouble(dividendo);
+ double _divisore = Convert.ToDouble(divisore);
+ try
+ {
+ answ = string.Format("{0:p}", _dividendo / _divisore);
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// effettua la registrazione degli eventi
+ ///
+ public void registraEventi()
+ {
+ // 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");
+ // solo se almeno uno dei due valori orig e new sono diversi da zero...)
+ if (valNew != "" || valOrig != "")
+ {
+ insEvento(ev2log, valOrig, valNew, filtEv);
+ }
+ }
+ }
+
+ ///
+ /// scrive immediatamente sulla pagina web il messaggio di avanzamento...
+ ///
+ ///
+ public void scriviAvanzamento(string _messaggio)
+ {
+ Response.Write(_messaggio);
+ Response.Flush();
+ }
+
+ ///
+ /// restituisce l'utente AS dall'utente win
+ ///
+ ///
+ ///
+ public string siglaDaUserWin(string utenteWin)
+ {
+ string sigla = "__";
+ try
+ {
+ DataLayer_AnagGen.UTENTERow riga = DataWrap.DW.taUtente.getByUserName(utenteWin)[0];
+ sigla = riga.SIGLA;
+ }
+ catch
+ { }
+ return sigla;
+ }
+
+ ///
+ /// converte una stringa in formato gg/mm/aaaa in stringa(intero data) in formato aaaammgg
+ ///
+ ///
+ ///
+ public string string2data(object val)
+ {
+ DateTime data = Convert.ToDateTime(val);
+ return (data.Year).ToString() + (data.Month).ToString().PadLeft(2, '0') + (data.Day).ToString().PadLeft(2, '0');
+ }
+
+ ///
+ /// effettua traduzione del lemma
+ ///
+ ///
+ ///
+ public string traduci(string lemma)
+ {
+ return user_std.UtSn.Traduci(lemma);
+ }
+
+ ///
+ /// effettua traduzione in inglese del lemma
+ ///
+ ///
+ ///
+ public string traduciEn(string lemma)
+ {
+ return user_std.UtSn.TraduciEn(lemma);
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ ///
+ /// indirizzo email dell'admin applicativo cui vanno le email in caso di anomalie...
+ ///
+ protected string _adminEmail;
+
+ ///
+ /// tabella di tutti i cdc
+ ///
+ protected DataLayer_AnagGen.CDCDataTable _allCdC;
+
+ ///
+ /// valore che determina se � possibile forzare impersonificazioen utente...
+ ///
+ protected bool _allowForceUser;
+
+ ///
+ /// stringa con CDC in (...) dei cdc abilitati (da permesso gerarchicamente a discendere...)
+ ///
+ protected string _AuthCdC;
+
+ ///
+ /// stringa con elenco CDC abilitati (da permesso gerarchicamente a discendere...)
+ ///
+ protected string _CdCUser;
+
+ ///
+ /// elenco delle pagine "common" ovvero da autorizzare ma senza bisogno diritti in
+ /// anagrafica - da web.config
+ ///
+ protected string _commonPages;
+
+ ///
+ /// tabella diritti
+ ///
+ protected DataLayer_AnagGen.DIRITTIDataTable _Diritti;
+
+ ///
+ /// elenco testuale csv dei cdc accessibili all'utente (x filtri tipo IN(...))
+ ///
+ protected string _elencoCdC;
+
+ ///
+ /// indirizzo email dell'applicativo da cui partono le email in caso di anomalie...
+ ///
+ protected string _fromEmail;
+
+ ///
+ /// dir di logging
+ ///
+ protected string _logBaseDir;
+
+ ///
+ /// livello di log (1-->5)
+ ///
+ protected int _logLevel;
+
+ ///
+ /// numero di righe standard x i datagrid
+ ///
+ protected int _righeDataGrid;
+
+ ///
+ /// numero di righe standard x i datagrid di anagrafica
+ ///
+ protected int _righeDataGridAnagr;
+
+ ///
+ /// numero di righe standard x i datagrid lunghi
+ ///
+ protected int _righeDataGridLong;
+
+ ///
+ /// numero di righe standard x i datagrid medi
+ ///
+ protected int _righeDataGridMed;
+
+ ///
+ /// numero di righe standard x i datagrid su mezza pagina
+ ///
+ protected int _righeDataGridShort;
+
+ ///
+ /// numero di righe standard x i selettori popup
+ ///
+ protected int _righeSelettore;
+
+ ///
+ /// elenco delle pagine "safe" ovvero da non autorizzare - da web.config
+ ///
+ protected string _safePages;
+
+ ///
+ /// indirizzo server SMTP
+ ///
+ protected string _smtpCli;
+
+ ///
+ /// tipo di anagrafica usata
+ ///
+ protected tipoAnagrafica _tipoAnagrafica = tipoAnagrafica.Standard;
+
+ ///
+ /// importo il tipo di vista del modulo
+ ///
+ protected tipoVistaMod _vistaModulo = tipoVistaMod.editing;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ ///
+ /// genera la stringa filtro x i cdc autorizzati x l'user
+ ///
+ ///
+ protected string elencoCdC
+ {
+ get
+ {
+ // messo qui caricamento dei cdc...
+ loadAllCdC();
+ //filtro sui CdC -- ATTENZIONE!!! possibile stack overflow se si supera un filtro con oltre 5000 char di posizioni... loop! vedi 647 mantis
+ string filtroCompleto = filtroPosizioneCdC();
+ string filtroCorrente = "";
+ string Filtraggio;
+ //dall'elenco dei CdC compone filtro x tabella corrente...
+ Filtraggio = "";
+ // setta a 0 il cdc precedente... poi inserisce il cdc SE E SOLO SE � diverso dal
+ // precedente: � distinct!!!
+ string _cdcPrec = "000";
+ string _cdcCurr = "";
+ int currPos = 0;
+ int filtLenght = filtroCompleto.Length;
+ int currLenght = 0;
+ // workaround: separo la ricerca in + tranches, andando a prendere solo (circa) 2000
+ // char alla volta...
+ if (filtroCompleto.Length < 2000)
+ {
+ // uso il filtro completo...
+ Filtraggio = recuperaCdC_daFiltro(filtroCompleto, ref Filtraggio, ref _cdcPrec, ref _cdcCurr);
+ }
+ else
+ {
+ while (currPos < filtLenght)
+ {
+ // se non trova significa che siamo all'ultimo "tratto" da meno di 1900 char...
+ if (filtLenght - currPos < 2100)
+ {
+ currLenght = filtLenght - currPos;
+ }
+ else
+ {
+ // cerco l'i-esima occorrenza di "(POSIZIONE LIKE" dopo circa 2000 dalla currPos...
+ currLenght = filtroCompleto.IndexOf("(POSIZIONE", currPos + 1900) - currPos;
+ }
+ filtroCorrente = filtroCompleto.Substring(currPos, currLenght);
+ // se termina con "OR " tolgo...
+ if (filtroCorrente.EndsWith("OR "))
+ {
+ filtroCorrente = filtroCorrente.Remove(currLenght - 3, 3);
+ }
+ Filtraggio = recuperaCdC_daFiltro(filtroCorrente, ref Filtraggio, ref _cdcPrec, ref _cdcCurr);
+ // sposto la posizione corrente...
+ currPos = currPos + currLenght;
+ }
+ }
+ return Filtraggio;
+ }
+ }
+
+ ///
+ /// legge e scrive in viewState la stringa di filtraggio...
+ ///
+ protected string FiltString
+ {
+ get
+ {
+ object o = ViewState["FiltString"];
+ if (o == null)
+ {
+ return String.Empty;
+ }
+ return (string)o;
+ }
+
+ set
+ {
+ ViewState["FiltString"] = value;
+ }
+ }
+
+ ///
+ /// variabile salvata in viewstate x la direzione del sorting
+ ///
+ protected bool SortAscending
+ {
+ //memorizza l'ultima direzione di sort x poterla invertire
+ get
+ {
+ object o = ViewState["SortAscending"];
+ if (o == null)
+ {
+ return true;
+ }
+ return (bool)o;
+ }
+
+ set
+ {
+ ViewState["SortAscending"] = value;
+ }
+ }
+
+ ///
+ /// variabile salvata in view state x la stringa di sorting - dg 2
+ ///
+ protected string SortField
+ {
+ //registra nella viewState la stringa di sorting
+ //(nome campo + scritta desc o nulla che equivale ad ascending...)
+ //si pu� impropriamente usare x + controlli... al max serve 1 click in +...
+ get
+ {
+ object o = ViewState["SortField"];
+ if (o == null)
+ {
+ return String.Empty;
+ }
+ return (string)o;
+ }
+
+ set
+ {
+ if (value == SortField)
+ {
+ // same as current sort file, toggle sort direction
+ SortAscending = !SortAscending;
+ }
+ ViewState["SortField"] = value;
+ }
+ }
+
+ ///
+ /// variabile salvata in view state x la stringa di sorting - dg 2
+ ///
+ protected string SortField2
+ {
+ //registra nella viewState la stringa di sorting
+ //(nome campo + scritta desc o nulla che equivale ad ascending...)
+ //si pu� impropriamente usare x + controlli... al max serve 1 click in +...
+ get
+ {
+ object o = ViewState["SortField2"];
+ if (o == null)
+ {
+ return String.Empty;
+ }
+ return (string)o;
+ }
+
+ set
+ {
+ if (value == SortField2)
+ {
+ // same as current sort file, toggle sort direction
+ SortAscending = !SortAscending;
+ }
+ ViewState["SortField2"] = value;
+ }
+ }
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ ///
+ /// aggiorna eventuali datalist e datagrid
+ ///
+ protected virtual void aggiornaControlliDataGL()
+ {
+ }
+
+ ///
+ /// aggiunge i link x i selettori
+ ///
+ protected virtual void aggiungiLink()
+ {
+ }
+
+ ///
+ /// popola gli oggetti e le labels... (B.1.6)
+ ///
+ protected virtual void bindControlli()
+ {
+ // IsPostBack � TRUE se utilizzo javascript ovvero confermo cancellazioni o modifico i controlli...
+ if (!IsPostBack)
+ {
+ DisegnaPagina();
+ }
+ }
+
+ ///
+ /// carica dalla cache i dataset necessari
+ ///
+ protected virtual void caricaDati()
+ { }
+
+ ///
+ /// verifica la condizione booleana e formatta di conseguenza la stringa di filtraggio da
+ /// accodare al filtro x CdC autorizzati
+ ///
+ /// condizione
+ /// tipo di eguaglianza
+ /// nome parametro
+ /// valore parametro
+ ///
+ protected string condFilter(bool _condizione, string _tipoEqual, string _nomeParam, string _valParam)
+ {
+ string outFilter = "";
+ if (_condizione && _valParam != "")
+ {
+ if (_tipoEqual == "=")
+ {
+ outFilter = " AND (" + _nomeParam.Replace("'", "''") + " = '" + _valParam.Replace("'", "''") + "')";
+ }
+ else if (_tipoEqual == "IN")
+ {
+ outFilter = String.Format(" AND ({0} IN ({1}))", _nomeParam.Replace("'", "''"), _valParam.Replace("'", "''"));
+ }
+ else
+ {
+ outFilter = " AND (" + _nomeParam.Replace("'", "''") + " LIKE '%" + _valParam.Replace("'", "''") + "%')";
+ }
+ }
+ return outFilter;
+ }
+
+ ///
+ /// crea la stringa di filtraggio x data secondo modalit� tipo inizio/fine/durante...
+ ///
+ ///
+ protected string dataFilter(bool _condizione, string _tipoPeriodo, string _nomeFrom, string _dataFrom, string _nomeTo, string _dataTo)
+ {
+ string outFilter = "";
+ if (_condizione)
+ {
+ // carica i valori dalle textbox... se non ci sono li imposta a: start = 01/01/1900
+ // end = 01/01/2200
+ try
+ {
+ _dataFrom = _dataFrom.Replace(".", "/");
+ if (string.IsNullOrEmpty(_dataFrom))
+ {
+ _dataFrom = "01/01/1900";
+ }
+ }
+ catch
+ {
+ _dataFrom = "01/01/1900";
+ }
+ try
+ {
+ _dataTo = _dataTo.Replace(".", "/");
+ if (string.IsNullOrEmpty(_dataTo))
+ {
+ _dataTo = "01/01/2200";
+ }
+ }
+ catch
+ {
+ _dataTo = "01/01/2200";
+ }
+ switch (_tipoPeriodo)
+ {
+ case "1":
+ // filtro su inizio
+ outFilter += " AND (" + _nomeFrom + " >= '" + _dataFrom + "' AND " + _nomeFrom + " <= '" + _dataTo + "') ";
+ break;
+
+ case "2":
+ // filtro su scadenza
+ outFilter += " AND (" + _nomeTo + " >= '" + _dataFrom + "' AND " + _nomeTo + " <= '" + _dataTo + "') ";
+ break;
+
+ case "3":
+ // filtro su "in corso"
+ outFilter += " AND NOT (" + _nomeFrom + " > '" + _dataTo + "' OR " + _nomeTo + " < '" + _dataFrom + "') ";
+ break;
+ }
+ }
+ return outFilter;
+ }
+
+ ///
+ /// crea la stringa di filtraggio x data secondo modalit� tipo minoreUguale / uguale / maggioreUguale...
+ ///
+ ///
+ protected string dataFilter(bool _condizione, string _tipoPeriodo, string _nome, string _data)
+ {
+ string outFilter = "";
+ if (_condizione)
+ {
+ // carica i valori dalle textbox... se non ci sono li imposta a: start = 01/01/1900
+ // end = 01/01/2200
+ try
+ {
+ _data = _data.Replace(".", "/");
+ if (string.IsNullOrEmpty(_data))
+ {
+ _data = "01/01/1900";
+ }
+ }
+ catch
+ {
+ _data = "01/01/1900";
+ }
+ switch (_tipoPeriodo)
+ {
+ case "<=":
+ // filtro su inizio
+ outFilter += " AND (" + _nome + " <= '" + _data + "') ";
+ break;
+
+ case "=":
+ // filtro su scadenza
+ outFilter += " AND (" + _nome + " = '" + _data + "') ";
+ break;
+
+ case ">=":
+ // filtro su "in corso"
+ outFilter += " AND (" + _nome + " >= '" + _data + "') ";
+ break;
+ }
+ }
+ return outFilter;
+ }
+
+ ///
+ /// verifica se tutti i dataset richiesti sono disponibili i cache
+ ///
+ ///
+ protected virtual bool datiDisponibili()
+ {
+ return true;
+ }
+
+ ///
+ /// disegna la pagina: prima i controlli poi il datagrid
+ ///
+ protected void DisegnaPagina()
+ {
+ sistemaControlli();
+ aggiungiLink();
+ aggiornaControlliDataGL();
+ traduciObj();
+ }
+
+ ///
+ /// selezione delle posizioni cdc autorizzate come stringa di filtraggio su POSIZIONE LIKE,
+ /// se non ce ne fossero redirige su unauthorized.aspx
+ ///
+ ///
+ protected string filtroPosizioneCdC()
+ {
+ string Filtraggio;
+ Filtraggio = " (";
+ DataLayer_AnagGen.CDCDataTable tblCdc = DataWrap.DW.taCdc.GetTopCdC(user_std.UtSn.utente, user_std.UtSn.dominio, user_std.UtSn.modulo);
+ if (tblCdc.Rows.Count == 0 && _safePages.IndexOf(_paginaCorrente) == -1)
+ {
+ logger.lg.scriviLog(string.Format("Errore in filtroPosizioneCdC: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
+ Response.Redirect("~/unauthorized.aspx");
+ }
+ foreach (DataLayer_AnagGen.CDCRow riga in tblCdc)
+ {
+ // aggiongo solo se non � contenuta la posizione...
+ if (Filtraggio.IndexOf(riga.POSIZIONE) == -1)
+ {
+ // controllo se posizione termina col punto...
+ if (riga.POSIZIONE.EndsWith("."))
+ {
+ Filtraggio += String.Format("(POSIZIONE LIKE '{0}%') OR ", riga.POSIZIONE);
+ }
+ else
+ {
+ Filtraggio += String.Format("(POSIZIONE LIKE '{0}.%') OR ", riga.POSIZIONE);
+ }
+ }
+ }
+ int lungFiltr = Filtraggio.Length;
+ Filtraggio = Filtraggio.Remove(lungFiltr - 3, 3);
+ Filtraggio += ") ";
+ return Filtraggio;
+ }
+
+ ///
+ /// (ri)carica i dataset del modulo
+ ///
+ protected virtual void forza_Update()
+ { }
+
+ ///
+ /// verifica la condizione booleana e formatta di conseguenza la stringa di filtraggio tipo
+ /// LIKE x i campi inseriti separati da # SE valParam !=""
+ ///
+ ///
+ ///
+ ///
+ protected string likeFilter(string _elencoCampi, string _valParam)
+ {
+ string outFilter = "";
+ if (_valParam != "")
+ {
+ outFilter = " AND ( ";
+ string comandoCompleto = _elencoCampi;
+ string[] comando = comandoCompleto.Split('#');
+ int numCampi = comando.GetLength(0);
+ for (int i = 1; i <= numCampi; i++)
+ {
+ outFilter += "(" + comando[i - 1] + " LIKE '%" + _valParam + "%')";
+ outFilter += " OR ";
+ }
+ outFilter = outFilter.Remove(outFilter.Length - 3, 3);
+ outFilter += " ) ";
+ }
+ return outFilter;
+ }
+
+ ///
+ /// legge il dataset dei CdC
+ ///
+ protected void loadAllCdC()
+ {
+ if (!memLayer.ML.isInCacheObject("_allCdC"))
+ {
+ _allCdC = DataWrap.DW.taCdc.GetData();
+ //Cache["_allCdC"] = _allCdC;
+ memLayer.ML.setCacheVal("_allCdC", _allCdC, true);
}
else
{
- // cerco l'i-esima occorrenza di "(POSIZIONE LIKE" dopo circa 2000 dalla currPos...
- currLenght = filtroCompleto.IndexOf("(POSIZIONE", currPos + 1900) - currPos;
+ _allCdC = (DataLayer_AnagGen.CDCDataTable)Cache["_allCdC"];
}
- filtroCorrente = filtroCompleto.Substring(currPos, currLenght);
- // se termina con "OR " tolgo...
- if (filtroCorrente.EndsWith("OR "))
+ }
+
+ ///
+ /// genera la stringa dei cdc autorizzati dell'utente
+ ///
+ protected void loadAuthCdC()
+ {
+ if (!memLayer.ML.isInSessionObject("_AuthCdC"))
{
- filtroCorrente = filtroCorrente.Remove(currLenght - 3, 3);
+ _CdCUser = elencoCdC;
+ memLayer.ML.setSessionVal("_CdCUser", _CdCUser);
+ _AuthCdC = string.Format(" COD_CDC IN ({0})", _CdCUser);
+ memLayer.ML.setSessionVal("_AuthCdC", _AuthCdC);
+ }
+ else
+ {
+ _AuthCdC = memLayer.ML.StringSessionObj("_AuthCdC");
}
- Filtraggio = recuperaCdC_daFiltro(filtroCorrente, ref Filtraggio, ref _cdcPrec, ref _cdcCurr);
- // sposto la posizione corrente...
- currPos = currPos + currLenght;
- }
}
- return Filtraggio;
- }
- }
- ///
- /// esegue la ricerca dei cdc nelle posizioni indicate dal filtro e restituisce elenco distinct degli stessi
- ///
- /// filtro con cui cercare i cdc (del tipo " (POSIZIONE LIKE 'T.1.2.3%') OR ... "
- /// stringa di filtraggio ricostruita per l'elenco dei cdc fino a quel momento trovati
- /// ultimo cdc trovato
- /// cdc corrente
- ///
- private string recuperaCdC_daFiltro(string filtroCorrente, ref string Filtraggio, ref string _cdcPrec, ref string _cdcCurr)
- {
- // esegue ciclo ricerca
- DataView dv = new DataView(_allCdC, filtroCorrente, "COD_CDC", DataViewRowState.CurrentRows);
- foreach (DataRowView rowView in dv)
- {
- _cdcCurr = rowView.Row[0].ToString();
- if (_cdcCurr != _cdcPrec && (Filtraggio.IndexOf(_cdcCurr) < 0)) // aggiunta verifica non ci siano duplicati visto che si fa in + tranches la ricerca cdc...
+
+ ///
+ /// leggi i parametri di configurazione standard dell'applicativo
+ ///
+ protected void loadDefaultsWebConfig()
{
- Filtraggio += "'" + _cdcCurr + "' , ";
+ _righeDataGrid = memLayer.ML.CRI("_righeDataGrid");
+ _righeDataGridAnagr = memLayer.ML.CRI("_righeDataGridAnagr");
+ _righeDataGridLong = memLayer.ML.CRI("_righeDataGridLong");
+ _righeDataGridMed = memLayer.ML.CRI("_righeDataGridMed");
+ _righeDataGridShort = memLayer.ML.CRI("_righeDataGridShort");
+ _adminEmail = memLayer.ML.CRS("_adminEmail");
+ _fromEmail = memLayer.ML.CRS("_fromEmail");
+ _smtpCli = memLayer.ML.CRS("_smtpCli");
+ _logLevel = memLayer.ML.CRI("_logLevel");
+ _safePages = memLayer.ML.CRS("_safePages");
+ _commonPages = memLayer.ML.CRS("_commonPages");
}
- _cdcPrec = _cdcCurr;
- }
- int lungFiltr = Filtraggio.Length;
- if (Filtraggio.EndsWith("' , "))
- {
- Filtraggio = Filtraggio.Remove(lungFiltr - 3, 3);
- }
- return Filtraggio;
- }
-
- #endregion
-
- #region funzioni di conversione da Id dati anagrafici
-
- ///
- /// restituisce il cdc dell'utente data la sua matricola
- ///
- ///
- ///
- public string cdcUtente(object val)
- {
- DataLayer_AnagGen.UTENTERow riga = DataWrap.DW.taUtente.getByMatricola(val.ToString())[0];
- return riga.COD_CDC;
- }
-
-
- ///
- /// restituisce l'utente AS dall'utente win
- ///
- ///
- ///
- public string siglaDaUserWin(string utenteWin)
- {
- string sigla = "__";
- try
- {
- DataLayer_AnagGen.UTENTERow riga = DataWrap.DW.taUtente.getByUserName(utenteWin)[0];
- sigla = riga.SIGLA;
- }
- catch
- { }
- return sigla;
- }
-
- ///
- /// restituisce la descr del CdC
- ///
- ///
- ///
- public string descrCdcDaId(object val)
- {
- // cambio sena obj completo in cache
- string label = "-";
- try
- {
- label = (DataWrap.DW.taCdc.getByCdc(val.ToString())[0]).DESCRIZIONE;
- }
- catch
- { }
- return label;
- }
-
-
-
- #endregion
-
- #region funzioni di concatenamento stringhe x comandi hyperlink & help
-
- ///
- /// invia la stringa jscript di conferma pre-cancellazione
- ///
- ///
- public string confermaCancellazione()
- {
- return string.Format("return confirm(\"{0}\");", user_std.UtSn.Traduci("confermaDel"));
- }
- ///
- /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
- ///
- /// verr� usato x posizione {0}, tipo "view"
- /// verr� usato x posizione {1}, tipo "_s.png"
- ///
- public string imgPath(tipoImg _tipo, dimImg _dimensione)
- {
- return imgPath(_tipo, _dimensione, tipoFileImg.png);
- }
-
- ///
- /// restituisce la stringa del path corretto per l'immagine richiesta nel formato "~/images/{0}{1}"
- ///
- /// verr� usato x posizione {0}, tipo "view"
- /// verr� usato x posizione {1}, tipo "_s.png"
- /// tipo del file richiesto..."
- ///
- public string imgPath(tipoImg _tipo, dimImg _dimensione, tipoFileImg _tipoFile)
- {
- string _imgName = "unknown";
- string _imgDim = "_s";
- string _imgType = "png";
- switch (_tipo)
- {
- case tipoImg.annulla:
- _imgName = "cancel";
- break;
- case tipoImg.approva:
- _imgName = "approva";
- break;
- case tipoImg.barcode:
- _imgName = "barcode_white";
- break;
- case tipoImg.barcodeArancio:
- _imgName = "barcode_orange";
- break;
- case tipoImg.clona:
- _imgName = "clonaObj";
- break;
- case tipoImg.conferma:
- _imgName = "apply";
- break;
- case tipoImg.elimina:
- _imgName = "elimina";
- break;
- case tipoImg.modifica:
- _imgName = "edit";
- break;
- case tipoImg.notepad:
- _imgName = "notepad";
- break;
- case tipoImg.notepadPdf:
- _imgName = "notepadPdf";
- break;
- case tipoImg.nuovo:
- _imgName = "new";
- break;
- case tipoImg.seleziona:
- _imgName = "view";
- break;
- case tipoImg.semaforoGiallo:
- _imgName = "semaGiallo";
- break;
- case tipoImg.semaforoRosso:
- _imgName = "semaRosso";
- break;
- case tipoImg.semaforoVerde:
- _imgName = "semaVerde";
- break;
- case tipoImg.stampa:
- _imgName = "print";
- break;
- default:
- break;
- }
- switch (_dimensione)
- {
- case dimImg.small:
- _imgDim = "_s";
- break;
- case dimImg.medium:
- _imgDim = "_m";
- break;
- case dimImg.large:
- _imgDim = "_l";
- break;
- default:
- break;
- }
- switch (_tipoFile)
- {
- case tipoFileImg.gif:
- _imgType = "gif";
- break;
- case tipoFileImg.jpg:
- _imgType = "jpg";
- break;
- case tipoFileImg.png:
- _imgType = "png";
- break;
- default:
- break;
- }
- return string.Format("~/images/{0}{1}.{2}", _imgName, _imgDim, _imgType);
- }
-
- #endregion
-
- #region funzioni dummy x traduzione
-
- ///
- /// effettua traduzione del lemma
- ///
- ///
- ///
- public string traduci(string lemma)
- {
- return user_std.UtSn.Traduci(lemma);
- }
- ///
- /// effettua traduzione in inglese del lemma
- ///
- ///
- ///
- public string traduciEn(string lemma)
- {
- return user_std.UtSn.TraduciEn(lemma);
- }
-
- #endregion
-
- #region gestione visibilit� da tipo modulo
-
- ///
- /// definisce visibilit�
- ///
- ///
- ///
- public bool isVisible(object cosa)
- {
- bool visibile;
- switch (cosa.ToString())
- {
- case "Select":
- visibile = (_vistaModulo == tipoVistaMod.selezione);
- break;
- case "Edit":
- visibile = (_vistaModulo == tipoVistaMod.editing);
- break;
- case "Delete":
- visibile = (_vistaModulo == tipoVistaMod.editing);
- break;
- default:
- visibile = false;
- break;
- }
- return visibile;
- }
- ///
- /// tipo di vista del modulo
- ///
- public tipoVistaMod vistaModulo
- {
- get
- {
- return _vistaModulo;
- }
- set
- {
- _vistaModulo = value;
- }
- }
-
- #endregion
-
- #region gestione eventi e logging
-
- ///
- /// effettua la registrazione degli eventi
- ///
- public void registraEventi()
- {
- // 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");
- // solo se almeno uno dei due valori orig e new sono diversi da zero...)
- if (valNew != "" || valOrig != "")
+ ///
+ /// caricamento dati applicazione da sessione (B.1.3)
+ ///
+ protected virtual void loadSessionData()
{
- insEvento(ev2log, valOrig, valNew, filtEv);
}
- }
- }
- ///
- /// effettua l'inserimento vero e proprio dell'evento letto dai valori in session x l'utente corrente...
- ///
- /// evento da loggare
- /// valori originali
- /// nuovi valori
- /// filtro associato
- public virtual void insEvento(string ev2log, string valOrig, string valNew, string filtEv)
- {
- // effettuo logging evento
- log2note.l2n.insEvento(user_std.UtSn.utente, _paginaCorrente, valOrig, valNew, ev2log, filtEv);
- }
- ///
- /// salva in sessione i valori indicati
- ///
- /// dictionary dei valori vecchi
- /// dictionary dei valori nuovi
- /// bool su abilitazione al log dell'oggetto
- /// descrizione evento da loggare
- /// filtro associato all'evento
- /// restituisce il numero di elementi contenuti, -1 significa nessuna differenza...
- public static int setLogValueToSession(Dictionary oldVal, Dictionary newVal, bool logEnabled, string ev2log, string filtroEv)
- {
- int answ = -1;
- // salvo i valori x logging
- confrontoValori.obj.paramOld = oldVal;
- confrontoValori.obj.paramNew = newVal;
- // faccio generare il diff...
- confrontoValori.obj.doDiff();
- // logging modifica
- memLayer.ML.setSessionVal("ev2log", ev2log);
- memLayer.ML.setSessionVal("logEn", logEnabled);
- memLayer.ML.setSessionVal("filtEv", filtroEv);
- memLayer.ML.setSessionVal("valOrig", confrontoValori.obj.valOld);
- memLayer.ML.setSessionVal("valNew", confrontoValori.obj.valNew);
- // se ci sono differenze allora restituisco posizione della prima differenza, cercando
nella stringa...
- try
- {
- if (confrontoValori.obj.valNew != "")
+
+ ///
+ /// caricamento dati user da sessione (B.1.1)
+ ///
+ protected void LoadUserData()
{
- string[] righe = confrontoValori.obj.valNew.Split('<');
- answ = righe.Length;
+ _paginaPrecedente = memLayer.ML.StringSessionObj("_paginaPrecedente");
+ setupUserDataMan();
+ loadDefaultsWebConfig();
+ if (user_std.UtSn.utente != "")
+ {
+ StandardDataLoad();
+ }
}
- }
- catch
- { }
- return answ;
- }
- ///
- /// salva in sessione i valori per un oggetto che sta x essere eliminato
- ///
- /// dictionary dei valori vecchi
- /// bool su abilitazione al log dell'oggetto
- /// descrizione evento da loggare
- /// filtro associato all'evento
- /// restituisce il numero di elementi contenuti, -1 significa nessuna differenza...
- public static int setLogValueToSession4del(Dictionary oldVal, bool logEnabled, string ev2log, string filtroEv)
- {
- int answ = -1;
- // salvo i valori x logging
- confrontoValori.obj.paramOld = oldVal;
- // faccio generare il diff...
- confrontoValori.obj.calcOldVal();
- // logging modifica
- memLayer.ML.setSessionVal("ev2log", ev2log);
- memLayer.ML.setSessionVal("logEn", logEnabled);
- memLayer.ML.setSessionVal("filtEv", filtroEv);
- memLayer.ML.setSessionVal("valOrig", confrontoValori.obj.valOld);
- memLayer.ML.setSessionVal("valNew", "-");
- // se ci sono differenze allora restituisco posizione della prima differenza, cercando
nella stringa...
- try
- {
- string[] righe = confrontoValori.obj.valNew.Split('<');
- answ = righe.Length;
- }
- catch
- { }
- return answ;
- }
+ ///
+ /// invio email con log
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected bool mandaEmail(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
+ {
+ return SteamWare.gestEmail.ge.mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
+ }
- ///
- /// wrapper per log con salvataggio dell'IP del chiamante
- ///
- ///
- ///
- public bool httpLog(string _testoPre)
- {
- bool answ = false;
- string postazione_IP = "";
- try
- {
- postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
- }
- catch
- { }
- logger.lg.scriviLog(postazione_IP + _testoPre);
- return answ;
- }
- ///
- /// wrapper per log con salvataggio dell'IP del chiamante
- ///
- /// The testo log.
- /// The tipo.
- ///
- public bool httpLog(string testoLog, tipoLog tipo)
- {
- bool answ = false;
- string postazione_IP = "";
- try
- {
- postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
- }
- catch
- { }
- logger.lg.scriviLog(postazione_IP + testoLog, tipo);
- return answ;
- }
+ ///
+ /// invio email senza log
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo)
+ {
+ bool answ = false;
+ try
+ {
+ answ = SteamWare.gestEmail.ge.mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo);
+ }
+ catch { }
+ return answ;
+ }
- ///
- /// event handler generico
- ///
- public event EventHandler eh_ucev;
- ///
- /// sollevo evento selezione
- ///
- protected void raiseEvent(ucEvType evType)
- {
- // sollevo evento nuovo valore...
- if (eh_ucev != null)
- {
- ucEvent evento = new ucEvent(evType);
- eh_ucev(this, evento);
- }
+ ///
+ /// salva in variabile pagina il nome della pagina corrente
+ ///
+ protected virtual void PagCorrente()
+ {
+ Uri MyUrl = Request.Url;
+ string delimStr = "/";
+ char[] delimiter = delimStr.ToCharArray();
+ string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
+ int n = finalUrl.Length;
+ _paginaCorrente = finalUrl[n - 1].ToString();
+ // tolgo .aspx!
+ _paginaCorrente = _paginaCorrente.Replace(".aspx", "");
+ if (string.IsNullOrEmpty(_paginaPrecedente) || _paginaPrecedente == null)
+ {
+ _paginaPrecedente = _paginaCorrente;
+ memLayer.ML.setSessionVal("_paginaPrecedente", _paginaPrecedente);
+ }
+ if (_paginaCorrente != _paginaPrecedente)
+ {
+ // in questo caso tolgo i vari filtering e gli indici...
+ memLayer.ML.emptySessionVal("_indexFilt");
+ memLayer.ML.emptySessionVal("valoreCercato");
+ _paginaPrecedente = _paginaCorrente;
+ memLayer.ML.setSessionVal("_paginaPrecedente", _paginaPrecedente);
+ }
+ }
+
+ ///
+ /// MAIN: esecuzione al caricamento del modulo delle routines di controllo utente e
+ /// creazione pagina
+ ///
+ ///
+ ///
+ protected virtual void Page_Load(object sender, System.EventArgs e)
+ {
+ // carico i dati...
+ LoadUserData();
+ SetUpByUserRight();
+ loadSessionData();
+ PredisponiDati();
+ bindControlli();
+ }
+
+ ///
+ /// predisposizione dati x pagina da cache/database a seconda della disponibilit� in cache o
+ /// refresh (B.1.4)
+ ///
+ protected void PredisponiDati()
+ {
+ if (!datiDisponibili())
+ {
+ resetUpdate();
+ forza_Update();
+ }
+ else
+ {
+ caricaDati();
+ }
+ }
+
+ ///
+ /// sollevo evento selezione
+ ///
+ protected void raiseEvent(ucEvType evType)
+ {
+ // sollevo evento nuovo valore...
+ if (eh_ucev != null)
+ {
+ ucEvent evento = new ucEvent(evType);
+ eh_ucev(this, evento);
+ }
+ }
+
+ ///
+ /// reset update del modulo corrente
+ ///
+ protected virtual void resetUpdate()
+ { }
+
+ ///
+ /// salva nella cache i dataset caricati
+ ///
+ protected virtual void salvaDati()
+ { }
+
+ ///
+ /// verifica che l'utente abbia almeno un permesso per la pagina corrente altrimenti
+ /// redirect ad unauthorized
+ ///
+ protected virtual void SetUpByUserRight()
+ {
+ PagCorrente();
+ // verifica la pagina NON sia di quelle "libere"
+ if (_safePages.IndexOf(_paginaCorrente) == -1)
+ {
+ // verifica l'utente sia autorizzato (in session...)
+ if (!user_std.UtSn.isAuth)
+ {
+ if (_paginaCorrente != "" && _paginaCorrente != "login.aspx")
+ {
+ Session["nextPage"] = _paginaCorrente;
+ }
+
+ Response.Redirect("login.aspx");
+ }
+ // verifica i permessi dell'utente per almeno vedere la pagina corrente SSE non �
+ // una common page...
+ if (!user_std.UtSn.isPageEnabled(_paginaCorrente) && _commonPages.IndexOf(_paginaCorrente) == -1)
+ {
+ logger.lg.scriviLog(string.Format("Errore in SetUpByUserRight: utente {0} non autorizzato per la pagina {1}", user_std.UtSn.utente, _paginaCorrente), tipoLog.STARTUP);
+ Response.Redirect("~/unauthorized.aspx");
+ }
+ }
+ }
+
+ ///
+ /// setup datamanagers...
+ ///
+ protected virtual void setupUserDataMan()
+ {
+ }
+
+ ///
+ /// sistema i vari controlli della pagina
+ ///
+ protected virtual void sistemaControlli()
+ { }
+
+ ///
+ /// legge i valori standard x dataset e parametri
+ ///
+ protected void StandardDataLoad()
+ {
+ try
+ {
+ loadAuthCdC();
+ }
+ catch
+ { }
+ }
+
+ ///
+ /// sistema tutte le labels traducendo i lemmi nella lingua utente ed in inglese
+ ///
+ protected virtual void traduciObj()
+ { }
+
+ #endregion Protected Methods
+
+ #region Private Methods
+
+ ///
+ /// esegue la ricerca dei cdc nelle posizioni indicate dal filtro e restituisce elenco
+ /// distinct degli stessi
+ ///
+ ///
+ /// filtro con cui cercare i cdc (del tipo " (POSIZIONE LIKE 'T.1.2.3%') OR ... "
+ ///
+ ///
+ /// stringa di filtraggio ricostruita per l'elenco dei cdc fino a quel momento trovati
+ ///
+ /// ultimo cdc trovato
+ /// cdc corrente
+ ///
+ private string recuperaCdC_daFiltro(string filtroCorrente, ref string Filtraggio, ref string _cdcPrec, ref string _cdcCurr)
+ {
+ // esegue ciclo ricerca
+ DataView dv = new DataView(_allCdC, filtroCorrente, "COD_CDC", DataViewRowState.CurrentRows);
+ foreach (DataRowView rowView in dv)
+ {
+ _cdcCurr = rowView.Row[0].ToString();
+ if (_cdcCurr != _cdcPrec && (Filtraggio.IndexOf(_cdcCurr) < 0)) // aggiunta verifica non ci siano duplicati visto che si fa in + tranches la ricerca cdc...
+ {
+ Filtraggio += "'" + _cdcCurr + "' , ";
+ }
+ _cdcPrec = _cdcCurr;
+ }
+ int lungFiltr = Filtraggio.Length;
+ if (Filtraggio.EndsWith("' , "))
+ {
+ Filtraggio = Filtraggio.Remove(lungFiltr - 3, 3);
+ }
+ return Filtraggio;
+ }
+
+ #endregion Private Methods
}
-
- #endregion
-
- }
-}
+}
\ No newline at end of file
diff --git a/SteamWare/user_std.cs b/SteamWare/user_std.cs
index f286bed..4623eb8 100644
--- a/SteamWare/user_std.cs
+++ b/SteamWare/user_std.cs
@@ -1,3 +1,4 @@
+using NLog;
using System;
using System.Collections.Generic;
@@ -183,7 +184,8 @@ namespace SteamWare
}
///
- /// � un boolean che indica se in session ci siano user/dominio e quindi utente autenticato in precedenza...
+ /// � un boolean che indica se in session ci siano user/dominio e quindi utente autenticato
+ /// in precedenza...
///
public bool isAuth
{
@@ -222,7 +224,7 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog(string.Format("Errore recupero lingua utente{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
+ Log.Info(string.Format("Errore recupero lingua utente{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
if (string.IsNullOrEmpty(answ))
{
@@ -314,7 +316,7 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog(String.Format("Errore recupero permessi!{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
+ Log.Info(String.Format("Errore recupero permessi!{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
return tabPermessi;
}
@@ -434,281 +436,6 @@ namespace SteamWare
#endregion Public Properties
- #region Private Methods
-
- ///
- /// controllo utente/pwd da tab
- ///
- ///
- ///
- ///
- private bool checkUserPwd(string _username, string _pwd)
- {
- bool risultato = false;
- try
- {
- risultato = DataWrap.DW.taUserData.getByUserPwd(_username, _pwd).Rows.Count > 0;
- }
- catch
- { }
- return risultato;
- }
-
- #endregion Private Methods
-
- #region Protected Methods
-
- ///
- /// cancella da session l'utente
- ///
- protected void clearAllUserData()
- {
- memLayer.ML.emptySessionVal("USER_NAME");
- memLayer.ML.emptySessionVal("DOMINIO");
- memLayer.ML.emptySessionVal("permessiUtente");
- }
-
- ///
- /// formatta un nodo in modo corretto dai dati indicati
- ///
- ///
- ///
- ///
- ///
- protected string formattaNodo(string titolo, string descrizione, string url, siteNodeType tipoNodo)
- {
- string _out = "";
- switch (tipoNodo)
- {
- case siteNodeType.startContainer:
- _out = string.Format("";
- break;
-
- case siteNodeType.leaf:
- _out = string.Format("", Traduci(titolo), Traduci(descrizione), url);
- break;
- }
- return _out;
- }
-
- ///
- /// salva dati accessori quali il cdc dell'utente...
- ///
- protected virtual void salvaDatiAccessori()
- {
- // salvo il cdc utente...
- memLayer.ML.setSessionVal("CdCUser", rigaUtente.COD_CDC);
- // verifico se necessario fare echo lemmi e vado in runMode di echo dei termini tradotti
- bool echoLemmi = false;
- try
- {
- echoLemmi = memLayer.ML.CRB("echoLemmi");
- }
- catch
- { }
- if (echoLemmi)
- {
- currRunMode = runModes.echoLemmi;
- }
- else
- {
- currRunMode = runModes.normal;
- }
- }
-
- ///
- /// Effettua setup dei permessi una volta salvati i diritti
- ///
- protected virtual void setPermessiDaDiritti()
- {
- // proseguo coi permessi
- DataLayer_AnagGen.PermessiDataTable allPermessi = DataWrap.DW.taPermessi.GetData();
- DataLayer_AnagGen.Permessi2FunzioneDataTable allPerm2Funz = DataWrap.DW.taPermessi2Funzione.GetData();
- DataLayer_AnagGen.PermessiDataTable _permessiUtente = new DataLayer_AnagGen.PermessiDataTable();
- DataLayer_AnagGen.PermessiDataTable _permessiUtenteWrite = new DataLayer_AnagGen.PermessiDataTable();
- string filtroFunz, filtroPerm, filtroPermWrite;
- filtroPerm = " COD_PERMESSO IN (";
- filtroPermWrite = " COD_PERMESSO IN (";
- // filtro i diritti utente x non avere duplicati...
- Dictionary funzioniUtente = new Dictionary();
- foreach (DataLayer_AnagGen.DIRITTIRow riga in diritti)
- {
- try
- {
- funzioniUtente.Add(riga.COD_FUNZIONE, riga.COD_FUNZIONE);
- }
- catch
- { }
- }
- foreach (KeyValuePair kvp in funzioniUtente)
- {
- filtroFunz = string.Format("COD_FUNZIONE='{0}'", kvp.Value);
- // recupero le righe dei righe2perm
- DataLayer_AnagGen.Permessi2FunzioneRow[] righe_p2f = (DataLayer_AnagGen.Permessi2FunzioneRow[])allPerm2Funz.Select(filtroFunz);
- foreach (DataLayer_AnagGen.Permessi2FunzioneRow riga_p2f in righe_p2f)
- {
- filtroPerm += string.Format("'{0}', ", riga_p2f.COD_PERMESSO);
- // se � write metto in tab relativa...
- try
- {
- if (riga_p2f.READWRITE == "S")
- {
- filtroPermWrite += string.Format("'{0}', ", riga_p2f.COD_PERMESSO);
- }
- }
- catch
- {
- }
- }
- }
- // cambio modalit� controllo permessi abilitati x problema permessi non trovati...
- if (filtroPerm != " COD_PERMESSO IN (")
- {
- filtroPerm = filtroPerm.Remove(filtroPerm.Length - 2);
- filtroPerm += ") ";
- DataLayer_AnagGen.PermessiRow[] righePerm = (DataLayer_AnagGen.PermessiRow[])allPermessi.Select(filtroPerm, "GRUPPO, NUMERO");
- foreach (DataLayer_AnagGen.PermessiRow rigaPerm in righePerm)
- {
- _permessiUtente.ImportRow(rigaPerm);
- }
- }
- else
- {
- logger.lg.scriviLog("Permessi utente non trovati!", tipoLog.ERROR);
- }
- permessi = _permessiUtente;
- // salvo, se ci sono, permessi write...
- if (filtroPermWrite != " COD_PERMESSO IN (")
- {
- filtroPermWrite = filtroPermWrite.Remove(filtroPermWrite.Length - 2);
- filtroPermWrite += ") ";
- DataLayer_AnagGen.PermessiRow[] righePermW = (DataLayer_AnagGen.PermessiRow[])allPermessi.Select(filtroPermWrite, "GRUPPO, NUMERO");
- foreach (DataLayer_AnagGen.PermessiRow rigaPerm in righePermW)
- {
- _permessiUtenteWrite.ImportRow(rigaPerm);
- }
- }
- else
- {
- logger.lg.scriviLog("Permessi utente WRITE non trovati!", tipoLog.ERROR);
- }
- permessiWrite = _permessiUtenteWrite;
- }
-
- ///
- /// Carica la tabella diritti dell'utente da db e salva in session
- ///
- protected virtual void setupDirittiPermessi()
- {
- DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserDominioModulo(utente, dominio, modulo);
- diritti = _dirittiUtente; // salvo in session i diritti..
- if (diritti.Count > 0)
- {
- setPermessiDaDiritti();
- }
- }
-
- ///
- /// Carica la tabella diritti dell'utente da db e salva in session SOLO per il CDC indicato
- ///
- ///
- protected virtual void setupDirittiPermessi(string cdc)
- {
- DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserDominioModuloCdc(utente, dominio, modulo, cdc);
- diritti = _dirittiUtente; // salvo in session i diritti..
- if (diritti.Count > 0)
- {
- setPermessiDaDiritti();
- }
- }
-
- ///
- /// Carica la tabella diritti dell'utente da db e salva in session
- ///
- protected virtual void setupDirittiPermessiByUsername()
- {
- DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserModulo(utente, modulo);
- diritti = _dirittiUtente; // salvo in session i diritti..
- if (diritti.Count > 0)
- {
- setPermessiDaDiritti();
- }
- }
-
- ///
- /// imposta la lingua utente dal valore della riga DB
- ///
- protected virtual void setupLingua()
- {
- string _lingua = "";
- try
- {
- _lingua = rigaUtente.COD_LINGUA;
- }
- catch { }
- if (string.IsNullOrEmpty(_lingua))
- {
- _lingua = "IT";
- }
-
- lingua = _lingua;
- }
-
- ///
- /// costruisce la mappa del sito per l'utente
- ///
- protected virtual void setupMappaSito()
- {
- string _mappa = "";
- _mappa += "";
- try
- {
- // partiamo dai permessi utente di numero "0" (sono intestazioni men�...)
- DataLayer_AnagGen.PermessiRow[] vociMenu = (DataLayer_AnagGen.PermessiRow[])permessi.Select("NUMERO ='0'", "GRUPPO");
- foreach (DataLayer_AnagGen.PermessiRow voce in vociMenu)
- {
- _mappa += formattaNodo(voce.NOME, voce.DESCRIZIONE, voce.URL, siteNodeType.startContainer);
- // per ogni livello riempiamo con i permessi figli
- DataLayer_AnagGen.PermessiRow[] pagine = (DataLayer_AnagGen.PermessiRow[])permessi.Select(string.Format("GRUPPO ='{0}' AND NUMERO > 0", voce.GRUPPO), "NUMERO");
- foreach (DataLayer_AnagGen.PermessiRow pagina in pagine)
- {
- _mappa += formattaNodo(pagina.NOME, pagina.DESCRIZIONE, pagina.URL, siteNodeType.leaf);
- }
- _mappa += formattaNodo(voce.NOME, voce.DESCRIZIONE, voce.URL, siteNodeType.endContainer);
- }
- }
- catch
- { }
- // salva in session...
- _mappa += "";
- mappaSito = _mappa;
- }
-
- ///
- /// carica la riga dati utente
- ///
- protected virtual void setupRiga()
- {
- //logger.lg.scriviLog(string.Format(@"setupRiga x utente {0}\{1}", dominio, utente), tipoLog.STARTUP);
- DataLayer_AnagGen.UTENTERow _rigaUtenteAnagGen = ((DataLayer_AnagGen.UTENTERow)DataWrap.DW.taUtente.GetDataByUtenteDominio(utente, dominio).Rows[0]);
- rigaUtente = _rigaUtenteAnagGen;
- }
-
- ///
- /// carica la riga dati utente da SOLO USERNAME
- ///
- protected virtual void setupRigaByUsername()
- {
- DataLayer_AnagGen.UTENTERow _rigaUtenteAnagGen = ((DataLayer_AnagGen.UTENTERow)DataWrap.DW.taUtente.getByUserName(utente).Rows[0]);
- rigaUtente = _rigaUtenteAnagGen;
- }
-
- #endregion Protected Methods
-
#region Public Methods
///
@@ -746,7 +473,7 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog($"Exception during ADuserOk:{Environment.NewLine}{exc}");
+ Log.Error($"Exception during ADuserOk:{Environment.NewLine}{exc}");
}
// risultato...
isOk = (isOkUser && isOkPerm);
@@ -771,7 +498,7 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog($"Exception during assegnaDirittoUtente:{Environment.NewLine}{exc}");
+ Log.Error($"Exception during assegnaDirittoUtente:{Environment.NewLine}{exc}");
}
return answ;
}
@@ -967,7 +694,8 @@ namespace SteamWare
}
///
- /// restituisce l'elenco delle funzioni abilitate dato modulo ed username partendo dalla radice dell'albero dei diritti
+ /// restituisce l'elenco delle funzioni abilitate dato modulo ed username partendo dalla
+ /// radice dell'albero dei diritti
///
///
///
@@ -978,7 +706,8 @@ namespace SteamWare
}
///
- /// restituisce la tabella (per utente corrente) dei CDC abilitati per l'applicazione attuale da sessione (se non c'� salva...)
+ /// restituisce la tabella (per utente corrente) dei CDC abilitati per l'applicazione
+ /// attuale da sessione (se non c'� salva...)
///
/// modulo di cui si testano i diritti
///
@@ -1014,7 +743,8 @@ namespace SteamWare
}
///
- /// conta il numero di permessi utente per la pagina attuale e restituisce true se ne trova almeno 1
+ /// conta il numero di permessi utente per la pagina attuale e restituisce true se ne trova
+ /// almeno 1
///
///
///
@@ -1037,7 +767,8 @@ namespace SteamWare
}
///
- /// verifica se il permesso utente per la pagina attuale sia write per almeno 1 diritto assegnato (restituisce true se ne trova almeno 1 con permessi2funzione.readwrite='S')
+ /// verifica se il permesso utente per la pagina attuale sia write per almeno 1 diritto
+ /// assegnato (restituisce true se ne trova almeno 1 con permessi2funzione.readwrite='S')
///
///
///
@@ -1111,7 +842,7 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog(string.Format("{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
+ Log.Info(string.Format("{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
return answ;
}
@@ -1134,13 +865,14 @@ namespace SteamWare
}
catch (Exception e)
{
- logger.lg.scriviLog(String.Format("Eccezione: {0}", e));
+ Log.Info(String.Format("Eccezione: {0}", e));
}
return answ;
}
///
- /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli altri dati
+ /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli
+ /// altri dati
///
///
///
@@ -1153,7 +885,7 @@ namespace SteamWare
clearAllUserData();
if (_username != "" && _dominio != "")
{
- //logger.lg.scriviLog(string.Format("startUpUtente:{2} dominio:\t{0}{2}username:\t{1}", _dominio, _username, Environment.NewLine), tipoLog.STARTUP);
+ //Log.Info(string.Format("startUpUtente:{2} dominio:\t{0}{2}username:\t{1}", _dominio, _username, Environment.NewLine), tipoLog.STARTUP);
utente = _username;
dominio = _dominio;
setupRiga();
@@ -1166,13 +898,14 @@ namespace SteamWare
}
catch (Exception exc)
{
- logger.lg.scriviLog(string.Format("Errore in fase di startUpUtente:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
+ Log.Info(string.Format("Errore in fase di startUpUtente:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
return risultato;
}
///
- /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli altri dati CON I DIRITTI SOLO per il CDC indicato
+ /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli
+ /// altri dati CON I DIRITTI SOLO per il CDC indicato
///
///
///
@@ -1197,7 +930,8 @@ namespace SteamWare
}
///
- /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli altri dati
+ /// Procedura da chiamare DOPO aver messo in session i dati utente/dominio x caricare gli
+ /// altri dati
///
///
///
@@ -1253,23 +987,23 @@ namespace SteamWare
{
if (DataWrap.DW.dictVocabolario != null)
{
- string key = $"{lingua }#{lemma}";
+ string key = $"{lingua}#{lemma}";
if (DataWrap.DW.dictVocabolario.ContainsKey(key))
{
answ = DataWrap.DW.dictVocabolario[lingua + "#" + lemma];
}
else
{
- logger.lg.scriviLog($"Lemma not found: {_lemma}", tipoLog.LEMMA);
+ Log.Info($"Lemma not found: {_lemma}", tipoLog.LEMMA);
}
}
}
}
catch (Exception exc)
{
- logger.lg.scriviLog(_lemma, tipoLog.LEMMA);
+ Log.Error(_lemma, tipoLog.LEMMA);
// loggo risultato x voc
- logger.lg.scriviLog($"Presenti {DataWrap.DW.numRecVoc} lemmi in vocabolario, richiesto lingua {lingua} | lemma {lemma}{Environment.NewLine}{exc}");
+ Log.Error($"Presenti {DataWrap.DW.numRecVoc} lemmi in vocabolario, richiesto lingua {lingua} | lemma {lemma}{Environment.NewLine}{exc}");
if (DataWrap.DW.numRecVoc > 4)
{
// mostro primi 4...
@@ -1278,7 +1012,7 @@ namespace SteamWare
{
if (i <= 4)
{
- logger.lg.scriviLog(string.Format("Key: {0} | Val: {1}", item.Key, item.Value), tipoLog.INFO);
+ Log.Info(string.Format("Key: {0} | Val: {1}", item.Key, item.Value), tipoLog.INFO);
i++;
}
}
@@ -1286,7 +1020,7 @@ namespace SteamWare
}
if (currRunMode == runModes.echoLemmi)
{
- logger.lg.scriviLog(_lemma, tipoLog.LEMMA);
+ Log.Info(_lemma, tipoLog.LEMMA);
}
return answ;
@@ -1334,7 +1068,8 @@ namespace SteamWare
}
///
- /// verifica nella tab diritti se l'utente abbia il right richiesto (come COD_FUNZIONE) e fornisce bool in risposta
+ /// verifica nella tab diritti se l'utente abbia il right richiesto (come COD_FUNZIONE) e
+ /// fornisce bool in risposta
///
///
///
@@ -1354,5 +1089,286 @@ namespace SteamWare
}
#endregion Public Methods
+
+ #region Protected Methods
+
+ ///
+ /// cancella da session l'utente
+ ///
+ protected void clearAllUserData()
+ {
+ memLayer.ML.emptySessionVal("USER_NAME");
+ memLayer.ML.emptySessionVal("DOMINIO");
+ memLayer.ML.emptySessionVal("permessiUtente");
+ }
+
+ ///
+ /// formatta un nodo in modo corretto dai dati indicati
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected string formattaNodo(string titolo, string descrizione, string url, siteNodeType tipoNodo)
+ {
+ string _out = "";
+ switch (tipoNodo)
+ {
+ case siteNodeType.startContainer:
+ _out = string.Format("";
+ break;
+
+ case siteNodeType.leaf:
+ _out = string.Format("", Traduci(titolo), Traduci(descrizione), url);
+ break;
+ }
+ return _out;
+ }
+
+ ///
+ /// salva dati accessori quali il cdc dell'utente...
+ ///
+ protected virtual void salvaDatiAccessori()
+ {
+ // salvo il cdc utente...
+ memLayer.ML.setSessionVal("CdCUser", rigaUtente.COD_CDC);
+ // verifico se necessario fare echo lemmi e vado in runMode di echo dei termini tradotti
+ bool echoLemmi = false;
+ try
+ {
+ echoLemmi = memLayer.ML.CRB("echoLemmi");
+ }
+ catch
+ { }
+ if (echoLemmi)
+ {
+ currRunMode = runModes.echoLemmi;
+ }
+ else
+ {
+ currRunMode = runModes.normal;
+ }
+ }
+
+ ///
+ /// Effettua setup dei permessi una volta salvati i diritti
+ ///
+ protected virtual void setPermessiDaDiritti()
+ {
+ // proseguo coi permessi
+ DataLayer_AnagGen.PermessiDataTable allPermessi = DataWrap.DW.taPermessi.GetData();
+ DataLayer_AnagGen.Permessi2FunzioneDataTable allPerm2Funz = DataWrap.DW.taPermessi2Funzione.GetData();
+ DataLayer_AnagGen.PermessiDataTable _permessiUtente = new DataLayer_AnagGen.PermessiDataTable();
+ DataLayer_AnagGen.PermessiDataTable _permessiUtenteWrite = new DataLayer_AnagGen.PermessiDataTable();
+ string filtroFunz, filtroPerm, filtroPermWrite;
+ filtroPerm = " COD_PERMESSO IN (";
+ filtroPermWrite = " COD_PERMESSO IN (";
+ // filtro i diritti utente x non avere duplicati...
+ Dictionary funzioniUtente = new Dictionary();
+ foreach (DataLayer_AnagGen.DIRITTIRow riga in diritti)
+ {
+ try
+ {
+ funzioniUtente.Add(riga.COD_FUNZIONE, riga.COD_FUNZIONE);
+ }
+ catch
+ { }
+ }
+ foreach (KeyValuePair kvp in funzioniUtente)
+ {
+ filtroFunz = string.Format("COD_FUNZIONE='{0}'", kvp.Value);
+ // recupero le righe dei righe2perm
+ DataLayer_AnagGen.Permessi2FunzioneRow[] righe_p2f = (DataLayer_AnagGen.Permessi2FunzioneRow[])allPerm2Funz.Select(filtroFunz);
+ foreach (DataLayer_AnagGen.Permessi2FunzioneRow riga_p2f in righe_p2f)
+ {
+ filtroPerm += string.Format("'{0}', ", riga_p2f.COD_PERMESSO);
+ // se � write metto in tab relativa...
+ try
+ {
+ if (riga_p2f.READWRITE == "S")
+ {
+ filtroPermWrite += string.Format("'{0}', ", riga_p2f.COD_PERMESSO);
+ }
+ }
+ catch
+ {
+ }
+ }
+ }
+ // cambio modalit� controllo permessi abilitati x problema permessi non trovati...
+ if (filtroPerm != " COD_PERMESSO IN (")
+ {
+ filtroPerm = filtroPerm.Remove(filtroPerm.Length - 2);
+ filtroPerm += ") ";
+ DataLayer_AnagGen.PermessiRow[] righePerm = (DataLayer_AnagGen.PermessiRow[])allPermessi.Select(filtroPerm, "GRUPPO, NUMERO");
+ foreach (DataLayer_AnagGen.PermessiRow rigaPerm in righePerm)
+ {
+ _permessiUtente.ImportRow(rigaPerm);
+ }
+ }
+ else
+ {
+ Log.Info("Permessi utente non trovati!", tipoLog.ERROR);
+ }
+ permessi = _permessiUtente;
+ // salvo, se ci sono, permessi write...
+ if (filtroPermWrite != " COD_PERMESSO IN (")
+ {
+ filtroPermWrite = filtroPermWrite.Remove(filtroPermWrite.Length - 2);
+ filtroPermWrite += ") ";
+ DataLayer_AnagGen.PermessiRow[] righePermW = (DataLayer_AnagGen.PermessiRow[])allPermessi.Select(filtroPermWrite, "GRUPPO, NUMERO");
+ foreach (DataLayer_AnagGen.PermessiRow rigaPerm in righePermW)
+ {
+ _permessiUtenteWrite.ImportRow(rigaPerm);
+ }
+ }
+ else
+ {
+ Log.Info("Permessi utente WRITE non trovati!", tipoLog.ERROR);
+ }
+ permessiWrite = _permessiUtenteWrite;
+ }
+
+ ///
+ /// Carica la tabella diritti dell'utente da db e salva in session
+ ///
+ protected virtual void setupDirittiPermessi()
+ {
+ DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserDominioModulo(utente, dominio, modulo);
+ diritti = _dirittiUtente; // salvo in session i diritti..
+ if (diritti.Count > 0)
+ {
+ setPermessiDaDiritti();
+ }
+ }
+
+ ///
+ /// Carica la tabella diritti dell'utente da db e salva in session SOLO per il CDC indicato
+ ///
+ ///
+ protected virtual void setupDirittiPermessi(string cdc)
+ {
+ DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserDominioModuloCdc(utente, dominio, modulo, cdc);
+ diritti = _dirittiUtente; // salvo in session i diritti..
+ if (diritti.Count > 0)
+ {
+ setPermessiDaDiritti();
+ }
+ }
+
+ ///
+ /// Carica la tabella diritti dell'utente da db e salva in session
+ ///
+ protected virtual void setupDirittiPermessiByUsername()
+ {
+ DataLayer_AnagGen.DIRITTIDataTable _dirittiUtente = DataWrap.DW.taDiritti.GetByUserModulo(utente, modulo);
+ diritti = _dirittiUtente; // salvo in session i diritti..
+ if (diritti.Count > 0)
+ {
+ setPermessiDaDiritti();
+ }
+ }
+
+ ///
+ /// imposta la lingua utente dal valore della riga DB
+ ///
+ protected virtual void setupLingua()
+ {
+ string _lingua = "";
+ try
+ {
+ _lingua = rigaUtente.COD_LINGUA;
+ }
+ catch { }
+ if (string.IsNullOrEmpty(_lingua))
+ {
+ _lingua = "IT";
+ }
+
+ lingua = _lingua;
+ }
+
+ ///
+ /// costruisce la mappa del sito per l'utente
+ ///
+ protected virtual void setupMappaSito()
+ {
+ string _mappa = "";
+ _mappa += "";
+ try
+ {
+ // partiamo dai permessi utente di numero "0" (sono intestazioni men�...)
+ DataLayer_AnagGen.PermessiRow[] vociMenu = (DataLayer_AnagGen.PermessiRow[])permessi.Select("NUMERO ='0'", "GRUPPO");
+ foreach (DataLayer_AnagGen.PermessiRow voce in vociMenu)
+ {
+ _mappa += formattaNodo(voce.NOME, voce.DESCRIZIONE, voce.URL, siteNodeType.startContainer);
+ // per ogni livello riempiamo con i permessi figli
+ DataLayer_AnagGen.PermessiRow[] pagine = (DataLayer_AnagGen.PermessiRow[])permessi.Select(string.Format("GRUPPO ='{0}' AND NUMERO > 0", voce.GRUPPO), "NUMERO");
+ foreach (DataLayer_AnagGen.PermessiRow pagina in pagine)
+ {
+ _mappa += formattaNodo(pagina.NOME, pagina.DESCRIZIONE, pagina.URL, siteNodeType.leaf);
+ }
+ _mappa += formattaNodo(voce.NOME, voce.DESCRIZIONE, voce.URL, siteNodeType.endContainer);
+ }
+ }
+ catch
+ { }
+ // salva in session...
+ _mappa += "";
+ mappaSito = _mappa;
+ }
+
+ ///
+ /// carica la riga dati utente
+ ///
+ protected virtual void setupRiga()
+ {
+ //Log.Info(string.Format(@"setupRiga x utente {0}\{1}", dominio, utente), tipoLog.STARTUP);
+ DataLayer_AnagGen.UTENTERow _rigaUtenteAnagGen = ((DataLayer_AnagGen.UTENTERow)DataWrap.DW.taUtente.GetDataByUtenteDominio(utente, dominio).Rows[0]);
+ rigaUtente = _rigaUtenteAnagGen;
+ }
+
+ ///
+ /// carica la riga dati utente da SOLO USERNAME
+ ///
+ protected virtual void setupRigaByUsername()
+ {
+ DataLayer_AnagGen.UTENTERow _rigaUtenteAnagGen = ((DataLayer_AnagGen.UTENTERow)DataWrap.DW.taUtente.getByUserName(utente).Rows[0]);
+ rigaUtente = _rigaUtenteAnagGen;
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
+
+ #region Private Methods
+
+ ///
+ /// controllo utente/pwd da tab
+ ///
+ ///
+ ///
+ ///
+ private bool checkUserPwd(string _username, string _pwd)
+ {
+ bool risultato = false;
+ try
+ {
+ risultato = DataWrap.DW.taUserData.getByUserPwd(_username, _pwd).Rows.Count > 0;
+ }
+ catch
+ { }
+ return risultato;
+ }
+
+ #endregion Private Methods
}
}
\ No newline at end of file