public bool startup() { TCPCmdDispatcher.getInstance().registerProcessorEx(2082, 4, 4, BoCaiManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(2083, 2, 2, BoCaiManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(2085, 1, 1, BoCaiManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(2086, 4, 4, BoCaiManager.getInstance(), TCPCmdFlags.IsStringArrayParams); this.NotifyEnterHandler1 = new EventSourceEx <KFCallMsg> .HandlerData { ID = 0, EventType = 10039, Handler = new Func <KFCallMsg, bool>(this.KFCallMsgFunc) }; this.NotifyEnterHandler2 = new EventSourceEx <KFCallMsg> .HandlerData { ID = 0, EventType = 10040, Handler = new Func <KFCallMsg, bool>(this.KFCallMsgFunc) }; KFCallManager.MsgSource.registerListener(10039, this.NotifyEnterHandler1); KFCallManager.MsgSource.registerListener(10040, this.NotifyEnterHandler2); BoCaiCaiShuZi.GetInstance().Init(); BoCaiCaiDaXiao.GetInstance().Init(); BoCaiShopManager.GetInstance().Init(); return(true); }
public bool LoadBuyList(long DataPeriods) { try { if (!this.IsStart) { return(true); } List <BuyBoCai2SDB> ItemList = new List <BuyBoCai2SDB>(); if (DataPeriods > 0L && !BoCaiManager.getInstance().GetBuyList2DB(this.BoCaiType, DataPeriods, out ItemList, 1)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜数字]获取购买记录失败 BoCaiType={0},DataPeriods={1}", this.BoCaiType, DataPeriods), null, true); return(false); } lock (this.mutex) { using (List <BuyBoCai2SDB> .Enumerator enumerator = ItemList.GetEnumerator()) { while (enumerator.MoveNext()) { BuyBoCai2SDB item = enumerator.Current; PlayerBuyBoCaiData playerBoCai = this.BoCaiBaseList.Find((PlayerBuyBoCaiData x) => x.RoleID == item.m_RoleID); if (null == playerBoCai) { playerBoCai = new PlayerBuyBoCaiData(); playerBoCai.BuyItemList = new List <BoCaiBuyItem>(); playerBoCai.ZoneID = item.ZoneID; playerBoCai.RoleID = item.m_RoleID; playerBoCai.ServerId = item.ServerId; playerBoCai.RoleName = item.m_RoleName; playerBoCai.strUserID = item.strUserID; this.BoCaiBaseList.Add(playerBoCai); } playerBoCai.BuyItemList.Add(new BoCaiBuyItem { BuyNum = item.BuyNum, strBuyValue = item.strBuyValue, DataPeriods = item.DataPeriods }); } } LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜数字]加载购买数据true ,DataPeriods = {0}", DataPeriods), null, true); this.IsStart = false; return(true); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜数字]猜数字获取排行 失败", null, true); return(false); }
private void GetRank() { try { List <OpenLottery> openHistory = BoCaiManager.getInstance().GetNewOpenLottery10(this.BoCaiType); if (null != openHistory) { ReturnValue <List <KFBoCaoHistoryData> > msgData = TcpCall.KFBoCaiManager.GetWinHistory(this.BoCaiType); if (!msgData.IsReturn) { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小]猜大小获取排行 失败", null, true); } else { List <KFBoCaoHistoryData> History = msgData.Value; lock (this.mutex) { this.OpenHistory = openHistory; this.WinHistory.Clear(); if (null != History) { using (List <KFBoCaoHistoryData> .Enumerator enumerator = History.GetEnumerator()) { while (enumerator.MoveNext()) { KFBoCaoHistoryData item = enumerator.Current; if (item.RoleID >= 0) { OpenLottery data = this.OpenHistory.Find((OpenLottery x) => x.DataPeriods == item.DataPeriods); if (data != null && !string.IsNullOrEmpty(data.strWinNum)) { item.OpenData = data.strWinNum; this.WinHistory.Add(item); } } } } } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } }
public void Init() { try { lock (this.mutex) { this.IsStart = true; this.StageData.isOpen = false; this.StageData.isOpenDay = false; GetOpenList DBData; if (BoCaiManager.getInstance().GetOpenList2DB(this.BoCaiType, out DBData) && DBData != null && null != DBData.ItemList) { this.StartServerOpenData = new OpenLottery(); this.StartServerOpenData.DataPeriods = 0L; if (DBData.ItemList.Count < 1) { this.StartServerOpenData.IsAward = true; this.StartServerOpenData.DataPeriods = DBData.MaxDataPeriods; } foreach (OpenLottery item in DBData.ItemList) { if (item.DataPeriods > this.StartServerOpenData.DataPeriods) { this.StartServerOpenData = item; } } } this.startNewGame(null, true); this.ServerData.UpOldOpenTime = TimeUtil.NowDateTime(); BoCaiManager.getInstance().OldtterySet(this.BoCaiType, this.ServerOpenData.DataPeriods); if (!this.StageData.isOpen) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜数字]博彩猜数字 暂未开启活动 OpenTime={0}", this.StageData.OpenTime), null, true); } } this.OpenLotterySetWin(); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } }
public void BigTimeUpData(bool reload = false) { try { DateTime _time = TimeUtil.NowDateTime(); this.CheckStageData(_time, reload); if (this.StageData.isOpenDay) { if (this.StageData.Stage < 5 && this.StageData.Stage >= 2 && this.ServerOpenData.DataPeriods < 1L) { this.GetOpenLotteryData(false); } else if (this.StageData.Stage >= 2 && this.StageData.Stage < 4 && (_time - this.ServerData.UpRateTime).TotalSeconds > 15.0) { this.GetOpenLotteryData(false); } else if (this.StageData.LastOpenTime < 0L && (_time - this.ServerData.UpRateTime).TotalSeconds > 3.0) { this.GetOpenLotteryData(false); } } else if (this.StageData.OpenTime > 60L && (long)(_time - this.ServerData.UpOldOpenTime).TotalMinutes > 30L) { this.ServerData.UpOldOpenTime = TimeUtil.NowDateTime(); if (string.IsNullOrEmpty(this.ServerOpenData.strWinNum)) { BoCaiManager.getInstance().OldtterySet(this.BoCaiType, this.ServerOpenData.DataPeriods); } else { BoCaiManager.getInstance().OldtterySet(this.BoCaiType, this.ServerOpenData.DataPeriods + 1L); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } }
public void Init() { try { lock (this.mutex) { this.StageData.isOpen = false; this.StageData.isOpenDay = false; this.startNewGame(null); this.ServerData.UpOldOpenTime = TimeUtil.NowDateTime(); BoCaiManager.getInstance().OldtterySet(this.BoCaiType, this.ServerOpenData.DataPeriods); if (!this.StageData.isOpen || !this.StageData.isOpenDay) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜大小] 初始化猜大小 博彩猜大小 暂未开启活动 isOpen={0}, OpenTime={1}", this.StageData.isOpen, this.StageData.OpenTime), null, true); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } }
public void BigTimeUpData(bool reload = false) { try { DateTime _time = TimeUtil.NowDateTime(); this.CheckStageData(_time, reload); if (this.StageData.isOpenDay) { if (this.StageData.Stage < 5 && this.StageData.Stage >= 2 && this.ServerOpenData.DataPeriods < 1L) { this.GetOpenLotteryData(false); } else if (this.StageData.Stage >= 2 && this.StageData.Stage < 4 && (_time - this.ServerData.UpBalanceTime).TotalSeconds > (double)this.UpAllBalanceTime) { this.GetOpenLotteryData(false); } else if (_time.Day != this.ServerData.UpBalanceTime.Day && _time.AddSeconds(-5.0).Day != this.ServerData.UpBalanceTime.Day) { this.GetOpenLotteryData(false); } this.OpenLotterySetWin(); } if (!this.RankResult && _time.Second % 5 == 0) { this.GetRank(); } if (this.StageData.Stage <= 2 && (_time - this.ServerData.UpOldOpenTime).Hours > 1) { this.ServerData.UpOldOpenTime = TimeUtil.NowDateTime(); BoCaiManager.getInstance().OldtterySet(this.BoCaiType, this.ServerOpenData.DataPeriods); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } }
public void OldtterySet(int BoCaiType, long DataPeriods) { try { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩]处理历史开奖 BoCaiType={0}, 处理界限 DataPeriods={1}", BoCaiType, DataPeriods), null, true); GetOpenList DBData; if (!BoCaiManager.getInstance().GetOpenList2DB(BoCaiType, out DBData)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_博彩]处理历史开奖 读库失败 GetOpenList2DB BoCaiType={0}, DataPeriods={1}", BoCaiType, DataPeriods), null, true); } else { foreach (OpenLottery item in DBData.ItemList) { OpenLottery Temp = item; if (BoCaiType != 1) { if (BoCaiType == 2) { if (item.DataPeriods >= Convert.ToInt64(string.Format("{0}1", TimeUtil.NowDataTimeString("yyMMdd")))) { continue; } } } if (string.IsNullOrEmpty(item.strWinNum) || string.IsNullOrEmpty(item.WinInfo)) { ReturnValue <List <OpenLottery> > Data = TcpCall.KFBoCaiManager.GetOpenLottery(BoCaiType, item.DataPeriods, true); if (!Data.IsReturn) { return; } List <OpenLottery> kuafuList = Data.Value; if (kuafuList == null || kuafuList.Count < 1) { continue; } Temp = kuafuList[0]; } if (Temp != null && Temp.DataPeriods >= 1L && Temp.XiaoHaoDaiBi >= 0) { Global.Send2DB <OpenLottery>(2084, Temp, 0); List <BuyBoCai2SDB> ItemList; if (!BoCaiManager.getInstance().GetBuyList2DB(BoCaiType, Temp.DataPeriods, out ItemList, 2)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_博彩]获取购买记录失败 BoCaiType={0},DataPeriods={1}", BoCaiType, Temp.DataPeriods), null, true); } else if (ItemList.Count < 1) { Temp.IsAward = true; Global.Send2DB <OpenLottery>(2084, Temp, 0); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩]还有0人没处理 完成处理历史开奖 BoCaiType={0}, DataPeriods={1}", BoCaiType, Temp.DataPeriods), null, true); continue; } if (string.IsNullOrEmpty(Temp.strWinNum) || string.IsNullOrEmpty(Temp.WinInfo)) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩] 没有开过奖处理历史退回{0}", Temp.DataPeriods), null, true); foreach (BuyBoCai2SDB buyItem in ItemList) { if (!this.ReturnItem(Temp, buyItem)) { Temp.IsAward = false; } } if (Temp.IsAward) { Global.Send2DB <OpenLottery>(2084, Temp, 0); } } else { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩]处理历史开奖{0}", Temp.DataPeriods), null, true); foreach (BuyBoCai2SDB buyItem in ItemList) { if (buyItem.BocaiType == 1) { string winType; double Rate = BoCaiCaiDaXiao.GetInstance().CompensateRate(Temp.strWinNum, Temp.WinInfo, out winType); if (Rate < 1.0) { LogManager.WriteLog(LogTypes.Info, "[ljl_博彩] 开奖 赔率 < 1 ", null, true); } else if (!this.SendWinItem(Temp, buyItem, Rate, true, winType)) { Temp.IsAward = false; } } else if (buyItem.BocaiType == 2) { if (!this.SendWinItem(Temp, buyItem)) { Temp.IsAward = false; } } else { Temp.IsAward = false; LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_博彩]购买记录 类型不对 BoCaiType={0},DataPeriods={1}", BoCaiType, Temp.DataPeriods), null, true); } } if (Temp.IsAward) { Global.Send2DB <OpenLottery>(2084, Temp, 0); } } } } ReturnValue <List <OpenLottery> > KFData = TcpCall.KFBoCaiManager.GetOpenLottery(BoCaiType, DBData.MaxDataPeriods, false); if (KFData.IsReturn) { List <OpenLottery> KuaFuList = KFData.Value; if (null != KuaFuList) { foreach (OpenLottery item in KuaFuList) { Global.Send2DB <OpenLottery>(2084, item, 0); } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } }
private void GetRank() { try { List <OpenLottery> openHistory = BoCaiManager.getInstance().GetNewOpenLottery10(this.BoCaiType); if (null != openHistory) { ReturnValue <List <KFBoCaoHistoryData> > msgData = TcpCall.KFBoCaiManager.GetWinHistory(this.BoCaiType); if (!msgData.IsReturn) { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜数字]猜数字获取排行 失败", null, true); } else { List <KFBoCaoHistoryData> History = msgData.Value; lock (this.mutex) { this.RankResult = true; this.OpenHistory = openHistory; this.WinHistory.Clear(); if (null != History) { using (List <KFBoCaoHistoryData> .Enumerator enumerator = History.GetEnumerator()) { while (enumerator.MoveNext()) { KFBoCaoHistoryData item = enumerator.Current; OpenLottery data = this.OpenHistory.Find((OpenLottery x) => x.DataPeriods == item.DataPeriods); if (data != null && !string.IsNullOrEmpty(data.strWinNum)) { item.OpenData = data.strWinNum; this.WinHistory.Add(item); } } } List <long> DataPeriodsList = new List <long>(); List <long> DataPeriodsList2 = new List <long>(); foreach (OpenLottery open in this.OpenHistory) { DataPeriodsList.Add(open.DataPeriods); } DataPeriodsList2 = this.BuyItemHistoryDict.Keys.ToList <long>(); using (List <long> .Enumerator enumerator3 = DataPeriodsList2.GetEnumerator()) { while (enumerator3.MoveNext()) { long Periods = enumerator3.Current; if (DataPeriodsList.Find((long x) => x == Periods) < 1L) { this.BuyItemHistoryDict.Remove(Periods); } } } foreach (long Periods2 in DataPeriodsList) { if (!this.BuyItemHistoryDict.ContainsKey(Periods2)) { List <BuyBoCai2SDB> ItemList; if (BoCaiManager.getInstance().GetBuyList2DB(this.BoCaiType, Periods2, out ItemList, 1)) { List <RoleBuyHistory> roleBuyList = new List <RoleBuyHistory>(); using (List <BuyBoCai2SDB> .Enumerator enumerator4 = ItemList.GetEnumerator()) { while (enumerator4.MoveNext()) { BuyBoCai2SDB dbdata = enumerator4.Current; RoleBuyHistory roledata = roleBuyList.Find((RoleBuyHistory x) => x.RoleID == dbdata.m_RoleID); if (null == roledata) { roledata = new RoleBuyHistory(); roledata.RoleID = dbdata.m_RoleID; roledata.BuyItemList = new List <BoCaiBuyItem>(); roleBuyList.Add(roledata); } roledata.BuyItemList.Add(new BoCaiBuyItem { BuyNum = dbdata.BuyNum, strBuyValue = dbdata.strBuyValue, DataPeriods = Periods2 }); } } this.BuyItemHistoryDict.Add(Periods2, roleBuyList); } } } } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } }
private void OpenLotterySetWin() { try { if (this.StageData.Stage == 5 && !this.ServerData.IsAward) { if (string.IsNullOrEmpty(this.ServerOpenData.strWinNum) || string.IsNullOrEmpty(this.ServerOpenData.WinInfo)) { this.GetOpenLotteryData(false); } if (this.FirstDataPeriods == this.ServerOpenData.DataPeriods && this.FirstDataPeriods > 0L) { if (null != this.StartServerOpenData) { if (this.StartServerOpenData.DataPeriods == this.FirstDataPeriods && this.StartServerOpenData.IsAward) { return; } } else if (this.StartServerStage > BoCaiStageEnum.Stage_Open) { return; } } if (this.ServerOpenData.DataPeriods >= 1L && this.ServerOpenData.XiaoHaoDaiBi >= 1 && !string.IsNullOrEmpty(this.ServerOpenData.strWinNum) && !string.IsNullOrEmpty(this.ServerOpenData.WinInfo)) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜数字]猜数字 开奖 GetOpenLottery su DataPeriods={0}", this.ServerOpenData.DataPeriods), null, true); List <BuyBoCai2SDB> BuyList = new List <BuyBoCai2SDB>(); lock (this.mutex) { foreach (PlayerBuyBoCaiData PlayerBuyData in this.BoCaiBaseList) { BuyBoCai2SDB buyItem = new BuyBoCai2SDB { ZoneID = PlayerBuyData.ZoneID, m_RoleID = PlayerBuyData.RoleID, ServerId = PlayerBuyData.ServerId, strUserID = PlayerBuyData.strUserID, m_RoleName = PlayerBuyData.RoleName, DataPeriods = this.ServerOpenData.DataPeriods, BocaiType = this.BoCaiType, IsSend = false, IsWin = false }; foreach (BoCaiBuyItem item in PlayerBuyData.BuyItemList) { if (item.DataPeriods == this.ServerOpenData.DataPeriods) { BuyBoCai2SDB temp = new BuyBoCai2SDB(); GlobalNew.Copy <BuyBoCai2SDB>(buyItem, ref temp); temp.BuyNum = item.BuyNum; temp.strBuyValue = item.strBuyValue; BuyList.Add(temp); } } } } this.ServerOpenData.IsAward = true; this.ServerData.IsAward = true; foreach (BuyBoCai2SDB buyItem in BuyList) { if (!BoCaiManager.getInstance().SendWinItem(this.ServerOpenData, buyItem)) { this.ServerOpenData.IsAward = false; } } if (this.ServerOpenData.IsAward) { Global.Send2DB <OpenLottery>(2084, this.ServerOpenData, 0); } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } }