Пример #1
0
        private LotteryPool1 GetSellingTicket1(LotteryPool1 lotteryPool1, int direction)
        {
            var lp1 = _pool1Repository.GetById(lotteryPool1.Id + direction);

            if (lp1 != null)
            {
                direction = 0 - direction;
                lp1       = GetSellingTicket1(lotteryPool1, direction);
                return(lp1);
            }
            else
            {
                if (lp1.Stat == (int)LotteryStat.Selling)
                {
                    return(lp1);
                }
                else
                {
                    int abs = Math.Abs(direction);
                    int i   = direction / abs;
                    abs++;
                    direction = i * abs;
                    lp1       = GetSellingTicket1(lotteryPool1, direction);
                    return(lp1);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 创建两个彩票池
 /// </summary>
 /// <param name="cmd"></param>
 private void ConstructPool(int cmd)
 {
     if (cmd == 0)
     {
         if (_pool0Repository.Table.Count() == 52 * 52 * 52 * 52)
         {
             List <LotteryPool0> lp0s = new List <LotteryPool0>();
             for (int i = 0; i < 52; i++)
             {
                 for (int j = 0; j < 52; j++)
                 {
                     for (int k = 0; k < 52; k++)
                     {
                         for (int l = 0; l < 52; l++)
                         {
                             var lp0 = new LotteryPool0()
                             {
                                 A       = i,
                                 B       = j,
                                 C       = k,
                                 D       = l,
                                 Stat    = (int)LotteryStat.Selling,
                                 Type    = (int)LotteryType.NotProcessed,
                                 BuyerId = 0
                             };
                             lp0s.Add(lp0);
                         }
                     }
                 }
             }
             //_pool0Repository.Table.
             _pool0Repository.InsertList(lp0s);
         }
         else
         {
             //批量更新
             var all0 = _pool0Repository.CurrentDbSet.ToList();
             foreach (var p0 in all0)
             {
                 p0.BuyerId = 0;
                 p0.Stat    = 0;
                 p0.Type    = 0;
             }
             _mysqlContext.SaveChanges();
         }
     }
     else if (cmd == 1)
     {
         if (_pool0Repository.Table.Count() == 52 * 52 * 52 * 52)
         {
             List <LotteryPool1> lp1s = new List <LotteryPool1>();
             for (int i = 0; i < 52; i++)
             {
                 for (int j = 0; j < 52; j++)
                 {
                     for (int k = 0; k < 52; k++)
                     {
                         for (int l = 0; l < 52; l++)
                         {
                             var lp1 = new LotteryPool1()
                             {
                                 A       = i,
                                 B       = j,
                                 C       = k,
                                 D       = l,
                                 Stat    = (int)LotteryStat.Selling,
                                 Type    = (int)LotteryType.NotProcessed,
                                 BuyerId = 0
                             };
                             lp1s.Add(lp1);
                         }
                     }
                 }
             }
             //_pool1Repository.Table.
             _pool1Repository.InsertList(lp1s);
         }
         else
         {
             //批量更新
             var all1 = _pool1Repository.CurrentDbSet.ToList();
             foreach (var p1 in all1)
             {
                 p1.BuyerId = 0;
                 p1.Stat    = 0;
                 p1.Type    = 0;
             }
             _mysqlContext.SaveChanges();
         }
     }
 }