// 开始统计 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); }
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); }
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); }
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); } } }
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); }
protected override MapReduceResult getMapReduceResult(IMongoQuery imq, GMUser user) { MapReduceResult mapResult = DBMgr.getInstance().executeMapReduce(TableName.PUMP_ACTIVE_PERSON, user.getDbServerID(), DbName.DB_PUMP, imq, MapReduceTable.getMap("activePerson"), MapReduceTable.getReduce("activePerson")); return(mapResult); }
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结束统计"); }
// 开始统计,返回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); }
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); }
// 开始统计 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); }
public static string getReduce(string key) { MapReduceTable t = ResMgr.getInstance().getTable <MapReduceTable>("map_reduce.csv"); if (t != null) { MapReduceItem item = t.getItem(key); if (item != null) { return(item.m_reduce); } } return(""); }
// 开始统计 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); }
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); }
// 开始统计 public override OpRes doStat(object param, GMUser user) { m_result.Clear(); m_cond.startQuery(); OpRes res = makeQuery(param, user, m_cond); if (res != OpRes.opres_success) { return(res); } ParamQuery p = (ParamQuery)param; if (isSame(p, user)) { return(query(p, null, user)); } else { m_lastSearchTime = p.m_time; m_dbId = user.getDbServerID(); } IMongoQuery imqTime = m_cond.getImq(); MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.STAT_PLAYER_DRAGON, user.getDbServerID(), DbName.DB_PUMP, imqTime, MapReduceTable.getMap("playerDragonBall"), MapReduceTable.getReduce("playerDragonBall"), MapTable); if (map_result != null) { return(query(p, null, user)); } return(OpRes.opres_success); }
// 开始统计 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); }
// 开始统计 public override OpRes doStat(object param, GMUser user) { m_result.Clear(); m_cond.startQuery(); OpRes res = makeQuery(param, user, m_cond); if (res != OpRes.opres_success) { return(res); } ParamIncomeExpenses p = (ParamIncomeExpenses)param; if (isSame(p, user)) { return(query(p, null, user)); } else { m_lastParam.assign(p, user.getDbServerID()); } IMongoQuery imqTime = m_cond.getImq(); MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(TableName.STAT_INCOME_EXPENSES, user.getDbServerID(), DbName.DB_PUMP, imqTime, MapReduceTable.getMap("playerIncomeExpenses"), MapReduceTable.getReduce("playerIncomeExpenses"), MapTable); if (map_result != null) { return(query(p, null, user)); } return(OpRes.opres_success); }
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(); } } }
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 = MongodbAccount.Instance.executeMapReduce(cinfo.m_loginTable, imq, MapReduceTable.getMap("active"), MapReduceTable.getReduce("active")); if (mapResult != null) { result.m_activeCount = (int)mapResult.OutputCount; } }
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); } } }
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结束统计"); }
// 开始统计 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); }
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); }