public void BuildDatabaseTree() { Dictionary <string, DatabaseInfo> databaseList = new Dictionary <string, DatabaseInfo>(); try { Refresh.IsEnabled = false; _fatalError = string.Empty; this.txtConnections.Text = "Data Connections"; this.txtHelp.Foreground = Helpers.VSThemes.GetWindowText(); txtConnections.Focus(); ItemDatabases.ContextMenu = new DatabasesContextMenu(new DatabaseMenuCommandParameters { ExplorerControl = this }, _parentWindow); ItemDatabases.Foreground = Helpers.VSThemes.GetWindowText(); ItemDatabases.ToolTip = "Right click to Manage Connections (and many other features)"; ItemDatabases.Items.Clear(); ItemDatabases.IsExpanded = true; var package = _parentWindow.Package as SqlCeToolboxPackage; if (package == null) { return; } if (!DataConnectionHelper.IsV35Installed() && !DataConnectionHelper.IsV40Installed()) { RuntimeMissing.Visibility = System.Windows.Visibility.Visible; } ItemDatabases.Items.Add("Loading..."); if (Properties.Settings.Default.ValidateConnectionsOnStart) { try { new DataConnectionHelper().ValidateConnections(package); } catch { } } databaseList = DataConnectionHelper.GetDataConnections(package, true, false); foreach (KeyValuePair <string, DatabaseInfo> info in DataConnectionHelper.GetOwnDataConnections()) { if (!databaseList.ContainsKey(info.Key)) { databaseList.Add(info.Key, info.Value); } } } catch (Exception e) { //Helpers.DataConnectionHelper.SendError(e, DatabaseType.SQLServer); _fatalError = e.Message; } finally { var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread Refresh.IsEnabled = true; } }
private void BuildDatabaseTree(bool fromUiThread) { var databaseList = new Dictionary <string, DatabaseInfo>(); _fatalError = string.Empty; try { var package = _parentWindow.Package as SqlCeToolboxPackage; if (package == null) { return; } if (Properties.Settings.Default.ValidateConnectionsOnStart) { try { new DataConnectionHelper().ValidateConnections(package); } catch { // ignored } } databaseList = DataConnectionHelper.GetDataConnections(package, true, false); foreach (var info in DataConnectionHelper.GetOwnDataConnections()) { if (!databaseList.ContainsKey(info.Key)) { databaseList.Add(info.Key, info.Value); } } //Boot Telemetry var dte = (DTE2)package.GetServiceHelper(typeof(DTE)); Telemetry.Enabled = Properties.Settings.Default.ParticipateInTelemetry; if (Telemetry.Enabled) { Telemetry.Initialize(dte, Assembly.GetExecutingAssembly().GetName().Version.ToString(), SqlCeToolboxPackage.VisualStudioVersion.ToString(), "d4881a82-2247-42c9-9272-f7bc8aa29315"); } DataConnectionHelper.LogUsage("Platform: Visual Studio " + SqlCeToolboxPackage.VisualStudioVersion.ToString(1)); } catch (Exception e) { _fatalError = e.Message; } finally { if (fromUiThread) { PrepareTreeView("Data Connections"); Refresh.IsEnabled = true; } var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread } }
public void BuildDatabaseTree() { SortedDictionary <string, string> databaseList = new SortedDictionary <string, string>(); try { Refresh.IsEnabled = false; this.txtConnections.Text = "SQL Server Compact Data Connections"; ItemDatabases.ContextMenu = new DatabasesContextMenu(new DatabasesMenuCommandParameters { ExplorerControl = this, DatabasesTreeViewItem = ItemDatabases }, this); ItemDatabases.Items.Clear(); ItemDatabases.IsExpanded = true; if (!DataConnectionHelper.IsRuntimeInstalled()) { var errorItem = new TreeViewItem(); errorItem.Header = string.Format("The SQL Server Compact {0}\r\nprovider could not be found,\r\ninstall or repair SQL Server Compact {1}", RepoHelper.apiVer, RepoHelper.apiVer); errorItem.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Yellow); ItemDatabases.Items.Add(errorItem); return; } ItemDatabases.Items.Add("Loading..."); ItemDatabases.IsExpanded = true; databaseList = DataConnectionHelper.GetDataConnections(); if (databaseList.Count == 0) { this.txtConnections.Text = "No SQL Server Compact Data Connections found,\r\n select Add from the context menu to add one."; } } catch (Exception e) { MessageBox.Show("Error getting list of databases from Data Connections, make sure to create one. " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } finally { var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread Refresh.IsEnabled = true; } FocusSelectedItem(); }
private void BuildDatabaseTree(bool fromUiThread) { var databaseList = new Dictionary <string, DatabaseInfo>(); _fatalError = string.Empty; try { var package = _parentWindow.Package as SqlCeToolboxPackage; if (package == null) { return; } if (Properties.Settings.Default.ValidateConnectionsOnStart) { try { new DataConnectionHelper().ValidateConnections(package); } catch { // ignored } } databaseList = DataConnectionHelper.GetDataConnections(package, true, false); foreach (var info in DataConnectionHelper.GetOwnDataConnections()) { if (!databaseList.ContainsKey(info.Key)) { databaseList.Add(info.Key, info.Value); } } } catch (Exception e) { _fatalError = e.Message; } finally { if (fromUiThread) { PrepareTreeView("Data Connections"); Refresh.IsEnabled = true; } var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread } }
public void BuildDatabaseTree() { SortedDictionary<string, string> databaseList = new SortedDictionary<string, string>(); try { Refresh.IsEnabled = false; this.txtConnections.Text = "SQL Server Compact Data Connections"; ItemDatabases.ContextMenu = new DatabasesContextMenu(new DatabasesMenuCommandParameters { ExplorerControl = this, DatabasesTreeViewItem = ItemDatabases }, this); ItemDatabases.Items.Clear(); ItemDatabases.IsExpanded = true; if (!DataConnectionHelper.IsRuntimeInstalled()) { var errorItem = new TreeViewItem(); errorItem.Header = string.Format("The SQL Server Compact {0}\r\nprovider could not be found,\r\ninstall or repair SQL Server Compact {1}", RepoHelper.apiVer, RepoHelper.apiVer); errorItem.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Yellow); ItemDatabases.Items.Add(errorItem); return; } ItemDatabases.Items.Add("Loading..."); ItemDatabases.IsExpanded = true; databaseList = DataConnectionHelper.GetDataConnections(); if (databaseList.Count == 0) { this.txtConnections.Text = "No SQL Server Compact Data Connections found,\r\n select Add from the context menu to add one."; } } catch (Exception e) { MessageBox.Show("Error getting list of databases from Data Connections, make sure to create one. " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } finally { var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread Refresh.IsEnabled = true; } FocusSelectedItem(); }
public void BuildDatabaseTree() { Dictionary<string, DatabaseInfo> databaseList = new Dictionary<string, DatabaseInfo>(); try { Refresh.IsEnabled = false; _fatalError = string.Empty; this.txtConnections.Text = "Data Connections"; this.txtHelp.Foreground = Helpers.VSThemes.GetWindowText(); txtConnections.Focus(); ItemDatabases.ContextMenu = new DatabasesContextMenu(new DatabaseMenuCommandParameters { ExplorerControl = this }, _parentWindow); ItemDatabases.Foreground = Helpers.VSThemes.GetWindowText(); ItemDatabases.ToolTip = "Right click to Manage Connections (and many other features)"; ItemDatabases.Items.Clear(); ItemDatabases.IsExpanded = true; var package = _parentWindow.Package as SqlCeToolboxPackage; if (package == null) return; if (!DataConnectionHelper.IsV35Installed() && !DataConnectionHelper.IsV40Installed()) { RuntimeMissing.Visibility = System.Windows.Visibility.Visible; } ItemDatabases.Items.Add("Loading..."); if (Properties.Settings.Default.ValidateConnectionsOnStart) { try { new DataConnectionHelper().ValidateConnections(package); } catch { } } databaseList = DataConnectionHelper.GetDataConnections(package, true, false); foreach (KeyValuePair<string, DatabaseInfo> info in DataConnectionHelper.GetOwnDataConnections()) { if (!databaseList.ContainsKey(info.Key)) databaseList.Add(info.Key, info.Value); } } catch (Exception e) { //Helpers.DataConnectionHelper.SendError(e, DatabaseType.SQLServer); _fatalError = e.Message; } finally { var fillList = new FillDatabaseListHandler(FillDatabaseList); Dispatcher.BeginInvoke(fillList, databaseList); //fill the tree on the UI thread Refresh.IsEnabled = true; } }