public static DBServer GetArticleServer() { if (null == _svrArticle) { _svrArticle = _svrFarm[DBRoles.Article]; } return _svrArticle; }
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(); }
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; }
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(); } } }
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; }
public static DBServer GetImageServer() { if (null == _svrImage) { _svrImage = _svrFarm[DBRoles.Image]; } return _svrImage; }
public static DBServer GetUserServer() { if (null == _svrUser) { _svrUser = _svrFarm[DBRoles.User]; } return _svrUser; }
public static DBServer GetUserGenerateServer() { if (null == _svrUserGenerate) { _svrUserGenerate = _svrFarm[DBRoles.UserGenerate]; } return _svrUserGenerate; }
public static DBServer GetSpaceServer() { if (null == _svrSpace) { _svrSpace = _svrFarm[DBRoles.Space]; } return _svrSpace; }
public static DBServer GetRobotServer() { if (null == _svrRobot) { _svrRobot = _svrFarm[DBRoles.Robot]; } return _svrRobot; }
public static DBServer GetProductionServer() { if (null == _svrProdution) { _svrProdution = _svrFarm[DBRoles.Production]; } return _svrProdution; }
public static DBServer GetManualHistoryServer() { if (null == _svrManualHistory) { _svrManualHistory = _svrFarm[DBRoles.ManualHistory]; } return _svrManualHistory; }