private LotteryPool0 GetSellingTicket0(LotteryPool0 lotteryPool0, int direction) { var lp0 = _pool0Repository.GetById(lotteryPool0.Id + direction); if (lp0 != null) { direction = 0 - direction; lp0 = GetSellingTicket0(lotteryPool0, direction); return(lp0); } else { if (lp0.Stat == (int)LotteryStat.Selling) { return(lp0); } else { int abs = Math.Abs(direction); int i = direction / abs; abs++; direction = i * abs; lp0 = GetSellingTicket0(lotteryPool0, direction); return(lp0); } } }
/// <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(); } } }