public void RenameConnection(object sender, ExecutedRoutedEventArgs e) { var databaseInfo = ValidateMenuInfo(sender); if (databaseInfo == null) { return; } if (databaseInfo.DatabaseInfo.FromServerExplorer) { return; } try { var ro = new RenameDialog(databaseInfo.DatabaseInfo.Caption); ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value && !string.IsNullOrWhiteSpace(ro.NewName) && !databaseInfo.DatabaseInfo.Caption.Equals(ro.NewName)) { DataConnectionHelper.RenameDataConnection(databaseInfo.DatabaseInfo.ConnectionString, ro.NewName); var control = _parentWindow.Content as ExplorerControl; if (control != null) { control.BuildDatabaseTree(); } DataConnectionHelper.LogUsage("DatabaseRenameConnection"); } } catch (Exception ex) { DataConnectionHelper.SendError(ex, databaseInfo.DatabaseInfo.DatabaseType); } }
public void Rename(object sender, ExecutedRoutedEventArgs e) { var menuInfo = ValidateMenuInfo(sender); if (menuInfo == null) { return; } try { using (IRepository repository = Helpers.DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo)) { RenameDialog ro = new RenameDialog(menuInfo.Name); ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !menuInfo.Name.Equals(ro.NewName)) { repository.RenameTable(menuInfo.Name, ro.NewName); if (ParentWindow != null && ParentWindow.Content != null) { ExplorerControl control = ParentWindow.Content as ExplorerControl; control.RefreshTables(menuInfo.DatabaseInfo); } Helpers.DataConnectionHelper.LogUsage("TableRename"); } } } catch (Exception ex) { Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false); } }
public void RenameNode(object sender, ExecutedRoutedEventArgs e) { var menuInfo = ValidateMenuInfo(sender); if (menuInfo == null) { return; } try { var ro = new RenameDialog(menuInfo.Name); ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !menuInfo.Name.Equals(ro.NewName)) { UmbracoApplicationContext.Current.Rename(menuInfo.NodeType, ro.NewName, menuInfo.NodeId); if (_parentWindow != null && _parentWindow.Content != null) { var control = _parentWindow.Content as ExplorerControl; control.RefreshItems(menuInfo.NodeType, menuInfo.NodeTypeName, ro.NewName); } } } catch (Exception ex) { MessageBox.Show("An error occured: " + ex.Message); } }
protected override void OnExecuted(EventArgs e) { base.OnExecuted(e); var file = main.FileList.SelectedFile; if (file != null && File.Exists(file.FullName)) { var dialog = new RenameDialog(file.FullName); var result = dialog.ShowModal(main); if (result == DialogResult.Ok) { File.Move(file.FullName, dialog.NewName); main.FileList.UpdateDirectory(); } } var dir = main.FileList.SelectedDirectory; if (dir != null) { var dialog = new RenameDialog(dir.FullName); var result = dialog.ShowModal(null); if (result == DialogResult.Ok) { if (Directory.Exists(dir.FullName)) { Directory.Move(dir.FullName, dialog.NewName); } else if (File.Exists(dir.FullName)) { File.Move(dir.FullName, dialog.NewName); } main.FileList.UpdateDirectory(); } } }