protected override void Init() { try { lock (this.mutex) { long delDataPeriods = this.GetNowPeriods(TimeUtil.NowDateTime().AddMonths(-6)); KFBoCaiDbManager.DelTableData("t_bocai_open_lottery", string.Format("BocaiType={1} AND DataPeriods < {0}", delDataPeriods, (int)this.BoCaiType)); KFBoCaiDbManager.DelTableData("t_bocai_buy_history", string.Format("BocaiType={1} AND DataPeriods < {0}", delDataPeriods, (int)this.BoCaiType)); this.InitConfig(); KFBoCaiDbManager.SelectOpenLottery((int)this.BoCaiType, this.SelectOpenHisttory10, out this.OpenHistory); List <KFBoCaoHistoryData> HistoryList = new List <KFBoCaoHistoryData>(); KFBoCaiDbManager.LoadLotteryHistory(this.BoCaiType, out HistoryList, "LIMIT 50"); this.addHistory(HistoryList); this.MaxPeriods = KFBoCaiDbManager.GetMaxPeriods((int)this.BoCaiType); if (this.MaxPeriods < 0L) { KFBoCaiDbManager.StopServer("[ljl_caidaxiao_猜大小] 猜大小 maxPeriods == -1"); } else { if (null == this.Config) { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小]猜大小配置文件错误", null, true); } this.Stage = BoCaiStageEnum.Stage_Ready; } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); KFBoCaiDbManager.StopServer("初始化 Exception"); } }
protected override void Init() { try { lock (this.mutex) { DateTime _time = TimeUtil.NowDateTime(); long delDataPeriods = this.GetNowPeriods(_time.AddYears(-1)); KFBoCaiDbManager.DelTableData("t_bocai_open_lottery", string.Format("BocaiType={1} AND DataPeriods < {0}", delDataPeriods, (int)this.BoCaiType)); KFBoCaiDbManager.DelTableData("t_bocai_buy_history", string.Format("BocaiType={1} AND DataPeriods < {0}", delDataPeriods, (int)this.BoCaiType)); this.InitConfig(); KFBoCaiDbManager.LoadLotteryHistory(this.BoCaiType, out this.BoCaiWinHistoryList, ""); KFBoCaiDbManager.SelectOpenLottery((int)this.BoCaiType, this.SelectOpenHisttory10, out this.OpenHistory); this.MaxPeriods = KFBoCaiDbManager.GetMaxPeriods((int)this.BoCaiType); if (this.MaxPeriods < 0L) { KFBoCaiDbManager.StopServer("[ljl_caidaxiao_猜数字] 猜数字 maxPeriods == -1"); } else { if (null == this.Config) { LogManager.WriteLog(LogTypes.Error, "[ljl_CaiShuZi_猜数字]猜数字配置文件错误", null, true); } else if (DateTime.Parse(this.Config.KaiQiShiJian) < _time) { long Periods = this.GetNowPeriods(_time); if (this.MaxPeriods == Periods) { this.StartServerSamePeriods(_time); return; } } else { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 未开启 开启时间 {0}", this.Config.KaiQiShiJian), null, true); } this.GetOldBalance(); this.Stage = BoCaiStageEnum.Stage_Ready; } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_CaiShuZi_猜数字]{0}", ex.ToString()), null, true); KFBoCaiDbManager.StopServer("初始化 Exception"); } }
public void InitData() { try { lock (this.mutex) { this.StartTime = TimeUtil.NowDateTime(); string Periods = TimeUtil.DataTimeToString(this.StartTime, "yyMMdd"); KFBoCaiDbManager.DelTableData("t_bocai_shop", string.Format("Periods!='{0}'", Periods)); KFBoCaiDbManager.SelectBoCaiShop(Periods, out this.cacheList); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true); } }
private void addHistory(List <KFBoCaoHistoryData> History) { try { long longData = 0L; lock (this.mutex) { this.BoCaiWinHistoryList.AddRange(History); List <long> dataTime = new List <long>(); using (List <KFBoCaoHistoryData> .Enumerator enumerator = this.BoCaiWinHistoryList.GetEnumerator()) { while (enumerator.MoveNext()) { KFBoCaoHistoryData item = enumerator.Current; if (dataTime.Find((long x) => x == item.DataPeriods) <= 0L) { dataTime.Add(item.DataPeriods); } } } if (dataTime.Count > 10) { dataTime.Sort(); dataTime.Reverse(); longData = dataTime[9]; this.BoCaiWinHistoryList = this.BoCaiWinHistoryList.FindAll((KFBoCaoHistoryData x) => x.DataPeriods >= longData); } this.BoCaiWinHistoryList.Sort(new Comparison <KFBoCaoHistoryData>(KFBoCaiCaiDaXiao.SortHistory)); } if (longData >= 1L) { if (!KFBoCaiDbManager.DelTableData("t_bocai_lottery_history", string.Format("DataPeriods < {0} AND `BocaiType`={1}", longData, (int)this.BoCaiType))) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜大小] DelTableData t_bocai_lottery_history false DataPeriods {0}", longData), null, true); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } }
public override void Thread() { try { lock (this.mutex) { if (BoCaiStageEnum.Stage_Ready < this.Stage && this.UpToDBOpenData.AllBalance != this.OpenData.AllBalance && this.OpenData.DataPeriods > 1L) { this.SetUpToDBOpenData(); if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { this.UpToDBOpenData.AllBalance = 0L; } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } if (BoCaiStageEnum.Stage_Open == this.Stage) { try { List <int> value = new List <int>(); int no3Num = 0; if ((long)this.Config.ChuFaBiZhong <= this.OpenData.AllBalance && this.RoleBuyDict.Count > 0) { int index = Global.GetRandomNumber(0, this.RoleBuyDict.Count); List <string> keyList = this.RoleBuyDict.Keys.ToList <string>(); List <KFBuyBocaiData> buyList = this.RoleBuyDict[keyList[index]]; index = Global.GetRandomNumber(0, buyList.Count); KFBoCaiDbManager.String2ListInt(buyList[index].BuyValue, out value); } else { while (value.Count < 5) { value.Add(Global.GetRandomNumber(0, 10)); } } int no1Num; int no2Num; List <KFBoCaoHistoryData> Hsitory; this.GetWinRoleNum(value, out no1Num, out no2Num, out no3Num, out Hsitory); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字]猜数1等奖人数={0},二等奖={1},3等奖={2}", no1Num, no2Num, no3Num), null, true); long No1Money = 0L; long No2Money = 0L; long No3Money = 0L; lock (this.mutex) { long no1Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[0].Percent); long no2Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[1].Percent); long no3Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[2].Percent); this.OpenData.SurplusBalance = this.OpenData.AllBalance; if (no1Num > 0) { this.OpenData.SurplusBalance -= no1Win; No1Money = no1Win / (long)no1Num; } if (no2Num > 0) { this.OpenData.SurplusBalance -= no2Win; No2Money = no2Win / (long)no2Num; } if (no3Num > 0) { this.OpenData.SurplusBalance -= no3Win; No3Money = no3Win / (long)no3Num; } this.OpenData.WinInfo = string.Format("{0},{1},{2}", No1Money, No2Money, No3Money); this.OpenData.strWinNum = KFBoCaiDbManager.ListInt2String(value); if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { LogManager.WriteLog(LogTypes.Error, "[ljl_CaiShuZi_猜数字]开始计算中奖了 KFBoCaiDbManager.InserOpenLottery(data) false", null, true); this.OpenData.SurplusBalance = 0L; this.OpenData.WinInfo = ""; this.OpenData.strWinNum = ""; return; } this.BoCaiWinHistoryList.Clear(); this.BoCaiWinHistoryList.AddRange(Hsitory); base.SetOpenHistory(this.GetOpenLottery()); this.Stage = BoCaiStageEnum.Stage_End; } foreach (KFBoCaoHistoryData item in Hsitory) { if (1 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No1Money; } else if (2 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No2Money; } else if (3 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No3Money; } if (!KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, item)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_CaiShuZi_猜数字]插入中奖历史 false DataPeriods ={0}, name={1},id={2},WinNo={3},WinMoney={4}", new object[] { item.DataPeriods, item.RoleName, item.RoleID, item.WinNo, item.WinMoney }), null, true); } } if (!KFBoCaiDbManager.DelTableData("t_bocai_lottery_history", string.Format("DataPeriods < {0}", this.OpenData.DataPeriods))) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_CaiShuZi_猜数字] DelTableData t_bocai_lottery_history false DataPeriods ={0}", this.OpenData.DataPeriods), null, true); } base.KFSendPeriodsData(); base.KFSendStageData(); } catch (Exception ex) { this.Stage = BoCaiStageEnum.Stage_End; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_CaiShuZi_猜数字]{0}", ex.ToString()), null, true); } } }