public int OnClose(ref uint pgrfSaveOptions) { if (!Properties.Settings.Default.PromptToSaveChangedScript) { return(Microsoft.VisualStudio.VSConstants.S_OK); } // Check if your content is dirty here, then var window = this.control as SqlEditorControl; if (window != null && window.IsDirty && !mustClose) { // Prompt a dialog DialogResult res = EnvDTEHelper.ShowMessageBox("This script has been modified. Do you want to save the changes ?", OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_QUERY); // If the users wants to save if (res == DialogResult.Yes) { window.SaveScript(true); } if (res == DialogResult.Cancel) { // If "cancel" is clicked, abort the close return(Microsoft.VisualStudio.VSConstants.E_ABORT); } if (res == DialogResult.No) { mustClose = true; } } return(Microsoft.VisualStudio.VSConstants.S_OK); }
public void DropScope(object sender, ExecutedRoutedEventArgs e) { if (EnvDTEHelper.ShowMessageBox("Do you really want to deprovision this scope?", Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_YESNO, Microsoft.VisualStudio.Shell.Interop.OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_WARNING) == System.Windows.Forms.DialogResult.No) { return; } var menuItem = sender as MenuItem; if (menuItem == null) { return; } var menuInfo = menuItem.CommandParameter as MenuCommandParameters; if (menuInfo == null) { return; } try { SyncFxHelper.DeprovisionSqlCeScope(menuInfo.DatabaseInfo.ConnectionString, menuInfo.Name); EnvDTEHelper.ShowMessage("Scope deprovisioned"); if (_parentWindow != null && _parentWindow.Content != null) { ExplorerControl control = _parentWindow.Content as ExplorerControl; control.BuildDatabaseTree(); } Helpers.DataConnectionHelper.LogUsage("SyncScopeDrop"); } catch (Exception ex) { Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType); } }
public void DropSubscription(object sender, ExecutedRoutedEventArgs e) { if (EnvDTEHelper.ShowMessageBox("Do you really want to remove replication metadata from the SQL Server Compact database?", Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_YESNO, Microsoft.VisualStudio.Shell.Interop.OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_WARNING) == System.Windows.Forms.DialogResult.No) { return; } var menuItem = sender as MenuItem; if (menuItem == null) { return; } var menuInfo = menuItem.CommandParameter as MenuCommandParameters; if (menuInfo == null) { return; } try { SqlCeReplicationHelper.DropPublication(menuInfo.DatabaseInfo.ConnectionString, menuInfo.Name); if (_parentWindow != null && _parentWindow.Content != null) { ExplorerControl control = _parentWindow.Content as ExplorerControl; control.BuildDatabaseTree(); } Helpers.DataConnectionHelper.LogUsage("SubscriptionDrop"); } catch (Exception ex) { Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false); } }
private bool TestConnection(bool showMessage) { try { if (_createDb) { if (!System.IO.File.Exists(dataSourceTextBox.Text)) { var engineHelper = DataConnectionHelper.CreateEngineHelper(DbType); engineHelper.CreateDatabase(_connectionString); } } using (DataConnectionHelper.CreateRepository(new DatabaseInfo { ConnectionString = _connectionString, DatabaseType = DbType })) { if (showMessage) { EnvDTEHelper.ShowMessage("Connection OK!"); } else { DialogResult = true; } } return(true); } catch (Exception ex) { if (ex.Message.Contains("Please upgrade using SqlCeEngine.Upgrade() method") && DbType == DatabaseType.SQLCE40) { if (EnvDTEHelper.ShowMessageBox("This database file is from an earlier version,\n\rwould you like to Upgrade it?\n\r(A copy of the original file will be named .bak)" , Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_YESNO , Microsoft.VisualStudio.Shell.Interop.OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND , Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_WARNING) == System.Windows.Forms.DialogResult.Yes) { var bakFile = dataSourceTextBox.Text + ".bak"; var go = true; try { if (System.IO.File.Exists(bakFile)) { if (EnvDTEHelper.ShowMessageBox(string.Format("{0} already exists, do you wish to overwrite it?", bakFile) , Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_YESNO , Microsoft.VisualStudio.Shell.Interop.OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND , Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_WARNING) == System.Windows.Forms.DialogResult.Yes) { System.IO.File.Delete(bakFile); } else { go = false; } } if (go) { System.IO.File.Copy(dataSourceTextBox.Text, dataSourceTextBox.Text + ".bak"); var helper = new SqlCeScripting.SqlCeHelper4(); helper.UpgradeTo40(_connectionString); DialogResult = true; } } catch (Exception ex2) { DataConnectionHelper.SendError(ex2, DbType, false); return(false); } } } else { DataConnectionHelper.SendError(ex, DbType, false); return(false); } } return(true); }