public override List<Database> GetDatabases(string domainName) { var _tmp = new List<Database>(); using (SqlConnection _conn = new SqlConnection(Settings.Default.connectionString)) { _conn.Open(); using (SqlCommand _cmd = new SqlCommand(@"SELECT data_bases.id as db_id, domains.name AS domain, data_bases.name, data_bases.type FROM data_bases LEFT OUTER JOIN domains ON domains.id = data_bases.dom_id LEFT OUTER JOIN db_users ON db_users.id = data_bases.default_user_id WHERE (domains.name = @NAME)", _conn)) { _cmd.Parameters.AddWithValue("@NAME", domainName); using (SqlDataReader _read = _cmd.ExecuteReader()) { while (_read.Read()) { var _d = new Database(); _d.Id = (int)_read["db_id"]; _d.Name = _read["name"].ToString(); _d.Domain = _read["domain"].ToString(); _d.DbType = _read["type"].ToString(); _d.Users = GetDatabaseUsers(_d.Id); _tmp.Add(_d); } } } _conn.Close(); } return _tmp; }
private List<Database> GetMySqlDatabases(string domainName) { var _tmp = new List<Database>(); using (SQLiteConnection _conn = new SQLiteConnection(Settings.Default.connectionString)) { _conn.Open(); using (SQLiteCommand _cmd = new SQLiteCommand(@"SELECT Sql.Id as db_id, D.Name as domain, Sql.Name as name FROM DomainMySQL as Sql LEFT JOIN Domain as D ON Sql.DomainId = D.DomainId WHERE D.Name = $NAME", _conn)) { _cmd.Parameters.AddWithValue("$NAME", domainName); using (SQLiteDataReader _read = _cmd.ExecuteReader()) { while (_read.Read()) { var _d = new Database(); _d.Id = Convert.ToInt32(_read["db_id"]); _d.Name = _read["name"].ToString(); _d.Domain = _read["domain"].ToString(); _d.DbType = "mysql"; _d.Users = GetMySqlDatabaseUsers(_d.Id); _tmp.Add(_d); } } } _conn.Close(); } return _tmp; }