public bool FazLogin(int id, string nome, int nivel, int avatar) { try { if (this.SessaoIniciada) { throw new Exception("Já existe uma sessão iniciada!"); } HttpContext.Current.Response.Cookies["id"].Value = id.ToString(); HttpContext.Current.Response.Cookies["nome"].Value = nome; HttpContext.Current.Response.Cookies["nivel"].Value = nivel.ToString(); HttpContext.Current.Response.Cookies["avatar"].Value = avatar.ToString(); HttpContext.Current.Response.Cookies["unixTime"].Value = Diversos.ObterTempoUnixAtual().ToString(); return(true); } catch (Exception ex) { Debug.WriteLine("FazLogin(): " + ex.Message); this.LimpaDados(); return(false); } }
public VarsAuxiliares() { this.horaDeArranque = Diversos.ObterTempoUnixAtual(); //Variáveis do LOG da aplicação string logDir = Application.StartupPath + @"\Logs\Log.txt"; int logMaxSize = 5120; bool logEnabled = true; #region Load configurations from INI File try { using (FicheiroINI ini = new FicheiroINI(iniPath)) { // Load Database configurations this.DB_CONNECTION_STRING = @"data source=" + ini.RetornaINI("Database", "Address", ".") + @"\" + ini.RetornaINI("Database", "Instance", "SQLEXPRESS") + "; Initial Catalog=" + ini.RetornaINI("Database", "DBName", "CTRL_PROD") + "; MultipleActiveResultSets=True; persist security info=False; UID=" + ini.RetornaINI("Database", "User", "streak") + "; PWD=" + ini.RetornaINI("Database", "Pass", "streak") + ";"; this.IpDb = ini.RetornaINI("Database", "Address", "."); #region Log //Log da aplicação logDir = ini.RetornaINI("AppLog", "logDir", logDir); logMaxSize = Convert.ToInt32(ini.RetornaINI("AppLog", "logMaxSize", Convert.ToString(logMaxSize))); logEnabled = ini.RetornaTrueFalseDeStringFicheiroINI("AppLog", "logEnabled", logEnabled); #endregion // Diversos this.LAST_LOCATION = new Point(Convert.ToInt32(ini.RetornaINI("App", "LocX", "0")), Convert.ToInt32(ini.RetornaINI("App", "Locy", "0"))); this.SETTINGS_UPDATE_RATE = Convert.ToInt32(ini.RetornaINI("App", "SETTINGS_UPDATE_RATE", this.SETTINGS_UPDATE_RATE.ToString())); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Loading Configs", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } #endregion this.LogDebug = new LogFile(logDir, logMaxSize, logEnabled); }