Esempio n. 1
0
        private void CheckAndUpgradeSchema()
        {
            OMLEngine.DatabaseManagement.DatabaseManagement dbm = new OMLEngine.DatabaseManagement.DatabaseManagement();

            OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBNotFound)
            {
                MessageBox.Show("Detected SQL Server but cannot find the database. Click OK to create the database.", "Databse problem", MessageBoxButtons.OK);
                // OML Instance but OML database does not exist
                dbm.ConfigureSQL(ScriptsPath);
                dbm.UpgradeSchemaVersion(ScriptsPath);

                // Retest the connection
                state = dbm.CheckDatabase();
            }

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired)
            {
                MessageBox.Show("Detected the OML Database but it requires updating. Click OK to update the database.", "Databse problem", MessageBoxButtons.OK);
                dbm.UpgradeSchemaVersion(ScriptsPath);

                // Retest the connection
                state = dbm.CheckDatabase();
            }

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK)
            {
                MessageBox.Show("The database appears all fine.", "Database status", MessageBoxButtons.OK);
                return;
            }
        }
Esempio n. 2
0
        private bool TestDBConnection(AddInHost host)
        {
            try
            {
                //return OMLEngine.Settings.OMLSettings.IsConnected;
                OMLEngine.DatabaseManagement.DatabaseManagement           dbm   = new OMLEngine.DatabaseManagement.DatabaseManagement();
                OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();
                switch (state)
                {
                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK:
                    return(true);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema:
                    throw (new Exception("The OML client is an older version than the database. Please upgrade the client components!"));

                //is this right?
                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionNotFound:
                    return(true);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.LoginFailure:
                    return(false);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired:
                {
                    //TODO: do upgrade bits here...
                    return(true);
                }

                default:
                    throw (new Exception(OMLEngine.DatabaseManagement.DatabaseInformation.LastSQLError));
                }
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(
                    ex.Message,
                    "CONNECTION FAILED", Microsoft.MediaCenter.DialogButtons.Ok, 5, false);
                return(false);

                //this._session.Close();
            }
            return(true);
        }
Esempio n. 3
0
        private bool TestDBConnection(AddInHost host)
        {
            try
            {
                //return OMLEngine.Settings.OMLSettings.IsConnected;
                OMLEngine.DatabaseManagement.DatabaseManagement dbm = new OMLEngine.DatabaseManagement.DatabaseManagement();
                OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();
                switch (state)
                {
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK:
                        return true;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema:
                        throw (new Exception("The OML client is an older version than the database. Please upgrade the client components!"));
                    //is this right?
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionNotFound:
                        return true;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.LoginFailure:
                        return false;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired:
                        {
                            //TODO: do upgrade bits here...
                            return true;
                        }
                    default:
                        throw (new Exception(OMLEngine.DatabaseManagement.DatabaseInformation.LastSQLError));
                }
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(
                ex.Message,
                "CONNECTION FAILED", Microsoft.MediaCenter.DialogButtons.Ok, 5, false);
                return false;

                //this._session.Close();
            }
            return true;
        }
Esempio n. 4
0
        /*** REMOVE ONCE THE UNIFIED WIX INSTALLERS ARE COMPLETE ***/
        /// <summary>
        /// Load the db connection settings and try to connect to the database.
        /// Give option to specify alternative sql connection details if connection
        /// attempt fails
        /// </summary>
        /// <returns></returns>
        private bool ValidateDatabase()
        {
            // Run database diagnostics
            OMLEngine.DatabaseManagement.DatabaseManagement dbm = new OMLEngine.DatabaseManagement.DatabaseManagement();

            OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired)
            {
                XtraMessageBox.Show("The OML database is an older version. Press OK to upgrade the database!", "Problem running DBEditor", MessageBoxButtons.OK);

                // Find the script path. Also include hack to find scripts if running from VS rathr than c:\program files....
                string ScriptsPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\SQLInstaller";
                if (Directory.Exists( Path.GetDirectoryName(Application.ExecutablePath) + "\\..\\..\\..\\SQL Scripts"))
                {
                    ScriptsPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\..\\..\\..\\SQL Scripts";
                }

                dbm.UpgradeSchemaVersion(ScriptsPath);

                // Retest the connection
                state = dbm.CheckDatabase();
            }

            switch (state)
            {
                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK:
                    return true;

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema:
                    XtraMessageBox.Show("The OML client is an older version than the database. Please upgrade the client components!", "Problem running DBEditor", MessageBoxButtons.OK);
                    return false;

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionNotFound:
                    return false;

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.LoginFailure:
                    if (XtraMessageBox.Show("This could be caused by the OML Server computer being unavailable. Do you want to specify the server used?", "Problem accessing database!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        SelectDatabaseServer sds = new SelectDatabaseServer();
                        if (sds.ShowDialog() == DialogResult.OK)
                        {
                            OMLEngine.DatabaseManagement.DatabaseInformation.SQLServerName = sds.Server;
                            OMLEngine.DatabaseManagement.DatabaseInformation.SQLInstanceName = sds.SQLInstance;
                            XtraMessageBox.Show("Please restart the program for the changes to take effect!");
                        }
                    }
                    return false;

                    break;
                default:
                    XtraMessageBox.Show(state.ToString() + " : " + OMLEngine.DatabaseManagement.DatabaseInformation.LastSQLError, "Problem accessing database!");
                    return false;
            }
        }
Esempio n. 5
0
        private void CheckAndUpgradeSchema()
        {
            OMLEngine.DatabaseManagement.DatabaseManagement dbm = new OMLEngine.DatabaseManagement.DatabaseManagement();

            OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBNotFound)
            {
                MessageBox.Show("Detected SQL Server but cannot find the database. Click OK to create the database.", "Databse problem", MessageBoxButtons.OK);
                // OML Instance but OML database does not exist
                dbm.ConfigureSQL(ScriptsPath);
                dbm.UpgradeSchemaVersion(ScriptsPath);

                // Retest the connection
                state = dbm.CheckDatabase();
            }

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired)
            {
                MessageBox.Show("Detected the OML Database but it requires updating. Click OK to update the database.", "Databse problem", MessageBoxButtons.OK);
                dbm.UpgradeSchemaVersion(ScriptsPath);

                // Retest the connection
                state = dbm.CheckDatabase();
            }

            if (state == OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK)
            {
                MessageBox.Show("The database appears all fine.", "Database status", MessageBoxButtons.OK);
                return;
            }
        }