Exemplo n.º 1
0
        private void UpdateDatabase(DatabaseContext.DatabaseType dbType)
        {
            //Our copy of DatbaseContext from Umbraco.Core
            _db.umbracoSitePath = umbracoSitePath;

            switch (dbType)
            {
            case DatabaseContext.DatabaseType.SQLCE:
                //Setup Datbase to use SQL CE
                _db.ConfigureEmbeddedDatabaseConnection();
                break;

            case DatabaseContext.DatabaseType.SQL:
                //If intergated security checked then
                if (security.IsChecked == true)
                {
                    //Intergrated security SQL connection
                    _db.ConfigureIntegratedSecurityDatabaseConnection(server.Text, databaseName.Text);
                    break;
                }
                //Normal SQL connection
                _db.ConfigureDatabaseConnection(server.Text, databaseName.Text, username.Text, password.Text, DatabaseContext.DatabaseType.SQL);
                break;

            case DatabaseContext.DatabaseType.Azure:
                //Normal Azure SQL connection
                _db.ConfigureDatabaseConnection(server.Text, databaseName.Text, username.Text, password.Text, DatabaseContext.DatabaseType.Azure);
                break;

            case DatabaseContext.DatabaseType.MySQL:
                //Normal MySQL connection
                _db.ConfigureDatabaseConnection(server.Text, databaseName.Text, username.Text, password.Text, DatabaseContext.DatabaseType.MySQL);
                break;

            case DatabaseContext.DatabaseType.Advanced:
                //Configure using custom DB connection string supplied
                _db.ConfigureDatabaseConnection(connection.Text);
                break;

            default:
                //Setup Datbase to use SQL CE
                _db.ConfigureEmbeddedDatabaseConnection();
                break;
            }
        }
Exemplo n.º 2
0
        private void TestDB(DatabaseContext.DatabaseType dbType, string connectionString, string providerName)
        {
            //Let's try....
            try
            {
                //Try and create & connect to the Database
                //If Advanced provider name etc all in the connection string
                if (dbType == DatabaseContext.DatabaseType.Advanced)
                {
                    var db = new UmbracoDatabase(connectionString);
                }
                else
                {
                    //Providing both connection string & provider name
                    var db = new UmbracoDatabase(connectionString, providerName);

                    //Now open the connection to test it out...
                    //Exception will fire if it can connect
                    db.OpenSharedConnection();
                }


                //Show a Success Message Box
                MessageBox.Show("Database Connection Sucessful", "Database Connection Test", MessageBoxButton.OK, MessageBoxImage.Information);

                //Enable Button
                CreateProjectBtn.IsEnabled = true;
            }
            catch (Exception ex)
            {
                var error = string.Format("Database Connection Error: {0}", ex.Message);

                //Show an Error Message Box
                MessageBox.Show(error, "Database Connection Test", MessageBoxButton.OK, MessageBoxImage.Error);

                //Disable Button
                CreateProjectBtn.IsEnabled = false;
            }
        }
Exemplo n.º 3
0
        private void CreateProjectClick(object sender, RoutedEventArgs e)
        {
            //Get the selected value from the dropdown
            var selectedEngine = (engineChoice.SelectedValue as ComboBoxItem).Content.ToString();

            //Set rendeing mode dependant on choice
            switch (selectedEngine)
            {
            case "MVC (Recommended)":
                //Updates config value...
                UpdateRenderingEngine(RenderingEngine.Mvc);
                break;

            case "WebForms":
                //Updates config value...
                UpdateRenderingEngine(RenderingEngine.WebForms);
                break;

            default:
                //Updates config value...
                UpdateRenderingEngine(RenderingEngine.Mvc);
                break;
            }

            //Set DB type
            //Get the selected value from the dropdown
            var selectedDB = (databaseType.SelectedValue as ComboBoxItem).Content.ToString();

            switch (selectedDB)
            {
            case "SQL CE File based Database (Recommended)":
                dbType = DatabaseContext.DatabaseType.SQLCE;
                UpdateDatabase(DatabaseContext.DatabaseType.SQLCE);
                break;

            case "SQL Server":
                //Update Database deals with the intergrated security check
                dbType = DatabaseContext.DatabaseType.SQL;
                UpdateDatabase(DatabaseContext.DatabaseType.SQL);
                break;

            case "SQL Azure":
                dbType = DatabaseContext.DatabaseType.SQL;
                UpdateDatabase(DatabaseContext.DatabaseType.Azure);
                break;

            case "MySQL":
                dbType = DatabaseContext.DatabaseType.MySQL;
                UpdateDatabase(DatabaseContext.DatabaseType.MySQL);
                break;

            case "Advanced":
                dbType = DatabaseContext.DatabaseType.SQL;
                UpdateDatabase(DatabaseContext.DatabaseType.Advanced);
                break;

            default:
                //As a default fallback - use SQL CE
                dbType = DatabaseContext.DatabaseType.SQLCE;
                UpdateDatabase(DatabaseContext.DatabaseType.SQLCE);
                break;
            }

            var skipInstaller = skipWebInstaller.IsChecked;

            //Only add config status version flag if skipping web installer
            if (skipInstaller == true)
            {
                //Update Config Status - Updates version number- means all config'd & skips installer
                //Substring - First 5 characters to get 7.0.0 as opposed to 7.0.0-RC
                UpdateConfigStatus(umbracoSitePath, umbracoVersionNumber.Substring(0, 5));

                //Create DB Schema in configured/chosen DB & update admin user
                _db.CreateDatabaseSchema(dbType, skipInstaller);
            }

            //Need to figure a way to close dialog from usercontrol
            Window parentWindow = Window.GetWindow(this);

            parentWindow.Close();
        }