public OlimpPrices Convert(OlimpOddEvent olimpOddEvent) { this.olimpPrices = new OlimpPrices(); this.olimpPrices.IsLive = false; this.olimpPrices.DateAdded = olimpOddEvent.DateAdded; this.properties = this.olimpPrices.GetType().GetProperties(); if (olimpOddEvent.moneyLine != null) { this.olimpPrices.HOME = olimpOddEvent.moneyLine.Home; this.olimpPrices.DRAW = olimpOddEvent.moneyLine.Draw; this.olimpPrices.AWAY = olimpOddEvent.moneyLine.Away; } if (olimpOddEvent.doubleChance != null) { this.olimpPrices.HOMEDRAW = olimpOddEvent.doubleChance.HomeDraw; this.olimpPrices.HOMEAWAY = olimpOddEvent.doubleChance.HomeAway; this.olimpPrices.DRAWAWAY = olimpOddEvent.doubleChance.AwayDraw; } this.olimpPrices.EventId = olimpOddEvent.EventId; this.olimpPrices.HomeTeam = olimpOddEvent.HomeTeam; this.olimpPrices.AwayTeam = olimpOddEvent.AwayTeam; this.olimpPrices.LeagueName = olimpOddEvent.LeagueName; this.olimpPrices.StartTime = olimpOddEvent.StartDate; if (olimpOddEvent.Totals != null) { this.SetTotalPricesToDatabase(olimpOddEvent.Totals); } if (olimpOddEvent.Handicaps != null) { this.SetHandicapPricesToDatabase(olimpOddEvent.Handicaps); } if (olimpOddEvent.HomeTotals != null) { this.SetHomeTeamTotalPricesTodatabase(olimpOddEvent.HomeTotals); } if (olimpOddEvent.AwayTotals != null) { this.SetAwayTeamTotalPricesToDatabase(olimpOddEvent.AwayTotals); } return(this.olimpPrices); }
public async Task <List <OlimpOddEvent> > GetTodayPrematchOdds(List <OlimpEvent> olimpEvents) { List <OlimpOddEvent> resultList = new List <OlimpOddEvent>(); ConcurrentBag <OlimpOddEvent> events = new ConcurrentBag <OlimpOddEvent>(); ParallelLoopResult result = Parallel.ForEach(olimpEvents, olimpEv => { OlimpOddEvent olimpOddEvent = this.GetOddsByEventId(olimpEv).Result; if (olimpOddEvent != null) { events.Add(olimpOddEvent); } } ); foreach (OlimpOddEvent oddEvent in events) { resultList.Add(oddEvent); } return(resultList); }
public async Task <OlimpOddEvent> GetOddsByEventId(OlimpEvent olimpEvent) { string url = "/en/sports/match/" + olimpEvent.EventId; HtmlNode documentNode = this.GetDocumentNodeByUrl(url); if (documentNode != null) { HtmlNode oddsContainer = documentNode.QuerySelector(".coef"); MoneyLine moneyLine = new MoneyLine(); DoubleChance doubleChance = new DoubleChance(); List <Total> totals = new List <Total>(); List <Handicap> handicaps = new List <Handicap>(); List <Total> homeTotals = new List <Total>(); List <Total> awayTotals = new List <Total>(); OlimpOddEvent olimpOddEvent = new OlimpOddEvent(); try { foreach (HtmlNode node in oddsContainer.ChildNodes) { if (node.OriginalName == "div" && this.GetAtributeValueByName(node, "class") == "") { foreach (HtmlNode htmlNode in node.ChildNodes) { if (htmlNode.OriginalName == "div" && this.GetAtributeValueByName(htmlNode, "class") == "livelineheader") { string type = this.GetMarketTypeByLiveheaderNode(htmlNode); if (type == "FULL TIME RESULT") { moneyLine = this.getMoneylineFoEvent(node, olimpEvent.EventId); } if (type == "DOUBLE CHANCE") { doubleChance = this.getDoubleChanceFoEvent(node, olimpEvent.EventId); } if (type == "TOTAL GOALS") { Total t = this.GetTotalForEvent(node, olimpEvent.EventId); if (t != null) { totals.Add(t); } } if (type == "ALTERNATIVE TOTAL GOALS") { List <Total> totals2 = this.GetTotalGoals(node, olimpEvent.EventId); if (totals2 != null) { totals.AddRange(totals2); } } if (type == "HANDICAP RESULT") { Handicap h = this.GetHandicap(node, olimpEvent.EventId); if (h != null) { handicaps.Add(h); } } if (type == "ALTERNATIVE HANDICAP RESULT") { List <Handicap> hdps = this.GetHandicaps(node, olimpEvent.EventId); if (hdps != null) { handicaps.AddRange(hdps); } } if (type == "TEAM TOTAL") { var result = this.GetTeamTotals(node, olimpEvent); if (result.home != null) { awayTotals = result.away; homeTotals = result.home; } } } } } } } catch (Exception ex) { return(null); } olimpOddEvent.moneyLine = moneyLine; olimpOddEvent.doubleChance = doubleChance; olimpOddEvent.Totals = totals; olimpOddEvent.Handicaps = handicaps; olimpOddEvent.AwayTotals = awayTotals; olimpOddEvent.HomeTotals = homeTotals; olimpOddEvent.EventId = olimpEvent.EventId; olimpOddEvent.HomeTeam = olimpEvent.HomeTeam; olimpOddEvent.AwayTeam = olimpEvent.AwayTeam; olimpOddEvent.LeagueName = olimpEvent.LeagueName; olimpOddEvent.StartDate = olimpEvent.StartDate; olimpOddEvent.DateAdded = DateTime.Now.ToString(); return(olimpOddEvent); } else { return(null); } }