private static void Run(int LotteryId, string IssueNum)
 {
     try
     {
         YoulePk10Check.list.Clear();
         DataTable dataTable = LotteryDAL.GetDataTable(LotteryId.ToString(), IssueNum);
         if (dataTable.Rows.Count > 0)
         {
             DataTable lotteryCheck = LotteryDAL.GetLotteryCheck(LotteryId);
             if (LotteryDAL.GetCurRealGet(LotteryId) < Convert.ToDecimal(lotteryCheck.Rows[0]["CheckPer"]))
             {
                 int    int32_1 = Convert.ToInt32(lotteryCheck.Rows[0]["CheckNum"]);
                 int    num1    = 0;
                 string codePk10;
                 do
                 {
                     Decimal num2 = new Decimal(0);
                     Decimal num3 = new Decimal(0);
                     Decimal num4 = new Decimal(0);
                     codePk10 = NumberCode.CreateCodePk10(10);
                     for (int index = 0; index < dataTable.Rows.Count; ++index)
                     {
                         DataRow row         = dataTable.Rows[index];
                         int     int32_2     = Convert.ToInt32(row["Id"]);
                         int     int32_3     = Convert.ToInt32(row["UserId"]);
                         string  sType       = row["PlayCode"].ToString();
                         string  CheckNumber = BetDetailDAL.GetBetDetail2(Convert.ToDateTime(row["STime2"]).ToString("yyyyMMdd"), int32_3.ToString(), int32_2.ToString());
                         if (string.IsNullOrEmpty(CheckNumber))
                         {
                             CheckNumber = "";
                         }
                         string  Pos  = row["Pos"].ToString();
                         Decimal num5 = Convert.ToDecimal(row["SingleMoney"]);
                         Decimal num6 = Convert.ToDecimal(row["Bonus"]);
                         Decimal num7 = Convert.ToDecimal(row["PointMoney"]);
                         Decimal num8 = Convert.ToDecimal(row["Times"]);
                         Decimal num9 = Convert.ToDecimal(row["Total"]);
                         num3 += num9 * num8;
                         int num10 = CheckPlay.Check(codePk10, CheckNumber, Pos, sType);
                         num4 += num6 * num8 * num5 * (Decimal)num10 / new Decimal(2) + num7;
                     }
                     Decimal num11 = num3 - num4;
                     if (num11 > new Decimal(0))
                     {
                         num1 = int32_1;
                     }
                     YoulePk10Check.list.Add(new KeyValue()
                     {
                         tKey   = codePk10,
                         tValue = num11
                     });
                     ++num1;
                 }while (num1 < int32_1);
                 List <KeyValue> list = YoulePk10Check.list.OrderByDescending <KeyValue, Decimal>((Func <KeyValue, Decimal>)(a => a.tValue)).ToList <KeyValue>();
                 if (new LotteryDataDAL().Exists(LotteryId, IssueNum))
                 {
                     return;
                 }
                 new LotteryDataDAL().AddYoule(LotteryId, IssueNum, list[0].tKey, DateTime.Now.ToString(), codePk10);
                 LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, list[0].tKey);
                 YoulePk10Check.SetOpenListJson(LotteryId);
             }
             else
             {
                 string codePk10 = NumberCode.CreateCodePk10(10);
                 if (new LotteryDataDAL().Exists(LotteryId, IssueNum))
                 {
                     return;
                 }
                 new LotteryDataDAL().AddYoule(LotteryId, IssueNum, codePk10, DateTime.Now.ToString(), codePk10);
                 LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, codePk10);
                 YoulePk10Check.SetOpenListJson(LotteryId);
             }
         }
         else
         {
             string codePk10 = NumberCode.CreateCodePk10(10);
             if (new LotteryDataDAL().Exists(LotteryId, IssueNum))
             {
                 return;
             }
             new LotteryDataDAL().AddYoule(LotteryId, IssueNum, codePk10, DateTime.Now.ToString(), codePk10);
             LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, codePk10);
             YoulePk10Check.SetOpenListJson(LotteryId);
         }
     }
     catch (Exception ex)
     {
         new LogExceptionDAL().Save("派奖异常", ex.Message);
     }
 }
