d596977dab
Aggiunta classe fileMover.cs Aggiunto DS DS_WebScip git-svn-id: https://keyhammer.ath.cx/svn/ETS/trunk@23 72332f79-082b-4ce8-9953-5b7f197a49bb
283 lines
8.2 KiB
C#
283 lines
8.2 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.IO;
|
|
|
|
namespace ETS_Data
|
|
{
|
|
public class utils
|
|
{
|
|
#region area table adapters
|
|
|
|
public DS_AnagraficaTableAdapters.UtentiTableAdapter taUtenti;
|
|
|
|
public DS_utilsTableAdapters.v_selFontiTableAdapter taSelFonti;
|
|
public DS_utilsTableAdapters.v_selCommesseTableAdapter taSelCommesse;
|
|
public DS_utilsTableAdapters.v_selFasiTableAdapter taSelFasi;
|
|
protected AppSettingsReader configAppSetReader;
|
|
|
|
/// <summary>
|
|
/// init dei table adapters
|
|
/// </summary>
|
|
protected void initTA()
|
|
{
|
|
taUtenti = new DS_AnagraficaTableAdapters.UtentiTableAdapter();
|
|
taSelFonti = new DS_utilsTableAdapters.v_selFontiTableAdapter();
|
|
taSelCommesse = new DS_utilsTableAdapters.v_selCommesseTableAdapter();
|
|
taSelFasi = new DS_utilsTableAdapters.v_selFasiTableAdapter();
|
|
}
|
|
/// <summary>
|
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
/// </summary>
|
|
protected virtual void setupConnectionStringBase()
|
|
{
|
|
string connStringETS_WS = (string)configAppSetReader.GetValue("ETS_WSConnectionString", typeof(string));
|
|
string connStringETS_WAnagrafica = (string)configAppSetReader.GetValue("ETS_AnagraficaConnectionString", typeof(string));
|
|
// connections del db
|
|
taUtenti.Connection.ConnectionString = connStringETS_WAnagrafica;
|
|
taSelFonti.Connection.ConnectionString = connStringETS_WS;
|
|
taSelCommesse.Connection.ConnectionString = connStringETS_WS;
|
|
taSelFasi.Connection.ConnectionString = connStringETS_WS;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Inizializzazione
|
|
|
|
protected utils()
|
|
{
|
|
configAppSetReader = new AppSettingsReader();
|
|
initTA();
|
|
setupConnectionStringBase();
|
|
}
|
|
|
|
/// <summary>
|
|
/// oggetto static per fare chiamate sul magazzino
|
|
/// </summary>
|
|
public static utils obj = new utils();
|
|
|
|
#endregion
|
|
|
|
#region area user
|
|
|
|
/// <summary>
|
|
/// utente correntemente connesso (Formato dominio\username)
|
|
/// </summary>
|
|
public string currUserAD
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
if (HttpContext.Current.User.Identity.IsAuthenticated)
|
|
{
|
|
answ = HttpContext.Current.User.Identity.Name;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// utente correntemente connesso per utilizzo FileSystem (Formato dominio.username)
|
|
/// </summary>
|
|
public string currUser_FS
|
|
{
|
|
get
|
|
{
|
|
return currUserAD.Replace(@"\", ".");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// utente correntemente connesso (Formato Cognome, nome)
|
|
/// </summary>
|
|
public string currUserCognomeNome
|
|
{
|
|
get
|
|
{
|
|
string answ = "-";
|
|
try
|
|
{
|
|
// cerco user da elenco...
|
|
DS_Anagrafica.UtentiRow riga = (DS_Anagrafica.UtentiRow)taUtenti.getByKey(currUserAD)[0];
|
|
answ = string.Format("{0} {1}", riga.Cognome.ToUpper(), riga.Nome);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area Session
|
|
|
|
/// <summary>
|
|
/// carica dalla sessione un dato di tipo object generico
|
|
/// </summary>
|
|
/// <param name="nomeVar"></param>
|
|
/// <returns></returns>
|
|
public object objSessionObj(string nomeVar)
|
|
{
|
|
if (HttpContext.Current.Session[nomeVar] != null)
|
|
{
|
|
return HttpContext.Current.Session[nomeVar];
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// carica dalla sessione un dato di tipo boolean (se vuoto false)
|
|
/// </summary>
|
|
/// <param name="nomeVar"></param>
|
|
/// <returns></returns>
|
|
public bool BoolSessionObj(string nomeVar)
|
|
{
|
|
if (HttpContext.Current.Session[nomeVar] != null)
|
|
{
|
|
return (bool)HttpContext.Current.Session[nomeVar];
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// carica dalla sessione un dato di tipo string
|
|
/// </summary>
|
|
/// <param name="nomeVar"></param>
|
|
/// <returns></returns>
|
|
public string StringSessionObj(string nomeVar)
|
|
{
|
|
if (HttpContext.Current.Session[nomeVar] != null)
|
|
{
|
|
return HttpContext.Current.Session[nomeVar].ToString();
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// carica dalla sessione un dato di tipo long
|
|
/// </summary>
|
|
/// <param name="nomeVar"></param>
|
|
/// <returns></returns>
|
|
public long LongSessionObj(string nomeVar)
|
|
{
|
|
if (HttpContext.Current.Session[nomeVar] != null)
|
|
{
|
|
return (long)Convert.ToInt32(HttpContext.Current.Session[nomeVar].ToString());
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// carica dalla sessione un dato di tipo int
|
|
/// </summary>
|
|
/// <param name="nomeVar"></param>
|
|
/// <returns></returns>
|
|
public int IntSessionObj(string nomeVar)
|
|
{
|
|
if (HttpContext.Current.Session[nomeVar] != null)
|
|
{
|
|
return (int)Convert.ToInt32(HttpContext.Current.Session[nomeVar].ToString());
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// inserisce in session un valore
|
|
/// </summary>
|
|
/// <param name="nome"></param>
|
|
/// <param name="valore"></param>
|
|
public bool setSessionVal(string nome, object valore)
|
|
{
|
|
bool _done = false;
|
|
try
|
|
{
|
|
HttpContext.Current.Session[nome] = valore;
|
|
_done = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return _done;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gestione file config
|
|
|
|
/// <summary>
|
|
/// legge dalla config un valore bool
|
|
/// </summary>
|
|
/// <param name="nomeParam"></param>
|
|
/// <returns></returns>
|
|
public bool confReadBool(string nomeParam)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = (bool)configAppSetReader.GetValue(nomeParam, typeof(bool));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// legge dalla config un valore string
|
|
/// </summary>
|
|
/// <param name="nomeParam"></param>
|
|
/// <returns></returns>
|
|
public string confReadString(string nomeParam)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = (string)configAppSetReader.GetValue(nomeParam, typeof(string));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// legge dalla config un valore int
|
|
/// </summary>
|
|
/// <param name="nomeParam"></param>
|
|
/// <returns></returns>
|
|
public int confReadInt(string nomeParam)
|
|
{
|
|
int answ = -1;
|
|
try
|
|
{
|
|
answ = (int)configAppSetReader.GetValue(nomeParam, typeof(int));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area file/dir
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|