private SchemataServer FindServer(string serverName) { int i = 0; bool found = false; SchemataServer server = null; while ((i < tree.Nodes.Count) && !found) { server = (SchemataServer)tree.Nodes[i]; if (!(found = server.DatabaseConnection.HostName.ToLower().Equals(serverName))) { i++; } } return(found ? server : null); }
private SchemataParameter[] FindProcParameters( string serverName, string schemaName, string procName) { SchemataProcedure procedure = null; SchemataServer server = FindServer(serverName); if (server != null) { SchemataSchema schema = server.FindSchema(schemaName); if (schema != null) { procedure = schema.FindProcedure(procName); } } return(procedure == null ? new SchemataParameter[0] : procedure.Parameters); }
//======================================================================================== // AddConnection() //======================================================================================== /// <summary> /// Adds a connection and its representation to both the schema selector /// and the object tree. /// </summary> /// <param name="con">The database connection to add.</param> public void AddConnection(DatabaseConnection con) { // find an existing node for this connection bool found = false; int i = 0; DatabaseConnection dc; while ((i < tree.Nodes.Count) && !found) { dc = ((SchemataServer)tree.Nodes[i]).DatabaseConnection; if ((dc.HostName == con.HostName) && (dc.ServiceName == con.ServiceName)) { found = true; } else { i++; } } if (!found) { // create a new node for the connection SchemataServer srvnode = new SchemataServer(con); srvnode.Expand(); tree.Nodes.Insert(0, srvnode); // after the node is expanded, it is auto discovered so we can grab schemas foreach (TreeNode node in srvnode.Nodes) { schemaBox.Items.Add(new SchemaItem((SchemataSchema)node)); } int index = schemaBox.FindString(srvnode.Text + "." + con.DefaultSchema); schemaBox.SelectedIndex = (index < 0 ? 0 : index); } }