Esempio n. 2
0
 private static void Run(int LotteryId, string IssueNum)
 {
     try
     {
         YoulePk10Check.list.Clear();
         DataTable dataTable = LotteryDAL.GetDataTable(LotteryId.ToString(), IssueNum);
         if (dataTable.Rows.Count > 0)
         {
             DataTable lotteryCheck = LotteryDAL.GetLotteryCheck(LotteryId);
             decimal   curRealGet   = LotteryDAL.GetCurRealGet(LotteryId);
             if (curRealGet < Convert.ToDecimal(lotteryCheck.Rows[0]["CheckPer"]))
             {
                 int    num  = Convert.ToInt32(lotteryCheck.Rows[0]["CheckNum"]);
                 int    num2 = 0;
                 string text;
                 do
                 {
                     decimal d    = 0m;
                     decimal num3 = 0m;
                     text = NumberCode.CreateCodePk10(10);
                     for (int i = 0; i < dataTable.Rows.Count; i++)
                     {
                         DataRow dataRow = dataTable.Rows[i];
                         int     num4    = Convert.ToInt32(dataRow["Id"]);
                         int     num5    = Convert.ToInt32(dataRow["UserId"]);
                         string  sType   = dataRow["PlayCode"].ToString();
                         string  text2   = BetDetailDAL.GetBetDetail2(Convert.ToDateTime(dataRow["STime2"]).ToString("yyyyMMdd"), num5.ToString(), num4.ToString());
                         if (string.IsNullOrEmpty(text2))
                         {
                             text2 = "";
                         }
                         string  pos = dataRow["Pos"].ToString();
                         decimal d2  = Convert.ToDecimal(dataRow["SingleMoney"]);
                         decimal d3  = Convert.ToDecimal(dataRow["Bonus"]);
                         decimal d4  = Convert.ToDecimal(dataRow["PointMoney"]);
                         decimal d5  = Convert.ToDecimal(dataRow["Times"]);
                         decimal d6  = Convert.ToDecimal(dataRow["Total"]);
                         d += d6 * d5;
                         int value = CheckPlay.Check(text, text2, pos, sType);
                         num3 += d3 * d5 * d2 * value / 2m + d4;
                     }
                     decimal num6 = d - num3;
                     if (num6 > 0m)
                     {
                         num2 = num;
                     }
                     KeyValue keyValue = new KeyValue();
                     keyValue.tKey   = text;
                     keyValue.tValue = num6;
                     YoulePk10Check.list.Add(keyValue);
                     num2++;
                 }while (num2 < num);
                 IOrderedEnumerable <KeyValue> source = from a in YoulePk10Check.list
                                                        orderby a.tValue descending
                                                        select a;
                 List <KeyValue> list = source.ToList <KeyValue>();
                 if (!new LotteryDataDAL().Exists(LotteryId, IssueNum))
                 {
                     new LotteryDataDAL().AddYoule(LotteryId, IssueNum, list[0].tKey, DateTime.Now.ToString(), text);
                     LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, list[0].tKey);
                     YoulePk10Check.SetOpenListJson(LotteryId);
                 }
             }
             else
             {
                 string text3 = NumberCode.CreateCodePk10(10);
                 if (!new LotteryDataDAL().Exists(LotteryId, IssueNum))
                 {
                     new LotteryDataDAL().AddYoule(LotteryId, IssueNum, text3, DateTime.Now.ToString(), text3);
                     LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, text3);
                     YoulePk10Check.SetOpenListJson(LotteryId);
                 }
             }
         }
         else
         {
             string text4 = NumberCode.CreateCodePk10(10);
             if (!new LotteryDataDAL().Exists(LotteryId, IssueNum))
             {
                 new LotteryDataDAL().AddYoule(LotteryId, IssueNum, text4, DateTime.Now.ToString(), text4);
                 LotteryCheck.RunYouleOfIssueNum(LotteryId, IssueNum, text4);
                 YoulePk10Check.SetOpenListJson(LotteryId);
             }
         }
     }
     catch (Exception ex)
     {
         new LogExceptionDAL().Save("派奖异常", ex.Message);
     }
 }