Exemplo n.º 1
0
    void statPaytype(IMongoQuery imq, ChannelInfo cinfo)
    {
        MapReduceResult mapResult = MongodbPayment.Instance.executeMapReduce(cinfo.m_paymentTable,
                                                                             imq,
                                                                             MapReduceTable.getMap("rechargePayType"),
                                                                             MapReduceTable.getReduce("rechargePayType"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                int       payType  = Convert.ToInt32(d["_id"]);
                BsonValue resValue = d["value"];

                int total          = resValue["total"].ToInt32();
                int rechargePerson = resValue["rechargePerson"].ToInt32();
                int rechargeCount  = resValue["rechargeCount"].ToInt32();

                Dictionary <string, object> upData = new Dictionary <string, object>();
                upData.Add("genTime", cinfo.m_statDay.Date.AddDays(-1));
                upData.Add("channel", cinfo.m_channelNum);
                upData.Add(payType.ToString() + "_rmb", total);
                upData.Add(payType.ToString() + "_rechargePerson", rechargePerson);
                upData.Add(payType.ToString() + "_rechargeCount", rechargeCount);

                IMongoQuery upCond = Query.And(Query.EQ("genTime", cinfo.m_statDay.Date.AddDays(-1)),
                                               Query.EQ("channel", cinfo.m_channelNum));
                string str = MongodbAccount.Instance.ExecuteStoreByQuery(TableName.CHANNEL_TD_PAY, upCond, upData);
            }
        }
    }
    List <int> getPlayerList()
    {
        List <int> playerList = new List <int>();

        IMongoQuery imq1 = Query.LT("genTime", BsonValue.Create(m_statDay));
        IMongoQuery imq2 = Query.GTE("genTime", BsonValue.Create(m_statDay.AddMinutes(-STAT_DELTA)));
        IMongoQuery imq  = Query.And(imq1, imq2);

        MapReduceResult mapResult = DBMgr.getInstance().executeMapReduce(TableName.LOG_PLAYER_INFO,
                                                                         0,
                                                                         DbName.DB_PUMP,
                                                                         imq,
                                                                         MapReduceTable.getMap("winLosePlayer"),
                                                                         MapReduceTable.getReduce("winLosePlayer"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    int playerId = Convert.ToInt32(d["_id"]);
                    playerList.Add(playerId);
                }
                catch (System.Exception ex)
                {
                }
            }
        }
        return(playerList);
    }
Exemplo n.º 3
0
    public override void doStat(object param, StatResult result)
    {
        ParamStat p = (ParamStat)param;

        ChannelInfo cinfo = p.m_channel;

        DateTime    mint = cinfo.m_statDay.Date.AddDays(-1), maxt = cinfo.m_statDay.Date;
        IMongoQuery imq1 = Query.LT("time", BsonValue.Create(maxt));
        IMongoQuery imq2 = Query.GTE("time", BsonValue.Create(mint));
        IMongoQuery imq3 = Query.EQ("channel", BsonValue.Create(cinfo.m_channelNum));

        IMongoQuery imq = Query.And(imq1, imq2, imq3);

        MapReduceResult mapResult = MongodbPayment.Instance.executeMapReduce(cinfo.m_paymentTable,
                                                                             imq,
                                                                             MapReduceTable.getMap("recharge"),
                                                                             MapReduceTable.getReduce("recharge"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                result.m_totalIncome += resValue["total"].ToInt32();
                result.m_rechargePersonNum++;
                result.m_rechargeCount += resValue["rechargeCount"].ToInt32();
            }
        }

        statPaytype(imq, cinfo);
    }
