// 传入ip地址 192.169.1.12
    public bool init(string url, DbServerInfo dbInfo, bool special = false)
    {
        m_client = new MongodbHelper[DbName.DB_NAME_MAX];
        // 是账号数据库,这里只创建一个,即可
        if (url == WebConfigurationManager.AppSettings["account"] && special)
        {
            m_client[DbName.DB_ACCOUNT]         = new MongodbHelper();
            m_client[DbName.DB_ACCOUNT].MongoDb = create(m_dbName[DbName.DB_ACCOUNT], url);

            // if (url == WebConfigurationManager.AppSettings["payment"] && special)
            {
                // 充值数据库只连接这个
                m_client[DbName.DB_PAYMENT]         = new MongodbHelper();
                m_client[DbName.DB_PAYMENT].MongoDb = create(m_dbName[DbName.DB_PAYMENT], url);
            }
        }
        else // 其他游戏相关数据库
        {
        }

        /*for (int i = 0; i < DbName.DB_NAME_MAX; i++)
         * {
         *  m_client[i] = new MongodbHelper();
         *  m_client[i].MongoDb = create(m_dbName[i], url);
         * }*/

        bool res = testDBConnect();

        if (res)
        {
            IndexMgr.getInstance().createIndex(this, url);
        }
        return(res);
    }
    // 传入ip地址 192.169.1.12
    public bool init(string url, DbServerInfo dbInfo, bool special = false)
    {
        m_client = new MongodbHelper[DbName.DB_NAME_MAX];
        // 是账号数据库,这里只创建一个,即可
        if (url == WebConfigurationManager.AppSettings["account"] + "_account" && special)
        {
            string tmpURL = WebConfigurationManager.AppSettings["account"];
            m_client[DbName.DB_ACCOUNT]         = new MongodbHelper();
            m_client[DbName.DB_ACCOUNT].MongoDb = create(m_dbName[DbName.DB_ACCOUNT], tmpURL);

            // if (url == WebConfigurationManager.AppSettings["payment"] && special)
            {
                // 充值数据库只连接这个
                m_client[DbName.DB_PAYMENT]         = new MongodbHelper();
                m_client[DbName.DB_PAYMENT].MongoDb = create(m_dbName[DbName.DB_PAYMENT], tmpURL);
            }

            m_client[DbName.DB_CONFIG]         = new MongodbHelper();
            m_client[DbName.DB_CONFIG].MongoDb = create(m_dbName[DbName.DB_CONFIG], tmpURL);
        }
//         else if (url == WebConfigurationManager.AppSettings["payment"] && special)
//         {
//             // 充值数据库只连接这个
//             m_client[DbName.DB_PAYMENT] = new MongodbHelper();
//             m_client[DbName.DB_PAYMENT].MongoDb = create(m_dbName[DbName.DB_PAYMENT], url);
//         }
        else // 其他游戏相关数据库
        {
            m_client[DbName.DB_PLAYER]         = new MongodbHelper();
            m_client[DbName.DB_PLAYER].MongoDb = create(m_dbName[DbName.DB_PLAYER], url);

            m_client[DbName.DB_PUMP]         = new MongodbHelper();
            m_client[DbName.DB_PUMP].MongoDb = create(m_dbName[DbName.DB_PUMP], dbInfo.m_logDbIp);

            m_client[DbName.DB_GAME]         = new MongodbHelper();
            m_client[DbName.DB_GAME].MongoDb = create(m_dbName[DbName.DB_GAME], url);
        }

        /*for (int i = 0; i < DbName.DB_NAME_MAX; i++)
         * {
         *  m_client[i] = new MongodbHelper();
         *  m_client[i].MongoDb = create(m_dbName[i], url);
         * }*/

        bool res = testDBConnect();

        if (res)
        {
            IndexMgr.getInstance().createIndex(this, url);
        }
        return(res);
    }
Esempio n. 3
0
    // 传入ip地址 192.169.1.12
    public bool init(string url, DbServerInfo dbInfo, bool special = false)
    {
        m_client = new MongodbHelper[DbName.DB_NAME_MAX];
        XmlConfig xml     = ResMgr.getInstance().getRes("dbserver.xml");
        string    accDbId = xml.getString("account", "");

        // 是账号数据库,这里只创建一个,即可
        if (url == accDbId)
        {
            m_client[DbName.DB_ACCOUNT]         = new MongodbHelper();
            m_client[DbName.DB_ACCOUNT].MongoDb = create(m_dbName[DbName.DB_ACCOUNT], url);

            //if (url == WebConfigurationManager.AppSettings["payment"] && special)
            {
                // 充值数据库只连接这个
                //  m_client[DbName.DB_PAYMENT] = new MongodbHelper();
                //  m_client[DbName.DB_PAYMENT].MongoDb = create(m_dbName[DbName.DB_PAYMENT], url);
            }

            m_client[DbName.DB_CONFIG]         = new MongodbHelper();
            m_client[DbName.DB_CONFIG].MongoDb = create(m_dbName[DbName.DB_CONFIG], url);

            if (isSameAccPlayerdb())
            {
                allocPlayerDb(url, dbInfo);
            }
        }
        // else if (url == WebConfigurationManager.AppSettings["payment"] && special)
        // {
        // 充值数据库只连接这个
        //  m_client[DbName.DB_PAYMENT] = new MongodbHelper();
        //  m_client[DbName.DB_PAYMENT].MongoDb = create(m_dbName[DbName.DB_PAYMENT], url);
        // }
        else // 其他游戏相关数据库
        {
            allocPlayerDb(url, dbInfo);
        }

        bool res = testDBConnect();

        if (res)
        {
            IndexMgr.getInstance().createIndex(this, url);
        }
        return(res);
    }