Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
        private void GetOldBalance()
        {
            List <OpenLottery> dList;

            KFBoCaiDbManager.SelectOpenLottery((int)this.BoCaiType, string.Format(" AND `strWinNum`!='{0}' ORDER BY `DataPeriods` DESC LIMIT 1;", ""), out dList);
            if (null == dList)
            {
                KFBoCaiDbManager.StopServer("找上期余额失败");
            }
            if (dList.Count > 0)
            {
                this.OpenData.AllBalance = Math.Max(this.OpenData.AllBalance, dList[0].SurplusBalance);
            }
        }
Ejemplo n.º 3
0
 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");
     }
 }
Ejemplo n.º 4
0
 private void StartServerSamePeriods(DateTime time)
 {
     try
     {
         OpenLottery data;
         KFBoCaiDbManager.SelectOpenLottery(this.MaxPeriods, (int)this.BoCaiType, out data);
         List <KFBuyBocaiData> HistoryList;
         if (null == data)
         {
             KFBoCaiDbManager.StopServer(string.Format("[ljl_CaiShuZi_猜数字] 开奖记录读取失败 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType));
         }
         else if (!string.IsNullOrEmpty(data.strWinNum))
         {
             if (data.XiaoHaoDaiBi < 1)
             {
                 data.XiaoHaoDaiBi = this.OpenData.XiaoHaoDaiBi;
             }
             this.OpenData = data;
             this.SetUpToDBOpenData();
             this.PeriodsStartTime = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss"));
             this.Stage            = BoCaiStageEnum.Stage_End;
             base.KFSendStageData();
             base.KFSendPeriodsData();
             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 并且已经开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true);
         }
         else if (!KFBoCaiDbManager.LoadBuyHistory((int)this.BoCaiType, this.MaxPeriods, out HistoryList))
         {
             KFBoCaiDbManager.StopServer(string.Format("[ljl_CaiShuZi_猜数字]读取购买记录失败 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType));
         }
         else
         {
             this.RoleBuyDict = new Dictionary <string, List <KFBuyBocaiData> >();
             using (List <KFBuyBocaiData> .Enumerator enumerator = HistoryList.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     KFBuyBocaiData        item = enumerator.Current;
                     List <KFBuyBocaiData> itemList;
                     if (this.RoleBuyDict.TryGetValue(item.GetKey(), out itemList))
                     {
                         KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(item.BuyValue));
                         if (temp == null)
                         {
                             itemList.Add(item);
                         }
                         else
                         {
                             temp.BuyNum += item.BuyNum;
                         }
                     }
                     else
                     {
                         itemList = new List <KFBuyBocaiData>();
                         itemList.Add(item);
                         this.RoleBuyDict.Add(item.GetKey(), itemList);
                     }
                 }
             }
             if (data.XiaoHaoDaiBi < 1)
             {
                 data.XiaoHaoDaiBi = this.OpenData.XiaoHaoDaiBi;
             }
             this.OpenData         = data;
             this.PeriodsStartTime = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss"));
             this.SetUpToDBOpenData();
             if (DateTime.Parse(this.Config.KaiJiangShiJian) >= time)
             {
                 this.Stage = BoCaiStageEnum.Stage_Buy;
                 LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 并且没开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true);
             }
             else if ((DateTime.Parse("23:59:59") - time).TotalMinutes < 2.0)
             {
                 this.Stage = BoCaiStageEnum.Stage_Open;
                 this.SetUpToDBOpenData();
                 LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 状态设置开奖 &&强制开奖 不足2分钟 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true);
                 this.Thread();
             }
             else
             {
                 this.Stage = BoCaiStageEnum.Stage_Open;
                 LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 状态设置开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true);
             }
             base.KFSendStageData();
             base.KFSendPeriodsData();
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_CaiShuZi_猜数字]{0}", ex.ToString()), null, true);
     }
 }