Exemplo n.º 4
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        m_result.reset();
        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.PLAYER_INFO,
                                                                          user.getDbServerID(),
                                                                          DbName.DB_PLAYER,
                                                                          null,
                                                                          MapReduceTable.getMap("vipLevel"),
                                                                          MapReduceTable.getReduce("vipLevel"));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    BsonValue resValue = d["value"];
                    int       count    = resValue["count"].ToInt32();
                    int       vip      = Convert.ToInt32(d["_id"]);
                    m_result.addVipLevel(vip, count);
                }
                catch (System.Exception ex)
                {
                }
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 5
0
    Dictionary <int, IncomeExInfo> calStartRemain(IMongoQuery imq)
    {
        Dictionary <int, IncomeExInfo> ret = new Dictionary <int, IncomeExInfo>();

        MapReduceResult mapResult = MongodbLog.Instance.executeMapReduce(TableName.PUMP_PLAYER_MONEY,
                                                                         imq,
                                                                         MapReduceTable.getMap("iteratorPlayer"),
                                                                         MapReduceTable.getReduce("iteratorPlayer"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                int playerId = Convert.ToInt32(d["_id"]);

                sr(playerId, 1, imq, ret);
                sr(playerId, 2, imq, ret);
                sr(playerId, 11, imq, ret);
                sr(playerId, 14, imq, ret);
            }

            IncomeExInfo info = new IncomeExInfo();
            info.m_start = bson.Count();
            ret[-1]      = info;
        }

        return(ret);
    }
Exemplo n.º 6
0
    public override void update(double delta)
    {
        if (DateTime.Now.Date < m_statDay)
        {
            return;
        }

        beginStat("StatNewPlayerOutlayDistribution开始统计");

        DateTime    startTime = m_statDay.Date.AddDays(-1);
        IMongoQuery imq1      = Query.LT("genTime", m_statDay);
        IMongoQuery imq2      = Query.GTE("genTime", startTime);
        // pumpPlayerMoney表,需新增playerCreateTime字段
        IMongoQuery imq3 = Query.LT("playerCreateTime", m_statDay);
        IMongoQuery imq4 = Query.GTE("playerCreateTime", startTime);
        IMongoQuery imq  = Query.And(imq1, imq2, imq3, imq4,
                                     Query.EQ("reason", (int)PropertyReasonType.type_reason_single_round_balance));

        MapReduceResult mapResult = MongodbLog.Instance.executeMapReduce(TableName.PUMP_PLAYER_MONEY,
                                                                         imq,
                                                                         MapReduceTable.getMap("newPlayerOutlay"),
                                                                         MapReduceTable.getReduce("newPlayerOutlay"),
                                                                         TableName.STAT_NEW_PLAYER_OUTLAY_DISTRIBUTION + "_map");

        if (mapResult != null)
        {
            MapReduceResult mapResult1 = MongodbLog.Instance.executeMapReduce(TableName.STAT_NEW_PLAYER_OUTLAY_DISTRIBUTION + "_map",
                                                                              null,
                                                                              MapReduceTable.getMap("newPlayerOutlayDistribution"),
                                                                              MapReduceTable.getReduce("newPlayerOutlayDistribution"));
            if (mapResult1 != null)
            {
                IEnumerable <BsonDocument> bson = mapResult1.GetResults();
                foreach (BsonDocument d in bson)
                {
                    BsonDocument resValue = (BsonDocument)d["value"];
                    Dictionary <string, object> upData = new Dictionary <string, object>();
                    upData.Add("genTime", startTime);
                    foreach (var key in resValue.Names)
                    {
                        int num = resValue[key].ToInt32();
                        upData.Add(key, num);
                    }

                    MongodbLog.Instance.ExecuteInsert(TableName.STAT_NEW_PLAYER_OUTLAY_DISTRIBUTION, upData);
                }
            }
        }

        addStatDay();

        endStat("StatNewPlayerOutlayDistribution结束统计");
    }
