public void updateOdds1x2Stat(string scheduleID) { try { ScheduleAnalysisBLL scheduleAnalysisBLL = new ScheduleAnalysisBLL(); ScheduleBLL scheduleBLL = new ScheduleBLL(); WebClientBLL bll = new WebClientBLL(); string actual = bll.UpdateOdds1x2Content(scheduleID); //获取赔率原始数据 Regex reg = new Regex("game\\=Array\\(\"" + "\\w[^;" + "]*;"); Match mat = reg.Match(actual); if (mat != null && !String.IsNullOrEmpty(mat.Value)) { 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>(); //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] oddsArr = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); foreach (string oddsStr in oddsArr) { string[] oddsArray = oddsStr.Replace("\"", "").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(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); } } } } catch (Exception e) { throw e; } }
public void updateOdds1x2Stat(string scheduleID) { try { ScheduleAnalysisBLL scheduleAnalysisBLL = new ScheduleAnalysisBLL(); ScheduleBLL scheduleBLL = new ScheduleBLL(); WebClientBLL bll = new WebClientBLL(); string actual = bll.UpdateOdds1x2Content(scheduleID); //获取赔率原始数据 Regex reg = new Regex("game\\=Array\\(\"" + "\\w[^;" + "]*;"); Match mat = reg.Match(actual); if (mat != null && !String.IsNullOrEmpty(mat.Value)) { 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>(); //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] oddsArr = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); foreach (string oddsStr in oddsArr) { string[] oddsArray = oddsStr.Replace("\"", "").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(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); } } } } catch (Exception e) { throw e; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ScheduleBLL schedulebll = new ScheduleBLL(); odds_rq rqbll = new odds_rq(); odds_bz bzbll = new odds_bz(); DataSet schedule = DbHelperSQL.Query("select top 200 id,scheduletypeid,Data,Date,home,away FROM Schedule where updated=1 order by id desc"); List<int> companyidList = new List<int>(); foreach (DataRow dr in schedule.Tables[0].Rows) { DataSet odds = DbHelperSQL.Query("select a.companyid, a.home aaa,a.pankou aab,a.away aac,b.home aba,b.pankou abb,b.away abc from tempdb..TempTable_Companys_Chupan_RQ a join tempdb..TempTable_Companys_Zhongpan_RQ b on a.scheduleid=b.scheduleid and a.companyid=b.companyid where a.scheduleid=" + dr["id"]); List<string> oddsList = new List<string>(); foreach (DataRow item in odds.Tables[0].Rows) { string[] sa = { item["aaa"].ToString(), item["aab"].ToString(), item["aac"].ToString(), item["aba"].ToString(), item["abb"].ToString(), item["abc"].ToString(), item["companyid"].ToString() }; oddsList.Add(string.Join(",", sa)); companyidList.Add(Convert.ToInt32(item["companyid"])); } if (oddsList.Count > 0) { //DataTable dt = rqbll.queryOddsPer(oddsList, 0.02f, 0, Convert.ToInt32(dr["id"])); //DataTable dt = rqbll.queryCompanyOddsPer(oddsList, 0, Convert.ToInt32(dr["id"])); DataTable dt = bzbll.queryCompanyOddsPer(oddsList, 0, Convert.ToInt32(dr["id"])); //DataTable dt = rqbll.queryCompanyOddsPer1(Convert.ToInt32(dr["scheduletypeid"]), Convert.ToInt32(dr["id"]), companyidList); try { double pankou = Convert.ToDouble(odds.Tables[0].Rows[0]["aab"]); if (dt.Rows.Count > 0) { if (Math.Abs(Convert.ToInt32(dt.Compute("avg(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("avg(rqs)", "1=1"))) > 10) { if (Convert.ToInt32(dt.Compute("avg(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("avg(rqs)", "1=1")) > 10 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) > pankou) { winCount++; } else if (Convert.ToInt32(dt.Compute("avg(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("avg(rqs)", "1=1")) < 10 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) < pankou) { winCount++; } totalCount++; } if (Math.Abs(Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1"))) > 0) { if (Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1")) > 0 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) > pankou) { winCount1++; } else if (Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1")) < 0 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) < pankou) { winCount1++; } totalCount1++; } double ycount = Convert.ToDouble(dt.Compute("count(rqy)", "rqy > rqs")); double scount = Convert.ToDouble(dt.Compute("count(rqy)", "rqy < rqs")); if (ycount + scount > 0) { if (ycount / (ycount + scount) > 0.7d || scount / (ycount + scount) > 0.7d) { if (ycount / (ycount + scount) > 0.7d && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) > pankou) { winCount2++; } else if (scount / (ycount + scount) > 0.7d && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) < pankou) { winCount2++; } totalCount2++; } } if (Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1")) < 0 && Convert.ToInt32(dt.Compute("count(rqy)", "rqy > rqs")) - Convert.ToInt32(dt.Compute("count(rqy)", "rqy < rqs")) >= 10) { if (Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) > pankou) { winCount3++; } totalCount3++; } else if (Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1")) >0 && Convert.ToInt32(dt.Compute("count(rqy)", "rqy > rqs")) - Convert.ToInt32(dt.Compute("count(rqy)", "rqy < rqs")) <= 10) { if (Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) < pankou) { winCount3++; } totalCount3++; } } //DataSet ds = rqbll.queryOddsCount(oddsList, 0.05f, 0, Convert.ToInt32(dr["id"]));//Convert.ToInt32(dr["scheduleTypeid"]) //if (ds != null && Convert.ToInt32(ds.Tables[0].Rows[0]["totalCount"]) > 0) //{ // int diff = Convert.ToInt32(ds.Tables[0].Rows[0][0]) - Convert.ToInt32(ds.Tables[0].Rows[0][2]); // //if (Math.Abs(diff) >= 5 && Math.Min(Convert.ToInt32(ds.Tables[0].Rows[0][0]), Convert.ToInt32(ds.Tables[0].Rows[0][2])) == 0) // //{ // if (diff > 0 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) > pankou) // { // winCount3++; // } // else if (diff < 0 && Convert.ToInt32(dr["home"]) - Convert.ToInt32(dr["away"]) < pankou) // { // winCount3++; // } // totalCount3++; // //} //} } catch (Exception) { throw; } } } } }