Exemple #1
0
        public bool BuyBoCai(KFBuyBocaiData data)
        {
            bool result;

            lock (this.mutex)
            {
                string str = this.SetWinInfo(data.BuyValue, data.BuyNum);
                if (string.IsNullOrEmpty(str))
                {
                    result = false;
                }
                else
                {
                    bool flag = true;
                    List <KFBuyBocaiData> itemList;
                    if (this.RoleBuyDict.TryGetValue(data.GetKey(), out itemList))
                    {
                        KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(data.BuyValue));
                        if (temp == null)
                        {
                            if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                            {
                                this.OpenData.WinInfo = str;
                                itemList.Add(data);
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            data.BuyNum += temp.BuyNum;
                            if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                            {
                                this.OpenData.WinInfo = str;
                                temp.BuyNum           = data.BuyNum;
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                    }
                    else if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                    {
                        itemList = new List <KFBuyBocaiData>();
                        itemList.Add(data);
                        this.OpenData.WinInfo = str;
                        this.RoleBuyDict.Add(data.GetKey(), itemList);
                    }
                    else
                    {
                        flag = false;
                    }
                    result = flag;
                }
            }
            return(result);
        }
Exemple #2
0
        public List <OpenLottery> GetOpenHistory()
        {
            if (null == this.OpenHistory)
            {
                KFBoCaiDbManager.SelectOpenLottery((int)this.BoCaiType, this.SelectOpenHisttory10, out this.OpenHistory);
                if (null == this.OpenHistory)
                {
                    return(null);
                }
            }
            List <OpenLottery> dList = new List <OpenLottery>();

            foreach (OpenLottery item in this.OpenHistory)
            {
                dList.Add(new OpenLottery
                {
                    DataPeriods    = item.DataPeriods,
                    strWinNum      = item.strWinNum,
                    BocaiType      = item.BocaiType,
                    SurplusBalance = item.SurplusBalance,
                    AllBalance     = item.AllBalance,
                    XiaoHaoDaiBi   = item.XiaoHaoDaiBi,
                    WinInfo        = item.WinInfo,
                    IsAward        = false
                });
            }
            return(dList);
        }
Exemple #3
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");
     }
 }
Exemple #4
0
        private bool StartBuy(long Periods, DateTime time)
        {
            this.PeriodsStartTime        = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss"));
            this.OpenData.DataPeriods    = Periods;
            this.OpenData.strWinNum      = "";
            this.OpenData.WinInfo        = "0,0,0";
            this.OpenData.BocaiType      = (int)this.BoCaiType;
            this.OpenData.SurplusBalance = 0L;
            this.OpenData.AllBalance     = 0L;
            this.SetUpToDBOpenData();
            bool result;

            if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData))
            {
                LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小] 猜大小开始购买 KFBoCaiDbManager.InserOpenLottery(data) false", null, true);
                result = false;
            }
            else
            {
                this.InsertHistoryData();
                LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜大小] 猜大小开启新的一轮 Periods={0}", Periods), null, true);
                result = true;
            }
            return(result);
        }