Exemplo n.º 7
0
    // 开始统计,返回0成功
    public override int doStat(object param)
    {
        m_result.reset();
        int retCode = 0;

        DBMgr.getInstance().checkDb(m_serverId);

        ParamStatWinLose   p         = (ParamStatWinLose)param;
        List <IMongoQuery> queryList = new List <IMongoQuery>();

        IMongoQuery imq1 = Query.LT("genTime", BsonValue.Create(p.m_end));
        IMongoQuery imq2 = Query.GTE("genTime", BsonValue.Create(p.m_start));

        queryList.Add(Query.And(imq1, imq2));
        queryList.Add(Query.EQ("playerId", BsonValue.Create(p.m_playerId)));
        IMongoQuery imq = Query.And(queryList);

        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.LOG_PLAYER_INFO,
                                                                          m_serverId,
                                                                          DbName.DB_PUMP,
                                                                          imq,
                                                                          MapReduceTable.getMap(m_algKey),
                                                                          MapReduceTable.getReduce(m_algKey));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    m_result.m_playerId = Convert.ToInt32(d["_id"]);

                    BsonValue resValue = d["value"];
                    m_result.m_playerOutlay = Convert.ToInt64(resValue["playerOutlay"]);
                    m_result.m_playerIncome = Convert.ToInt64(resValue["playerIncome"]);
                    m_result.m_washCount    = Convert.ToInt64(resValue["washCount"]);
                }
                catch (System.Exception ex)
                {
                    retCode = FunRet.RET_HAS_EXCEPTION;
                    LogMgr.log.Error("StatWinLoseA:" + ex.ToString());
                }
            }
        }
        else
        {
            retCode = FunRet.RET_HAS_EXCEPTION;
        }

        return(retCode);
    }
Exemplo n.º 8
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        ParamQueryRecharge p   = (ParamQueryRecharge)param;
        QueryMgr           mgr = user.getSys <QueryMgr>(SysType.sysTypeQuery);

        m_cond.startQuery();
        OpRes res = mgr.makeQuery(param, QueryType.queryTypeRecharge, user, m_cond);

        if (res != OpRes.opres_success)
        {
            return(res);
        }

        IMongoQuery   imq = m_cond.getImq();
        QueryDocument qd  = (QueryDocument)imq;

        if (!qd.Contains("PayTime"))
        {
            return(OpRes.op_res_time_format_error);
        }

        m_result.Clear();
        QueryRecharge   rq         = mgr.getQuery <QueryRecharge>(QueryType.queryTypeRecharge);
        int             serverId   = DBMgr.getInstance().getSpecialServerId(DbName.DB_PAYMENT);
        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(rq.getPlatInfo().m_tableName,
                                                                          serverId,
                                                                          DbName.DB_PAYMENT,
                                                                          imq,
                                                                          MapReduceTable.getMap("sameOrderId"),
                                                                          MapReduceTable.getReduce("sameOrderId"));
        int count = 0;

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                count = resValue["total"].ToInt32();
                if (count > 1)
                {
                    ResultSameOrderIdItem tmp = new ResultSameOrderIdItem();
                    m_result.Add(tmp);
                    tmp.m_count   = count;
                    tmp.m_orderId = Convert.ToString(d["_id"]);
                }
            }
        }
        return(OpRes.opres_success);
    }
    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);
    }
Exemplo n.º 10
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        IMongoQuery imqTime = null;
        string      time    = (string)param;

        if (!string.IsNullOrEmpty(time))
        {
            DateTime mint = DateTime.Now, maxt = DateTime.Now;
            bool     res = Tool.splitTimeStr(time, ref mint, ref maxt);
            if (!res)
            {
                return(OpRes.op_res_time_format_error);
            }

            m_result.reset();

            IMongoQuery imq1 = Query.LT("create_time", BsonValue.Create(maxt));
            IMongoQuery imq2 = Query.GTE("create_time", BsonValue.Create(mint));
            imqTime = Query.And(imq1, imq2);
        }

        m_result.reset();
        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.PLAYER_INFO,
                                                                          user.getDbServerID(),
                                                                          DbName.DB_PLAYER,
                                                                          imqTime,
                                                                          MapReduceTable.getMap("vipLevel"),
                                                                          MapReduceTable.getReduce("vipLevel"));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    BsonValue resValue = d["value"];
                    int       count    = resValue["count"].ToInt32();
                    int       vip      = Convert.ToInt32(d["_id"]);
                    m_result.addVipLevel(vip, count);
                }
                catch (System.Exception ex)
                {
                }
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 11
0
    int statPlayerRecharge(ChannelInfo cinfo, IMongoQuery cond, string acc)
    {
        IMongoQuery     imq       = Query.And(cond, Query.EQ(StatLTV.ACC_KEY_1, acc));
        MapReduceResult mapResult = MongodbPayment.Instance.executeMapReduce(cinfo.m_paymentTable,
                                                                             imq,
                                                                             MapReduceTable.getMap("recharge"),
                                                                             MapReduceTable.getReduce("recharge"));
        int total = 0;

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                total += resValue["total"].ToInt32();
            }
        }
        return(total);
    }
