/// <summary>
 /// Creates a new instance of the <see cref="SqlServerDatabaseSetupScreen"/> class.
 /// </summary>
 public SqlServerDatabaseSetupScreen()
 {
     m_sqlServerSetup = new SqlServerSetup();
     m_sqlServerSetup.DataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection; AdapterType=System.Data.SqlClient.SqlDataAdapter";
     InitializeComponent();
     this.Loaded += new RoutedEventHandler(SqlServerDatabaseSetupScreen_Loaded);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="SqlServerDatabaseSetupScreen"/> class.
 /// </summary>
 public SqlServerDatabaseSetupScreen()
 {
     m_sqlServerSetup = new SqlServerSetup();
     m_sqlServerSetup.DataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection; AdapterType=System.Data.SqlClient.SqlDataAdapter";
     InitializeComponent();
     this.Loaded += new RoutedEventHandler(SqlServerDatabaseSetupScreen_Loaded);
 }
        // Occurs when the user chooses to test their database connection.
        private void TestConnectionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SqlServerSetup testSqlServerSetup = new SqlServerSetup();
                testSqlServerSetup.ConnectionString   = m_sqlServerSetup.ConnectionString;
                testSqlServerSetup.DataProviderString = m_sqlServerSetup.DataProviderString;
                testSqlServerSetup.DatabaseName       = null;
                testSqlServerSetup.Timeout            = "5";

                using (AdoDataConnection connection = testSqlServerSetup.OpenConnection())
                {
                }

                MessageBox.Show("Database connection succeeded.");
            }
            catch
            {
                string failMessage = "Database connection failed."
                                     + " Please check your username and password."
                                     + " Additionally, you may need to modify your connection under advanced settings.";

                MessageBox.Show(failMessage);
            }
        }
