Пример #1
0
 private void updateOddsHistory()
 {
     if (Request["odds"] != null && Request["scheduleid"] != null)
     {
         JObject result = new JObject();
         try
         {
             string[]       allOddsArray = Request.Form["odds"].Split('^');
             List <string>  swhereList   = new List <string>();
             List <string>  ewhereList   = new List <string>();
             List <decimal> swlist       = new List <decimal>();
             List <decimal> sdlist       = new List <decimal>();
             List <decimal> sllist       = new List <decimal>();
             List <decimal> ewlist       = new List <decimal>();
             List <decimal> edlist       = new List <decimal>();
             List <decimal> ellist       = new List <decimal>();
             foreach (string oddsStr in allOddsArray)
             {
                 string[] oddsArray = oddsStr.Split('|');
                 swhereList.Add("(companyid=" + oddsArray[0] + " and s_win=" + oddsArray[3] +
                                " and s_draw=" + oddsArray[4] + " and s_lost=" + oddsArray[5] + ")");
                 swlist.Add(Convert.ToDecimal(oddsArray[6]));
                 sdlist.Add(Convert.ToDecimal(oddsArray[7]));
                 sllist.Add(Convert.ToDecimal(oddsArray[8]));
                 if (!string.IsNullOrEmpty(oddsArray[10]) && !string.IsNullOrEmpty(oddsArray[11]) && !string.IsNullOrEmpty(oddsArray[12]) && !string.IsNullOrEmpty(oddsArray[13]) && !string.IsNullOrEmpty(oddsArray[14]) && !string.IsNullOrEmpty(oddsArray[15]))
                 {
                     ewhereList.Add("(companyid=" + oddsArray[0] + " and e_win=" + oddsArray[10] +
                                    " and e_draw=" + oddsArray[11] + " and e_lost=" + oddsArray[12] + ")");
                     ewlist.Add(Convert.ToDecimal(oddsArray[13]));
                     edlist.Add(Convert.ToDecimal(oddsArray[14]));
                     ellist.Add(Convert.ToDecimal(oddsArray[15]));
                 }
             }
             DataSet sds = scheduleBLL.statOddsHistory("(" + String.Join(" or ", swhereList.ToArray()) + ")");
             DataSet eds = scheduleBLL.statOddsHistory("(" + String.Join(" or ", ewhereList.ToArray()) + ")");
             if (sds != null && eds != null)
             {
                 ScheduleAnalysis model = new ScheduleAnalysis();
                 model.scheduleid = Convert.ToInt32(Request.Form["scheduleid"]);
                 model.oddswin    = ewlist.Average() - swlist.Average();
                 model.oddsdraw   = edlist.Average() - sdlist.Average();
                 model.oddslost   = ellist.Average() - sllist.Average();
                 model.perwin     = Convert.ToDecimal(eds.Tables[0].Rows[0][0]) - Convert.ToDecimal(sds.Tables[0].Rows[0][0]);
                 model.perdraw    = Convert.ToDecimal(eds.Tables[0].Rows[0][1]) - Convert.ToDecimal(sds.Tables[0].Rows[0][1]);
                 model.perlost    = Convert.ToDecimal(eds.Tables[0].Rows[0][2]) - Convert.ToDecimal(sds.Tables[0].Rows[0][2]);
                 model.time       = DateTime.Now;
                 if (!scheduleAnalysisBLL.Exists(model))
                 {
                     scheduleAnalysisBLL.Add(model);
                     Response.Write("更新赔率成功");
                 }
             }
         }
         catch (Exception e)
         {
             Response.Write(e.Message);
         }
     }
 }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request["odds"] != null)
         {
             string[]  oddsArray = Request["odds"].Split('|');
             DataTable dt        = this.FillOddsHistory(oddsArray);                              //填充
             DateTime  stime     = Convert.ToDateTime(dt.Compute("max(time)", "")).AddHours(-6); // 6小时内
             dt = dt.Select("time > '" + stime.ToString() + "'").CopyToDataTable();
             JArray data = new JArray();
             foreach (DataRow dr in dt.Rows)
             {
                 DataSet ds = scheduleBLL.statOddsHistory("companyid=" + oddsArray[0] + " and e_win=" + dr["odds_w"] +
                                                          " and e_draw=" + dr["odds_d"] + " and e_lost=" + dr["odds_l"]);
                 if (Convert.ToInt32(ds.Tables[0].Rows[0]["totalcount"]) > 0)
                 {
                     JObject obj = new JObject();
                     obj.Add("time", dr["time"].ToString());
                     obj.Add("win", Convert.ToDecimal(ds.Tables[0].Rows[0]["perwin"]) - Convert.ToDecimal(dr["per_w"]) * 100);
                     obj.Add("draw", Convert.ToDecimal(ds.Tables[0].Rows[0]["perdraw"]) - Convert.ToDecimal(dr["per_d"]) * 100);
                     obj.Add("lost", Convert.ToDecimal(ds.Tables[0].Rows[0]["perlost"]) - Convert.ToDecimal(dr["per_l"]) * 100);
                     obj.Add("totalcount", Convert.ToInt32(ds.Tables[0].Rows[0]["totalcount"]));
                     data.Add(obj);
                 }
             }
             Response.Write(data.ToString());
             Response.End();
         }
     }
 }