Exemplo n.º 12
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        string   time = (string)param;
        DateTime mint = DateTime.Now, maxt = DateTime.Now;
        bool     res = Tool.splitTimeStr(time, ref mint, ref maxt);

        if (!res)
        {
            return(OpRes.op_res_time_format_error);
        }

        IMongoQuery imq1 = Query.LT("genTime", BsonValue.Create(maxt));
        IMongoQuery imq2 = Query.GTE("genTime", BsonValue.Create(mint));
        IMongoQuery imq  = Query.And(imq1, imq2);

        m_result.Clear();
        MapReduceResult mapResult = getMapReduceResult(imq, user);

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue    resValue = d["value"];
                ResultActive tmp      = new ResultActive();
                m_result.Add(tmp);
                tmp.m_time  = Convert.ToDateTime(d["_id"]).ToLocalTime().ToString();
                tmp.m_game1 = resValue["game1"].ToInt32();
                tmp.m_game2 = resValue["game2"].ToInt32();
                tmp.m_game3 = resValue["game3"].ToInt32();
                tmp.m_game4 = resValue["game4"].ToInt32();
                tmp.m_game5 = resValue["game5"].ToInt32();
                tmp.m_game6 = resValue["game6"].ToInt32();
                tmp.m_game7 = resValue["game7"].ToInt32();
                tmp.m_game8 = resValue["game8"].ToInt32();
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 13
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        ParamQueryRecharge p   = (ParamQueryRecharge)param;
        QueryMgr           mgr = user.getSys <QueryMgr>(SysType.sysTypeQuery);

        m_cond.startQuery();
        OpRes res = mgr.makeQuery(param, QueryType.queryTypeRecharge, user, m_cond);

        if (res != OpRes.opres_success)
        {
            return(res);
        }

        IMongoQuery imq = m_cond.getImq();

        m_result.reset();
        QueryRecharge   rq         = mgr.getQuery <QueryRecharge>(QueryType.queryTypeRecharge);
        int             serverId   = DBMgr.getInstance().getSpecialServerId(DbName.DB_PAYMENT);
        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(rq.getPlatInfo().m_tableName,
                                                                          serverId,
                                                                          DbName.DB_PAYMENT,
                                                                          imq,
                                                                          MapReduceTable.getMap("recharge"),
                                                                          MapReduceTable.getReduce("recharge"));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                m_result.m_total += resValue["total"].ToInt32();
                m_result.m_rechargePersonNum++;
                m_result.m_rechargeCount += resValue["rechargeCount"].ToInt32();
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 14
0
    void stat()
    {
        // DateTime now = DateTime.Now;
        //IMongoQuery imq1 = Query.GTE("logout_time", now.AddDays(-7));
        //IMongoQuery imq2 = Query.EQ("is_robot", false);
        //IMongoQuery imq = Query.And(imq1, imq2);
        IMongoQuery     imq       = Query.EQ("is_robot", false);
        MapReduceResult mapResult = MongodbPlayer.Instance.executeMapReduce(TableName.PLAYER_INFO,
                                                                            imq,
                                                                            MapReduceTable.getMap("totalMoney"),
                                                                            MapReduceTable.getReduce("totalMoney"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                m_moneyTotal = resValue["total"].ToInt64();
                m_safeBox    = resValue["box"].ToInt64();
            }
        }
    }
