Ejemplo n.º 1
0
    private void PopulateMatchDetails(Match match)
    {
        DOM Document = new DOM("http://svenskfotboll.se/ovriga-serier/information/?widget=1&scr=result&fmid=" + match.ID);

            var DetailRows = Document.Query("table[@id='iMatchInfo']//tr");
            match.Venue = DetailRows.GetCellValueByFirstColumn("Spelplats");
            match.Referee = DetailRows.GetCellValueByFirstColumn("Domare");
            match.AssistingReferee1 = DetailRows.GetCellValueByFirstColumn("Ass. domare 1");
            match.AssistingReferee2 = DetailRows.GetCellValueByFirstColumn("Ass. domare 2");

            if (match.Venue != "")
            {
                var VenueLocation = GeoCoder.GeoCodeAddress(match.Venue);
                if (VenueLocation != null)
                {
                    match.VenueLongitude = VenueLocation.Longitude;
                    match.VenueLatitude = VenueLocation.Latitude;
                }
            }

            var Logotypes = Document.Query("table[@class='clTblMatch']//img");

            if (Logotypes.Count > 1)
            {
                match.Team1Logo = "http://svenskfotboll.se" + Logotypes[0].GetAttributeValue("src");
                match.Team2Logo = "http://svenskfotboll.se" + Logotypes[1].GetAttributeValue("src");

                match.Team1Logo = match.Team1Logo.Replace("/width_125", "");
                match.Team2Logo = match.Team1Logo.Replace("/width_125", "");
            }

            var PlayerTables = Document.GetTableByHeader("Laguppställning");
            var SecondaryPlayerTables = Document.GetTableByHeader("Ersättare");

            if (PlayerTables.Count > 1)
            {
                match.Team1Players = GetPlayers(PlayerTables[0]);
                match.Team2Players = GetPlayers(PlayerTables[1]);
            }

            if (SecondaryPlayerTables.Count > 1)
            {
                match.Team1SecondaryPlayers = GetPlayers(SecondaryPlayerTables[0]);
                match.Team2SecondaryPlayers = GetPlayers(SecondaryPlayerTables[1]);
            }

            // To not flood their server
            System.Threading.Thread.Sleep(200);
    }