public void DragDrop_CopyDatabase(AppObject draggingObject) { var conn = this.FindServerConnection(); if (draggingObject is DatabaseAppObject) { try { IDatabaseSource dsource = ((DatabaseAppObject)draggingObject).FindDatabaseConnection(); var dbprops = new DatabaseProperties(); dbprops.Name = dsource.DatabaseName; DatabasePropertiesForm.Run(dbprops, new GenericDatabaseSource(conn, conn.Connection, null), false); //string newname = InputBox.Run(Texts.Get("s_name_of_new_database"), dsource.DatabaseName); //if (newname == null) return; if (ArrayTool.Contains(conn.Databases, dbprops.Name)) { StdDialog.ShowError(Texts.Get("s_database_allready_exists")); return; } IDatabaseSource newdb = conn.CreateDatabase(dbprops.Name, dbprops.SpecificData); CopyDbWizard.Run(dsource.CloneSource(), newdb.CloneSource()); //CopyDbProcess.StartProcess(dsource.CloneSource(), newdb.CloneSource(), null); } catch (Exception e) { Errors.Report(e); } } }
public void AlterDatabase() { var dbconn = this.FindDatabaseConnection(ConnPack); if (!AlterDatabaseVisible() || dbconn == null) { return; } var dbmem = new DatabaseStructureMembers(); dbmem.DatabaseOptions = true; var m_db = dbconn.InvokeLoadStructure(dbmem, null); var props = new DatabaseProperties { Name = dbconn.DatabaseName, SpecificData = m_db.SpecificData, }; if (DatabasePropertiesForm.Run(props, dbconn, true)) { var plan = new AlterPlan(); var opts = new DbDiffOptions(); plan.ChangeDatabaseOptions(dbconn.DatabaseName, props.SpecificData); plan.Transform(dbconn.Dialect.DumperCaps, opts, dbconn); string alterSql = dbconn.Dialect.GenerateScript(dmp => plan.CreateRunner().Run(dmp, opts)); if (SqlConfirmForm.Run(alterSql)) { dbconn.AlterDatabase(plan, opts); } } }
public DatabasePropertiesForm(DatabaseProperties props, IDatabaseSource conn, bool readOnlyName) { InitializeComponent(); m_props = props; DatabaseStructure dbs = new DatabaseStructure(); dbs.SpecificData.AddAll(props.SpecificData); if (conn.Dialect != null) { m_editor = conn.Dialect.GetSpecificEditor(dbs, conn); } propertyFrame1.SelectedObject = m_editor; tbxName.ReadOnly = readOnlyName; tbxName.Text = props.Name; }
public void MenuCreateDatabase() { var dbprops = new DatabaseProperties(); dbprops.Name = "newdb"; if (DatabasePropertiesForm.Run(dbprops, new GenericDatabaseSource(m_conn, m_conn.Connection, null), false)) { if (ArrayTool.Contains(m_conn.Databases, dbprops.Name)) { StdDialog.ShowError(Texts.Get("s_database_allready_exists")); return; } InvokeScript(fmt => { fmt.CreateDatabase(dbprops.Name, dbprops.SpecificData); }); TreeNodeExtension.CompleteRefresh(this); } }
public override void CreateNew(AppObject appobj, ConnectionPack connpack) { var dbprops = new DatabaseProperties(); dbprops.Name = "newdb"; var server = appobj.FindServerConnection(connpack); if (server == null || server.Connection == null) { return; } if (DatabasePropertiesForm.Run(dbprops, new GenericDatabaseSource(server, server.Connection, null), false)) { if (ArrayTool.Contains(server.Databases, dbprops.Name)) { StdDialog.ShowError(Texts.Get("s_database_allready_exists")); return; } server.Connection.InvokeScript(fmt => { fmt.CreateDatabase(dbprops.Name, dbprops.SpecificData); }, null); appobj.CallCompleteChanged(); } }
public static bool Run(DatabaseProperties props, IDatabaseSource conn, bool readOnlyName) { var win = new DatabasePropertiesForm(props, conn, readOnlyName); return(win.ShowDialogEx() == DialogResult.OK); }