public void Update() { if (this.InActivityTime() || this.InAwardTime()) { DateTime now = TimeUtil.NowDateTime(); if (!(now < this.lastUpdateTime.AddSeconds(15.0))) { this.lastUpdateTime = now; InputKingPaiHangDataEx tmpRankEx = KFCopyRpcClient.getInstance().GetPlatChargeKing(); if (tmpRankEx != null) { List <InputKingPaiHangData> tmpRankList = tmpRankEx.ListData; if (tmpRankEx.StartTime != this.FromDate || tmpRankEx.EndTime != this.ToDate) { } if (tmpRankList != null) { bool bNeedSort = false; int i; for (i = 1; i < tmpRankList.Count <InputKingPaiHangData>(); i++) { if (tmpRankList[i].PaiHangValue > tmpRankList[i - 1].PaiHangValue) { bNeedSort = true; break; } } if (bNeedSort) { tmpRankList.Sort((InputKingPaiHangData _left, InputKingPaiHangData _right) => _right.PaiHangValue - _left.PaiHangValue); } tmpRankList.ForEach(delegate(InputKingPaiHangData _item) { _item.PaiHangValue = Global.TransMoneyToYuanBao(_item.PaiHangValue); }); int procListIdx = 0; i = 0; while (i < this.chargeItemList.Count && procListIdx < tmpRankList.Count) { if (tmpRankList[procListIdx].PaiHangValue >= this.chargeItemList[i].NeedChargeYB) { tmpRankList[procListIdx].PaiHang = this.chargeItemList[i].Rank; procListIdx++; } i++; } if (procListIdx < tmpRankList.Count) { tmpRankList.RemoveRange(procListIdx, tmpRankList.Count - procListIdx); } } this.RealRankList = tmpRankList; } } } else { this.RealRankList = null; } }
public void Update() { if (!IsNeedDownload()) { return; } try { ClientServerListData clientListData = new ClientServerListData(); clientListData.lTime = TimeUtil.NOW(); clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString()); byte[] clientBytes = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData); byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl, clientBytes, 2000, 30000); if (responseData == null) { return; } InputKingPaiHangDataEx tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length); if (tmpRankEx != null) { rankEx = tmpRankEx; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, "PlatChargeKingManager.Update exception", ex); } }
public InputKingPaiHangDataEx GetRankEx() { InputKingPaiHangDataEx result = null; lock (this.Mutex) { this.bHasVisitor = true; result = this.rankEx; } return(result); }
public List <InputKingPaiHangDataEx> MergePlatfromInputKingListEveryDay(Dictionary <int, List <InputKingPaiHangDataEx> > EveryPlatfrom) { List <InputKingPaiHangDataEx> res = new List <InputKingPaiHangDataEx>(); List <InputKingPaiHangDataEx> result; if (EveryPlatfrom == null) { result = res; } else { Dictionary <int, List <InputKingPaiHangDataEx> > dict = new Dictionary <int, List <InputKingPaiHangDataEx> >(); int temp = 0; foreach (List <InputKingPaiHangDataEx> iter in EveryPlatfrom.Values) { foreach (InputKingPaiHangDataEx it in iter) { temp++; if (dict.ContainsKey(temp)) { dict[temp].Add(it); } else { dict.Add(temp, new List <InputKingPaiHangDataEx> { it }); } } temp = 0; } foreach (KeyValuePair <int, List <InputKingPaiHangDataEx> > iter2 in dict) { InputKingPaiHangDataEx OnePlatfrom = this.MergePlatfromInputKingList(iter2.Value); if (OnePlatfrom != null) { res.Add(OnePlatfrom); } else { res.Add(new InputKingPaiHangDataEx()); } } result = res; } return(result); }
public override bool CheckCondition(GameClient client, int extTag) { bool result; try { JieriPlatChargeKingEveryDay.ChargeItem ci = null; if (!this.IdVsChargeItemDict.TryGetValue(extTag, out ci)) { result = false; } else { DateTime startTime = DateTime.Parse(this.FromDate); DateTime endTime = DateTime.Parse(this.ToDate); DateTime now = TimeUtil.NowDateTime(); lock (this.Mutex) { if (now < startTime.AddDays((double)ci.Day)) { return(false); } InputKingPaiHangDataEx kfpaihangData = null; if (this._kfRankDict == null || !this._kfRankDict.TryGetValue(ci.Day, out kfpaihangData)) { return(false); } DateTime rankTm; DateTime.TryParse(kfpaihangData.RankTime, out rankTm); if (rankTm < startTime.AddDays((double)ci.Day)) { return(false); } List <InputKingPaiHangData> paihangDataList = null; if (this._realRankDict == null || !this._realRankDict.TryGetValue(ci.Day, out paihangDataList)) { return(false); } InputKingPaiHangData myData = paihangDataList.Find((InputKingPaiHangData x) => 0 == string.Compare(x.UserID, client.strUserID, true)); if (myData == null || myData.PaiHang != ci.Rank) { return(false); } string huoDongKeyStr = Global.GetHuoDongKeyString(this.FromDate, this.ToDate); long hasgettimes = KFCopyRpcClient.getInstance().QueryHuodongAwardUserHist(77, huoDongKeyStr, client.strUserID); if (hasgettimes < 0L) { return(false); } int bitVal = Global.GetBitValue(ci.Day); if ((hasgettimes & (long)bitVal) == (long)bitVal) { return(false); } } result = true; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", this.CfgFile, ex.Message), null, true); result = false; } return(result); }
public InputKingPaiHangDataEx MergePlatfromInputKingList(List <InputKingPaiHangDataEx> EveryPlatfrom) { InputKingPaiHangDataEx InputRes = new InputKingPaiHangDataEx(); InputKingPaiHangDataEx result; if (EveryPlatfrom == null) { result = InputRes; } else { bool flag = false; string RankTime = ""; string StartTime = ""; string EndTime = ""; List <InputKingPaiHangData> list = new List <InputKingPaiHangData>(); foreach (InputKingPaiHangDataEx it in EveryPlatfrom) { if (it != null) { if (it.ListData != null) { if (!flag && !string.IsNullOrEmpty(it.RankTime) && !string.IsNullOrEmpty(it.StartTime) && !string.IsNullOrEmpty(it.EndTime)) { RankTime = it.RankTime; StartTime = it.StartTime; EndTime = it.EndTime; flag = true; } foreach (InputKingPaiHangData iter in it.ListData) { if (iter != null) { list.Add(iter); } } } } } list.Sort(delegate(InputKingPaiHangData _left, InputKingPaiHangData _right) { int result2; if (_left.PaiHangValue > _right.PaiHangValue) { result2 = -1; } else if (_left.PaiHangValue < _right.PaiHangValue) { result2 = 1; } else if (!string.IsNullOrEmpty(_left.InputTime)) { int res = _left.InputTime.CompareTo(_right.InputTime); if (0 == res) { if (!string.IsNullOrEmpty(_left.UserID)) { result2 = _left.UserID.CompareTo(_right.UserID); } else { result2 = 1; } } else { result2 = res; } } else if (!string.IsNullOrEmpty(_left.UserID)) { result2 = _left.UserID.CompareTo(_right.UserID); } else { result2 = 1; } return(result2); }); InputRes.ListData = list; InputRes.RankTime = RankTime; InputRes.StartTime = StartTime; InputRes.EndTime = EndTime; result = InputRes; } return(result); }
public void Update() { try { lock (this.Mutex) { if (this.IsNeedDownload()) { bool flag = false; List <InputKingPaiHangDataEx> list = new List <InputKingPaiHangDataEx>(); if (KuaFuServerManager.GetPlatChargeKingUrl != null) { for (int i = 0; i < KuaFuServerManager.GetPlatChargeKingUrl.Length; i++) { ClientServerListData clientListData = new ClientServerListData(); clientListData.lTime = TimeUtil.NOW(); clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString()); byte[] clientBytes = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData); byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl[i], clientBytes, 2000, 30000); if (responseData == null) { flag = true; break; } InputKingPaiHangDataEx tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length); if (tmpRankEx == null) { flag = true; break; } list.Add(tmpRankEx); } if (flag) { this.rankEx = new InputKingPaiHangDataEx(); } else { this.rankEx = this.MergePlatfromInputKingList(list); } } } if (this.IsNeedDownloadEveryDay()) { if (KuaFuServerManager.GetPlatChargeKingUrl_EveryDay != null) { bool flag = false; Dictionary <int, List <InputKingPaiHangDataEx> > dict = new Dictionary <int, List <InputKingPaiHangDataEx> >(); for (int i = 0; i < KuaFuServerManager.GetPlatChargeKingUrl_EveryDay.Length; i++) { List <InputKingPaiHangDataEx> tempRankExList = new List <InputKingPaiHangDataEx>(); if (this.MeiRiPCKingFromDate < this.MeiRiPCKingToDate) { DateTime timeLoop = this.MeiRiPCKingFromDate; while (timeLoop < this.MeiRiPCKingToDate && timeLoop < TimeUtil.NowDateTime()) { InputKingPaiHangDataEx tmpRankEx = null; byte[] clientBytes = DataHelper2.ObjectToBytes <InputKingPaiHangDataSearch>(new InputKingPaiHangDataSearch { startDate = timeLoop.ToString("yyyy-MM-dd HH:mm:ss"), endDate = timeLoop.AddDays(1.0).AddSeconds(-1.0).ToString("yyyy-MM-dd HH:mm:ss") }); byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl_EveryDay[i], clientBytes, 2000, 30000); if (responseData != null) { tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length); } if (null != tmpRankEx) { tempRankExList.Add(tmpRankEx); } else { tempRankExList.Add(new InputKingPaiHangDataEx()); flag = true; } if (flag) { break; } timeLoop = timeLoop.AddDays(1.0); } if (flag) { break; } if (!dict.ContainsKey(i)) { dict.Add(i, tempRankExList); } } } if (flag) { this.rankExList = new List <InputKingPaiHangDataEx>(); } else { this.rankExList = this.MergePlatfromInputKingListEveryDay(dict); } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, "PlatChargeKingManager.Update exception", ex, true); } }
public void Update() { if (InActivityTime() || InAwardTime()) { DateTime now = TimeUtil.NowDateTime(); if (now < lastUpdateTime.AddSeconds(updateIntervalSec)) { return; } lastUpdateTime = now; InputKingPaiHangDataEx tmpRankEx = KFCopyRpcClient.getInstance().GetPlatChargeKing(); if (tmpRankEx == null) { return; } List <InputKingPaiHangData> tmpRankList = tmpRankEx.ListData; if (tmpRankEx.StartTime != FromDate || tmpRankEx.EndTime != ToDate) { // tmpRankList = null; } if (tmpRankList != null) { // 排下序,防止意外 // 排序这里要注意:老陶那边会排序,充值金额相同的按照时间排序 // 所以这里做一个检查,如果顺序ok就不排序了,防止打乱时间顺序 bool bNeedSort = false; for (int i = 1; i < tmpRankList.Count(); ++i) { if (tmpRankList[i].PaiHangValue > tmpRankList[i - 1].PaiHangValue) { bNeedSort = true; break; } } if (bNeedSort) { tmpRankList.Sort((_left, _right) => { return(_right.PaiHangValue - _left.PaiHangValue); }); } tmpRankList.ForEach(_item => _item.PaiHangValue = Global.TransMoneyToYuanBao(_item.PaiHangValue)); int procListIdx = 0; for (int i = 0; i < chargeItemList.Count && procListIdx < tmpRankList.Count; ++i) { if (tmpRankList[procListIdx].PaiHangValue >= chargeItemList[i].NeedChargeYB) { tmpRankList[procListIdx].PaiHang = chargeItemList[i].Rank; ++procListIdx; } } if (procListIdx < tmpRankList.Count) { tmpRankList.RemoveRange(procListIdx, tmpRankList.Count - procListIdx); } } RealRankList = tmpRankList; } else { RealRankList = null; } }