public string GetOddsPointChartsData(string scheduleID, string[] companyids) { JSONHelper json = new JSONHelper(); json.success = true; DataSet dsAllTime = dal.GetChangeTimesByCompanys(scheduleID, string.Join(",", companyids)); List<float> avehomeklist = new List<float>(); List<float> avedrawklist = new List<float>(); List<float> aveawayklist = new List<float>(); List<float> avehomevlist = new List<float>(); List<float> avedrawvlist = new List<float>(); List<float> aveawayvlist = new List<float>(); List<float> avereratelist = new List<float>(); Odds1x2History lastmodel = new Odds1x2History(); foreach (DataRow dr in dsAllTime.Tables[0].Rows) { ds = dal.GetAvgNumber(int.Parse(scheduleID), DateTime.Parse(dr[0].ToString())); List<Odds1x2History> oddsList = dal.GetLastListByCompanys(int.Parse(scheduleID), string.Join(",", companyids), DateTime.Parse(dr["time"].ToString())); List<float> homeklist = new List<float>(); List<float> drawklist = new List<float>(); List<float> awayklist = new List<float>(); List<float> reratelist = new List<float>(); foreach (Odds1x2History item in oddsList) { homeklist.Add(item.home * float.Parse(ds.Tables[0].Rows[0]["avghomep"].ToString())); drawklist.Add(item.draw * float.Parse(ds.Tables[0].Rows[0]["avgdrawp"].ToString())); awayklist.Add(item.away * float.Parse(ds.Tables[0].Rows[0]["avgawayp"].ToString())); reratelist.Add(item.returnrate * 100); } avehomeklist.Add(homeklist.Average()); avedrawklist.Add(drawklist.Average()); aveawayklist.Add(awayklist.Average()); avehomevlist.Add(this.CalculationVariance(homeklist)); avedrawvlist.Add(this.CalculationVariance(drawklist)); aveawayvlist.Add(this.CalculationVariance(awayklist)); avereratelist.Add(reratelist.Average()); } int h = 0, d = 0, a = 0; int hh = 0, dd = 0, aa = 0; for (int i = 1; i < avehomeklist.Count; i++) { if (avehomeklist[i] < avehomeklist[i - 1]) h++; else if (avehomeklist[i] > avehomeklist[i - 1]) h--; if (avedrawklist[i] < avedrawklist[i - 1]) d++; else if (avedrawklist[i] > avedrawklist[i - 1]) d--; if (aveawayklist[i] < aveawayklist[i - 1]) a++; else if (aveawayklist[i] > aveawayklist[i - 1]) a--; if (avehomevlist[i] <= avehomevlist[i - 1]) { if (avehomeklist[i] < avehomeklist[i - 1]) hh++; else if (avehomeklist[i] > avehomeklist[i - 1]) hh--; } if (avedrawvlist[i] <= avedrawvlist[i - 1]) { if (avedrawklist[i] < avedrawklist[i - 1]) dd++; else if (avedrawklist[i] > avedrawklist[i - 1]) dd--; } if (aveawayvlist[i] <= aveawayvlist[i - 1]) { if (aveawayklist[i] < aveawayklist[i - 1]) aa++; else if (aveawayklist[i] > aveawayklist[i - 1]) aa--; } } json.AddItem("name", "主胜"); json.AddItem("point", h.ToString()); json.AddItem("xpoint", hh.ToString()); json.ItemOk(); json.AddItem("name", "平局"); json.AddItem("point", d.ToString()); json.AddItem("xpoint", dd.ToString()); json.ItemOk(); json.AddItem("name", "客胜"); json.AddItem("point", a.ToString()); json.AddItem("xpoint", aa.ToString()); json.ItemOk(); json.totlalCount = 3; return json.ToString(); }
/// <summary> /// ��ѯij�û���Ͷע�б� /// </summary> /// <param name="userid"></param> /// <returns></returns> public string GetBetRecordList(string userid) { JSONHelper json = new JSONHelper(); ds = dal.GetList(userid); json.success = true; foreach (DataRow dr in ds.Tables[0].Rows) { //Ͷע��¼������ json.AddItem("id", dr["id"].ToString()); json.AddItem("lineid", dr["lineid"].ToString()); json.AddItem("teamname", dr["teamname"].ToString()); json.AddItem("traditional", dr["traditional"].ToString()); json.AddItem("starttime", dr["starttime"].ToString()); json.AddItem("endtime", dr["endtime"].ToString()); json.AddItem("bettime", dr["bettime"].ToString()); json.AddItem("itemid", dr["itemid"].ToString()); json.AddItem("detailid", dr["detailid"].ToString()); json.AddItem("betmoney", dr["betmoney"].ToString()); json.AddItem("returnmoney", dr["returnmoney"].ToString()); json.AddItem("result", dr["result"].ToString()); json.AddItem("sourceid", dr["sourceid"].ToString()); //Ͷע�̱߳����� json.AddItem("linename", dr["linename"].ToString()); json.AddItem("linebetmoney", dr["linebetmoney"].ToString()); json.AddItem("profit", dr["profit"].ToString()); json.AddItem("state", dr["state"].ToString()); json.AddItem("iscomplete", dr["iscomplete"].ToString()); json.AddItem("isbetting", dr["isbetting"].ToString()); //Ͷע��Ŀ������ json.AddItem("itemname", dr["itemname"].ToString()); //Ͷעϸ������ json.AddItem("detailname", dr["detailname"].ToString()); json.ItemOk(); } json.totlalCount = ds.Tables[0].Rows.Count; string betRecordlist = json.ToString(); return betRecordlist; }
public string GetOddsCompanyChartsData(string scheduleID, string[] companyids, double time) { JSONHelper json = new JSONHelper(); json.success = true; DataSet dsStart = dal.GetCompanyStartPoint(scheduleID, companyids); DataSet dsEnd = dal.GetCompanyEndPoint(scheduleID, companyids); DateTime firsttime; DateTime lasttime = DateTime.Parse(dsEnd.Tables[0].Rows[0][0].ToString()); if (time == 0) { firsttime = DateTime.Parse(dsStart.Tables[0].Rows[0][0].ToString()); } else { firsttime = lasttime.AddSeconds(0 - time); } double timespace = (lasttime - firsttime).TotalSeconds / 60; while (firsttime <= lasttime) { Odds1x2History model = new Odds1x2History(); ds = dal.GetAvgNumber(int.Parse(scheduleID), firsttime); DataRow dr = ds.Tables[0].Rows[0]; List<Odds1x2History> oddsList = dal.GetLastListByCompanys(int.Parse(scheduleID), string.Join(",", companyids), firsttime); int home = 0; int draw = 0; int away = 0; int nhome = 0; int ndraw = 0; int naway = 0; int count = 0; foreach (Odds1x2History item in oddsList) { item.homek = item.home * float.Parse(dr["avghomep"].ToString()); item.drawk = item.draw * float.Parse(dr["avgdrawp"].ToString()); item.awayk = item.away * float.Parse(dr["avgawayp"].ToString()); if (item.homek < item.returnrate * 100 - 2) { home++; } else if (item.homek >= item.returnrate * 100 + 2) { nhome--; } if (item.drawk < item.returnrate * 100 - 2) { draw++; } else if (item.drawk >= item.returnrate * 100 + 2) { ndraw--; } if (item.awayk < item.returnrate * 100 - 2) { away++; } else if (item.awayk >= item.returnrate * 100 + 2) { naway--; } count++; } json.AddItem("home", home.ToString()); json.AddItem("draw", draw.ToString()); json.AddItem("away", away.ToString()); json.AddItem("nhome", nhome.ToString()); json.AddItem("ndraw", ndraw.ToString()); json.AddItem("naway", naway.ToString()); json.AddItem("count", count.ToString()); json.AddItem("time", firsttime.ToString()); json.ItemOk(); firsttime = firsttime.AddSeconds(timespace); } json.totlalCount = ds.Tables[0].Rows.Count; return json.ToString(); }
public string GetOdds1x2ChangeListByTime(string scheduleID, string[] companynames, long timespace) { ds = dal.GetFirstTimePoint(scheduleID); DateTime time = DateTime.Parse(ds.Tables[0].Rows[0][0].ToString()); DateTime nowtime = DateTime.Now; JSONHelper json = new JSONHelper(); while (time > nowtime) { //ds = dal.GetAvgNumber(int.Parse(scheduleID), time); //json.AddItem("home", ); //json.AddItem("draw", model.draw.ToString()); //json.AddItem("away", model.away.ToString()); //time.AddSeconds(3600); } json.success = true; throw new NotImplementedException(); }
/// <summary> /// 获得历史改变的赔率 /// </summary> /// <param name="scheduleid"></param> /// <param name="companyids"></param> /// <param name="companynames"></param> /// <returns></returns> public string GetOdds1x2ChangeList(string scheduleid, string[] companyids, string[] companynames, string tcompanyid) { JSONHelper json = new JSONHelper(); for (int i = 0; i < companyids.Length; i++) { List<Odds1x2History> list = dal.GetList(scheduleid, companyids[i]); json.success = true; foreach (Odds1x2History model in list) { this.FillOdds1x2Kelly(model, tcompanyid); //投注记录表数据 json.AddItem("id", model.id.ToString()); json.AddItem("scheduleid", model.scheduleid.ToString()); json.AddItem("companyid", model.companyid.ToString()); json.AddItem("companyname", companynames[i]); json.AddItem("home", model.home.ToString()); json.AddItem("draw", model.draw.ToString()); json.AddItem("away", model.away.ToString()); json.AddItem("homep", model.homep.ToString()); json.AddItem("drawp", model.drawp.ToString()); json.AddItem("awayp", model.awayp.ToString()); json.AddItem("homek", model.homek.ToString()); json.AddItem("drawk", model.drawk.ToString()); json.AddItem("awayk", model.awayk.ToString()); json.AddItem("returnrate", model.returnrate.ToString()); json.AddItem("time", model.time.ToString("yyyy-MM-dd HH:mm")); json.ItemOk(); } json.totlalCount += list.Count; } return json.ToString(); }
/// <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 GetAveKellyChartsData(string scheduleID, string[] companyids) { JSONHelper json = new JSONHelper(); json.success = true; List<Odds1x2History> firstOddsList = dal.GetFirstListByCompanys(int.Parse(scheduleID), string.Join(",", companyids)); List<float> firstHomekList = new List<float>(); List<float> firstDrawkList = new List<float>(); List<float> firstAwaykList = new List<float>(); int firstHomekCount = 0; int firstDrawkCount = 0; int firstAwaykCount = 0; foreach (Odds1x2History model in firstOddsList) { this.FillOdds1x2Kelly(model, ""); firstHomekList.Add(model.homek); firstDrawkList.Add(model.drawk); firstAwaykList.Add(model.awayk); if (model.homek < model.awayk && model.homek < model.drawk) { firstHomekCount++; } else if (model.homek >= 100) { firstHomekCount--; } if (model.drawk < model.awayk && model.drawk < model.homek) { firstDrawkCount++; } else if (model.drawk >= 100) { firstDrawkCount--; } if (model.awayk < model.homek && model.awayk < model.drawk) { firstAwaykCount++; } else if (model.awayk >= 100) { firstAwaykCount--; } } List<Odds1x2History> lastOddsList = dal.GetLastListByCompanys(int.Parse(scheduleID), string.Join(",", companyids)); List<float> lastHomekList = new List<float>(); List<float> lastDrawkList = new List<float>(); List<float> lastAwaykList = new List<float>(); int lastHomekCount = 0; int lastDrawkCount = 0; int lastAwaykCount = 0; foreach (Odds1x2History model in lastOddsList) { this.FillOdds1x2Kelly(model, ""); lastHomekList.Add(model.homek); lastDrawkList.Add(model.drawk); lastAwaykList.Add(model.awayk); if (model.homek < model.awayk && model.homek < model.drawk) { lastHomekCount++; } else if (model.homek >= 100) { lastHomekCount--; } if (model.drawk < model.awayk && model.drawk < model.homek) { lastDrawkCount++; } else if (model.drawk >= 100) { lastDrawkCount--; } if (model.awayk < model.homek && model.awayk < model.drawk) { lastAwaykCount++; } else if (model.awayk >= 100) { lastAwaykCount--; } } json.AddItem("name", "主胜"); json.AddItem("firstkelly", firstHomekList.Average().ToString()); json.AddItem("lastkelly", lastHomekList.Average().ToString()); json.AddItem("firstsupport", firstHomekCount.ToString()); json.AddItem("lastsupport", lastHomekCount.ToString()); json.ItemOk(); json.AddItem("name", "平局"); json.AddItem("firstkelly", firstDrawkList.Average().ToString()); json.AddItem("lastkelly", lastDrawkList.Average().ToString()); json.AddItem("firstsupport", firstDrawkCount.ToString()); json.AddItem("lastsupport", lastDrawkCount.ToString()); json.ItemOk(); json.AddItem("name", "客胜"); json.AddItem("firstkelly", firstAwaykList.Average().ToString()); json.AddItem("lastkelly", lastAwaykList.Average().ToString()); json.AddItem("firstsupport", firstAwaykCount.ToString()); json.AddItem("lastsupport", lastAwaykCount.ToString()); json.ItemOk(); return json.ToString(); }