Пример #1
0
        private void ProcessarCompetitions(List <Competition> competitions)
        {
            AzureStorageUtil azureStorageUtil = new AzureStorageUtil();

            // Elimina Tudo;
            azureStorageUtil.ClearAzureStructure();

            List <string>  ignoredCompetitions   = GetIgnoredCompetitions();
            List <dynamic> competitionsProcessed = new List <dynamic>();

            foreach (Competition competition in competitions)
            {
                dynamic competitionProcessed = new ExpandoObject();
                competitionProcessed.Name = competition.caption;
                competitionProcessed.Id   = competition.id;
                competitionsProcessed.Add(competitionProcessed);


                if (ignoredCompetitions.Count(s => s.Equals(competition.league)) == 0)
                {
                    LeagueTable leagueTable = GetLeagueTable(competition.id);
                    Fixtures    fixtures    = GetFixtures(competition.id);

                    // Somente campeonatos pontos corridos
                    if ((leagueTable != null) && (leagueTable.standing != null) && (fixtures != null))
                    {
                        string jsonLeagueTable = JsonConvert.SerializeObject(leagueTable);
                        string jsonFixtures    = JsonConvert.SerializeObject(fixtures);

                        Model.Azure.Competition competitionAzure = GetCompetitionAzure(competition);

                        azureStorageUtil.AddCompetition(competitionAzure);
                        azureStorageUtil.AddLeagueTableData(competitionAzure, jsonLeagueTable);
                        azureStorageUtil.AddFixturesData(competitionAzure, jsonFixtures);

                        competitionProcessed.Status = "OK";
                    }
                    else
                    {
                        competitionProcessed.Status = "Does not have LeagueTable.";
                    }
                }
                else
                {
                    competitionProcessed.Status = "Ignorada";
                }
            }

            dataGridView1.DataSource = competitionsProcessed.ToDataTable();
            dataGridView1.Refresh();
        }
Пример #2
0
        private Model.Azure.Competition GetCompetitionAzure(Competition competition)
        {
            Model.Azure.Competition competitionAzure = new Model.Azure.Competition(competition.id);

            competitionAzure.caption           = competition.caption;
            competitionAzure.league            = competition.league;
            competitionAzure.year              = competition.year;
            competitionAzure.currentMatchday   = competition.currentMatchday;
            competitionAzure.numberOfMatchdays = competition.numberOfMatchdays;
            competitionAzure.numberOfTeams     = competition.numberOfTeams;
            competitionAzure.numberOfGames     = competition.numberOfGames;
            competitionAzure.lastUpdated       = competition.lastUpdated;

            return(competitionAzure);
        }