Example #1
0
        public static DBServer GetArticleServer()
        {
            if (null == _svrArticle)
            {
                _svrArticle = _svrFarm[DBRoles.Article];
            }

            return _svrArticle;
        }
Example #2
0
        private static void _SaveToFile(DBServer svr)
        {
            string sServerCfgPath = _GetConfigFilePath();
            StreamWriter fs = new StreamWriter(sServerCfgPath);
            XmlWriter writer = new XmlTextWriter(fs);
            XmlSerializer serializer = new XmlSerializer(typeof(SMTPServer));
            serializer.Serialize(writer, svr);

            fs.Close();
        }
Example #3
0
        public static OdbcConnection CreateConnectionToServer(DBServer svr)
        {
            OdbcConnection odbcconn = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};" +
               "Server=" + svr._sServer + ";" +
               "Port=3306;" +
               "Option=16384;" +
               "Pooling=true;" +
               "Stmt=;" +
               "Database=" + svr._sDatabase + ";" +
               "Uid=" + svr._sUser + ";" +
               "Pwd=" + svr._sPassword + ";");

            odbcconn.Open();

            return odbcconn;
        }
Example #4
0
        private void GetDBRunningThreads(DBServer server)
        {
            OdbcConnection conn = null;

            try
            {
                conn = DataConnection.CreateConnectionToServer(server);
                DataTable dt = new DataTable();

                OdbcDataAdapter da = new OdbcDataAdapter("SHOW GLOBAL STATUS;", conn);

                da.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        if (row[0].ToString() == "Threads_running")
                        {
                            Interlocked.Exchange(ref server._cRunningThreads, Convert.ToInt32(row[1]));
                            break;
                        }
                    }
                }
                else
                {
                    // Shouldn't happen
                    server._cRunningThreads = 50;
                }
            }
            catch (Exception)
            {
                // REVIEW: Out of memory? Made the server look really busy.
                Interlocked.Exchange(ref server._cRunningThreads, Int32.MaxValue);
            }
            finally
            {
                if (null != conn)
                {
                    conn.Close();
                }
            }
        }
Example #5
0
        private OdbcConnection _CreateConnectionWorker(DBRoles role)
        {
            // Image server is not using MySQL
            Debug.Assert(DBRoles.Image != role);

            _svr = GetServerForRole(role);

            OdbcConnection odbcconn = CreateConnectionToServer(_svr);

            //The following steps are due to our DB is using GBK encoding
            OdbcCommand cmd = new OdbcCommand("SET NAMES 'gbk';", odbcconn);

            cmd.ExecuteNonQuery();

            return odbcconn;
        }
Example #6
0
        public static DBServer GetImageServer()
        {
            if (null == _svrImage)
            {
                _svrImage = _svrFarm[DBRoles.Image];
            }

            return _svrImage;
        }
Example #7
0
        public static DBServer GetUserServer()
        {
            if (null == _svrUser)
            {
                _svrUser = _svrFarm[DBRoles.User];
            }

            return _svrUser;
        }
Example #8
0
        public static DBServer GetUserGenerateServer()
        {
            if (null == _svrUserGenerate)
            {
                _svrUserGenerate = _svrFarm[DBRoles.UserGenerate];
            }

            return _svrUserGenerate;
        }
Example #9
0
        public static DBServer GetSpaceServer()
        {
            if (null == _svrSpace)
            {
                _svrSpace = _svrFarm[DBRoles.Space];
            }

            return _svrSpace;
        }
Example #10
0
        public static DBServer GetRobotServer()
        {
            if (null == _svrRobot)
            {
                _svrRobot = _svrFarm[DBRoles.Robot];
            }

            return _svrRobot;
        }
Example #11
0
        public static DBServer GetProductionServer()
        {
            if (null == _svrProdution)
            {
                _svrProdution = _svrFarm[DBRoles.Production];
            }

            return _svrProdution;
        }
Example #12
0
 public static DBServer GetManualHistoryServer()
 {
     if (null == _svrManualHistory)
     {
         _svrManualHistory = _svrFarm[DBRoles.ManualHistory];
     }
     return _svrManualHistory;
 }