string processBlackInfo(string parm) { string res = ""; try { List <UserRanking> lst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString()); if (lst != null && lst.Count > 0) { int cnt = int.Parse(parm); for (int i = 0; i < lst.Count; ++i) { if (i >= cnt) { break; } res += lst[i].UserName + "###" + lst[i].Score; if (i + 1 < cnt) { res += ","; } } } else { res = "排行榜正在更新,或排行榜为空"; } } catch (System.Exception e) { res = e.Message; } return(res); }
string processModify(string parm) { string info = ""; string[] p = parm.Split(','); string modifyWhich = p[0]; int index = int.Parse(p[1]) - 1; int score = int.Parse(p[2]); if ("ranking" == modifyWhich) { UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(index); if (null == ur) { info = "要修改的数据不存在"; } else { var cache = new ShareCacheStruct <UserRanking>(); UserRanking theUR = cache.FindKey(ur.UserID); theUR.ModifyLocked(() => { theUR.Score = score; }); info = "修改数据成功"; } } return(info); }
void doAdd_black(string parm) { string[] usridStr = parm.Split(','); for (int i = 0; i < usridStr.Length; ++i) { try { int index = int.Parse(usridStr[i]); var cache = new ShareCacheStruct <UserRanking>(); List <UserRanking> lst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString()); UserRanking ur = null; if (lst != null && lst.Count > index) { ur = lst[index]; } var blackCache = new ShareCacheStruct <BlackListData>(); if (ur != null) { blackCache.Add(UR2BLD(ur)); ConsoleLog.showNotifyInfo("add to black list id:" + UserId); } else { ConsoleLog.showErrorInfo(0, "not find userRanking id:" + UserId); } } catch (System.Exception e) { ConsoleLog.showErrorInfo(0, "black list exception:" + e.Message); } } }
public override bool TakeAction() { RankingFactorNew.Singleton().Loop <UserRankingTotal>(typeof(RankingTotal).ToString(), cbFuncRankingTotal); var cache = new PersonalCacheStruct <GameUser>(); GameUser p = null; if (requestPack.UserID > 0) { p = cache.FindKey(requestPack.UserID.ToString()); } if (p == null) { RankingFactorNew.Singleton().Loop <UserRanking>(typeof(RankingScore).ToString(), cbFuncDuang); } else { if (p.version != "1.08") { RankingFactorNew.Singleton().Loop <UserRanking>(typeof(RankingScore).ToString(), cbFuncDuang); } else { RankingFactorNew.Singleton().Loop <UserRanking>(typeof(RankingScore).ToString(), cbFunc8self8); } } return(true); }
public void doIt() { ConsoleLog.showNotifyInfo("RankingClear Begin:"); RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); RankingFactorNew.Singleton().Loop <UserRanking>(typeof(RankingScore).ToString(), addRankingReward); // get fake data. // getFake(); // memoryData,clear lst and unload sharecache RankingFactorNew.Singleton().Clear <UserRanking>(typeof(RankingScore).ToString()); // redis delete List <int> keysremove = new List <int>(); var urcache = new ShareCacheStruct <UserRanking>(); float percent = GameConfigMgr.Instance().getInt("rankclear_perscent", 1) / 100.0f; int reduceScore = GameConfigMgr.Instance().getInt("rank_score_redice", 10000); float reduceAfterScorre = GameConfigMgr.Instance().getfloat("rank_clear_after", 0.1f); urcache.Foreach((string str, UserRanking ur) => { if (ur.Score > reduceScore) { ur.ModifyLocked(() => { ur.Score = (int)(reduceAfterScorre * ur.Score); }); } return(true); }); // ZyGames.Framework.Redis.RedisConnectionPool.Process(client => // { // string delKey = "$" + typeof(UserRanking).ToString(); // for(int i=0; i<keysremove.Count; ++i) // { // byte[] byteKeys = Encoding.UTF8.GetBytes(keysremove[i].ToString()); // client.HDel(delKey, byteKeys); // } // }); // mysql delete // var dbProvider = DbConnectionProvider.CreateDbProvider("ConnData"); // var command = dbProvider.CreateCommandStruct("UserRanking", CommandMode.Delete); // command.Parser(); // dbProvider.ExecuteQuery(System.Data.CommandType.Text, command.Sql, command.Parameters); // update UserRankingTotal RankingFactorNew.Singleton().Refresh <UserRankingTotal>(typeof(RankingTotal).ToString()); // add fake data mybe this is has not data .... // setFake(); RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); ConsoleLog.showNotifyInfo("RankingClear End"); }
void setFake() { // add fake UserRanking Data at ConsoleLog.showNotifyInfo("setFake:" + fakeLst.Count); var cache = new ShareCacheStruct <UserRanking>(); for (int i = 0; i < fakeLst.Count; ++i) { cache.Add(copy(fakeLst[i])); } fakeLst.Clear(); fakeLst = null; RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); }
void doAdd_delById(string parm) { string[] ids = parm.Split(','); for (int i = 0; i < ids.Length; ++i) { var urCache = new ShareCacheStruct <UserRanking>(); int id = int.Parse(ids[i]); UserRanking ur = urCache.FindKey(id); if (ur != null) { urCache.Delete(ur); // delete form cache and redis. } } RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); }
void thread_processSort(object theParms) { string parm = theParms as string; string[] p = parm.Split(','); string sortWhich = p[0]; if ("ranking" == sortWhich) { RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); } else if ("rankingtotal" == sortWhich) { RankingFactorNew.Singleton().Refresh <UserRankingTotal>(typeof(RankingTotal).ToString()); } }
void getFake() { ConsoleLog.showNotifyInfo("get fake begin"); fakeLst = new List <UserRanking>(); int num = GameConfigMgr.Instance().getInt("rank_send_num", 10); float percent = GameConfigMgr.Instance().getInt("rankclear_perscent", 1) / 100.0f; int reduceScore = GameConfigMgr.Instance().getInt("rank_score_redice", 1); List <UserRanking> urlst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString()); if (null == urlst) { TraceLog.WriteError("getFake()"); ConsoleLog.showErrorInfo(0, "getFake()"); return; } var rankCache = new ShareCacheStruct <UserRanking>(); var userCache = new PersonalCacheStruct <GameUser>(); for (int i = 0; i < urlst.Count; ++i) { if (i > num) { break; } UserRanking ur = urlst[i]; if (ur.Score > reduceScore) { ur.Score = (int)((float)urlst[i].Score * percent); UserRanking cacheUR = rankCache.FindKey(ur.UserID); if (null != cacheUR) { cacheUR.ModifyLocked(() => { cacheUR.Score = ur.Score; }); } GameUser cacheGU = userCache.FindKey(ur.UserID.ToString()); if (null != cacheGU) { cacheGU.ModifyLocked(() => { cacheGU.Score = ur.Score; }); } } fakeLst.Add(copy(ur)); } ConsoleLog.showNotifyInfo("getFake:" + fakeLst.Count); ConsoleLog.showNotifyInfo("get fake end"); }
string delUserRanking(string parm) { doAdd_black(parm); List <UserRanking> lst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString()); List <UserRanking> delList = new List <UserRanking>(); if (null != lst && lst.Count != 0) { string [] ids = parm.Split(','); for (int i = 0; i < ids.Length; ++i) { int id = int.Parse(ids[i]) - 1; if (id >= lst.Count) { continue; } delList.Add(lst[id]); } } else { return("排行榜正在更新或为空"); } if (delList.Count > 0) { var cache = new ShareCacheStruct <UserRanking>(); resultSTR = "删除的玩家数据:{"; foreach (var v in delList) { cache.Delete(v); resultSTR += v.UserName + ":" + v.Score + ","; } resultSTR += "}"; RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); } else { resultSTR = "要删除的数据不存在"; } return(resultSTR); }
void doAdd_delByIndex(string parm) { string[] p = parm.Split(','); int rankingIndex = int.Parse(p[0]) - 1; UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(rankingIndex); if (null != ur) { var cache = new ShareCacheStruct <UserRanking>(); cache.Delete(ur); var cachePersonal = new PersonalCacheStruct <GameUser>(); GameUser gu = cachePersonal.FindKey(ur.UserID.ToString()); var black = new ShareCacheStruct <BlackListData>(); BlackListData bld = UR2BLD(gu); black.AddOrUpdate(bld); } processSort("ranking"); }
string processDelete(string parm) { string info = ""; string[] p = parm.Split(','); string deleteWhitch = p[0]; int deleteIndex = int.Parse(p[1]) - 1; if ("ranking" == deleteWhitch) { UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(deleteIndex); if (ur == null) { info = "没有找到要删除的数据"; } else { var cache = new ShareCacheStruct <UserRanking>(); cache.Delete(ur); info = "删除数据成功"; } } return(info); }
protected override void OnStartAffer() { new ShareCacheStruct <UserRanking>(); new ShareCacheStruct <HistoryUserRanking>(); new ShareCacheStruct <ExchangeCode>(); new ShareCacheStruct <UserRankingTotal>(); NewGameConfig.Singleton().CreateDBTable(); happyMapInit(); List <GameRanking.Pack.ConfigData> LST_d = new List <GameRanking.Pack.ConfigData>(); NewGameConfig.Singleton().getActivityDate(LST_d, "1.08"); GameConfigMgr.Instance().Start(); RankingFactorNew.Singleton().add <UserRanking>(typeof(RankingScore).ToString(), new RankingScore()); RankingFactorNew.Singleton().add <UserRankingTotal>(typeof(RankingTotal).ToString(), new RankingTotal()); bool openDebug = GameConfigMgr.Instance().getInt("timer_open_debug", 0) == 1; if (openDebug) { string str = GameConfigMgr.Instance().getString("timer_user_ranking", "10000,20000"); RankingFactorNew.Singleton().Start <UserRanking>(typeof(RankingScore).ToString(), sortMethod.sortType.Interval, str); RankingFactorNew.Singleton().Start <UserRankingTotal>(typeof(RankingTotal).ToString(), sortMethod.sortType.Interval, str); } else { string strTiming = GameConfigMgr.Instance().getString("timer_user_ranking_timming", "00:00"); RankingFactorNew.Singleton().Start <UserRanking>(typeof(RankingScore).ToString(), sortMethod.sortType.Timing, strTiming); RankingFactorNew.Singleton().Start <UserRankingTotal>(typeof(RankingTotal).ToString(), sortMethod.sortType.Timing, strTiming); ConsoleLog.showNotifyInfo("timer_user_ranking_timming begin:" + strTiming); } RankingClear.Instance().Start(); RealItemCntUpdate.Instance().Start(); }
void doAdd() { var urCatch = new ShareCacheStruct <UserRanking>(); string paramStr = requestPack.param; string[] arrStr = paramStr.Split('#'); string cmd = arrStr[0]; string parm = arrStr[1]; if ("rankingReward" == cmd) { processRankingReward(parm); } else if ("sort" == cmd) { processSort(parm); } else if ("modifyByIndex" == cmd) { processModify(parm); } else if ("addByIndex" == cmd) { processAdd(parm); } else if ("deleteByIndex" == cmd) { processDelete(parm); } else if ("modifyByUserID" == cmd) { doAddModify(parm); } else if ("delById" == cmd) { doAdd_black(parm); doAdd_delById(parm); } else if ("delByIndex" == cmd) { doAdd_delByIndex(parm); } else if ("from" == cmd) { } else if ("save" == cmd) { } else if ("trans" == cmd) { } else if ("update" == cmd) { RankingFactorNew.Singleton().Refresh <UserRankingTotal>(typeof(RankingTotal).ToString()); RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); } else if ("black" == cmd) { doAdd_black(parm); } else if ("del" == cmd) { doAdd_del(parm); } else if ("order" == cmd) { doAdd_order(parm); } else if ("3rdid" == cmd) { doAdd_PayUserInfo(parm); } else if ("finishOrder" == cmd) { doAdd_finishOrder(parm); } else if ("allServerCompensation" == cmd) { doAdd_allServerCompensation(parm); } else if ("enterCnt" == cmd) { doAdd_enterCnt(parm); } else if ("clearRanking" == cmd) { doAdd_clearRanking(parm); } else if ("reCreateHappy" == cmd) { doAdd_reCreateHappy(parm); } else if ("happyDataFormat" == cmd) { doAdd_HappyDataFormat(parm); } else if ("happyDataMap" == cmd) { doAdd_HappyDataMap(parm); } else if ("happyDataAddItem" == cmd) { doAdd_HappyDataAddItem(parm); } else if ("optMapKey" == cmd) { doAdd_RemoveMap(parm); } else if ("addHMD" == cmd) { doAdd_HMD(parm); } else if ("doFrom" == cmd) { doAdd_DoFrom(parm); } }