Exemplo n.º 15
0
    void stat()
    {
        DateTime    startTime = m_statDay.AddDays(-1);
        DateTime    endTime   = m_statDay;
        IMongoQuery imq1      = Query.LT("genTime", BsonValue.Create(endTime));
        IMongoQuery imq2      = Query.GTE("genTime", BsonValue.Create(startTime));
        IMongoQuery imq       = Query.And(imq1, imq2);

        beginStat("StatPlayerTotalIncomeExpensesNew MapReduce开始统计");

        MapReduceResult mapResult = MongodbLog.Instance.executeMapReduce(TableName.PUMP_PLAYER_MONEY,
                                                                         imq,
                                                                         MapReduceTable.getMap("incomeExpensesNew"),
                                                                         MapReduceTable.getReduce("incomeExpensesNew"));

        endStat("StatPlayerTotalIncomeExpensesNew MapReduce结束统计");

        if (mapResult != null)
        {
            beginStat("StatPlayerTotalIncomeExpensesNew 开始写入数据");
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            StatIncomeExpensesItemBase item = new StatIncomeExpensesItemBase();
            foreach (BsonDocument d in bson)
            {
                BsonValue    resValue = d["value"];
                BsonDocument bd       = (BsonDocument)resValue;
                foreach (var gameName in bd.Names)
                {
                    int gameId = Convert.ToInt32(gameName);

                    BsonDocument gameData = (BsonDocument)bd[gameName];
                    foreach (var itemId in gameData.Names)
                    {
                        Dictionary <string, object> upData = new Dictionary <string, object>();
                        upData.Add("genTime", startTime);
                        upData.Add("gameId", gameId);
                        upData.Add("itemId", Convert.ToInt32(itemId));

                        BsonDocument itemData = (BsonDocument)gameData[itemId];

                        bool isAdd = false;
                        foreach (var ulkey in itemData.Names)
                        {
                            BsonDocument uldate = (BsonDocument)itemData[ulkey];
                            long         income = uldate["income"].ToInt64();
                            long         outlay = uldate["outlay"].ToInt64();
                            if (income > 0)
                            {
                                upData.Add(ulkey + "z", income);
                                isAdd = true;
                            }
                            if (outlay > 0)
                            {
                                upData.Add(ulkey + "f", outlay);
                                isAdd = true;
                            }
                        }

                        if (isAdd)
                        {
                            MongodbLog.Instance.ExecuteInsert(TableName.STAT_INCOME_EXPENSES_NEW, upData);
                        }
                    }
                }
            }

            endStat("StatPlayerTotalIncomeExpensesNew 结束写入数据");
        }

        IMongoQuery imq3 = Query.EQ("is_robot", false);

        MapReduceResult mapResult1 = MongodbPlayer.Instance.executeMapReduce(TableName.PLAYER_INFO,
                                                                             imq3,
                                                                             MapReduceTable.getMap("incomeExpensesRemain"),
                                                                             MapReduceTable.getReduce("incomeExpensesRemain"));

        if (mapResult1 != null)
        {
            IEnumerable <BsonDocument> bson = mapResult1.GetResults();
            StatIncomeExpensesItemBase item = new StatIncomeExpensesItemBase();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];

                item.m_goldRemain = resValue["goldRemain"].ToInt64();
                item.m_gemRemain  = resValue["gemRemain"].ToInt64();
                item.m_dbRemain   = resValue["dbRemain"].ToInt64();
                item.m_chipRemain = resValue["chipRemain"].ToInt64();

                Dictionary <int, IncomeExInfo> incomeInfo = calStartRemain(imq);

                addDataRemain(item, startTime, incomeInfo);
            }
        }
    }