Ejemplo n.º 4
0
 public void Setup()
 {
     ConfigFileManager.CopyWebConfig();
     ConfigFileManager.CopyConnectionStringsConfig();
     ConfigFileManager.CopyRoadkillConfig();
     SqlServerSetup.RecreateLocalDbData();
 }
        public void Setup()
        {
            SqlServerSetup.RecreateLocalDbData();

            string sqlFile     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Integration", "Import", "screwturn3.sql");
            string sqlCommands = File.ReadAllText(sqlFile);

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = sqlCommands;
                    command.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 6
0
        public void TearDown()
        {
            Console.WriteLine("~~~~~~~~~~~~ Installer acceptance tests teardown ~~~~~~~~~~~~");
            string sitePath = Settings.WEB_PATH;

            try
            {
                // Remove any attachment folders used by the installer tests
                string installerTestsAttachmentsPath = Path.Combine(sitePath, "AcceptanceTests");
                Directory.Delete(installerTestsAttachmentsPath, true);
                Console.WriteLine("Deleted temp attachment folders for installer tests");
            }
            catch { }

            // Reset the db and web.config back for all other acceptance tests
            SqlServerSetup.RecreateLocalDbData();
            ConfigFileManager.CopyConnectionStringsConfig();
            Console.WriteLine("Copied databases and web.config back for installer tests");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        }
Ejemplo n.º 7
0
        public void Setup()
        {
            string url = ConfigurationManager.AppSettings["url"];

            if (string.IsNullOrEmpty(url))
            {
                url = "http://localhost:9876";
            }

            Console.WriteLine("============ Acceptance tests setup ============");

            SqlServerSetup.RecreateLocalDbData();
            ConfigFileManager.CopyRoadkillConfig();

            BaseUrl            = url;
            LoginUrl           = BaseUrl + "/user/login";
            LogoutUrl          = BaseUrl + "/user/logout";
            Driver             = AcceptanceTestsSetup.Driver;
            IsWindowsAuthTests = (ConfigurationManager.AppSettings["useWindowsAuth"] == "true");

            Console.WriteLine("=================================================");
        }
Ejemplo n.º 8
0
        private IDbConnection OpenNewConnection()
        {
            IDbConnection connection = null;

            try
            {
                string databaseType       = m_state["newDatabaseType"].ToString();
                string connectionString   = string.Empty;
                string dataProviderString = string.Empty;

                if (databaseType == "SQLServer")
                {
                    SqlServerSetup sqlServerSetup = m_state["sqlServerSetup"] as SqlServerSetup;
                    connectionString   = sqlServerSetup.ConnectionString;
                    dataProviderString = sqlServerSetup.DataProviderString;

                    if (string.IsNullOrWhiteSpace(dataProviderString))
                    {
                        dataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection; AdapterType=System.Data.SqlClient.SqlDataAdapter";
                    }
                }
                else if (databaseType == "MySQL")
                {
                    MySqlSetup mySqlSetup = m_state["mySqlSetup"] as MySqlSetup;
                    connectionString   = mySqlSetup.ConnectionString;
                    dataProviderString = mySqlSetup.DataProviderString;

                    if (string.IsNullOrWhiteSpace(dataProviderString))
                    {
                        dataProviderString = "AssemblyName={MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d}; ConnectionType=MySql.Data.MySqlClient.MySqlConnection; AdapterType=MySql.Data.MySqlClient.MySqlDataAdapter";
                    }
                }
                else if (databaseType == "Oracle")
                {
                    OracleSetup oracleSetup = m_state["oracleSetup"] as OracleSetup;
                    connectionString   = oracleSetup.ConnectionString;
                    dataProviderString = oracleSetup.DataProviderString;

                    if (string.IsNullOrWhiteSpace(dataProviderString))
                    {
                        dataProviderString = OracleSetup.DefaultDataProviderString;
                    }
                }
                else if (databaseType == "PostgreSQL")
                {
                    PostgresSetup postgresSetup = m_state["postgresSetup"] as PostgresSetup;
                    connectionString   = postgresSetup.ConnectionString;
                    dataProviderString = PostgresSetup.DataProviderString;
                }
                else
                {
                    string destination = m_state["sqliteDatabaseFilePath"].ToString();
                    connectionString   = "Data Source=" + destination + "; Version=3";
                    dataProviderString = "AssemblyName={System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139}; ConnectionType=System.Data.SQLite.SQLiteConnection; AdapterType=System.Data.SQLite.SQLiteDataAdapter";
                }

                if (!string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(dataProviderString))
                {
                    Dictionary <string, string> dataProviderSettings = dataProviderString.ParseKeyValuePairs();
                    string assemblyName       = dataProviderSettings["AssemblyName"];
                    string connectionTypeName = dataProviderSettings["ConnectionType"];

                    Assembly assembly       = Assembly.Load(new AssemblyName(assemblyName));
                    Type     connectionType = assembly.GetType(connectionTypeName);
                    connection = (IDbConnection)Activator.CreateInstance(connectionType);
                    connection.ConnectionString = connectionString;
                    connection.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open new database connection: " + ex.Message, "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error);

                if (connection != null)
                {
                    connection.Dispose();
                }

                connection = null;
            }

            return(connection);
        }
Ejemplo n.º 9
0
 public void TestFixtureSetup()
 {
     SqlServerSetup.RecreateLocalDbData();
 }
Ejemplo n.º 10
0
        // Gets a database connection to the SQL Server database configured earlier in the setup.
        private IDbConnection GetSqlServerConnection()
        {
            SqlServerSetup sqlSetup = m_state["sqlServerSetup"] as SqlServerSetup;

            return((sqlSetup == null) ? null : new SqlConnection(sqlSetup.ConnectionString));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Called when all startup conditions have been meet. The database is now
        /// accessible as well.
        /// </summary>
        private void FinalStartUp()
        {
            if ((_notification != null) && _notification.IsLoaded && _notification.IsVisible)
            {
                _notification.Close();
            }

            // Disable AlwaysUseDefaults which was being used prior to this...
            ConfigurationManager.AlwaysUseDefaults = false;

            // Task Manager Protection
            // SettingManager.SetStoreSetting("DontDisableTaskManager", 0);
            int?isDisabled = SettingManager.GetInt32("DontDisableTaskManager");

            if (isDisabled.HasValue && (isDisabled.Value == 1))
            {
                BeginStartup();
                return;
            }
            if (!TaskManagerServiceHelper.IsInstalled)
            {
                if (PosDialogWindow.ShowDialog(Types.Strings.DoYouWantToInstallTheTaskManagerAccessService,
                                               Types.Strings.InstallService, DialogButtons.YesNo, false) == DialogButton.Yes)
                {
                    new Thread(TaskManagerServiceHelper.InstallThread).Start();
                }
            }
            else if (!TaskManagerServiceHelper.IsStarted)
            {
                if (PosDialogWindow.ShowDialog(Types.Strings.DoYouWantToStartTheTaskManagerAccessService,
                                               Types.Strings.StartService, DialogButtons.YesNo, false) == DialogButton.Yes)
                {
                    new Thread(TaskManagerServiceHelper.StartThread).Start();
                }
            }
            else
            {
                TaskManagerServiceHelper.IsTaskManagerDisabled = true;
            }


            // Install the SQL Assembly (if one is pending installation)
            if (Updater.InstallSQLAssembly())
            {
#if DEBUG
                PosDialogWindow.ShowDialog("New SQL Assembly Installed", Types.Strings.Information);
#endif
            }

            // Apply any required database patches at runtime
            SqlServerSetup.ApplyDatabasePatches();

            // Check to make sure the model classes and the tables match
            if (!DataModelBase.ValidateDatabase())
            {
#if DEBUG
                string results = DataModelBase.InvalidDatabaseReport();
                PosDialogWindow.ShowDialog(
                    results,
                    "Invalid Database Report");
#else
                PosDialogWindow.ShowDialog(
                    Strings.TheDatabaseDesignCurrentlyBeingUsedIsIncorrectForThisVersionOfTempos,
                    Strings.StartupError);
#endif
                UserControlManager.ShowTaskbar(true);
                Application.Current.Shutdown();
                return;
            }

            // Enable user control
            UserControlManager.Enable(ConfigurationManager.UseKeyboardHook);
            UserControlManager.ShowTaskbar(false);

            // Start-up MainWindow
            Show();
            _mainWindow = new MainWindow();
            _mainWindow.Show();
        }
Ejemplo n.º 12
0
 private void DoFinishInstallThreadStart()
 {
     SqlServerSetup.FinishInstall();
     Dispatcher.Invoke((Action)(FinalStartUp));
 }