public string GetRemoteHtml(string path, string[] paramArray) { WebClient web = WebClientBLL.getWebClient(); string url = string.Format(root + path, paramArray); return(web.DownloadString(url)); }
public string LoadHistoryFile(string date) { WebClient web = WebClientBLL.getWebClient(); string url = string.Format(HistoryDataURL, date); string s = web.DownloadString(url + "&" + DateTime.Now); return(s); }
public static void UpdateLiveDataContent() { WebClient web = WebClientBLL.getWebClient(); TimeSpan ts = DateTime.Now - DateTime.Parse("1970-1-1 "); string s = web.DownloadString(LiveDataURL + "?" + (long)ts.TotalMilliseconds); DataCache.SetCache("LiveDataContent", s); }
public static void UpdateHistoryLiveDataContent(string date) { WebClient web = WebClientBLL.getWebClient(); string url = string.Format(HistoryDataURL, date); string s = web.DownloadString(url + "&" + DateTime.Now); DataCache.SetCache("LiveDataContent", s); }
public static void UpdateOddsDataContent(string date) { WebClient web = WebClientBLL.getWebClient(); string url = string.Format(root + OddsDataURL, date); string s = web.DownloadString(url + "&_t=" + DateTime.Now); DataCache.SetCache("OddsDetailContent", s); }
/// <summary> /// 读取即时比分数据 /// </summary> /// <returns></returns> public string LoadLiveFile() { WebClient web = WebClientBLL.getWebClient(); TimeSpan ts = DateTime.Now - DateTime.Parse("1970-1-1 "); string s = web.DownloadString(LiveDataURL + "?" + (long)ts.TotalMilliseconds); return(s); }
/// <summary> /// 增加一条数据 /// </summary> public string Add(string scheduleID, string companyids, string historyids, DateTime time) { WebClientBLL bll = new WebClientBLL(); string[] companyidArr = companyids.Split(','); string[] historyidArr = historyids.Split(','); int count = 0; if (companyidArr.Length == historyidArr.Length) { dal.Delete(scheduleID); for (int i = 0; i < companyidArr.Length; i++) { string s = bll.GetOddsHistoryContent(historyidArr[i]); Lexer lexer = new Lexer(s); Parser parser = new Parser(lexer); NodeList bodyNodes = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children; ITag table = bodyNodes.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableTag))[0] as ITag; NodeList tableRows = table.Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableRow)); for (int f = 0; f < tableRows.Count; f++) { ITag row = tableRows[f] as ITag; if (row.Attributes["ALIGN"].Equals("center") && row.Attributes["BGCOLOR"].Equals("#FFFFFF")) { Odds1x2History model = new Odds1x2History(); model.companyid = int.Parse(companyidArr[i]); model.scheduleid = int.Parse(scheduleID); model.home = float.Parse(row.Children[0].ToPlainTextString()); model.draw = float.Parse(row.Children[1].ToPlainTextString()); model.away = float.Parse(row.Children[2].ToPlainTextString()); this.FillOdds1x2History(model); string[] t2 = row.Children[3].ToPlainTextString().Replace("showtime(", "").Replace(")", "").Split(','); int yy = int.Parse(t2[0]); int mm = int.Parse(t2[1].Remove(2)); int dd = int.Parse(t2[2]); int hh = int.Parse(t2[3]); int mi = int.Parse(t2[4]); int ss = int.Parse(t2[5]); model.time = new DateTime(yy, mm, dd, hh, mi, ss, DateTimeKind.Utc).AddHours(8d); if (model.time > time) { continue; } dal.Add(model); count++; } } } } JSONHelper json = new JSONHelper(); json.success = true; json.totlalCount = count; return(json.ToString()); }
public string GetOddsHistoryContent(string id) { WebClient web = WebClientBLL.getWebClient(); //string url = string.Format(Odds1x2, scheduleID); string url = string.Format(OddsHistoryURL, id); string s = web.DownloadString(url + "&" + DateTime.Now); return(s); }
public static void UpdateAnalysisContent(string scheduleID) { WebClient web = WebClientBLL.getWebClient(); //string url = string.Format(Odds1x2, scheduleID); string url = string.Format(AnalysisURL, scheduleID); string s = web.DownloadString(url + "?" + DateTime.Now); DataCache.SetCache("AnalysisContent", s); }
public string UpdateOdds1x2Content(string scheduleID) { WebClient web = WebClientBLL.getWebClient(); //string url = string.Format(Odds1x2, scheduleID); string url = string.Format(Odds1x2URL, scheduleID); TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks); string s = web.DownloadString(url + "?" + ts.TotalMilliseconds); return(s); }
public static void UpdateMarkets() { WebClient web = WebClientBLL.getWebClient(); web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)"); web.Headers.Add("Accept", "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"); web.Headers.Add("Accept-Language", "zh-CN"); string s = web.DownloadString(MarketsURL + "?" + DateTime.Now); DataCache.SetCache("MarketsURL", s); }
/// <summary> /// 增加一条数据 /// </summary> public string Add(string scheduleID, string companyids, string historyids,DateTime time) { WebClientBLL bll = new WebClientBLL(); string[] companyidArr = companyids.Split(','); string[] historyidArr = historyids.Split(','); int count = 0; if (companyidArr.Length == historyidArr.Length) { dal.Delete(scheduleID); for (int i = 0; i < companyidArr.Length; i++) { string s = bll.GetOddsHistoryContent(historyidArr[i]); Lexer lexer = new Lexer(s); Parser parser = new Parser(lexer); NodeList bodyNodes = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children; ITag table = bodyNodes.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableTag))[0] as ITag; NodeList tableRows = table.Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableRow)); for (int f = 0; f < tableRows.Count; f++) { ITag row = tableRows[f] as ITag; if (row.Attributes["ALIGN"].Equals("center") && row.Attributes["BGCOLOR"].Equals("#FFFFFF")){ Odds1x2History model = new Odds1x2History(); model.companyid = int.Parse(companyidArr[i]); model.scheduleid = int.Parse(scheduleID); model.home = float.Parse(row.Children[0].ToPlainTextString()); model.draw = float.Parse(row.Children[1].ToPlainTextString()); model.away = float.Parse(row.Children[2].ToPlainTextString()); this.FillOdds1x2History(model); string[] t2 = row.Children[3].ToPlainTextString().Replace("showtime(", "").Replace(")", "").Split(','); int yy = int.Parse(t2[0]); int mm = int.Parse(t2[1].Remove(2)); int dd = int.Parse(t2[2]); int hh = int.Parse(t2[3]); int mi = int.Parse(t2[4]); int ss = int.Parse(t2[5]); model.time = new DateTime(yy, mm, dd, hh, mi, ss, DateTimeKind.Utc).AddHours(8d); if (model.time > time) { continue; } dal.Add(model); count++; } } } } JSONHelper json = new JSONHelper(); json.success = true; json.totlalCount = count; return json.ToString(); }
private void GetHistoryLiveFile() { try { WebClientBLL bll = new WebClientBLL(); StringJSON = bll.LoadHistoryFile(Request.Form["now"]); } catch (Exception e) { System.Diagnostics.Debug.Write(e); throw; } }
private void GetLiveFile() { try { WebClientBLL bll = new WebClientBLL(); StringJSON = bll.LoadLiveFile(); } catch (Exception e) { System.Diagnostics.Debug.Write(e); throw; } }
public string GetOdds1x2(string scheduleID) { try { WebClientBLL bll = new WebClientBLL(); string actual = bll.UpdateOdds1x2Content(scheduleID); JArray data = new JArray(); //获取赔率原始数据 Regex reg = new Regex("game\\=Array\\(\"" + "\\w[^;" + "]*;"); Match mat = reg.Match(actual); if (mat != null) { //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] compstrs = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); DataSet ds = dal.GetCompanyGroupOddsCount(scheduleID); foreach (string compstr in compstrs) { JObject item = new JObject(); string[] oddsArr = compstr.Replace("\"", "").Split('|'); for (int i = 0; i < oddsArr.Length; i++) { item.Add("Odds_" + i, oddsArr[i]); } AddGameInfo(actual, item); if (ds.Tables[0].Select("companyid='" + oddsArr[0] + "'").Length > 0) { item.Add("OddsCount", int.Parse(ds.Tables[0].Select("companyid='" + oddsArr[0] + "'")[0]["oddscount"].ToString())); } data.Add(item); } } JObject result = new JObject(); result.Add(new JProperty("totlalCount", data.Count)); result.Add(new JProperty("data", data)); return(result.ToString()); } catch (Exception) { return(""); } }
public string GetBetLiveData(string date, int companyid) { WebClientBLL web = new WebClientBLL(); string actual = ""; if (string.IsNullOrEmpty(date)) { actual = web.LoadLiveFile(); } else { actual = web.LoadHistoryFile(date); } List <string> existList = new List <string>(); //string[] sArray = Regex.Split(actual, "\r\n", RegexOptions.IgnoreCase); //SeoWebSite.DAL.BetExpDAO betExpDAO = new SeoWebSite.DAL.BetExpDAO(); //foreach (string i in sArray) //{ // if (i.StartsWith("A[") && i.EndsWith("];")) // { // string matchid = i.Split(new char[2] { '[', ']' })[3].Split(',')[0]; // //existList.Add(betExpDAO.GetIsExpByID(matchid)); // } //} actual = ("var favorites=['" + string.Join("','", existList.ToArray()) + "'];") + actual; string showids = ""; if (companyid != 0) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load("http://live.nowodds.com/data/goal" + companyid + ".xml"); showids = xmldoc.SelectNodes("c/ids")[0].InnerText; } actual = ("var showlist=[" + showids + "];") + actual; return(actual); }
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 updateOdds1x2(string scheduleID) { try { OddsDAO oddsDAO = new OddsDAO(); CompanyDAO companyDAO = new CompanyDAO(); 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)) { //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] compstrs = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); foreach (string compstr in compstrs) { JObject item = new JObject(); string[] oddsArr = compstr.Replace("\"", "").Split('|'); #region 插入公司数据 if (!companyDAO.Exists(int.Parse(oddsArr[0])) && oddsArr.Length > 22) { SeoWebSite.Model.Company company = new SeoWebSite.Model.Company(); company.id = int.Parse(oddsArr[0]); company.fullname = oddsArr[21]; company.name = oddsArr[2]; company.isprimary = Convert.ToBoolean(int.Parse(oddsArr[22])); company.isexchange = Convert.ToBoolean(int.Parse(oddsArr[23])); companyDAO.Add(company); } #endregion #region 插入欧赔数据 if (!oddsDAO.Exists(int.Parse(oddsArr[1]))) { Odds odds = new Odds(); odds.scheduleid = int.Parse(scheduleID); odds.companyid = int.Parse(oddsArr[0]); odds.id = int.Parse(oddsArr[1]); odds.s_win = decimal.Parse(oddsArr[3]); odds.s_draw = decimal.Parse(oddsArr[4]); odds.s_lost = decimal.Parse(oddsArr[5]); odds.s_winper = decimal.Parse(oddsArr[6]); odds.s_drawper = decimal.Parse(oddsArr[7]); odds.s_lostper = decimal.Parse(oddsArr[8]); if (!String.IsNullOrEmpty(oddsArr[9])) { odds.s_return = decimal.Parse(oddsArr[9]); } if (!String.IsNullOrEmpty(oddsArr[10])) { odds.e_win = decimal.Parse(oddsArr[10]); } if (!String.IsNullOrEmpty(oddsArr[11])) { odds.e_draw = decimal.Parse(oddsArr[11]); } if (!String.IsNullOrEmpty(oddsArr[12])) { odds.e_lost = decimal.Parse(oddsArr[12]); } if (!String.IsNullOrEmpty(oddsArr[13])) { odds.e_winper = decimal.Parse(oddsArr[13]); } if (!String.IsNullOrEmpty(oddsArr[14])) { odds.e_drawper = decimal.Parse(oddsArr[14]); } if (!String.IsNullOrEmpty(oddsArr[15])) { odds.e_lostper = decimal.Parse(oddsArr[15]); } if (!String.IsNullOrEmpty(oddsArr[16])) { odds.e_return = decimal.Parse(oddsArr[16]); } if (!String.IsNullOrEmpty(oddsArr[17])) { odds.winkelly = decimal.Parse(oddsArr[17]); } if (!String.IsNullOrEmpty(oddsArr[18])) { odds.drawkelly = decimal.Parse(oddsArr[18]); } if (!String.IsNullOrEmpty(oddsArr[19])) { odds.lostkelly = decimal.Parse(oddsArr[19]); } string[] timeArr = oddsArr[20].Split(','); odds.lastupdatetime = new DateTime(int.Parse(timeArr[0]), int.Parse(timeArr[1].Remove(2)), int.Parse(timeArr[2]), int.Parse(timeArr[3]), int.Parse(timeArr[4]), int.Parse(timeArr[5])).AddHours(8); oddsDAO.Add(odds); } #endregion } } } catch (WebException e) { HttpWebResponse response = (HttpWebResponse)e.Response; if (response != null) //排除对象为空的错误 { if (response.StatusCode == HttpStatusCode.NotFound) //判断是否是404错误 sdal.Delete(Convert.ToInt32(scheduleID)); } } }
public string GetOdds1x2(string scheduleID) { try { WebClientBLL bll = new WebClientBLL(); string actual = bll.UpdateOdds1x2Content(scheduleID); JArray data = new JArray(); //获取赔率原始数据 Regex reg = new Regex("game\\=Array\\(\"" + "\\w[^;" + "]*;"); Match mat = reg.Match(actual); if (mat != null) { //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] compstrs = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); DataSet ds = dal.GetCompanyGroupOddsCount(scheduleID); foreach (string compstr in compstrs) { JObject item = new JObject(); string[] oddsArr = compstr.Replace("\"", "").Split('|'); for (int i = 0; i < oddsArr.Length; i++) { item.Add("Odds_" + i, oddsArr[i]); } AddGameInfo(actual, item); if (ds.Tables[0].Select("companyid='" + oddsArr[0] + "'").Length > 0) { item.Add("OddsCount", int.Parse(ds.Tables[0].Select("companyid='" + oddsArr[0] + "'")[0]["oddscount"].ToString())); } data.Add(item); } } JObject result = new JObject(); result.Add(new JProperty("totlalCount", data.Count)); result.Add(new JProperty("data", data)); return result.ToString(); } catch (Exception) { return ""; } }
public string GetBetLiveData(string date, int companyid) { WebClientBLL web = new WebClientBLL(); string actual = ""; if (string.IsNullOrEmpty(date)) { actual = web.LoadLiveFile(); } else { actual = web.LoadHistoryFile(date); } List<string> existList = new List<string>(); //string[] sArray = Regex.Split(actual, "\r\n", RegexOptions.IgnoreCase); //SeoWebSite.DAL.BetExpDAO betExpDAO = new SeoWebSite.DAL.BetExpDAO(); //foreach (string i in sArray) //{ // if (i.StartsWith("A[") && i.EndsWith("];")) // { // string matchid = i.Split(new char[2] { '[', ']' })[3].Split(',')[0]; // //existList.Add(betExpDAO.GetIsExpByID(matchid)); // } //} actual = ("var favorites=['" + string.Join("','", existList.ToArray()) + "'];") + actual; string showids = ""; if (companyid != 0) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load("http://live.nowodds.com/data/goal" + companyid + ".xml"); showids = xmldoc.SelectNodes("c/ids")[0].InnerText; } actual = ("var showlist=[" + showids + "];") + actual; return actual; }
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; } }
private void getOdds3in1() { SeoWebSite.BLL.odds_rq odds_rqbll = new SeoWebSite.BLL.odds_rq(); WebClientBLL webClientBLL = new WebClientBLL(); try { if (Request["scheduleid"] != null && Request["companyid"] != null) { string scheduleid = Request.Form["scheduleid"]; string[] companyid_Array = Request.Form["companyid"].Split(','); DataTable dt = new DataTable(); dt.Columns.Add("scheduleid", typeof(int)); dt.Columns.Add("companyid", typeof(int)); dt.Columns.Add("aaa", typeof(double)); dt.Columns.Add("aab", typeof(double)); dt.Columns.Add("aac", typeof(double)); dt.Columns.Add("aba", typeof(double)); dt.Columns.Add("abb", typeof(double)); dt.Columns.Add("abc", typeof(double)); dt.Columns.Add("baa", typeof(double)); dt.Columns.Add("bab", typeof(double)); dt.Columns.Add("bac", typeof(double)); dt.Columns.Add("bba", typeof(double)); dt.Columns.Add("bbb", typeof(double)); dt.Columns.Add("bbc", typeof(double)); dt.Columns.Add("caa", typeof(double)); dt.Columns.Add("cab", typeof(double)); dt.Columns.Add("cac", typeof(double)); dt.Columns.Add("cba", typeof(double)); dt.Columns.Add("cbb", typeof(double)); dt.Columns.Add("cbc", typeof(double)); dt.Columns.Add("aaa1", typeof(string)); dt.Columns.Add("aab1", typeof(string)); dt.Columns.Add("aac1", typeof(string)); dt.Columns.Add("aba1", typeof(string)); dt.Columns.Add("abb1", typeof(string)); dt.Columns.Add("abc1", typeof(string)); dt.Columns.Add("baa1", typeof(string)); dt.Columns.Add("bab1", typeof(string)); dt.Columns.Add("bac1", typeof(string)); dt.Columns.Add("bba1", typeof(string)); dt.Columns.Add("bbb1", typeof(string)); dt.Columns.Add("bbc1", typeof(string)); foreach (string companyid in companyid_Array) { string[] paramArr = { companyid, scheduleid }; string s = webClientBLL.GetRemoteHtml("odds/detail.aspx?companyID={0}&scheduleid={1}", paramArr); Parser parser = Parser.CreateParser(s, "utf-8"); AndFilter andFilter = new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("bgColor", "#bbbbbb")); NodeList tableList = parser.ExtractAllNodesThatMatch(andFilter); parser = Parser.CreateParser(s, "utf-8"); //NodeList h3tag = parser.ExtractAllNodesThatMatch(new TagNameFilter("h3")); //string year = h3tag[0].ToPlainTextString().Remove(5); if (tableList.Count == 3) { DataRow dr = dt.NewRow(); dr["scheduleid"] = scheduleid; dr["companyid"] = companyid; NodeList tdList; string pankou; #region 让球盘 AndFilter andFilter1 = new AndFilter(new TagNameFilter("tr"), new HasAttributeFilter("class", "ts1")); NodeList list = tableList[0].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//初盘 pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); double per1 = 0, per2 = 0, per3 = 0; double per4 = 0, per5 = 0, per6 = 0; if (!string.IsNullOrEmpty(pankou)) { dr["aaa"] = tdList[0].ToPlainTextString(); dr["aab"] = pankou; dr["aac"] = tdList[2].ToPlainTextString(); DataSet ds = odds_rqbll.queryCompanyOddsCount(companyid, tdList[0].ToPlainTextString(), pankou, tdList[2].ToPlainTextString(), Convert.ToInt32(Request.Form["scheduleType"]), "Chupan"); if (Convert.ToDouble(ds.Tables[0].Rows[0][3]) > 0) { per1 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per2 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per3 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); dr["aaa1"] = ds.Tables[0].Rows[0][0].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; dr["aab1"] = ds.Tables[0].Rows[0][1].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; dr["aac1"] = ds.Tables[0].Rows[0][2].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; } } tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//终盘 pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["aba"] = tdList[0].ToPlainTextString(); dr["abb"] = pankou; dr["abc"] = tdList[2].ToPlainTextString(); DataSet ds = odds_rqbll.queryCompanyOddsCount(companyid, tdList[0].ToPlainTextString(), pankou, tdList[2].ToPlainTextString(), Convert.ToInt32(Request.Form["scheduleType"]), "Zhongpan"); if (Convert.ToDouble(ds.Tables[0].Rows[0][3]) > 0) { per4 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per5 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per6 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); dr["aba1"] = ds.Tables[0].Rows[0][0].ToString() + "(<font color=" + (per4 > per1 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; dr["abb1"] = ds.Tables[0].Rows[0][1].ToString() + "(<font color=" + (per5 > per2 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; dr["abc1"] = ds.Tables[0].Rows[0][2].ToString() + "(<font color=" + (per6 > per3 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; } } } #endregion #region 标准盘 list = tableList[1].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); dr["baa"] = tdList[0].ToPlainTextString(); dr["bab"] = tdList[1].ToPlainTextString(); dr["bac"] = tdList[2].ToPlainTextString(); tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//终盘 dr["bba"] = tdList[0].ToPlainTextString(); dr["bbb"] = tdList[1].ToPlainTextString(); dr["bbc"] = tdList[2].ToPlainTextString(); } #endregion #region 大小盘 list = tableList[2].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); pankou = CommonHelper.BallSizeToBall(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["caa"] = tdList[0].ToPlainTextString(); dr["cab"] = pankou; dr["cac"] = tdList[2].ToPlainTextString(); } tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); pankou = CommonHelper.BallSizeToBall(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["cba"] = tdList[0].ToPlainTextString(); dr["cbb"] = pankou; dr["cbc"] = tdList[2].ToPlainTextString(); } } #endregion dt.Rows.Add(dr); } } if (dt.Rows.Count > 0) { DataRow dr1 = dt.NewRow(); #region 亚洲盘统计 List<double> pankouList1 = new List<double>(); List<double> homefcList1 = new List<double>(); List<double> awayfcList1 = new List<double>(); List<double> pankouList2 = new List<double>(); List<double> homefcList2 = new List<double>(); List<double> awayfcList2 = new List<double>(); foreach (DataRow dr in dt.Rows) { if (dr["aab"] != DBNull.Value && !pankouList1.Contains(Convert.ToDouble(dr["aab"]))) { pankouList1.Add(Convert.ToDouble(dr["aab"])); } if (dr["abb"] != DBNull.Value && !pankouList2.Contains(Convert.ToDouble(dr["abb"]))) { pankouList2.Add(Convert.ToDouble(dr["abb"])); } } foreach (decimal item in pankouList2) { if (dt.Select("aab=" + item).Count() > 1) { double fc = Convert.ToDouble(dt.Compute("Var(aaa)", "aab=" + item)); homefcList1.Add(fc); fc = Convert.ToDouble(dt.Compute("Var(aac)", "aab=" + item)); awayfcList1.Add(fc); } if (dt.Select("abb=" + item).Count() > 1) { double fc = Convert.ToDouble(dt.Compute("Var(aba)", "abb=" + item)); homefcList2.Add(fc); fc = Convert.ToDouble(dt.Compute("Var(abc)", "abb=" + item)); awayfcList2.Add(fc); } } dr1["aaa"] = Convert.ToDouble(dt.Compute("Avg(aaa)", "1=1")); dr1["aac"] = Convert.ToDouble(dt.Compute("Avg(aac)", "1=1")); dr1["aaa1"] = homefcList1.Average(); dr1["aac1"] = awayfcList1.Average(); dr1["aba"] = Convert.ToDouble(dt.Compute("Avg(aba)", "1=1")); dr1["abc"] = Convert.ToDouble(dt.Compute("Avg(abc)", "1=1")); dr1["aba1"] = "<font color=" + (homefcList2.Average() > homefcList1.Average() ? "red" : "green") + ">" + homefcList2.Average() + "</font>"; dr1["abc1"] = "<font color=" + (awayfcList2.Average() > awayfcList1.Average() ? "red" : "green") + ">" + awayfcList2.Average() + "</font>"; #endregion dr1["baa"] = Convert.ToDouble(dt.Compute("Avg(baa)", "1=1")); dr1["bab"] = Convert.ToDouble(dt.Compute("Avg(bab)", "1=1")); dr1["bac"] = Convert.ToDouble(dt.Compute("Avg(bac)", "1=1")); dr1["bba"] = Convert.ToDouble(dt.Compute("Avg(bba)", "1=1")); dr1["bbb"] = Convert.ToDouble(dt.Compute("Avg(bbb)", "1=1")); dr1["bbc"] = Convert.ToDouble(dt.Compute("Avg(bbc)", "1=1")); dr1["baa1"] = Convert.ToDouble(dt.Compute("Var(baa)", "1=1")); dr1["bab1"] = Convert.ToDouble(dt.Compute("Var(bab)", "1=1")); dr1["bac1"] = Convert.ToDouble(dt.Compute("Var(bac)", "1=1")); dr1["bba1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bba)", "1=1")) > Convert.ToDouble(dr1["baa1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bba)", "1=1")) + "</font>"; dr1["bbb1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bbb)", "1=1")) > Convert.ToDouble(dr1["bab1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bbb)", "1=1")) + "</font>"; dr1["bbc1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bbc)", "1=1")) > Convert.ToDouble(dr1["bac1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bbc)", "1=1")) + "</font>"; dt.Rows.Add(dr1); } JObject result = new JObject(); result.Add(new JProperty("success", true)); result.Add(new JProperty("totlalCount", dt.Rows.Count)); result.Add(new JProperty("data", JArray.FromObject(dt))); JsonStr = result.ToString(); } else { JsonStr = "{success:false,message:'请求数据异常!'}"; } } catch (Exception e) { JsonStr = "{success:false,message:'" + e.Message + "'}"; } }
private void updateOdds() { //SeoWebSite.BLL.odds_bz odds_bzBLL = new SeoWebSite.BLL.odds_bz(); //SeoWebSite.BLL.odds_rq odds_rqBLL = new SeoWebSite.BLL.odds_rq(); //SeoWebSite.BLL.odds_dx odds_dxBLL = new SeoWebSite.BLL.odds_dx(); //SeoWebSite.BLL.Company companyBLL = new SeoWebSite.BLL.Company(); NowGoalBLL nowGoalBLL = new NowGoalBLL(); WebClientBLL webClientBLL = new WebClientBLL(); try { //if (Request["scheduleid"] != null && Request["companyid"] != null) //{ // string scheduleid = Request.Form["scheduleid"]; // string companyid = Request.Form["companyid"]; // string[] paramArr = { companyid, scheduleid }; // string s = webClientBLL.GetRemoteHtml("odds/detail.aspx?companyID={0}&scheduleid={1}", paramArr); // if (string.IsNullOrEmpty(s)) // { // scheduleBLL.Delete(int.Parse(scheduleid)); // JsonStr = "{success:false,message:'已删除错误的比赛数据'}"; // } // Parser parser = Parser.CreateParser(s, "utf-8"); // AndFilter andFilter = new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("bgColor", "#bbbbbb")); // NodeList tableList = parser.ExtractAllNodesThatMatch(andFilter); // parser = Parser.CreateParser(s, "utf-8"); // NodeList h3tag = parser.ExtractAllNodesThatMatch(new TagNameFilter("h3")); // string year = h3tag[0].ToPlainTextString().Remove(5); // if (tableList.Count == 3) // { // odds_rqBLL.Delete(companyid, scheduleid); // odds_bzBLL.Delete(companyid, scheduleid); // odds_dxBLL.Delete(companyid, scheduleid); // AndFilter andFilter1 = new AndFilter(new TagNameFilter("tr"), new HasAttributeFilter("class", "ts1")); // #region 让球盘 // NodeList list = tableList[0].Children.ExtractAllNodesThatMatch(andFilter1); // for (int i = 0; i < list.Count; i++) // { // NodeList tdList = list[i].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); // string pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); // if (!string.IsNullOrEmpty(pankou)) // { // SeoWebSite.Model.odds_rq model = new SeoWebSite.Model.odds_rq(); // model.scheduleID = int.Parse(scheduleid); // model.companyID = int.Parse(companyid); // model.home = decimal.Parse(tdList[0].ToPlainTextString()); // model.pankou = decimal.Parse(pankou); // model.away = decimal.Parse(tdList[2].ToPlainTextString()); // model.time = DateTime.Parse(year + "-" + tdList[3].ToPlainTextString().Replace("早餐", "")); // odds_rqBLL.Add(model); // } // } // #endregion // #region 标准盘 // list = tableList[1].Children.ExtractAllNodesThatMatch(andFilter1); // for (int i = 0; i < list.Count; i++) // { // NodeList tdList = list[i].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); // SeoWebSite.Model.odds_bz model = new SeoWebSite.Model.odds_bz(); // model.scheduleID = int.Parse(scheduleid); // model.companyID = int.Parse(companyid); // model.home = decimal.Parse(tdList[0].ToPlainTextString()); // model.draw = decimal.Parse(tdList[1].ToPlainTextString()); // model.away = decimal.Parse(tdList[2].ToPlainTextString()); // model.time = DateTime.Parse(year + "-" + tdList[3].ToPlainTextString().Replace("早餐", "")); // odds_bzBLL.Add(model); // } // #endregion // #region 大小盘 // list = tableList[2].Children.ExtractAllNodesThatMatch(andFilter1); // for (int i = 0; i < list.Count; i++) // { // NodeList tdList = list[i].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); // string pankou = CommonHelper.BallSizeToBall(tdList[1].ToPlainTextString()); // if (!string.IsNullOrEmpty(pankou)) // { // SeoWebSite.Model.odds_dx model = new SeoWebSite.Model.odds_dx(); // model.scheduleID = int.Parse(scheduleid); // model.companyID = int.Parse(companyid); // model.big = decimal.Parse(tdList[0].ToPlainTextString()); // model.pankou = decimal.Parse(pankou); // model.small = decimal.Parse(tdList[2].ToPlainTextString()); // model.time = DateTime.Parse(year + "-" + tdList[3].ToPlainTextString().Replace("早餐", "")); // odds_dxBLL.Add(model); // } // } // #endregion // } // JsonStr = "{success:true}"; //} if (Request["scheduleid"] != null && !string.IsNullOrEmpty(Request.Form["scheduleid"])) { nowGoalBLL.updateOdds1x2(Request.Form["scheduleid"]); scheduleBLL.SetUpdated(Request.Form["scheduleid"], true); JsonStr = "{success:true}"; } else { JsonStr = "{success:false,message:'请求数据异常!'}"; } } catch (Exception e) { JsonStr = "{success:false,message:'" + e.Message + "'}"; } }
private string getMatchResult(string matchid) { WebClientBLL bll = new WebClientBLL(); string html = bll.GetRemoteHtml("/detail/{0}.html", new string[] { matchid }); Lexer lexer = new Lexer(html); Parser parser = new Parser(lexer); INode tableNode = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children[0]; TableTag tt = tableNode as TableTag; string home = tt.GetRow(0).Columns[0].Children[0].Children[0].ToPlainTextString(); string away = tt.GetRow(0).Columns[2].Children[0].Children[0].ToPlainTextString(); string hscore = tt.GetRow(0).Columns[1].Children[0].Children[1].Children[0].ToPlainTextString(); string ascore = tt.GetRow(0).Columns[1].Children[0].Children[1].Children[2].ToPlainTextString(); string asia = tt.GetRow(0).Columns[1].Children[0].Children[0].Children[0].ToPlainTextString(); return home + " " + hscore + "-" + ascore + " " + away + " " + asia; }
/// <summary> /// 获得综合赔率 /// </summary> /// <param name="scheduleID">比赛编码</param> /// <param name="companyID">公司编码列表</param> /// <returns></returns> public string GetOddsDetail(string scheduleID, string companyID, string dateStr) { if (string.IsNullOrEmpty(dateStr)) { WebClientBLL.UpdateOddsDetailContent(companyID); } else { WebClientBLL.UpdateOddsDataContent(dateStr); } string actual = DataCache.GetCache("OddsDetailContent").ToString(); List <string> alist = new List <string>(); List <string> blist = new List <string>(); List <string> clist = new List <string>(); //2让球盘 3标准盘 4大小盘 string oddsStr = actual.Split('$')[2];//2=让球盘 string[] oddsArray = oddsStr.Split(';'); foreach (string odds in oddsArray) { string[] oddsInfo = odds.Split(','); if (oddsInfo[0] == scheduleID) { alist.Add(odds); } } oddsStr = actual.Split('$')[3];//2=让球盘 oddsArray = oddsStr.Split(';'); foreach (string odds in oddsArray) { string[] oddsInfo = odds.Split(','); if (oddsInfo[0] == scheduleID) { blist.Add(odds); } } oddsStr = actual.Split('$')[4];//2=让球盘 oddsArray = oddsStr.Split(';'); foreach (string odds in oddsArray) { string[] oddsInfo = odds.Split(','); if (oddsInfo[0] == scheduleID) { clist.Add(odds); } } JArray data = new JArray(); foreach (string companyid in companyID.Split(',')) { JObject obj = JObject.Parse("{scheduleid:" + scheduleID + ",companyid:" + companyid + "}"); foreach (string a in alist) { string[] aArr = a.Split(','); if (aArr[1] == companyid) { obj.Add("aaa", aArr[3]); obj.Add("aab", aArr[2]); obj.Add("aac", aArr[4]); obj.Add("aba", aArr[6]); obj.Add("abb", aArr[5]); obj.Add("abc", aArr[7]); } } foreach (string b in blist) { string[] bArr = b.Split(','); if (bArr[1] == companyid) { obj.Add("baa", bArr[2]); obj.Add("bab", bArr[3]); obj.Add("bac", bArr[4]); obj.Add("bba", bArr[5]); obj.Add("bbb", bArr[6]); obj.Add("bbc", bArr[7]); } } foreach (string c in clist) { string[] cArr = c.Split(','); if (cArr[1] == companyid) { obj.Add("caa", cArr[3]); obj.Add("cab", cArr[2]); obj.Add("cac", cArr[4]); obj.Add("cba", cArr[6]); obj.Add("cbb", cArr[5]); obj.Add("cbc", cArr[7]); } } data.Add(obj); } JObject result = new JObject(); result.Add(new JProperty("totlalCount", data.Count)); result.Add(new JProperty("data", data)); return(result.ToString()); }
public string Analysis(string scheduleID) { WebClientBLL.UpdateAnalysisContent(scheduleID); string actual = DataCache.GetCache("AnalysisContent").ToString(); string h_data = ""; Regex reg = new Regex("var h_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];"); Match mat = reg.Match(actual); if (mat != null) { h_data = mat.Value; } h_data = h_data.Replace("var h_data=[[", "").Replace("]];", ""); string h2h_home = ""; reg = new Regex("var h2h_home \\= " + "\\d+;"); mat = reg.Match(actual); if (mat != null) { h2h_home = StringPlus.DelLastChar(mat.Value.Replace("var h2h_home = ", ""), ";"); } string a_data = ""; reg = new Regex("var a_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];"); mat = reg.Match(actual); if (mat != null) { a_data = mat.Value; } a_data = a_data.Replace("var a_data=[[", "").Replace("]];", ""); string h2h_away = ""; reg = new Regex("var h2h_away \\= " + "\\d+;"); mat = reg.Match(actual); if (mat != null) { h2h_away = StringPlus.DelLastChar(mat.Value.Replace("var h2h_away = ", ""), ";"); } //分解出主队过去成绩 string[] h_dataArr = Regex.Split(h_data, "\\],\\[", RegexOptions.IgnoreCase); float h_point = 100f; float h_goalcount = 0f; int h_sixpoint = 0; foreach (string arr in h_dataArr) { string[] match = arr.Split(','); if (h2h_home == match[4]) { h_point = PredictionHelper.EloHomePointsCalculation(h_point, match[17]); h_goalcount += int.Parse(match[8]); } else { h_point = PredictionHelper.EloAwayPointsCalculation(h_point, match[17]); h_goalcount += int.Parse(match[9]); } h_sixpoint = PredictionHelper.SixGamePointCalculation(h_sixpoint, match[17]); } //分解出客队过去成绩 string[] a_dataArr = Regex.Split(a_data, "\\],\\[", RegexOptions.IgnoreCase); float a_point = 100; float a_goalcount = 0f; int a_sixpoint = 0; foreach (string arr in a_dataArr) { string[] match = arr.Split(','); if (h2h_away == match[4]) { a_point = PredictionHelper.EloHomePointsCalculation(a_point, match[17]); a_goalcount += int.Parse(match[8]); } else { a_point = PredictionHelper.EloAwayPointsCalculation(a_point, match[17]); a_goalcount += int.Parse(match[9]); } a_sixpoint = PredictionHelper.SixGamePointCalculation(a_sixpoint, match[17]); } string HomePossible = PredictionHelper.EloHomePrediction(h_point, a_point) * 100 + "%"; string AwayPossible = PredictionHelper.EloAwayPrediction(h_point, a_point) * 100 + "%"; //string SixGame = PredictionHelper.SixGamePrediction(h_sixpoint, a_sixpoint); StringBuilder sb = new StringBuilder(); sb.Append("埃罗预测法 :主队积分为" + h_point + ",客队积分为" + a_point + ",按照埃罗预测法主队获胜的可能性有" + HomePossible + ",客队获胜的可能性有" + AwayPossible); return(sb.ToString()); }
public string GetPrediction(string scheduleID, float num) { WebClientBLL.UpdateAnalysisContent(scheduleID); string actual = DataCache.GetCache("AnalysisContent").ToString(); string h_data = ""; Regex reg = new Regex("var h_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];"); Match mat = reg.Match(actual); if (mat != null) { h_data = mat.Value; } h_data = h_data.Replace("var h_data=[[", "").Replace("]];", ""); string h2h_home = ""; reg = new Regex("var h2h_home \\= " + "\\d+;"); mat = reg.Match(actual); if (mat != null) { h2h_home = StringPlus.DelLastChar(mat.Value.Replace("var h2h_home = ", ""), ";"); } string a_data = ""; reg = new Regex("var a_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];"); mat = reg.Match(actual); if (mat != null) { a_data = mat.Value; } a_data = a_data.Replace("var a_data=[[", "").Replace("]];", ""); string h2h_away = ""; reg = new Regex("var h2h_away \\= " + "\\d+;"); mat = reg.Match(actual); if (mat != null) { h2h_away = StringPlus.DelLastChar(mat.Value.Replace("var h2h_away = ", ""), ";"); } float big = 0f; float small = 0f; //分解出主队过去成绩 string[] h_dataArr = Regex.Split(h_data, "\\],\\[", RegexOptions.IgnoreCase); foreach (string arr in h_dataArr) { string[] match = arr.Split(','); float goal = float.Parse(match[8]) + float.Parse(match[9]); if (goal > num) { big++; } else if (goal < num) { small++; } } //分解出客队过去成绩 string[] a_dataArr = Regex.Split(a_data, "\\],\\[", RegexOptions.IgnoreCase); foreach (var arr in a_dataArr) { string[] match = arr.Split(','); float goal = float.Parse(match[8]) + float.Parse(match[9]); if (goal > num) { big++; } else if (goal < num) { small++; } } float bigprobability = big / (h_dataArr.Length + a_dataArr.Length); float smallprobability = small / (h_dataArr.Length + a_dataArr.Length); StringBuilder sb = new StringBuilder(); sb.Append("大于" + num + "的机会有 :" + bigprobability); sb.Append("<br /><br />"); sb.Append("小于" + num + "的机会有 :" + smallprobability); sb.Append("<br /><br />"); sb.Append("走盘的机会有 :" + (1f - bigprobability - smallprobability)); return(sb.ToString()); }
public void updateOdds1x2(string scheduleID) { try { OddsDAO oddsDAO = new OddsDAO(); CompanyDAO companyDAO = new CompanyDAO(); 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)) { //所有公司数据 string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4); //分解出每个公司数据 string[] compstrs = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase); foreach (string compstr in compstrs) { JObject item = new JObject(); string[] oddsArr = compstr.Replace("\"", "").Split('|'); #region 插入公司数据 if (!companyDAO.Exists(int.Parse(oddsArr[0])) && oddsArr.Length > 22) { SeoWebSite.Model.Company company = new SeoWebSite.Model.Company(); company.id = int.Parse(oddsArr[0]); company.fullname = oddsArr[21]; company.name = oddsArr[2]; company.isprimary = Convert.ToBoolean(int.Parse(oddsArr[22])); company.isexchange = Convert.ToBoolean(int.Parse(oddsArr[23])); companyDAO.Add(company); } #endregion #region 插入欧赔数据 if (!oddsDAO.Exists(int.Parse(oddsArr[1]))) { Odds odds = new Odds(); odds.scheduleid = int.Parse(scheduleID); odds.companyid = int.Parse(oddsArr[0]); odds.id = int.Parse(oddsArr[1]); odds.s_win = decimal.Parse(oddsArr[3]); odds.s_draw = decimal.Parse(oddsArr[4]); odds.s_lost = decimal.Parse(oddsArr[5]); odds.s_winper = decimal.Parse(oddsArr[6]); odds.s_drawper = decimal.Parse(oddsArr[7]); odds.s_lostper = decimal.Parse(oddsArr[8]); if (!String.IsNullOrEmpty(oddsArr[9])) { odds.s_return = decimal.Parse(oddsArr[9]); } if (!String.IsNullOrEmpty(oddsArr[10])) { odds.e_win = decimal.Parse(oddsArr[10]); } if (!String.IsNullOrEmpty(oddsArr[11])) { odds.e_draw = decimal.Parse(oddsArr[11]); } if (!String.IsNullOrEmpty(oddsArr[12])) { odds.e_lost = decimal.Parse(oddsArr[12]); } if (!String.IsNullOrEmpty(oddsArr[13])) { odds.e_winper = decimal.Parse(oddsArr[13]); } if (!String.IsNullOrEmpty(oddsArr[14])) { odds.e_drawper = decimal.Parse(oddsArr[14]); } if (!String.IsNullOrEmpty(oddsArr[15])) { odds.e_lostper = decimal.Parse(oddsArr[15]); } if (!String.IsNullOrEmpty(oddsArr[16])) { odds.e_return = decimal.Parse(oddsArr[16]); } if (!String.IsNullOrEmpty(oddsArr[17])) { odds.winkelly = decimal.Parse(oddsArr[17]); } if (!String.IsNullOrEmpty(oddsArr[18])) { odds.drawkelly = decimal.Parse(oddsArr[18]); } if (!String.IsNullOrEmpty(oddsArr[19])) { odds.lostkelly = decimal.Parse(oddsArr[19]); } string[] timeArr = oddsArr[20].Split(','); odds.lastupdatetime = new DateTime(int.Parse(timeArr[0]), int.Parse(timeArr[1].Remove(2)), int.Parse(timeArr[2]), int.Parse(timeArr[3]), int.Parse(timeArr[4]), int.Parse(timeArr[5])).AddHours(8); oddsDAO.Add(odds); } #endregion } } } catch (WebException e) { HttpWebResponse response = (HttpWebResponse)e.Response; if (response != null) //排除对象为空的错误 { if (response.StatusCode == HttpStatusCode.NotFound) //判断是否是404错误 { sdal.Delete(Convert.ToInt32(scheduleID)); } } } }