OpRes statAve(IMongoQuery imq, GMUser user)
    {
        m_result.Clear();
        MapReduceResult mapResult = DBMgr.getInstance().executeMapReduce(TableName.STAT_PLAYER_GAME_BET_RESULT,
                                                                         user.getDbServerID(),
                                                                         DbName.DB_PUMP,
                                                                         imq,
                                                                         MapReduceTable.getMap("userGameBet"),
                                                                         MapReduceTable.getReduce("userGameBet"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();

            foreach (BsonDocument d in bson)
            {
                ResultItemPlayerGameBet tmp = new ResultItemPlayerGameBet();
                m_result.Add(tmp);

                BsonValue resValue = d["value"];

                tmp.m_time  = Convert.ToDateTime(d["_id"]).ToLocalTime();
                tmp.m_round = resValue["playerCount"].ToInt32();

                long   max = resValue["maxCarry"].ToInt64();
                long   min = resValue["minCarry"].ToInt64();
                double sum = resValue["sumCarry"].ToDouble();
                tmp.addData(ResultItemPlayerGameBet.CARRY, sum, max, min);

                max = resValue["maxOutlay"].ToInt64();
                min = resValue["minOutlay"].ToInt64();
                sum = resValue["sumOutlay"].ToDouble();
                tmp.addData(ResultItemPlayerGameBet.OUTLAY, sum, max, min);

                max = resValue["maxWin"].ToInt64();
                min = resValue["minWin"].ToInt64();
                sum = resValue["sumWin"].ToDouble();
                tmp.addData(ResultItemPlayerGameBet.WIN, sum, max, min);

                max = resValue["maxLose"].ToInt64();
                min = resValue["minLose"].ToInt64();
                sum = resValue["sumLose"].ToDouble();
                tmp.addData(ResultItemPlayerGameBet.LOSE, sum, max, min);

                tmp.m_rw = resValue["rw"].ToInt64();
            }
        }

        return(OpRes.opres_success);
    }
    private OpRes query(ParamQuery param, IMongoQuery imq, GMUser user)
    {
        List <Dictionary <string, object> > dataList =
            DBMgr.getInstance().executeQuery(TableName.STAT_PLAYER_GAME_BET_RESULT, user.getDbServerID(), DbName.DB_PUMP, imq,
                                             0, 0, null, "genTime", false);

        if (dataList == null || dataList.Count == 0)
        {
            return(OpRes.op_res_not_found_data);
        }

        int i = 0;

        for (i = 0; i < dataList.Count; i++)
        {
            ResultItemPlayerGameBet tmp = new ResultItemPlayerGameBet();
            m_result.Add(tmp);

            Dictionary <string, object> data = dataList[i];
            tmp.m_time     = Convert.ToDateTime(data["genTime"]).ToLocalTime();
            tmp.m_round    = Convert.ToInt32(data["round"]);
            tmp.m_playerId = Convert.ToInt32(data["playerId"]);
            tmp.m_gameId   = Convert.ToInt32(data["gameId"]);

            long max = Convert.ToInt64(data["maxCarry"]);
            long min = Convert.ToInt64(data["minCarry"]);
            long sum = Convert.ToInt64(data["sumCarry"]);
            tmp.addData(ResultItemPlayerGameBet.CARRY, sum, max, min);

            max = Convert.ToInt64(data["maxOutlay"]);
            min = Convert.ToInt64(data["minOutlay"]);
            sum = Convert.ToInt64(data["sumOutlay"]);
            tmp.addData(ResultItemPlayerGameBet.OUTLAY, sum, max, min);

            max = Convert.ToInt64(data["maxWin"]);
            min = Convert.ToInt64(data["minWin"]);
            sum = Convert.ToInt64(data["sumWin"]);
            tmp.addData(ResultItemPlayerGameBet.WIN, sum, max, min);

            max = Convert.ToInt64(data["maxLose"]);
            min = Convert.ToInt64(data["minLose"]);
            sum = Convert.ToInt64(data["sumLose"]);
            tmp.addData(ResultItemPlayerGameBet.LOSE, sum, max, min);
        }

        return(OpRes.opres_success);
    }