public void AddCeDatabase(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                string connectionString = string.Empty;
#if V35
                var dialog = new Connection35Dialog();
#else
                var dialog = new ConnectionDialog();
#endif
                dialog.Owner = Application.Current.MainWindow;
                bool?result = dialog.ShowDialog();
                if (result.HasValue && result.Value == true)
                {
                    if (!string.IsNullOrWhiteSpace(dialog.ConnectionString))
                    {
                        Helpers.DataConnectionHelper.SaveDataConnection(dialog.ConnectionString);
                        _parentWindow.BuildDatabaseTree();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex));
            }
        }
예제 #2
0
        public void AddCe35Database(object sender, ExecutedRoutedEventArgs e)
        {
            // http://www.mztools.com/articles/2007/MZ2007011.aspx
            if (!Helpers.DataConnectionHelper.DDEXProviderIsInstalled(new Guid(Resources.SqlCompact35Provider)))
            {
                EnvDTEHelper.ShowError("The version 3.5 Visual Studio DDEX provider is not installed, cannot add connection");
                return;
            }
            try
            {
                var objIVsDataConnectionDialogFactory = package.GetServiceHelper(typeof(IVsDataConnectionDialogFactory)) as IVsDataConnectionDialogFactory;
                var objIVsDataConnectionDialog        = objIVsDataConnectionDialogFactory.CreateConnectionDialog();
                objIVsDataConnectionDialog.AddAllSources();
                objIVsDataConnectionDialog.SelectedSource   = new Guid("130BADA6-E128-423c-9D07-02E4734D45D4");
                objIVsDataConnectionDialog.SelectedProvider = new Guid(Resources.SqlCompact35Provider);

                if (objIVsDataConnectionDialog.ShowDialog() && objIVsDataConnectionDialog.SelectedProvider == new Guid(Resources.SqlCompact35Provider))
                {
                    Helpers.DataConnectionHelper.SaveDataConnection(package, objIVsDataConnectionDialog.EncryptedConnectionString, objIVsDataConnectionDialog.DisplayConnectionString, DatabaseType.SQLCE35, new Guid(Resources.SqlCompact35Provider));
                    ExplorerControl control = _parentWindow.Content as ExplorerControl;
                    control.BuildDatabaseTree();
                    Helpers.DataConnectionHelper.LogUsage("DatabasesAddCe35Database");
                }
                objIVsDataConnectionDialog.Dispose();
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, DatabaseType.SQLCE35);
            }
        }
예제 #3
0
 private void AddCeDatabase(DatabaseType dbType)
 {
     try
     {
         var    dialog = new ConnectionDialog();
         string path;
         if (TryGetInitialPath(package, out path))
         {
             dialog.InitialPath = path;
         }
         dialog.DbType       = dbType;
         dialog.ShowDdexInfo = package.VSSupportsSimpleDDEX4Provider() || package.VSSupportsSimpleDDEX35Provider();
         dialog.CouldSupportPrivateProvider =
             (dbType == DatabaseType.SQLCE40 && (SqlCeToolboxPackage.VisualStudioVersion == new Version(12, 0) || SqlCeToolboxPackage.VisualStudioVersion == new Version(14, 0))) ||
             (dbType == DatabaseType.SQLCE35 && package.VSSupportsEF6());
         bool?result = dialog.ShowModal();
         if (result.HasValue && result.Value == true)
         {
             if (!string.IsNullOrWhiteSpace(dialog.ConnectionString))
             {
                 Helpers.DataConnectionHelper.SaveDataConnection(dialog.ConnectionString, dbType, package);
                 ExplorerControl control = _parentWindow.Content as ExplorerControl;
                 control.BuildDatabaseTree();
                 Helpers.DataConnectionHelper.LogUsage("DatabasesAddCeDatabase");
             }
         }
     }
     catch (Exception ex)
     {
         Helpers.DataConnectionHelper.SendError(ex, dbType);
     }
 }
예제 #4
0
 public void AddSQLiteDatabase(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         var    dialog = new SQLiteConnectionDialog();
         string path;
         if (TryGetInitialPath(package, out path))
         {
             dialog.InitialPath = path;
         }
         bool?result = dialog.ShowModal();
         if (result.HasValue && result.Value == true)
         {
             if (!string.IsNullOrWhiteSpace(dialog.ConnectionString))
             {
                 Helpers.DataConnectionHelper.SaveDataConnection(dialog.ConnectionString, DatabaseType.SQLite, package);
                 ExplorerControl control = _parentWindow.Content as ExplorerControl;
                 control.BuildDatabaseTree();
                 Helpers.DataConnectionHelper.LogUsage("DatabasesAddSQLiteDatabase");
             }
         }
     }
     catch (Exception ex)
     {
         Helpers.DataConnectionHelper.SendError(ex, DatabaseType.SQLite);
     }
 }
예제 #5
0
        public void Rename(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);

            if (menuInfo != null)
            {
                try
                {
                    using (IRepository repository = RepoHelper.CreateRepository(menuInfo.Connectionstring))
                    {
                        RenameDialog ro = new RenameDialog(menuInfo.Name);
                        ro.Owner = Application.Current.MainWindow;
                        ro.ShowDialog();
                        if (ro.DialogResult.HasValue && ro.DialogResult.Value && !string.IsNullOrWhiteSpace(ro.NewName))
                        {
                            repository.RenameTable(menuInfo.Name, ro.NewName);
                            if (_parent != null)
                            {
                                _parent.BuildDatabaseTree();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(DataConnectionHelper.ShowErrors(ex));
                }
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
        public void DropSubscription(object sender, ExecutedRoutedEventArgs e)
        {
            if (MessageBox.Show("Do you really want to remove replication metadata from the SQL Server Compact database?", "SQL Server Compact Toolbox", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) == MessageBoxResult.No)
            {
                return;
            }

            var menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                var menuInfo = menuItem.CommandParameter as MenuCommandParameters;

                if (menuInfo != null)
                {
                    try
                    {
                        SqlCeReplicationHelper.DropPublication(menuInfo.Connectionstring, menuInfo.Name);
                        if (_parent != null)
                        {
                            _parent.BuildDatabaseTree();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex));
                    }
                }
            }
        }
예제 #9
0
 public void FixConnections(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         new DataConnectionHelper().ValidateConnections(package);
         ExplorerControl control = _parentWindow.Content as ExplorerControl;
         control.BuildDatabaseTree();
         Helpers.DataConnectionHelper.LogUsage("DatabasesFixConnections");
     }
     catch (Exception ex)
     {
         Helpers.DataConnectionHelper.SendError(ex, DatabaseType.SQLServer, false);
     }
 }