/// <summary>Gets the databases for a server</summary> /// <param name="server">Server to get the databases of</param> /// <returns>List of database items</returns> private List<BaseItem> GetDatabases(ServerItem server) { List<BaseItem> items = new List<BaseItem>(); List<Database> databases = server.DataAccess.GetDatabases(); foreach (Database db in databases) { BaseItem dataItem = new BaseItem(ItemType.Database, db.Name, server); items.Add(dataItem); } return items; }
/// <summary>Gets the tables or views</summary> /// <param name="parent">Folder that was expanded</param> /// <param name="server">Server item the tables are under</param> /// <param name="DatabaseName">Name of the database to look in</param> /// <returns>List of table or view items</returns> private List<BaseItem> GetFolderChildren(BaseItem parent, ServerItem server, string DatabaseName) { List<BaseItem> items = new List<BaseItem>(); string oldDatabase = server.DataAccess.SelectedDatabase; server.DataAccess.SetDatabase(DatabaseName); switch (parent.Name) { case "Tables": items = GetTableViews(ItemType.Table, parent, server.DataAccess.GetTables()); break; case "Views": items = GetTableViews(ItemType.View, parent, server.DataAccess.GetViews()); break; case "Columns": items = GetColumns(parent, server.DataAccess.GetColumns(parent.Parent.Name)); break; case "Keys": items = GetKeys(parent, server.DataAccess.GetKeys(parent.Parent.Name)); break; } server.DataAccess.SetDatabase(oldDatabase); return items; }
/// <summary>Adds a server to the tree</summary> /// <param name="dataAccess">Data access object to associate with the server</param> private void AddServer(DataAccessBase dataAccess) { ServerItem item = new ServerItem(dataAccess.DataSource); item.DataAccess = dataAccess; if (_tree.Cache.ContainsKey("ROOT")) { _tree.Cache["ROOT"].Add(item); } else { List<BaseItem> items = new List<BaseItem>(); items.Add(item); _tree.Cache.Add("ROOT", items); } _tree.OnNodesInserted(TreePath.Empty, new int[] { _tree.Cache["ROOT"].Count - 1 }, new object[] { item }); }