Exemplo n.º 16
0
    // 开始统计
    public override OpRes doStat(object param, GMUser user)
    {
        ParamQuery p = (ParamQuery)param;

        if (string.IsNullOrEmpty(p.m_time))
        {
            return(OpRes.op_res_time_format_error);
        }

        DateTime mint = DateTime.Now, maxt = DateTime.Now;
        bool     res = Tool.splitTimeStr(p.m_time, ref mint, ref maxt);

        if (!res)
        {
            return(OpRes.op_res_time_format_error);
        }

        m_result.Clear();

        int serverId = DBMgr.getInstance().getSpecialServerId(DbName.DB_ACCOUNT);

        if (serverId == -1)
        {
            return(OpRes.op_res_failed);
        }

        IMongoQuery imq1    = Query.LT("genTime", BsonValue.Create(maxt));
        IMongoQuery imq2    = Query.GTE("genTime", BsonValue.Create(mint));
        IMongoQuery imqTime = Query.And(imq1, imq2);

        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.CHANNEL_TD,
                                                                          serverId,
                                                                          DbName.DB_ACCOUNT,
                                                                          imqTime,
                                                                          MapReduceTable.getMap("LTV"),
                                                                          MapReduceTable.getReduce("LTV"));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    ResultLTVItem tmp = new ResultLTVItem();
                    tmp.m_genTime = Convert.ToDateTime(d["_id"]).ToLocalTime().ToShortDateString();
                    BsonValue resValue = d["value"];
                    tmp.m_regeditCount       = resValue["regeditCount"].ToInt32();
                    tmp.m_1DayTotalRecharge  = resValue["day1TotalRecharge"].ToInt32();
                    tmp.m_3DayTotalRecharge  = resValue["day3TotalRecharge"].ToInt32();
                    tmp.m_7DayTotalRecharge  = resValue["day7TotalRecharge"].ToInt32();
                    tmp.m_14DayTotalRecharge = resValue["day14TotalRecharge"].ToInt32();
                    tmp.m_30DayTotalRecharge = resValue["day30TotalRecharge"].ToInt32();
                    tmp.m_60DayTotalRecharge = resValue["day60TotalRecharge"].ToInt32();
                    tmp.m_90DayTotalRecharge = resValue["day90TotalRecharge"].ToInt32();

                    m_result.Add(tmp);
                }
                catch (System.Exception ex)
                {
                }
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 17
0
    public override OpRes exportData(StreamWriter sheet, ExportParam param, int dbServerId)
    {
        for (int i = 0; i < s_head.Length; i++)
        {
            sheet.Write(s_head[i]);
            sheet.Write(',');
        }
        sheet.WriteLine();

        MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.PUMP_RECHARGE_PLAYER,
                                                                          dbServerId,
                                                                          DbName.DB_PUMP,
                                                                          m_imq,
                                                                          MapReduceTable.getMap("rechargePlayer"),
                                                                          MapReduceTable.getReduce("rechargePlayer"));

        if (map_result != null)
        {
            IEnumerable <BsonDocument> bson = map_result.GetResults();
            foreach (BsonDocument d in bson)
            {
                try
                {
                    ResultRPlayerItem tmp = new ResultRPlayerItem();

                    tmp.m_playerId = Convert.ToInt32(d["_id"]);
                    BsonValue resValue = d["value"];
                    tmp.m_rechargeCount = resValue["rechargeCount"].ToInt32();
                    tmp.m_rechargeMoney = resValue["rechargeMoney"].ToInt32();
                    tmp.m_loginCount    = resValue["loginCount"].ToInt32();

                    var arr = resValue["enterGame"].AsBsonArray;
                    for (int i = 0; i < arr.Count; i++)
                    {
                        tmp.addEnterCount(i + 1, arr[i].ToInt32());
                    }

                    Dictionary <string, object> pd = ExportExcelBase.getPlayerProperty(tmp.m_playerId, dbServerId, s_fields);
                    if (pd != null)
                    {
                        tmp.m_mostGold      = Convert.ToInt32(pd["maxGold"]);
                        tmp.m_remainGold    = Convert.ToInt32(pd["gold"]);
                        tmp.m_regTime       = Convert.ToDateTime(pd["create_time"]).ToLocalTime();
                        tmp.m_lastLoginTime = Convert.ToDateTime(pd["logout_time"]).ToLocalTime();
                    }

                    sheet.Write(tmp.m_playerId); sheet.Write(",");
                    sheet.Write(tmp.m_rechargeCount); sheet.Write(",");
                    sheet.Write(tmp.m_rechargeMoney); sheet.Write(",");

                    sheet.Write(tmp.m_regTime.ToString()); sheet.Write(",");
                    sheet.Write(tmp.m_loginCount); sheet.Write(",");
                    sheet.Write(tmp.m_remainGold); sheet.Write(",");
                    sheet.Write(tmp.m_lastLoginTime.ToString()); sheet.Write(",");
                    sheet.Write(tmp.m_mostGold); sheet.Write(",");

                    sheet.Write(tmp.getEnterCount((int)GameId.fishlord)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.shcd)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.cows)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.dragon)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.crocodile)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.baccarat)); sheet.Write(",");
                    sheet.Write(tmp.getEnterCount((int)GameId.dice));

                    sheet.WriteLine();
                }
                catch (System.Exception ex)
                {
                }
            }
        }
        return(OpRes.opres_success);
    }