Exemple #5
0
 private bool AddItem(KFBoCaiShopDB Item)
 {
     try
     {
         lock (this.mutex)
         {
             KFBoCaiShopDB data = this.cacheList.Find((KFBoCaiShopDB x) => x.ID == Item.ID && Item.WuPinID == x.WuPinID);
             if (null == data)
             {
                 data = Item;
                 this.cacheList.Add(Item);
             }
             else
             {
                 data.BuyNum += Item.BuyNum;
             }
             KFBoCaiDbManager.ReplaceBoCaiShop(data);
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true);
     }
     return(false);
 }
 private void GetWinRoleNum(List <int> value, out int no1Num, out int no2Num, out int no3Num, out List <KFBoCaoHistoryData> Hsitory)
 {
     no1Num  = 0;
     no2Num  = 0;
     no3Num  = 0;
     Hsitory = new List <KFBoCaoHistoryData>();
     lock (this.mutex)
     {
         foreach (List <KFBuyBocaiData> BuyDataList in this.RoleBuyDict.Values)
         {
             foreach (KFBuyBocaiData BuyData in BuyDataList)
             {
                 int        sameNum = 0;
                 List <int> tempList;
                 KFBoCaiDbManager.String2ListInt(BuyData.BuyValue, out tempList);
                 if (tempList.Count == value.Count)
                 {
                     for (int i = 0; i < value.Count; i++)
                     {
                         if (value[i] == tempList[i])
                         {
                             sameNum++;
                         }
                     }
                     KFBoCaoHistoryData HistoryData = new KFBoCaoHistoryData();
                     HistoryData.DataPeriods = this.OpenData.DataPeriods;
                     HistoryData.RoleID      = BuyData.RoleID;
                     HistoryData.ZoneID      = BuyData.ZoneID;
                     HistoryData.ServerID    = BuyData.ServerID;
                     HistoryData.RoleName    = BuyData.RoleName;
                     HistoryData.BuyNum      = BuyData.BuyNum;
                     if (5 == sameNum)
                     {
                         no1Num           += BuyData.BuyNum;
                         HistoryData.WinNo = 1;
                     }
                     else if (4 == sameNum)
                     {
                         no2Num           += BuyData.BuyNum;
                         HistoryData.WinNo = 2;
                     }
                     else
                     {
                         if (3 != sameNum)
                         {
                             continue;
                         }
                         no3Num           += BuyData.BuyNum;
                         HistoryData.WinNo = 3;
                     }
                     Hsitory.Add(HistoryData);
                 }
             }
         }
     }
 }
Exemple #7
0
        private KFBoCaoHistoryData InsertHistoryData()
        {
            KFBoCaoHistoryData HistoryData = new KFBoCaoHistoryData();

            HistoryData.DataPeriods = this.OpenData.DataPeriods;
            HistoryData.RoleID      = -1;
            HistoryData.ZoneID      = -1;
            HistoryData.ServerID    = -1;
            HistoryData.RoleName    = "占位";
            HistoryData.BuyNum      = -1;
            HistoryData.WinMoney    = -1L;
            KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, HistoryData);
            return(HistoryData);
        }
        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);
            }
        }
 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");
     }
 }
Exemple #10
0
        public bool IsCanBuy(string buyValue, int buyNum, long DataPeriods)
        {
            bool result;

            if (this.Stage != BoCaiStageEnum.Stage_Buy || DataPeriods != this.OpenData.DataPeriods)
            {
                result = false;
            }
            else
            {
                List <int> value = new List <int>();
                KFBoCaiDbManager.String2ListInt(buyValue, out value);
                result = (value.Count == 5);
            }
            return(result);
        }
Exemple #11
0
 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);
     }
 }
Exemple #12
0
        public bool BuyBoCai(KFBuyBocaiData data)
        {
            bool result;

            lock (this.mutex)
            {
                bool flag = false;
                List <KFBuyBocaiData> itemList;
                if (this.RoleBuyDict.TryGetValue(data.GetKey(), out itemList))
                {
                    KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(data.BuyValue));
                    if (temp == null)
                    {
                        if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                        {
                            itemList.Add(data);
                            flag = true;
                        }
                    }
                    else
                    {
                        data.BuyNum += temp.BuyNum;
                        if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                        {
                            temp.BuyNum = data.BuyNum;
                            flag        = true;
                        }
                    }
                }
                else if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data))
                {
                    itemList = new List <KFBuyBocaiData>();
                    itemList.Add(data);
                    this.RoleBuyDict.Add(data.GetKey(), itemList);
                    flag = true;
                }
                if (flag)
                {
                    this.OpenData.AllBalance += (long)((double)(data.BuyNum * this.OpenData.XiaoHaoDaiBi) * (1.0 - this.Config.XiTongChouCheng));
                }
                result = flag;
            }
            return(result);
        }
Exemple #13
0
 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);
     }
 }
