private void FillTableItems(KeyValuePair<string, DatabaseInfo> database, DatabaseTreeViewItem parentItem, Exception ex, RoutedEventArgs args) { if (ex != null) { string error = Helpers.DataConnectionHelper.CreateEngineHelper(database.Value.DatabaseType).FormatError(ex); if (error.Contains("Minor Err.: 25028")) { PasswordDialog pwd = new PasswordDialog(); pwd.ShowModal(); if (pwd.DialogResult.HasValue && pwd.DialogResult.Value == true && !string.IsNullOrWhiteSpace(pwd.Password)) { database.Value.ConnectionString = database.Value.ConnectionString + ";Password="******"locale identifier") dbInfo.LCID = int.Parse(values.Value); if (values.Key.ToLowerInvariant() == "encryption mode") dbInfo.EncryptionMode = values.Value; if (string.IsNullOrWhiteSpace(dbInfo.EncryptionMode)) dbInfo.EncryptionMode = "None"; if (values.Key.ToLowerInvariant() == "case sensitive") dbInfo.CaseSensitive = bool.Parse(values.Value); if (values.Key == "DatabaseSize") dbInfo.Size = values.Value; if (values.Key == "SpaceAvailable") dbInfo.SpaceAvailable = values.Value; if (values.Key == "Created") dbInfo.Created = values.Value; if (values.Key == "ServerVersion") dbInfo.ServerVersion = values.Value; } TrackSelection(dbInfo); } } var tables = _repository.GetAllTableNames(); var columns = _repository.GetAllColumns(); var primaryKeys = _repository.GetAllPrimaryKeys(); var foreignKeys = _repository.GetAllForeignKeys(); var indexes = _repository.GetAllIndexes(); foreach (var table in tables) { if (!Properties.Settings.Default.DisplayDescriptionTable && table.Equals("__ExtendedProperties")) { continue; } var item = TreeViewHelper.CreateTreeViewItemWithImage(table, "../Resources/table_16xLG.png", true); item.ContextMenu = new TableContextMenu(new MenuCommandParameters { DatabaseInfo = database.Value, Name = table, MenuItemType = MenuType.Table }, _parentWindow); item.ToolTip = table; item.Tag = new TableInfo { Name = table, RowCount = _repository.GetRowCount(table) }; if (DescriptionCache != null) { var desc = DescriptionCache.Where(dc => dc.Parent == null && dc.Object == table).Select(dc => dc.Description).SingleOrDefault(); if (!string.IsNullOrWhiteSpace(desc)) { item.ToolTip = desc; } } var tableColumns = (from col in columns where col.TableName == table select col).ToList<Column>(); var tablePrimaryKeys = primaryKeys.Where(pk => pk.TableName == table).ToList(); var tableForeignKeys = foreignKeys.Where(fk => fk.ConstraintTableName == table).ToList(); var tableIndexes = indexes.Where(i => i.TableName == table).ToList(); parentItem.Items.Add(item); item.Expanded += (s, e) => GetTableColumns(s, e, tableColumns, tableForeignKeys, tablePrimaryKeys, tableIndexes, database); } } } catch (Exception ex2) { Helpers.DataConnectionHelper.SendError(ex2, database.Value.DatabaseType, false); } }
public void SetPassword(object sender, ExecutedRoutedEventArgs e) { var databaseInfo = ValidateMenuInfo(sender); if (databaseInfo == null) return; try { var dbInfo = databaseInfo.DatabaseInfo; var pwd = new PasswordDialog(); pwd.ShowModal(); if (pwd.DialogResult.HasValue && pwd.DialogResult.Value) { var helper = DataConnectionHelper.CreateEngineHelper(databaseInfo.DatabaseInfo.DatabaseType); var newConnectionString = helper.ChangeDatabasePassword(databaseInfo.DatabaseInfo.ConnectionString, pwd.Password); if (dbInfo.FromServerExplorer) { var providerId = Resources.SqlCompact35Provider; if (dbInfo.DatabaseType == DatabaseType.SQLCE40) providerId = Resources.SqlCompact40Provider; DataConnectionHelper.RemoveDataConnection(package, dbInfo.ConnectionString, new Guid(providerId)); } else { DataConnectionHelper.RemoveDataConnection(databaseInfo.DatabaseInfo.ConnectionString); } if (!string.IsNullOrEmpty(newConnectionString)) { DataConnectionHelper.SaveDataConnection(newConnectionString, dbInfo.DatabaseType, package); EnvDTEHelper.ShowMessage("Password was set, and connection updated"); } else { EnvDTEHelper.ShowMessage("Password was set, but could not update connection, please reconnect the database"); } var control = _parentWindow.Content as ExplorerControl; if (control != null) control.BuildDatabaseTree(); DataConnectionHelper.LogUsage("DatabaseMaintainSetPassword"); } } catch (Exception ex) { DataConnectionHelper.SendError(ex, databaseInfo.DatabaseInfo.DatabaseType, false); } }