Exemplo n.º 18
0
        public String Mapreduced(Dictionary <string, string> fields, List <string> movement = null, List <string> objs = null, List <string> locations = null, List <string> users = null, Int64 start = 0, Int64 end = 0)
        {
            var orderfield = "folio";


            try
            {
                List <string> cols = new List <string>();
                foreach (var x in fields)
                {
                    cols.Add(x.Key);
                }
                cols.Add("CreatedTimeStamp");
                string[] arrayfields    = cols.ToArray();
                string[] arraymov       = movement.ToArray();
                string[] arrayobjs      = objs.ToArray();
                string[] arraylocations = locations.ToArray();
                string[] arrayusers     = users.ToArray();

                BsonArray bsonarraymov   = new BsonArray();
                BsonArray bsonarrayobjs  = new BsonArray();
                BsonArray bsonarrayloc   = new BsonArray();
                BsonArray bsonarrayusers = new BsonArray();
                for (int i = 0; i < arraymov.Length; i++)
                {
                    bsonarraymov.Add(arraymov[i]);
                }
                for (int i = 0; i < arrayobjs.Length; i++)
                {
                    bsonarrayobjs.Add(arrayobjs[i]);
                }
                for (int i = 0; i < arraylocations.Length; i++)
                {
                    bsonarrayloc.Add(arraylocations[i]);
                }
                for (int i = 0; i < arrayusers.Length; i++)
                {
                    bsonarrayusers.Add(arrayusers[i]);
                }


                List <BsonDocument> documents = new List <BsonDocument>();

                var query = Query.And(Query.In("movement", bsonarraymov), Query.In("object", bsonarrayobjs), Query.In("location", bsonarrayloc), Query.In("Creator", bsonarrayusers), Query.GTE("CreatedTimeStamp", start), Query.LTE("CreatedTimeStamp", end));

                /*Realiza la conexion */
                MongoCollection Demand    = conection.getCollection("Demand");
                MongoCollection Movements = conection1.getCollection("MovementProfiles");
                MongoCollection Locations = conection2.getCollection("Locations");

                var Movementsfunction = @"function() {
                var key = this._id.valueOf();
                var value={movement:this.name};
                 emit(key,value);
                   }";
                var Locationsfunction = @"function() {
                var key = this._id.valueOf();
                var value={location:this.name};
                 emit(key,value);
                   }";
                var Demandfunction    = @"function() {
                    var key = this.movement;
                     var value = {id:this._id.valueOf(),folio:this.folio,object:this.object,total:this.total,status:this.status,movementFields:this.movementFields,CreatedDate:this.CreatedDate,CreatedTimeStamp:this.CreatedTimeStamp,Creator:this.Creator,system_status:this.system_status};
                     emit(key,value);
                
                   }";
                var Demandfunction2   = @"function() {
                    var key = this.location;
                     var value = {id:this._id.valueOf(),folio:this.folio,object:this.object,total:this.total,status:this.status,movementFields:this.movementFields,CreatedDate:this.CreatedDate,CreatedTimeStamp:this.CreatedTimeStamp,Creator:this.Creator,system_status:this.system_status};
                     emit(key,value);
                
                   }";

                var reducefunction = @"function (key, values) {
               var reduced = {id:'',folio:'',movement:'',location:'',object:'',total:'',status:'',movementFields:'',CreatedDate:'',CreatedTimeStamp:'',Creator:'',system_status:''};
                var index=0;
              values.forEach(function(value){
              
          
                 
                    if(value.movement != null && reduced.movement ==''){
                    
                    reduced.movement = value.movement;
                  
                    }
                    if(value.location != null && reduced.location == ''){
                    
                    reduced.location = value.location;
                  
                    }
                   
                    if(value.id != null){
                       reduced.id= value.id;
                       reduced.folio = value.folio;
                      
                        reduced.object = value.object;
                        reduced.total = value.total;
                        reduced.status = value.status;
                        reduced.movementFields = value.movementFields;
                        reduced.CreatedDate = value.CreatedDate;
                        reduced.CreatedTimeStamp = value.CreatedTimeStamp;
                        reduced.Creator = value.Creator;
                        reduced.system_status = value.system_status;

                     
                    }
           
            });
           
            return reduced;
          }";

                /*Establece las propiedades a seguir del mapreduce */
                MapReduceOptionsBuilder options = new MapReduceOptionsBuilder();
                options.SetOutput(MapReduceOutput.Inline);
                options.SetOutput(MapReduceOutput.Reduce("result", true));



                /* Realiza los mapreduce sobre el mismo resultado */
                MapReduceResult result = Movements.MapReduce(Movementsfunction, reducefunction, options);
                // result = Locations.MapReduce(Locationsfunction, reducefunction, options);

                result = Demand.MapReduce(Demandfunction, reducefunction, options);
                //    result = Demand.MapReduce(Demandfunction2, reducefunction, options);


                /* resultado en json */
                string results = result.GetResults().ToJson();
                return(results);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 19
