/// <summary> /// Fetches all schema names from the current connection and loads them in the <see cref="SchemasList"/> tree. /// </summary> /// <returns><c>true</c> if schemas were loaded successfully, <c>false</c> otherwise.</returns> private bool LoadSchemas() { if (SchemasList.HeaderNodes.Count < 2) { return(false); } try { // Avoids flickering of schemas list while adding the items to it. SchemasList.BeginUpdate(); LoadedSchemas.ForEach(schema => schema.Dispose()); LoadedSchemas.Clear(); foreach (TreeNode node in SchemasList.Nodes) { node.Nodes.Clear(); } DataTable databases = _wbConnection.GetSchemaCollection("Databases", null); foreach (DataRow row in databases.Rows) { string schemaName = row["DATABASE_NAME"].ToString(); // If the user has specified a filter then check it if (!string.IsNullOrEmpty(_filter) && !schemaName.ToUpper().Contains(_filter)) { continue; } // Create the DbSchema and MySqlListViewNode objects var schemaObject = new DbSchema(_wbConnection, schemaName, row["DEFAULT_CHARACTER_SET_NAME"].ToString(), row["DEFAULT_COLLATION_NAME"].ToString(), DisplaySchemaCollationsToolStripMenuItem.Checked); string lcSchemaName = schemaName.ToLowerInvariant(); var headerNode = SchemasList.HeaderNodes[_systemSchemasListValues.Contains(lcSchemaName) ? 1 : 0]; LoadedSchemas.Add(schemaObject); var node = SchemasList.AddDbObjectNode(headerNode, schemaObject); node.ImageIndex = DisplaySchemaCollationsToolStripMenuItem.Checked ? 1 : 0; } if (SchemasList.Nodes[0].GetNodeCount(true) > 0) { SchemasList.Nodes[0].Expand(); } // Avoids flickering of schemas list while adding the items to it. SchemasList.EndUpdate(); return(true); } catch (Exception ex) { MiscUtilities.ShowCustomizedErrorDialog(Resources.SchemasLoadingErrorTitle, ex.Message, true); MySqlSourceTrace.WriteAppErrorToLog(ex); return(false); } }
/// <summary> /// Fetches all schema names from the current connection and loads them in the <see cref="SchemasList"/> tree. /// </summary> /// <returns><c>true</c> if schemas were loaded successfully, <c>false</c> otherwise.</returns> private bool LoadSchemas() { if (SchemasList.HeaderNodes.Count < 2) { return(false); } Cursor = Cursors.WaitCursor; try { // Avoids flickering of schemas list while adding the items to it. SchemasList.BeginUpdate(); LoadedSchemas.ForEach(schema => schema.Dispose()); LoadedSchemas.Clear(); foreach (TreeNode node in SchemasList.Nodes) { node.Nodes.Clear(); } var databases = _wbConnection.GetSchemaInformation(SchemaInformationType.Databases, false, null); foreach (DataRow row in databases.Rows) { var schemaName = row["DATABASE_NAME"].ToString(); // If the user has specified a filter then check it if (!string.IsNullOrEmpty(_filter) && !schemaName.ToUpper().Contains(_filter)) { continue; } // Create the DbSchema and MySqlListViewNode objects var schemaObject = new DbSchema(_wbConnection, schemaName, row["DEFAULT_CHARACTER_SET_NAME"].ToString(), row["DEFAULT_COLLATION_NAME"].ToString(), DisplaySchemaCollationsToolStripMenuItem.Checked); var lcSchemaName = schemaName.ToLowerInvariant(); var headerNode = SchemasList.HeaderNodes[MySqlWorkbenchConnection.SystemSchemaNames.Contains(lcSchemaName) ? 1 : 0]; LoadedSchemas.Add(schemaObject); var node = SchemasList.AddDbObjectNode(headerNode, schemaObject); node.ImageIndex = DisplaySchemaCollationsToolStripMenuItem.Checked ? 1 : 0; } if (SchemasList.Nodes[0].GetNodeCount(true) > 0) { SchemasList.Nodes[0].Expand(); } // Avoids flickering of schemas list while adding the items to it. SchemasList.EndUpdate(); return(true); } catch (Exception ex) { Logger.LogException(ex, true, Resources.SchemasLoadingErrorTitle); return(false); } finally { Cursor = Cursors.Default; } }