Beispiel #1
0
 internal static void Initialize(DBInfo info)
 {
     DBInfo = info;
     MySql = new MySqlDatabase(DBInfo.IPAddress, DBInfo.PortNo, DBInfo.CharSet, DBInfo.DBName, DBInfo.UserId, DBInfo.UserPwd);
 }
Beispiel #2
0
 internal static void AddDBInfo(DBInfo info)
 {
     MySqlDatabase mysql = new MySqlDatabase(info.IPAddress, info.PortNo, info.CharSet, info.DBName, info.UserId, info.UserPwd);
     Tuple<DBInfo, MySqlDatabase> data = new Tuple<DBInfo, MySqlDatabase>(info, mysql);
     _listDB.Add(data);
 }
Beispiel #3
0
 internal static void Initialize(DBInfo info)
 {
     DBInfo = info;
     MySql = new ConnectionPool(DBInfo.IPAddress, DBInfo.PortNo, DBInfo.CharSet, DBInfo.DBName, DBInfo.UserId, DBInfo.UserPwd);
 }
Beispiel #4
0
        public static void Refresh()
        {
            String dbName = Starter.CustomData.GetValue("SystemDB/dbname");
            String dbHost = Starter.CustomData.GetValue("SystemDB/ipaddress");
            Int32 dbPort = Starter.CustomData.GetValue("SystemDB/portno").ToInt32();
            String userId = Starter.CustomData.GetValue("SystemDB/userid");
            String userPwd = Starter.CustomData.GetValue("SystemDB/userpwd");

            MySqlDatabase systemDB = new MySqlDatabase(dbHost, dbPort, "", dbName, userId, userPwd);
            using (DBCommand cmd = new DBCommand(systemDB))
            {
                cmd.CommandText.Append("select uid, worldid, dbtype, dbname, ipaddress, portno, userid, passwd");
                cmd.CommandText.Append(", charset, shardkey_start, shardkey_end");
                cmd.CommandText.Append(" from t_listdb;");
                DataReader reader = cmd.Query();

                while (reader.Read())
                {
                    DBInfo info = new DBInfo()
                    {
                        Uid = reader.GetInt32(0),
                        WorldId = reader.GetInt32(1),
                        DBType = (DBType)reader.GetInt32(2),
                        DBName = reader.GetString(3),
                        IPAddress = reader.GetString(4),
                        PortNo = reader.GetInt32(5),
                        UserId = reader.GetString(6),
                        UserPwd = reader.GetString(7),
                        CharSet = (reader.IsDBNull(8) == true ? "" : reader.GetString(8)),
                        ShardKeyStart = (reader.IsDBNull(9) == true ? 0 : reader.GetInt32(9)),
                        ShardKeyEnd = (reader.IsDBNull(10) == true ? 0 : reader.GetInt32(10))
                    };
                    Items.Add(info);

                    if (info.DBType == DBType.System)
                        SystemDB.Initialize(info);

                    else if (info.DBType == DBType.Auth)
                        AuthDB.Initialize(info);

                    else if (info.DBType == DBType.Game)
                        GameDB.AddDBInfo(info);
                }
            }
            systemDB.Release();
        }
Beispiel #5
0
 internal static void AddDBInfo(DBInfo info)
 {
     ConnectionPool mysql = new ConnectionPool(info.IPAddress, info.PortNo, info.CharSet, info.DBName, info.UserId, info.UserPwd);
     Tuple<DBInfo, ConnectionPool> data = new Tuple<DBInfo, ConnectionPool>(info, mysql);
     _listDB.Add(data);
 }