private void AddFolder_Click(object sender, EventArgs e) { if (this.ServerList.SelectedIndex >= 0) { Directories newFolder = new Directories(); newFolder.DirectoryName = Globals.AppFolder; newFolder.VHostID = Globals.VHosts[this.ServerList.SelectedIndex].VHostID; newFolder.DirectoryID = Database.AddUpdateDirectory(newFolder); Globals.VHosts[this.ServerList.SelectedIndex].Directory.Add(newFolder); this.Folders.Items.Add(newFolder.DirectoryName); this.Folders.SelectedIndex = this.Folders.Items.Count - 1; this.Folders_DoubleClick(null, null); } }
public int AddUpdateDirectory(Directories Dir) { if (Dir.DirectoryID > 0) { try { return(Globals.dbConn.ExecuteNonQuery("UPDATE Directories SET " + "VHostID = " + Dir.VHostID + ", " + "Others = '" + Dir.Others + "', " + "AllowOverride = " + ((Dir.AllowOverride == true) ? "1" : "0") + ", " + "MultiViews = " + ((Dir.MultiViews == true) ? "1" : "0") + ", " + "Indexes = " + ((Dir.Indexes == true) ? "1" : "0") + ", " + "Includes = " + ((Dir.Includes == true) ? "1" : "0") + ", " + "SymLinks = " + ((Dir.SymLinks == true) ? "1" : "0") + ", " + "DirectoryName = '" + Dir.DirectoryName + "' " + "WHERE VHostID = " + Dir.VHostID)); } catch (Exception /*ex*/) { //Globals.Error.Show(ex.Message); return(-1); } } else { Globals.dbConn.ExecuteNonQuery("INSERT INTO Directories ('VHostID', 'Others', 'AllowOverride', 'MultiViews', 'Indexes', 'Includes', 'SymLinks', 'DirectoryName') VALUES (" + Dir.VHostID + ", " + "'" + Dir.Others + "', " + ((Dir.AllowOverride == true) ? "1" : "0") + ", " + ((Dir.MultiViews == true) ? "1" : "0") + ", " + ((Dir.Indexes == true) ? "1" : "0") + ", " + ((Dir.Includes == true) ? "1" : "0") + ", " + ((Dir.SymLinks == true) ? "1" : "0") + ", " + "'" + Dir.DirectoryName + "'" + ")"); return(Convert.ToInt32(Globals.dbConn.ExecuteScalar("SELECT MAX(DirectoryID) from Directories"))); } }
public void DeleteDirectory(Directories Dir) { Globals.dbConn.ExecuteNonQuery("DELETE FROM Directories WHERE DirectoryID = " + Dir.DirectoryID); }
public void LoadVirtualHosts() { Globals.VHosts.Clear(); // Load Virtual Hosts info from database. DataTable DBVHosts = Globals.dbConn.GetDataTable("SELECT * FROM VirtualHosts"); foreach (DataRow rowVH in DBVHosts.Rows) { VirtualHost VH = new VirtualHost(); foreach (DataColumn colVH in DBVHosts.Columns) { try { PropertyInfo pi = VH.GetType().GetProperty(colVH.ToString()); pi.SetValue(VH, Convert.ChangeType(rowVH[colVH], pi.PropertyType), null); //Object collection = pi.GetValue(VH, null); } catch (Exception /*ex*/) { //Globals.Error.Show("Column: " + colVH.ToString() + "\r\nContent: " + rowVH[colVH].ToString() + "\r\n" + ex.Message); } } // Load Aliases info for each Virtual Host from database. DataTable DBAliases = Globals.dbConn.GetDataTable("SELECT * FROM Aliases WHERE VHostID = " + rowVH["VHostID"].ToString()); foreach (DataRow rowAl in DBAliases.Rows) { Aliases Alias = new Aliases(); foreach (DataColumn colAl in DBAliases.Columns) { try { PropertyInfo pi = Alias.GetType().GetProperty(colAl.ToString()); pi.SetValue(Alias, Convert.ChangeType(rowAl[colAl], pi.PropertyType), null); } catch (Exception) { } } VH.Alias.Add(Alias); } // Load Directories info for each Virtual Host from database. DataTable DBDirectories = Globals.dbConn.GetDataTable("SELECT * FROM Directories WHERE VHostID = " + rowVH["VHostID"].ToString()); foreach (DataRow rowDir in DBDirectories.Rows) { Directories Directory = new Directories(); foreach (DataColumn colDir in DBDirectories.Columns) { try { PropertyInfo pi = Directory.GetType().GetProperty(colDir.ToString()); pi.SetValue(Directory, Convert.ChangeType(rowDir[colDir], pi.PropertyType), null); } catch (Exception) { } } VH.Directory.Add(Directory); } Globals.VHosts.Add(VH); } }