private bool ReturnItem(OpenLottery data, BuyBoCai2SDB buyItem) { try { buyItem.IsSend = true; BoCaiBuy2DBList.getInstance().AddData(buyItem, 0, false); if (!"True".Equals(Global.Send2DB <BuyBoCai2SDB>(2082, buyItem, 0))) { LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩]更新数据库标志失败,返回道具,没关系 线程会自动处理旧数据,{0},{1}", buyItem.m_RoleName, buyItem.DataPeriods), null, true); return(false); } int returnNum = buyItem.BuyNum * data.XiaoHaoDaiBi; string strTitle = "猜大小"; if (buyItem.BocaiType == 2) { strTitle = "猜数字"; } string strIntro = string.Format("因系统维护原因导致{0}期{1}玩法没有正常开奖,系统将返还您当期下注的欢乐代币。", buyItem.DataPeriods, strTitle); List <GoodsData> goodsData = new List <GoodsData> { HuanLeDaiBiManager.GetInstance().GetHuanLeDaiBi(returnNum) }; return(this.SendMail(buyItem, goodsData, strTitle, strIntro, returnNum, false)); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } return(false); }
private void startNewGame(OpenLottery OpenData = null) { try { lock (this.mutex) { this.BoCaiBaseList.Clear(); this.ServerOpenData.XiaoHaoDaiBi = -1; this.ServerData = new CenterServerCaiDaXiao(); this.GetRank(); if (null != OpenData) { this.SetOpenLotteryData(OpenData, true, false); this.GetStageData(); } else { this.GetStageData(); if (this.StageData.isOpenDay && this.StageData.Stage >= 2) { if (!this.GetOpenLotteryData(true)) { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小]本期开奖数据 失败", null, true); } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } }
public static void SelectOpenLottery(int BocaiType, string cmd, out List <OpenLottery> dList) { dList = null; MySqlDataReader sdr = null; try { string sql = string.Format("SELECT `SurplusBalance`,`XiaoHaoDaiBi`,`strWinNum`,`WinInfo`,`AllBalance`,`DataPeriods` FROM t_bocai_open_lottery WHERE `BocaiType`={0}{1}", BocaiType, cmd); sdr = DbHelperMySQL.ExecuteReader(sql, false); dList = new List <OpenLottery>(); while (sdr != null && sdr.Read()) { OpenLottery data = new OpenLottery(); data.DataPeriods = Convert.ToInt64(sdr["DataPeriods"]); data.AllBalance = Convert.ToInt64(sdr["AllBalance"]); data.SurplusBalance = Convert.ToInt64(sdr["SurplusBalance"]); data.XiaoHaoDaiBi = Convert.ToInt32(sdr["XiaoHaoDaiBi"]); data.strWinNum = sdr["strWinNum"].ToString(); data.WinInfo = sdr["WinInfo"].ToString(); data.BocaiType = BocaiType; dList.Add(data); } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.Message); } finally { if (sdr != null) { sdr.Close(); } } }
public bool KFCallMsgFunc(KFCallMsg msg) { try { switch (msg.KuaFuEventType) { case 10039: { KFStageData data = msg.Get <KFStageData>(); if (null != data) { if (data.BoCaiType == BoCaiTypeEnum.Bocai_CaiShuzi) { BoCaiCaiShuZi.GetInstance().SetStageData(data, true); } else if (data.BoCaiType == BoCaiTypeEnum.Bocai_Dice) { BoCaiCaiDaXiao.GetInstance().SetStageData(data, true); } } else { BoCaiCaiDaXiao.GetInstance().SetStageData(data, true); BoCaiCaiShuZi.GetInstance().SetStageData(data, true); } break; } case 10040: { OpenLottery data2 = msg.Get <OpenLottery>(); if (null != data2) { if (data2.BocaiType == 2) { BoCaiCaiShuZi.GetInstance().SetOpenLotteryData(data2, false, false); } else if (data2.BocaiType == 1) { BoCaiCaiDaXiao.GetInstance().SetOpenLotteryData(data2, false, true); } } else { BoCaiCaiDaXiao.GetInstance().SetOpenLotteryData(data2, false, true); BoCaiCaiShuZi.GetInstance().SetOpenLotteryData(data2, false, false); } break; } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]跨服消息{0}", ex.ToString()), null, true); } return(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.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 bool SetOpenLotteryData(OpenLottery OpenData, bool init = false, bool isKF = false) { try { lock (this.mutex) { if (null != OpenData) { if (OpenData.DataPeriods < 1L || OpenData.XiaoHaoDaiBi < 1) { if (this.StageData.Stage > 1) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜大小] DataPeriods = {0},XiaoHaoDaiBi={1} ", OpenData.DataPeriods, OpenData.XiaoHaoDaiBi), null, true); } return(false); } if (this.ServerOpenData.DataPeriods != OpenData.DataPeriods && this.ServerOpenData.DataPeriods > 0L && !init) { this.startNewGame(OpenData); return(true); } if (this.ServerOpenData.DataPeriods != OpenData.DataPeriods) { } this.ServerOpenData = OpenData; this.ServerData.UpRateTime = TimeUtil.NowDateTime(); Global.Send2DB <OpenLottery>(2084, OpenData, 0); if (isKF && this.StageData.Stage == 2) { this.UpdateBoCai(); } return(true); } else { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小] 猜大小 TcpCall.KFBoCaiManager.GetOpenLottery = null", null, true); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } return(false); }
private bool GetOpenLotteryData(bool init = false) { try { ReturnValue <OpenLottery> msgData = TcpCall.KFBoCaiManager.GetOpenLottery(this.BoCaiType); if (!msgData.IsReturn) { return(false); } OpenLottery OpenData = msgData.Value; return(this.SetOpenLotteryData(OpenData, init, false)); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } return(false); }
public void SetOpenHistory(OpenLottery dOpen) { if (null == this.OpenHistory) { KFBoCaiDbManager.SelectOpenLottery((int)this.BoCaiType, this.SelectOpenHisttory10, out this.OpenHistory); if (null == this.OpenHistory) { return; } } if (!string.IsNullOrEmpty(dOpen.strWinNum)) { if (null == this.OpenHistory.Find((OpenLottery x) => x.DataPeriods == dOpen.DataPeriods)) { this.OpenHistory.Insert(0, dOpen); while (this.OpenHistory.Count > 10) { this.OpenHistory.RemoveAt(this.OpenHistory.Count - 1); } } } }
public static bool InserOpenLottery(OpenLottery data) { try { string sql = string.Format("REPLACE INTO t_bocai_open_lottery(DataPeriods, AllBalance, SurplusBalance, XiaoHaoDaiBi, BocaiType, strWinNum, WinInfo) VALUES({0},{1},{2},{3},{4},'{5}','{6}');", new object[] { data.DataPeriods, data.AllBalance, data.SurplusBalance, data.XiaoHaoDaiBi, data.BocaiType, data.strWinNum, data.WinInfo }); return(DbHelperMySQL.ExecuteSql(sql) > -1); } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public bool SendWinItem(OpenLottery data, BuyBoCai2SDB buyItem, double Rate, bool isSendMail, string winType) { try { buyItem.IsSend = true; if (!winType.Equals(buyItem.strBuyValue)) { buyItem.IsWin = false; BoCaiBuy2DBList.getInstance().AddData(buyItem, -1, true); return(true); } int WinNum = (int)(Rate * (double)buyItem.BuyNum * (double)data.XiaoHaoDaiBi); string strTitle = "猜大小"; string strIntro = string.Format("恭喜您在{0}期猜大小玩法中,获得欢乐代币{1},系统将邮件的形式将您获取的欢乐代币返还与你。", buyItem.DataPeriods, WinNum); buyItem.IsWin = true; string strLog = string.Format("TYPE= {8},id={6},name={7}, {0}期开奖{1}赢得{2},自己购买{3},{4}注,info={5}", new object[] { data.DataPeriods, data.strWinNum, WinNum, buyItem.strBuyValue, buyItem.BuyNum, data.WinInfo, buyItem.m_RoleID, buyItem.m_RoleName, buyItem.BocaiType }); BoCaiBuy2DBList.getInstance().AddData(buyItem, -1, false); if (!"True".Equals(Global.Send2DB <BuyBoCai2SDB>(2082, buyItem, 0))) { LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩]更新数据库标志失败,不发奖励,没关系 会自动处理旧数据{0}", strLog), null, true); return(WinNum < 1); } if (WinNum < 1) { return(true); } GoodsData Goods = HuanLeDaiBiManager.GetInstance().GetHuanLeDaiBi(WinNum); List <GoodsData> goodsData = new List <GoodsData> { Goods }; if (isSendMail) { return(this.SendMail(buyItem, goodsData, strTitle, strIntro, WinNum, true)); } GameClient client = GameManager.ClientMgr.FindClient(buyItem.m_RoleID); if (client != null && Global.CanAddGoods3(client, Goods.GoodsID, WinNum, Goods.Binding, "1900-01-01 12:00:00", true)) { int ret = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, Goods.GoodsID, Goods.GCount, Goods.Quality, Goods.Props, Goods.Forge_level, Goods.Binding, Goods.Site, Goods.Jewellist, true, 1, "猜大小中奖", "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, null, null, 0, true); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩]放在背包ret={1},{0}", strLog, ret), null, true); return(true); } return(this.SendMail(buyItem, goodsData, strTitle, strIntro, WinNum, true)); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } return(false); }
public bool SetOpenLotteryData(OpenLottery OpenData, bool init = false, bool isKF = false) { try { lock (this.mutex) { if (null != OpenData) { if (this.FirstDataPeriods < 1L) { this.FirstDataPeriods = OpenData.DataPeriods; } if (OpenData.DataPeriods < 1L || OpenData.XiaoHaoDaiBi < 1) { if (this.StageData.Stage > 1) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜数字] DataPeriods = {0},XiaoHaoDaiBi={1} ", OpenData.DataPeriods, OpenData.XiaoHaoDaiBi), null, true); } return(false); } if (this.ServerOpenData.DataPeriods < 1L) { if (!this.LoadBuyList(OpenData.DataPeriods)) { return(false); } } if (this.ServerOpenData.DataPeriods < OpenData.DataPeriods && this.ServerOpenData.DataPeriods > 1L && !init) { this.startNewGame(OpenData, false); return(true); } if (this.ServerOpenData.DataPeriods < OpenData.DataPeriods) { } this.ServerOpenData = OpenData; this.ServerData.UpBalanceTime = TimeUtil.NowDateTime(); if (this.FirstDataPeriods == OpenData.DataPeriods && this.StartServerStage > BoCaiStageEnum.Stage_Open) { if (null != this.StartServerOpenData) { if (this.StartServerOpenData.DataPeriods != this.FirstDataPeriods || !this.StartServerOpenData.IsAward) { Global.Send2DB <OpenLottery>(2084, OpenData, 0); } } } else { Global.Send2DB <OpenLottery>(2084, OpenData, 0); } if (isKF && this.StageData.Stage == 2) { this.UpdateBoCai(); } return(true); } else { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜数字] 猜数字 TcpCall.KFBoCaiManager.GetOpenLottery = null", null, true); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), 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.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); } }