Example #1
0
 private static void Run(int LotteryId, string IssueNum)
 {
     try
     {
         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"]))
             {
                 List <KeyValue> list  = new List <KeyValue>();
                 int             num   = Convert.ToInt32(lotteryCheck.Rows[0]["CheckNum"]);
                 string[]        array = new string[20];
                 int             num2  = 0;
                 do
                 {
                     decimal d    = 0m;
                     decimal num3 = 0m;
                     array = NumberCode.CreateCode20();
                     int    num4          = (Convert.ToInt32(array[0]) + Convert.ToInt32(array[1]) + Convert.ToInt32(array[2]) + Convert.ToInt32(array[3])) % 10;
                     int    num5          = (Convert.ToInt32(array[4]) + Convert.ToInt32(array[5]) + Convert.ToInt32(array[6]) + Convert.ToInt32(array[7])) % 10;
                     int    num6          = (Convert.ToInt32(array[8]) + Convert.ToInt32(array[9]) + Convert.ToInt32(array[10]) + Convert.ToInt32(array[11])) % 10;
                     int    num7          = (Convert.ToInt32(array[12]) + Convert.ToInt32(array[13]) + Convert.ToInt32(array[14]) + Convert.ToInt32(array[15])) % 10;
                     int    num8          = (Convert.ToInt32(array[16]) + Convert.ToInt32(array[17]) + Convert.ToInt32(array[18]) + Convert.ToInt32(array[19])) % 10;
                     string lotteryNumber = string.Concat(new object[]
                     {
                         num4,
                         ",",
                         num5,
                         ",",
                         num6,
                         ",",
                         num7,
                         ",",
                         num8
                     });
                     for (int i = 0; i < dataTable.Rows.Count; i++)
                     {
                         DataRow dataRow = dataTable.Rows[i];
                         int     num9    = Convert.ToInt32(dataRow["Id"]);
                         int     num10   = Convert.ToInt32(dataRow["UserId"]);
                         string  sType   = dataRow["PlayCode"].ToString();
                         string  text    = BetDetailDAL.GetBetDetail2(Convert.ToDateTime(dataRow["STime2"]).ToString("yyyyMMdd"), num10.ToString(), num9.ToString());
                         if (string.IsNullOrEmpty(text))
                         {
                             text = "";
                         }
                         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(lotteryNumber, text, pos, sType);
                         num3 += d3 * d5 * d2 * value / 2m + d4 * d5;
                     }
                     decimal num11 = d - num3;
                     if (num11 > 0m)
                     {
                         num2 = num;
                     }
                     list.Add(new KeyValue
                     {
                         tKey   = string.Join(",", array),
                         tValue = num11
                     });
                     num2++;
                 }while (num2 < num);
                 IOrderedEnumerable <KeyValue> source = from a in list
                                                        orderby a.tValue descending
                                                        select a;
                 List <KeyValue> list2 = source.ToList <KeyValue>();
                 GYouleCheck.SetOpenListJson(LotteryId, IssueNum, list2[0].tKey, DateTime.Now.ToString(), string.Concat(list2[0].tValue));
             }
             else
             {
                 string[] value2 = NumberCode.CreateCode20();
                 GYouleCheck.SetOpenListJson(LotteryId, IssueNum, string.Join(",", value2), DateTime.Now.ToString(), "0");
             }
         }
         else
         {
             string[] value3 = NumberCode.CreateCode20();
             GYouleCheck.SetOpenListJson(LotteryId, IssueNum, string.Join(",", value3), DateTime.Now.ToString(), "0");
         }
     }
     catch (Exception ex)
     {
         new LogExceptionDAL().Save("派奖异常", ex.Message);
     }
 }
 private static void Run(int LotteryId, string IssueNum)
 {
     try
     {
         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"]))
             {
                 List <KeyValue> source   = new List <KeyValue>();
                 int             int32_1  = Convert.ToInt32(lotteryCheck.Rows[0]["CheckNum"]);
                 string[]        strArray = new string[20];
                 int             num1     = 0;
                 do
                 {
                     Decimal  num2          = new Decimal(0);
                     Decimal  num3          = new Decimal(0);
                     Decimal  num4          = new Decimal(0);
                     string[] code20        = NumberCode.CreateCode20();
                     string   LotteryNumber = ((Convert.ToInt32(code20[0]) + Convert.ToInt32(code20[1]) + Convert.ToInt32(code20[2]) + Convert.ToInt32(code20[3])) % 10).ToString() + "," + (object)((Convert.ToInt32(code20[4]) + Convert.ToInt32(code20[5]) + Convert.ToInt32(code20[6]) + Convert.ToInt32(code20[7])) % 10) + "," + (object)((Convert.ToInt32(code20[8]) + Convert.ToInt32(code20[9]) + Convert.ToInt32(code20[10]) + Convert.ToInt32(code20[11])) % 10) + "," + (object)((Convert.ToInt32(code20[12]) + Convert.ToInt32(code20[13]) + Convert.ToInt32(code20[14]) + Convert.ToInt32(code20[15])) % 10) + "," + (object)((Convert.ToInt32(code20[16]) + Convert.ToInt32(code20[17]) + Convert.ToInt32(code20[18]) + Convert.ToInt32(code20[19])) % 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(LotteryNumber, CheckNumber, Pos, sType);
                         num4 += num6 * num8 * num5 * (Decimal)num10 / new Decimal(2) + num7 * num8;
                     }
                     Decimal num11 = num3 - num4;
                     if (num11 > new Decimal(0))
                     {
                         num1 = int32_1;
                     }
                     source.Add(new KeyValue()
                     {
                         tKey   = string.Join(",", code20),
                         tValue = num11
                     });
                     ++num1;
                 }while (num1 < int32_1);
                 List <KeyValue> list = source.OrderByDescending <KeyValue, Decimal>((Func <KeyValue, Decimal>)(a => a.tValue)).ToList <KeyValue>();
                 GYouleCheck.SetOpenListJson(LotteryId, IssueNum, list[0].tKey, DateTime.Now.ToString(), string.Concat((object)list[0].tValue));
             }
             else
             {
                 string[] code20 = NumberCode.CreateCode20();
                 GYouleCheck.SetOpenListJson(LotteryId, IssueNum, string.Join(",", code20), DateTime.Now.ToString(), "0");
             }
         }
         else
         {
             string[] code20 = NumberCode.CreateCode20();
             GYouleCheck.SetOpenListJson(LotteryId, IssueNum, string.Join(",", code20), DateTime.Now.ToString(), "0");
         }
     }
     catch (Exception ex)
     {
         new LogExceptionDAL().Save("派奖异常", ex.Message);
     }
 }