/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> if managed resources should be disposed; otherwise, <c>false</c>.</param> protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } if (LoadedTables != null) { LoadedTables.ForEach(dbo => dbo.Dispose()); LoadedTables.Clear(); } if (LoadedViews != null) { LoadedViews.ForEach(dbo => dbo.Dispose()); LoadedViews.Clear(); } if (LoadedProcedures != null) { LoadedProcedures.ForEach(dbo => dbo.Dispose()); LoadedProcedures.Clear(); } _wbConnection = null; } base.Dispose(disposing); }
/// <summary> /// Fetches all MySQL table names of the given type from the current connection and loads them in the <see cref="LoadedProcedures"/> list. /// </summary> private void LoadTables() { var tablesTable = _wbConnection.GetSchemaCollection("Tables", null, _wbConnection.Schema); if (tablesTable == null) { return; } LoadedTables.ForEach(dbo => dbo.Dispose()); LoadedTables.Clear(); LoadedTables.AddRange(tablesTable.Rows.Cast <DataRow>().Select(dataRow => dataRow["TABLE_NAME"].ToString()).Select(tableName => new DbTable(_wbConnection, tableName))); }
/// <summary> /// Refreshes the DB objects list control with current objects in the connected schema. /// </summary> /// <param name="reloadFromServer">Flag indicating whether DB objects must be reloaded from the connected MySQL server.</param> private bool RefreshDbObjectsList(bool reloadFromServer) { if (DBObjectList.HeaderNodes.Count < 3) { return(false); } bool success = true; try { // Avoids flickering of DB Objects lists while adding the items to it. DBObjectList.BeginUpdate(); DBObjectList.ClearChildNodes(); if (reloadFromServer) { LoadTables(); LoadViews(); LoadProcedures(); } // Refresh Tables foreach (var dbTable in LoadedTables.Where(table => string.IsNullOrEmpty(Filter) || table.Name.ToUpper().Contains(Filter))) { var node = DBObjectList.AddDbObjectNode(DBObjectList.HeaderNodes[0], dbTable); dbTable.Selected = false; node.ImageIndex = 0; } // Refresh Views foreach (var dbView in LoadedViews.Where(view => string.IsNullOrEmpty(Filter) || view.Name.ToUpper().Contains(Filter))) { var node = DBObjectList.AddDbObjectNode(DBObjectList.HeaderNodes[1], dbView); dbView.Selected = false; node.ImageIndex = 1; } // Refresh Procedures foreach (var dbProcedure in LoadedProcedures.Where(procedure => string.IsNullOrEmpty(Filter) || procedure.Name.ToUpper().Contains(Filter))) { var node = DBObjectList.AddDbObjectNode(DBObjectList.HeaderNodes[2], dbProcedure); dbProcedure.Selected = false; node.ImageIndex = 2; } DBObjectList.ExpandAll(); DBObjectList.Nodes[0].EnsureVisible(); // Avoids flickering of DB Objects lists while adding the items to it. DBObjectList.EndUpdate(); DBObjectList_AfterSelect(null, null); } catch (Exception ex) { success = false; MiscUtilities.ShowCustomizedErrorDialog(Resources.RefreshDBObjectsErrorTitle, ex.Message, true); MySqlSourceTrace.WriteAppErrorToLog(ex); } return(success); }