Exemple #14
0
        private bool StartBuy(DateTime time, long Periods, long SurplusBalance = 0L)
        {
            this.PeriodsStartTime        = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss"));
            this.OpenData.DataPeriods    = Periods;
            this.OpenData.strWinNum      = "";
            this.OpenData.WinInfo        = "";
            this.OpenData.BocaiType      = (int)this.BoCaiType;
            this.OpenData.SurplusBalance = SurplusBalance;
            this.SetUpToDBOpenData();
            bool result;

            if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData))
            {
                LogManager.WriteLog(LogTypes.Error, "[ljl_CaiShuZi_猜数字]KFBoCaiDbManager.InserOpenLottery(data) false", null, true);
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Exemple #15
0
 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);
             }
         }
     }
 }
Exemple #16
0
 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);
         }
     }
 }
Exemple #17
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);
     }
 }
Exemple #18
0
 public override void Thread()
 {
     try
     {
         lock (this.mutex)
         {
             if (this.Stage != BoCaiStageEnum.Stage_Init && !this.UpToDBOpenData.WinInfo.Equals(this.OpenData.WinInfo) && this.OpenData.DataPeriods > 1L)
             {
                 this.SetUpToDBOpenData();
                 if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData))
                 {
                     this.UpToDBOpenData.WinInfo = "";
                 }
                 else
                 {
                     this.InsertHistoryData();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true);
     }
     if (BoCaiStageEnum.Stage_Open == this.Stage)
     {
         try
         {
             List <KFBoCaoHistoryData> History = new List <KFBoCaoHistoryData>();
             lock (this.mutex)
             {
                 int        Value   = 0;
                 List <int> openVal = new List <int>();
                 for (int i = 0; i < 3; i++)
                 {
                     int num = Global.GetRandomNumber(1, 7);
                     openVal.Add(num);
                     Value += num;
                 }
                 this.OpenData.strWinNum = KFBoCaiDbManager.ListInt2String(openVal);
                 LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜大小]猜大小 {0},winNum={1}", this.OpenData.DataPeriods, this.OpenData.strWinNum), null, true);
                 if (Value > 3 && Value < 11)
                 {
                     Value = 1;
                 }
                 else if (Value >= 11 && Value < 18)
                 {
                     Value = 3;
                 }
                 else
                 {
                     Value = 2;
                 }
                 if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData))
                 {
                     LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小] 猜大小 开始计算中奖了 KFBoCaiDbManager.InserOpenLottery(data) false", null, true);
                     return;
                 }
                 double Rate = this.CompensateRate((DiceValueEnum)Value);
                 foreach (List <KFBuyBocaiData> BuyDataList in this.RoleBuyDict.Values)
                 {
                     foreach (KFBuyBocaiData BuyData in BuyDataList)
                     {
                         if (Value == Convert.ToInt32(BuyData.BuyValue))
                         {
                             History.Add(new KFBoCaoHistoryData
                             {
                                 DataPeriods = this.OpenData.DataPeriods,
                                 RoleID      = BuyData.RoleID,
                                 ZoneID      = BuyData.ZoneID,
                                 ServerID    = BuyData.ServerID,
                                 RoleName    = BuyData.RoleName,
                                 BuyNum      = BuyData.BuyNum,
                                 WinMoney    = (long)((int)(Rate * (double)BuyData.BuyNum))
                             });
                         }
                     }
                 }
             }
             if (History.Count > 5)
             {
                 History.Sort(new Comparison <KFBoCaoHistoryData>(KFBoCaiCaiDaXiao.SortHistory));
             }
             History = History.GetRange(0, Math.Min(5, History.Count));
             foreach (KFBoCaoHistoryData item in History)
             {
                 if (!KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, item))
                 {
                     LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜大小]猜大小插入中奖历史 false DataPeriods ={0}", item.DataPeriods), null, true);
                 }
             }
             if (History.Count < 1)
             {
                 History.Add(this.InsertHistoryData());
             }
             this.addHistory(History);
             base.SetOpenHistory(this.GetOpenLottery());
             this.Stage = BoCaiStageEnum.Stage_End;
             base.KFSendPeriodsData();
             base.KFSendStageData();
         }
         catch (Exception ex)
         {
             this.Stage = BoCaiStageEnum.Stage_End;
             LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true);
         }
     }
 }