public ConfigSite Buscar(string dominio) { try { ConfigSite dataLote = null; DBSession session = new DBSession(); Query quey = session.CreateQuery("SELECT * FROM ConfigSite WHERE dominio = @dominio"); quey.SetParameter("dominio", dominio); IDataReader reader = quey.ExecuteQuery(); if (reader.Read()) { dataLote = new ConfigSite(Convert.ToString(reader["dominio"]), Convert.ToString(reader["imagem"])); } reader.Close(); session.Close(); return(dataLote); } catch (Exception error) { throw error; } }
public void Excluir(ConfigSite variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("DELETE FROM ConfigSite WHERE dominio = @dominio"); query.SetParameter("dominio", variavel.dominio); query.ExecuteUpdate(); session.Close(); } catch (Exception error) { throw error; } }
public void Alterar(ConfigSite variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("UPDATE ConfigSite SET imagem = @imagem WHERE dominio = @dominio"); query.SetParameter("dominio", variavel.dominio) .SetParameter("imagem", variavel.imagem); query.ExecuteUpdate(); session.Close(); } catch (Exception error) { throw error; } }
public void Salvar(ConfigSite variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("INSERT INTO ConfigSite (imagem, dominio) VALUES (@imagem, @dominio) "); query.SetParameter("imagem", variavel.imagem) .SetParameter("dominio", variavel.dominio); query.ExecuteUpdate(); session.Close(); } catch (Exception error) { throw error; } }
private void _Start() { if (Settings.Current[Constants.RUNNING_USERNAME_SETTING_NAME] == null) { Settings.Current[Constants.RUNNING_USERNAME_SETTING_NAME] = "www"; } pidfile = null; consoleMessages = false; if (args.Length > 0) { for (int x = 0; x < args.Length; x++) { switch (args[x]) { case "--runningUser": Settings.Current[Constants.RUNNING_USERNAME_SETTING_NAME] = args[x + 1]; x += 1; break; case "--pidfile": pidfile = args[x + 1]; x += 1; break; case "--showConsoleMessages": consoleMessages = true; break; case "--showRunningThreads": _runningThreads = new List <NameValuePair>(); _runningThreadsOutputter = new Timer(new TimerCallback(_OutputRunningThreads), null, 30000, 30000); break; case "--showPerformanceData": perfomanceMessages = true; if (!ModuleController.Current.IsModuleEnabled("SystemMonitoring")) { ModuleController.Current.EnableModule("SystemMonitoring"); } EventController.RegisterEventHandler(this); break; default: Console.WriteLine("Invalid command line arguements specified " + args[x] + ", ignoring."); break; } } } if (Utility.OperatingSystem == null) { Console.WriteLine("Unknown operating system, exiting..."); _shutdownEvent.Set(); return; } if (consoleMessages) { ConfigSite.TurnOnConsoleLogging(); } foreach (FileInfo fi in new DirectoryInfo(basePath).GetFiles("*.dll")) { if (consoleMessages) { Console.WriteLine("Loading assembly from dll " + fi.Name + " ..."); } Assembly.LoadFile(fi.FullName); if (consoleMessages) { Console.WriteLine("Loaded assembly from dll " + fi.Name + "."); } } if (consoleMessages) { Console.WriteLine("Loaded assemblies: "); foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { try { if (ass.GetName().Name != "mscorlib" && !ass.GetName().Name.StartsWith("System.") && ass.GetName().Name != "System" && !ass.GetName().Name.StartsWith("Microsoft")) { Console.WriteLine(ass.GetName().FullName); } } catch (Exception e) { Logger.LogError(e); } } } if (ProcessSecurityControl.Current.CurrentProcessUserID != ProcessSecurityControl.Current.GetUIDForUser("root")) { Console.WriteLine("You must run this application as the root user, it will secure itself afterwards."); _shutdownEvent.Set(); return; } else { if (consoleMessages) { Console.WriteLine("Starting up control socket..."); } if (consoleMessages) { Console.WriteLine("Control Socket started."); } if (consoleMessages) { Console.WriteLine("Starting up Website through Server Control..."); } ServerControl.Start(); if (_runningThreads != null) { ServerControl.RegisterBackgroundOperationPreCall(_preCall); ServerControl.RegisterBackgrounOperationPostCall(_postCall); } if (consoleMessages) { Console.WriteLine("Website started with Server Control."); } try { if (consoleMessages) { Console.WriteLine("Closing up Process security..."); } ProcessSecurityControl.Current.CloseProcessSecurity(); if (consoleMessages) { Console.WriteLine("Process Security Closed."); } } catch (Exception e) { Logger.LogError(e); Console.WriteLine("WARNING!!! An error occured changing the security role of the current process away from root. It is still running as the root user."); } if (pidfile != null) { if (consoleMessages) { Console.WriteLine("Writing process ID to pidile " + pidfile + "..."); } SetPidFile(pidfile); if (consoleMessages) { Console.WriteLine("Process ID written to file."); } } } _internalShutdownEvent.WaitOne(); OnStop(); }