Example #1
0
        } //END Write Function

        /// <summary>
        /// Write data into the database (MySQL).
        /// *This method is thread safe, but the DB_MySQL Class is NOT*
        /// </summary>
        private bool WriteMySQL(DBMySQL.DB_MySQL DBObject, DriverComm.DataExtClass[] DataWrite)
        {
            bool retVal = false;

            if ((DBObject.isInitialized) && (DataWrite != null))
            {
                retVal = DBObject.Write(DataWrite);
                Status.AddSummary(DBObject.Status.GetSummary());
            }

            return(retVal);
        } //END WriteMySQL Function
Example #2
0
        } //END Add Driver function.

        /// <summary>
        /// Initialize the Database conectivity. Requires that drives are added before Initializing.
        /// *This method is not thread safe*
        /// <param name="InitialSet">Do an initial set of the Database tables.</param>  </summary>
        public int Initialize(bool InitialSet)
        {
            int retVal;

            InitialSet = true; //always initialize fully
            retVal     = -1;

            if (DatabaseConf.MasterSrv.Enable)
            {
                //Build the Driver and Initialize for MySQL
                if (DatabaseConf.MasterSrv.Type == DBConfig.DBServerType.MySQL)
                {
                    MasterMySQL = new DBMySQL.DB_MySQL(DatabaseConf.MasterSrv, true);
                    MasterMySQL.Initialize(DriversConf, InitialSet);

                    Status.AddSummary(MasterMySQL.Status.GetSummary());

                    if (MasterMySQL.isInitialized)
                    {
                        Status.NewStat(StatT.Good, "Master Srv Initialized.");
                        isInitialized = true; retVal = 1;
                    }
                    else
                    {
                        Status.NewStat(StatT.Bad, "Master Srv Init Failed.");
                        isInitialized = false; retVal = -1;
                    }
                } //END IF MySQL Initialization.

                if (DatabaseConf.MasterSrv.Type == DBConfig.DBServerType.MySQLPool)
                {
                    MMySQLPool = new DBMySQL.DB_MySQLPool(DatabaseConf.MasterSrv, true);
                    MMySQLPool.Initialize(DriversConf, InitialSet);

                    Status.AddSummary(MMySQLPool.Status.GetSummary());

                    if (MMySQLPool.isInitialized)
                    {
                        Status.NewStat(StatT.Good, "Master Srv Initialized.");
                        isInitialized = true; retVal = 1;
                    }
                    else
                    {
                        Status.NewStat(StatT.Bad, "Master Srv Init Failed.");
                        isInitialized = false; retVal = -1;
                    }
                } //END IF MySQLPool Initialization.
            }     //Master Server Initialization.

            if (DatabaseConf.BackupSrv.Enable)
            {
                //Build the Driver and Initialize for MySQL
                if (DatabaseConf.BackupSrv.Type == DBConfig.DBServerType.MySQL)
                {
                    BackupMySQL = new DBMySQL.DB_MySQL(DatabaseConf.BackupSrv, false);
                    BackupMySQL.Initialize(DriversConf, InitialSet);

                    Status.AddSummary(BackupMySQL.Status.GetSummary());

                    if (BackupMySQL.isInitialized)
                    {
                        Status.NewStat(StatT.Good, "Backup Srv Initialized.");
                        isInitialized = true; retVal = 2;
                    }
                    else
                    {
                        Status.NewStat(StatT.Bad, "Backup Srv Init Failed.");
                        isInitialized = false; retVal = -2;
                    }
                } //END IF MySQL Initialization.

                if (DatabaseConf.BackupSrv.Type == DBConfig.DBServerType.MySQLPool)
                {
                    BMySQLPool = new DBMySQL.DB_MySQLPool(DatabaseConf.MasterSrv, true);
                    BMySQLPool.Initialize(DriversConf, InitialSet);

                    Status.AddSummary(BMySQLPool.Status.GetSummary());

                    if (BMySQLPool.isInitialized)
                    {
                        Status.NewStat(StatT.Good, "Backup Srv Initialized.");
                        isInitialized = true; retVal = 1;
                    }
                    else
                    {
                        Status.NewStat(StatT.Bad, "Backup Srv Init Failed.");
                        isInitialized = false; retVal = -1;
                    }
                } //END IF MySQLPool Initialization.
            }     //Backup Server Initialization.

            //Count the enabled number of tags
            CountVars();

            return(retVal);
        } // END Initialization Function