private void AddNodesForServer(ServerDefinition server) { var serverNode = new DatabaseTreeNode { ServerDefinition = server, IsServerNode = true }; try { var databases = QueryRunner.GetDatabasesForServer(server); var nodes = new List <TreeViewModel <DatabaseTreeNode> >(); foreach (var db in databases.OrderBy(db => db.DatabaseName)) { if (Settings.HideSystemDatabases && systemDatabases.Contains(db.DatabaseName)) { continue; } var dbNode = new DatabaseTreeNode { IsServerNode = false, DatabaseDefinition = db, }; var dbNodeViewModel = new TreeViewModel <DatabaseTreeNode>(db.DatabaseName, dbNode); dbNodeViewModel.IsChecked = server.SelectedDatabases.Contains(db.DatabaseName); nodes.Add(dbNodeViewModel); } var serverNodeViewModel = new TreeViewModel <DatabaseTreeNode>($"{server.DisplayName} ({nodes.Count})", serverNode); serverNodeViewModel.Children.AddRange(nodes); serverNodeViewModel.IsExpanded = false; nodes.ForEach(node => node.InitParent(serverNodeViewModel)); databaseTreeModel.Add(serverNodeViewModel); } catch (Exception) { var serverNodeViewModel = new TreeViewModel <DatabaseTreeNode>(server.DisplayName + " (Connection Failed)", serverNode); databaseTreeModel.Add(serverNodeViewModel); } }
private void AddNodesForServer(ServerDefinition server) { var serverNode = new DatabaseTreeNode { ServerDefinition = server, IsServerNode = true }; try { var databases = QueryRunner.GetDatabasesForServer(server); var serverNodeViewModel = new TreeViewModel <DatabaseTreeNode>(server.DisplayName, serverNode); databaseTreeModel.Add(serverNodeViewModel); foreach (var db in databases) { if (Settings.Default.HideSystemDatabases && systemDatabases.Contains(db.DatabaseName)) { continue; } var dbNode = new DatabaseTreeNode { IsServerNode = false, DatabaseDefinition = db }; var dbNodeViewModel = new TreeViewModel <DatabaseTreeNode>(db.DatabaseName, dbNode); serverNodeViewModel.Children.Add(dbNodeViewModel); } } catch (Exception) { var serverNodeViewModel = new TreeViewModel <DatabaseTreeNode>(server.DisplayName + " (Connection Failed)", serverNode); databaseTreeModel.Add(serverNodeViewModel); } DatabasesTreeView.Items.Refresh(); }
private void RunQuery() { var query = QueryTextBox.Text; var databases = GetSelectedDatabases().ToList(); var timer = Stopwatch.StartNew(); var result = QueryRunner.BulkQuery(databases, query).Result; Debug.WriteLine("Total query time: " + timer.ElapsedMilliseconds); if (result.Messages.Count > 0) { TextBoxMessages.Text = string.Join(Environment.NewLine, result.Messages); TextBoxMessages.Visibility = Visibility.Visible; } else { TextBoxMessages.Text = string.Empty; TextBoxMessages.Visibility = Visibility.Collapsed; } if (result.ResultTable != null) { ResultDataGrid.ItemsSource = result.ResultTable.DefaultView; } }