/// <summary>
 /// 初始化开奖信息(一期)
 /// </summary>
 public void InitialTodayInfo(Lotterys Lottery, DateTime dt)
 {
     using (e = new LotteryAPPEntities())
     {
         var dtS   = dt.Date.AddHours((double)Lottery.TimeStart.Value);
         var dtE   = dtS;//dtS.AddHours(Lottery..Value);
         var query = e.LotteryOpen.Count(n => n.LotteryId == Lottery.Id && (n.ScheduleOpenTime > dtS && n.ScheduleOpenTime <= dtE));
         if (query == 0)
         {
             //int AddZero = Lottery.BetweenMinute == 1 ? 4 : 3;
             using (tran = new TransactionScope())
             {
                 for (int i = 1; true; i++)
                 {
                     var ot = dtS.AddMinutes(i * (int)Lottery.BetweenMinute.Value);
                     if (ot > dtE)//超期退出循环
                     {
                         break;
                     }
                     var code = GetAllCodeList()[random.Next(0, GetAllCodeList().Count)];
                     var open = new LotteryOpen
                     {
                         LotteryId        = Lottery.Id,
                         OpenStatus       = (int)Enum_LotteryOpenStatus.Schedule,
                         ScheduleOpenCode = code, //预先开出随机号
                         ScheduleOpenTime = ot,   //间隔多少时间一期
                         Expect           = ot.Date.ToString("yyyyMMdd") + MyTool.AddZeroStr(i, Lottery.ExceptLength.HasValue? Lottery.ExceptLength.Value:0),
                         ExpectDate       = ot.Date.ToString("yyyyMMdd"),
                         RerollCount      = 0,
                     };
                     e.LotteryOpen.Add(open);
                     var info = new LotteryOpenInfo
                     {
                         Expect    = open.Expect,
                         LotteryId = open.LotteryId,
                         OpenCode  = "",
                         OpenDate  = open.ScheduleOpenTime.Date,
                         OpenTime  = open.ScheduleOpenTime,
                     };
                     e.LotteryOpenInfo.Add(info);
                 }
                 e.SaveChanges();
                 tran.Complete();
             }
         }
     }
 }
 public void Add(LotteryOpenInfo Info)
 {
     using (e = new LotteryAPPEntities())
     {
         try
         {
             if (e.LotteryOpenInfo.FirstOrDefault(n => n.LotteryId == Info.LotteryId && n.Expect == Info.Expect) != null)
             {
                 return;//存在期号不增加
             }
             e.LotteryOpenInfo.Add(Info);
             e.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }