public OddDTO CoKeoDoHandicap(OddDTO keoOU) { var oddHandicap = this.Odds.Where(o => o.Type == eOddType.Handicap).Reverse(); foreach (OddDTO odd in oddHandicap) { int tg = 0; int tg2 = 0; int.TryParse(odd.AtTime, out tg); int.TryParse(keoOU.AtTime, out tg2); if (tg > tg2) { if (odd.Score == keoOU.Score) // khi ti so can nhau { if (odd.isRedOdd) // co diem do tai Handicap o cung ti so { if (odd.Away + odd.Home == GiaChuanHDC) { this.RedHandicap = true; } return(odd); } } } } return(null); }
private void OddsParse(string HTML, string node, eOddType type) { List <OddDTO> listOdds = new List <OddDTO>(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(HTML); var node1 = doc.DocumentNode.SelectSingleNode(node) .Descendants("tr") .Skip(2) .Where(tr => tr.Elements("td").Count() > 1); List <List <string> > table = node1.Select(tr => tr.Elements("td").Select(td => td.OuterHtml.Trim()).ToList()) .ToList(); foreach (List <string> lstOdd in table) { OddDTO odd = new OddDTO(); odd.AtTime = Utils.StripHTML(lstOdd[0]); odd.Score = Utils.StripHTML(lstOdd[1]); float fl = 0; if (float.TryParse(Utils.StripHTML(lstOdd[2]), out fl)) { odd.Home = fl; } odd.Odd = Utils.StripHTML(lstOdd[3]); if (float.TryParse(Utils.StripHTML(lstOdd[4]), out fl)) { odd.Away = fl; } odd.OddTime = Utils.StripHTML(lstOdd[5]); odd.Status = Utils.StripHTML(lstOdd[6]); odd.Type = type; if (lstOdd[2].Contains("red")) { odd.isRedHome = true; } if (lstOdd[3].Contains("red")) { odd.isRedOdd = true; } if (lstOdd[4].Contains("red")) { odd.isRedAway = true; } if (lstOdd[2].Contains("green")) { odd.isGreenHome = true; } if (lstOdd[4].Contains("green")) { odd.isGreenAway = true; } this.Odds.Add(odd); } }
public OddDTO CoKeoCoTheDanh(OddDTO keoOU) { var oddOverUnder = this.Odds.Where(o => o.Type == eOddType.OverUnder); foreach (OddDTO odd in oddOverUnder) { float keohientai = Utils.OUParse(odd.Odd); float keoDo = Utils.OUParse(keoOU.Odd); int tg = 0; int tg2 = 0; int.TryParse(odd.AtTime, out tg); int.TryParse(keoOU.AtTime, out tg2); if (keohientai < keoDo && tg > tg2) { if (odd.Home == keoOU.Home) { return(odd); } } } return(null); }