0
    public override void update(double delta)
    {
        if (DateTime.Now.Date < m_statDay)
        {
            return;
        }

        beginStat("StatNewPlayerLevelFishActivity开始统计");

        DateTime    startTime = m_statDay.Date.AddDays(-1);
        IMongoQuery imq1      = Query.LT("genTime", m_statDay);
        IMongoQuery imq2      = Query.GTE("genTime", startTime);
        IMongoQuery imq       = Query.And(imq1, imq2);

        MapReduceResult mapResult = MongodbLog.Instance.executeMapReduce(TableName.PUMP_NEW_PLAYER_FIRECOUNT_FISHLEVEL,
                                                                         imq,
                                                                         MapReduceTable.getMap("newPlayerFireCountDistribution"),
                                                                         MapReduceTable.getReduce("newPlayerFireCountDistribution"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonDocument resValue = (BsonDocument)d["value"];
                Dictionary <string, object> upData = new Dictionary <string, object>();
                upData.Add("genTime", startTime);
                foreach (var key in resValue.Names)
                {
                    int num = resValue[key].ToInt32();
                    upData.Add(key, num);
                }

                MongodbLog.Instance.ExecuteInsert(TableName.STAT_NEW_PLAYER_FIRECOUNT_DISTRIBUTION, upData);
            }
        }

        //////////////////////////////////////////////////////////////////////////
        MapReduceResult mapResult1 = MongodbLog.Instance.executeMapReduce(TableName.PUMP_NEW_PLAYER_FIRECOUNT_FISHLEVEL,
                                                                          imq,
                                                                          MapReduceTable.getMap("newPlayerFishLevelDistribution"),
                                                                          MapReduceTable.getReduce("newPlayerFishLevelDistribution"));

        if (mapResult1 != null)
        {
            IEnumerable <BsonDocument> bson = mapResult1.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonDocument resValue = (BsonDocument)d["value"];
                Dictionary <string, object> upData = new Dictionary <string, object>();
                upData.Add("genTime", startTime);
                foreach (var key in resValue.Names)
                {
                    int num = resValue[key].ToInt32();
                    upData.Add(key, num);
                }

                MongodbLog.Instance.ExecuteInsert(TableName.STAT_NEW_PLAYER_FISHLEVEL_DISTRIBUTION, upData);
            }
        }

        addStatDay();

        endStat("StatNewPlayerLevelFishActivity结束统计");
    }