Ejemplo n.º 1
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            MyXml  xml      = new MyXml(_GAME_SERVER_CONFIG_S);
            string hostname = xml.GetStr("GameServerConfiguration", "GameMySQL", "Hostname");
            string username = xml.GetStr("GameServerConfiguration", "GameMySQL", "Username");
            string password = xml.GetStr("GameServerConfiguration", "GameMySQL", "Password");
            string database = xml.GetStr("GameServerConfiguration", "GameMySQL", "Database");
            string szPort   = xml.GetStr("GameServerConfiguration", "GameMySQL", "Port");

            if (ushort.TryParse(szPort, out ushort usPort))
            {
                usPort = 3306;
            }
            Kernel.GameDbConfig = new MySqlConfig(hostname, username, password, database, usPort);

            hostname = xml.GetStr("GameServerConfiguration", "LogMySQL", "Hostname");
            username = xml.GetStr("GameServerConfiguration", "LogMySQL", "Username");
            password = xml.GetStr("GameServerConfiguration", "LogMySQL", "Password");
            database = xml.GetStr("GameServerConfiguration", "LogMySQL", "Database");
            szPort   = xml.GetStr("GameServerConfiguration", "LogMySQL", "Port");
            if (ushort.TryParse(szPort, out usPort))
            {
                usPort = 3306;
            }
            Kernel.LogDbConfig = new MySqlConfig(hostname, username, password, database, usPort);

            hostname = xml.GetStr("GameServerConfiguration", "ResourceMySQL", "Hostname");
            username = xml.GetStr("GameServerConfiguration", "ResourceMySQL", "Username");
            password = xml.GetStr("GameServerConfiguration", "ResourceMySQL", "Password");
            database = xml.GetStr("GameServerConfiguration", "ResourceMySQL", "Database");
            szPort   = xml.GetStr("GameServerConfiguration", "ResourceMySQL", "Port");
            if (ushort.TryParse(szPort, out usPort))
            {
                usPort = 3306;
            }
            Kernel.ResourceDbConfig = new MySqlConfig(hostname, username, password, database, usPort);

            xml      = new MyXml(_ACCOUNT_SERVER_CONFIG_S);
            hostname = xml.GetStr("AccountServerConfiguration", "MySQL", "Hostname");
            username = xml.GetStr("AccountServerConfiguration", "MySQL", "Username");
            password = xml.GetStr("AccountServerConfiguration", "MySQL", "Password");
            database = xml.GetStr("AccountServerConfiguration", "MySQL", "Database");
            szPort   = xml.GetStr("AccountServerConfiguration", "MySQL", "Port");
            if (ushort.TryParse(szPort, out usPort))
            {
                usPort = 3306;
            }
            Kernel.AccountDbConfig = new MySqlConfig(hostname, username, password, database, usPort);

            SessionFactory.StartAccountConnection(Kernel.AccountDbConfig.Host,
                                                  Kernel.AccountDbConfig.User,
                                                  Kernel.AccountDbConfig.Pass,
                                                  Kernel.AccountDbConfig.Database,
                                                  Kernel.AccountDbConfig.Port);
            SessionFactory.StartGameConnection(Kernel.GameDbConfig.Host,
                                               Kernel.GameDbConfig.User,
                                               Kernel.GameDbConfig.Pass,
                                               Kernel.GameDbConfig.Database,
                                               Kernel.GameDbConfig.Port);
            SessionFactory.StartLogConnection(Kernel.LogDbConfig.Host,
                                              Kernel.LogDbConfig.User,
                                              Kernel.LogDbConfig.Pass,
                                              Kernel.LogDbConfig.Database,
                                              Kernel.LogDbConfig.Port);
            SessionFactory.StartResourceConnection(Kernel.ResourceDbConfig.Host,
                                                   Kernel.ResourceDbConfig.User,
                                                   Kernel.ResourceDbConfig.Pass,
                                                   Kernel.ResourceDbConfig.Database,
                                                   Kernel.ResourceDbConfig.Port);
        }