public List <TeamResults> GetTable(string data) { var teamResultses = new List <TeamResults>(); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(data); var node = htmlDocument.DocumentNode.SelectSingleNode("//table[@class='positions']"); var rows = node.SelectNodes("tr"); var correctedRows = rows.Skip(1); foreach (var elem in correctedRows) { var innerNodes = elem.SelectNodes("th|td").ToList(); if (innerNodes.Count > 0) { var result = new TeamResults { Position = Convert.ToInt32(innerNodes[0].SelectSingleNode("strong").InnerHtml), Name = innerNodes[1].SelectSingleNode("a").InnerHtml, Score = innerNodes[2].InnerHtml + "-" + innerNodes[3].InnerHtml }; teamResultses.Add(result); } } return(teamResultses); }
public void SortByAverageScore() { List <TeamResult> ordered = TeamResults.OrderByDescending(o => o.AverageScore).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
internal void SortByTeamNumber() { List <TeamResult> ordered = TeamResults.OrderBy(o => o.TeamNumber).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
//FIXME - still sorts by avg. pow. cells internal void SortByBroken() { List <TeamResult> ordered = TeamResults.OrderBy(o => o.TotalBroken).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
internal void SortByAveragePowercells() { List <TeamResult> ordered = TeamResults.OrderByDescending(o => o.AveragePowercells).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
public void SortByPowercellCount() { List <TeamResult> ordered = TeamResults.OrderByDescending(o => o.TotalPowercells).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
public void SortByRankingPoints() { List <TeamResult> ordered = TeamResults.OrderByDescending(o => o.TotalRP).ToList(); TeamResults.Clear(); foreach (TeamResult item in ordered) { TeamResults.Add(item); } }
public List<TeamResults> GetScoreTable(int seriesID) { List<TeamResults> ScoreTable = (List<TeamResults>)Utilities.GetFromCache(seriesID + ":Scores"); if (ScoreTable == null) { ScoreTable = new List<TeamResults>(); DOM Document = new DOM(GetWidgetUrl("table", seriesID)); var TableRows = Document.Query("table//tr"); int RowCount = 0; foreach (XmlNode Row in TableRows) { if (RowCount > 2) { var Columns = Row.SelectNodes("td"); TeamResults score = new TeamResults(); score.TeamName = Columns.ValueOfIndex(0); score.MatchesPlayed = Columns.ValueOfIndex(1); score.MatchesWon = Columns.ValueOfIndex(2); score.MatchesDraw = Columns.ValueOfIndex(3); score.MatchesLost = Columns.ValueOfIndex(4); score.GoalsMadeAndReceived = Columns.ValueOfIndex(5); score.Difference = Columns.ValueOfIndex(6); score.Points = Columns.ValueOfIndex(7); ScoreTable.Add(score); } RowCount = RowCount + 1; } Utilities.InsertToCache(seriesID + ":Scores", ScoreTable); } return ScoreTable; }
public void ExecuteLoadEventTeamsCommand() { if (IsBusy) { return; } IsBusy = true; try { TeamResults.Clear(); var teams = DataStoreTeam.GetItemsAsync(true).Result; foreach (var team in teams) { TeamDetailViewModel matchViewModel = new TeamDetailViewModel(App.currFRCEventKey, team); TeamResult teamResult = new TeamResult(); teamResult.TeamNumber = team.TeamNumber; teamResult.Name = team.Name; teamResult.TotalRP = matchViewModel.TotalRP; teamResult.TotalScore = matchViewModel.TotalScore; teamResult.AverageScore = matchViewModel.AverageScore; teamResult.TotalPowercells = matchViewModel.TotalPowercells; teamResult.AveragePowercells = matchViewModel.AveragePowercells; teamResult.TotalBroken = matchViewModel.TotalBroken; TeamResults.Add(teamResult); } } catch (Exception ex) { Title = ex.Message; } finally { IsBusy = false; } }
public ActionResult Index(Guid? userId) { if(userId.HasValue) ViewBag.Scores = db.Scores.Where(x => x.User.Id == userId); var groups = db.Groups.OrderBy(x => x.Name); var tournamentData = new List<TableData>(); foreach (var g in groups) { var td = new TableData(); td.Group = g; foreach (var t in g.Teams) { var teamScores = db.Scores.Where(x => x.User.Id == user.Id && (x.Fixture.Away.Id == t.Id || x.Fixture.Home.Id == t.Id)); var teamResults = new TeamResults(){ Team = t }; foreach (var s in teamScores) { if (s.Fixture.Away == t) { //Team played away teamResults.goals += (s.AwayScore - s.HomeScore); if (s.AwayScore > s.HomeScore) { //game was won teamResults.points += 3; teamResults.wins += 1; } else if (s.AwayScore == s.HomeScore) { //game was drawn teamResults.points += 1; teamResults.draws += 1; } else { //gane was lost teamResults.losses += 1; } } else { //Team played home teamResults.goals += (s.HomeScore - s.AwayScore); if (s.HomeScore > s.AwayScore) { //game was won teamResults.points += 3; teamResults.wins += 1; } else if (s.HomeScore == s.AwayScore) { //game was drawn teamResults.points += 1; teamResults.draws += 1; } else { //gane was lost teamResults.losses += 1; } } } td.TeamResults.Add(teamResults); } tournamentData.Add(td); } return View(tournamentData); }