Exemplo n.º 1
0
 private void addImageUrl(FixtureList list)
 {
     int[]    competitionIDs = { 2021, 2016, 2030, 2014, 2077, 2002, 2004, 2019, 2121, 2015, 2142, 2084, 2003, 2017, 2009, 2145, 2137, 2013, 2008, 2024, 2119 };
     string[] imageUrls      =
     {
         "/images/english-flag-small.jpg",
         "/images/english-flag-small.jpg",
         "/images/english-flag-small.jpg",
         "/images/spanish-flag-small.jpg",
         "/images/spanish-flag-small.jpg",
         "/images/german-flag-small.jpg",
         "/images/german-flag-small.jpg",
         "/images/italian-flag-small.jpg",
         "/images/italian-flag-small.jpg",
         "/images/french-flag-small.jpg",
         "/images/french-flag-small.jpg",
         "/images/scotland-flag-large.jpg",
         "/images/dutch-flag-small.jpg",
         "/images/portuguese-flag-small.jpg",
         "/images/belgian-flag-small.jpg",
         "/images/american-flag-small.jpg",
         "/images/russian-flag-small.jpg",
         "/images/brazilian-flag-small.jpg",
         "/images/australian-flag-small.jpg",
         "/images/argentinian-flag-small.jpg",
         "/images/japanese-flag-small.jpg"
     };
     list.imageUrl = imageUrls[Array.IndexOf(competitionIDs, list.leagueId)];
 }
Exemplo n.º 2
0
        /// <summary>
        /// Destroy a fixture. This removes the fixture from the broad-phase and
        /// destroys all contacts associated with this fixture. This will
        /// automatically adjust the mass of the body if the body is dynamic and the
        /// fixture has positive density.
        /// All fixtures attached to a body are implicitly destroyed when the body is destroyed.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="fixture">The fixture to be removed.</param>
        public void DestroyFixture(Fixture fixture)
        {
            Debug.Assert(World.IsLocked == false);
            if (World.IsLocked)
            {
                return;
            }

            Debug.Assert(fixture.Body == this);

            // Remove the fixture from this body's singly linked list.
            Debug.Assert(FixtureList.Count > 0);

#if DEBUG
            // You tried to remove a shape that is not attached to this body.
            Debug.Assert(FixtureList.Contains(fixture));
#endif

            // Destroy any contacts associated with the fixture.
            ContactEdge edge = ContactList;
            while (edge != null)
            {
                Contact c = edge.Contact;
                edge = edge.Next;

                Fixture fixtureA = c.FixtureA;
                Fixture fixtureB = c.FixtureB;

                if (fixture == fixtureA || fixture == fixtureB)
                {
                    // This destroys the contact and removes it from
                    // this body's contact list.
                    World.ContactManager.Destroy(c);
                }
            }

            if ((Flags & BodyFlags.Active) == BodyFlags.Active)
            {
                BroadPhase broadPhase = World.ContactManager.BroadPhase;
                fixture.DestroyProxies(broadPhase);
            }

            FixtureList.Remove(fixture);
            fixture.Destroy();
            fixture.Body = null;

            ResetMassData();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Destroy a fixture. This removes the fixture from the broad-phase and
        /// destroys all contacts associated with this fixture. This will
        /// automatically adjust the mass of the body if the body is dynamic and the
        /// fixture has positive density.
        /// All fixtures attached to a body are implicitly destroyed when the body is destroyed.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="fixture">The fixture to be removed.</param>
        public void DestroyFixture(Fixture fixture)
        {
            if (fixture == null)
            {
                return;
            }

            Debug.Assert(fixture.Body == this);

            // Remove the fixture from this body's singly linked list.
            Debug.Assert(FixtureList.Count > 0);

            // You tried to remove a fixture that not present in the fixturelist.
            Debug.Assert(FixtureList.Contains(fixture));

            // Destroy any contacts associated with the fixture.
            ContactEdge edge = ContactList;

            while (edge != null)
            {
                Contact c = edge.Contact;
                edge = edge.Next;

                Fixture fixtureA = c.FixtureA;
                Fixture fixtureB = c.FixtureB;

                if (fixture == fixtureA || fixture == fixtureB)
                {
                    // This destroys the contact and removes it from
                    // this body's contact list.
                    _world.ContactManager.Destroy(c);
                }
            }

            if (Enabled)
            {
                IBroadPhase broadPhase = _world.ContactManager.BroadPhase;
                fixture.DestroyProxies(broadPhase);
            }

            FixtureList.Remove(fixture);
            fixture.Destroy();
            fixture.Body = null;

            ResetMassData();
        }
Exemplo n.º 4
0
        // GET: /Fixture/5
        public ActionResult Index(int id)
        {
            FixtureList fixtures = null;

            using (TournamentEntities data = new TournamentEntities())
            {
                Group group = data.Groups.SingleOrDefault(g => g.GroupID == id);

                if (group != null)
                {
                    fixtures = new FixtureList(group);
                }
            }

            ViewBag.GroupID = id;

            return View("Index", fixtures);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a fixture and attach it to this body.
        /// If the density is non-zero, this function automatically updates the mass of the body.
        /// Contacts are not created until the next time step.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="density">The density.</param>
        /// <returns></returns>
        public Fixture CreateFixture(Shape shape, float density)
        {
            Debug.Assert(World.IsLocked == false);
            if (World.IsLocked)
            {
                return(null);
            }

            Fixture fixture = new Fixture(this, shape, density);

            if ((Flags & BodyFlags.Active) == BodyFlags.Active)
            {
                BroadPhase broadPhase = World.ContactManager.BroadPhase;
                fixture.CreateProxies(broadPhase, ref Xf);
            }

            FixtureList.Add(fixture);
            fixture.Body = this;

            // Adjust mass properties if needed.
            if (fixture.Density > 0.0f)
            {
                ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            World.Flags |= WorldFlags.NewFixture;

            if (World.FixtureAdded != null)
            {
                World.FixtureAdded(fixture);
            }

            return(fixture);
        }
        public IApiResponseParsingResult ParseResponse(ParseApiResponse message)
        {
            var responseType = ApiResponseType.Unknown;

            try
            {
                object response;

                var responseXml = DynamicXml.Parse(message.Data);
                responseType = responseXml.GetName();

                switch (responseType)
                {
                case ApiResponseType.CompetitorProfile:
                    response = CompetitorProfile.Parse(responseXml);
                    break;

                case ApiResponseType.FixtureChanges:
                    response = FixtureChangeList.Parse(responseXml);
                    break;

                case ApiResponseType.FixturesFixture:
                    response = FixtureList.Parse(responseXml);
                    break;

                case ApiResponseType.MatchSummary:
                    response = MatchSummary.Parse(responseXml);
                    break;

                case ApiResponseType.MarketDescriptions:
                    response = MarketDescriptionList.Parse(responseXml);
                    break;

                case ApiResponseType.MatchTimeline:
                    response = MatchTimeline.Parse(responseXml);
                    break;

                case ApiResponseType.PlayerProfile:
                    response = PlayerProfile.Parse(responseXml);
                    break;

                case ApiResponseType.RaceTournamentInfo:
                case ApiResponseType.SimpleTournamentInfo:
                case ApiResponseType.StandardTournamentInfo:
                case ApiResponseType.TournamentInfo:
                    response = TournamentInfo.Parse(responseXml);
                    break;

                case ApiResponseType.Response:
                    response = Response.Parse(responseXml);
                    break;

                case ApiResponseType.Schedule:
                    response = Schedule.Parse(responseXml);
                    break;

                case ApiResponseType.SportCategories:
                    response = SportCategoriesList.Parse(responseXml);
                    break;

                case ApiResponseType.Sports:
                    response = SportList.Parse(responseXml);
                    break;

                case ApiResponseType.SportTournaments:
                    response = SportTournamentList.Parse(responseXml);
                    break;

                case ApiResponseType.Tournaments:
                    response = TournamentList.Parse(responseXml);
                    break;

                case ApiResponseType.VenueSummary:
                    response = VenueSummary.Parse(responseXml);
                    break;

                default:
                    throw new NotSupportedException(
                              $"Message of specified type ['{responseType}'] can not be parsed.");
                }

                return(new ApiResponseParsed
                {
                    Language = message.Language,
                    Response = response,
                    RequestId = message.RequestId,
                    EventId = message.EventId,
                    ProductType = message.ProductType
                });
            }
            catch (Exception e)
            {
                throw;
                //return new ApiResponseParsingFailed(
                //    failureReason: e,
                //    requestId: message.RequestId,
                //    responseData: message.Data,
                //    responseType: responseType
                //);
            }
        }
Exemplo n.º 7
0
        private IEnumerable <FixtureList> getFixturesFromDatabase()
        {
            List <FixtureList> fixtureLists = new List <FixtureList>();
            List <int>         leagueIds    = new List <int>();
            List <Fixture>     allFixtures  = new List <Fixture>();

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                connection.Open();
                using (SqlCommand sqlCommand = new SqlCommand("SELECT * from Fixture as fixture " +
                                                              "Where fixture.FixtureListId like '%" + getDatabaseDateString(dateString) + "%'", connection))
                {
                    using (SqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Fixture fixture = new Fixture();
                            fixture.homeTeamName       = reader["HomeTeamName"].ToString();
                            fixture.awayTeamName       = reader["AwayTeamName"].ToString();
                            fixture.matchId            = reader["MatchId"].ToString();
                            fixture.homeTeamId         = int.Parse(reader["HomeTeamId"].ToString());
                            fixture.awayTeamId         = int.Parse(reader["AwayTeamId"].ToString());
                            fixture.leagueName         = reader["LeagueName"].ToString();
                            fixture.leagueId           = int.Parse(reader["LeagueId"].ToString());
                            fixture.finished           = (bool)reader["Finished"];
                            fixture.postponed          = (bool)reader["Postponed"];
                            fixture.homeScore          = (int)reader["HomeScore"];
                            fixture.awayScore          = (int)reader["AwayScore"];
                            fixture.predictedHomeScore = (int)reader["PredictedHomeScore"];
                            fixture.predictedAwayScore = (int)reader["PredictedAwayScore"];
                            fixture.utcDate            = reader["UtcDate"].ToString();
                            fixture.strong             = (bool)reader["Strong"];
                            allFixtures.Add(fixture);
                        }
                        reader.Close();
                    }
                }
                using (SqlCommand sqlCommand = new SqlCommand("SELECT * from FixtureList as fixtureList " +
                                                              "Where fixturelist.FixtureListId like '%" + getDatabaseDateString(dateString) + "%'", connection))
                {
                    using (SqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            FixtureList list = new FixtureList();
                            list.leagueName = reader["LeagueName"].ToString();
                            list.utcDate    = reader["UtcDate"].ToString();
                            list.imageUrl   = reader["ImageUrl"].ToString();
                            list.leagueId   = int.Parse(reader["LeagueId"].ToString());
                            list.fixtures   = new List <Fixture>();
                            foreach (Fixture fixture in allFixtures)
                            {
                                if (fixture.leagueId == list.leagueId)
                                {
                                    list.fixtures.Add(fixture);
                                }
                            }
                            fixtureLists.Add(list);
                        }
                        reader.Close();
                    }
                }
                connection.Close();
                return(reorderFixtureLists(fixtureLists));
            }
        }
Exemplo n.º 8
0
        private async Task <IEnumerable <FixtureList> > getFixturesFromApi(DateTime?date)
        {
            using (HttpResponseMessage response = await client.GetAsync("https://api.football-data.org/v2/matches" + competitionPriorityOrder + "&" + dateString))
            {
                if (response.IsSuccessStatusCode)
                {
                    List <FixtureList> fixtureLists = new List <FixtureList>();
                    JObject            jsonObject   = JObject.Parse(await response.Content.ReadAsStringAsync());
                    JArray             allMatches   = (JArray)jsonObject["matches"];

                    for (int i = 0; i < allMatches.Count; i++)
                    {
                        string competitionId = allMatches[i]["competition"]["id"].ToString();
                        if (allMatches[i]["status"].ToString() != "CANCELLED")
                        {
                            Fixture fixture = new Fixture
                            {
                                matchId      = allMatches[i]["id"].ToString(),
                                homeTeamId   = int.Parse(allMatches[i]["homeTeam"]["id"].ToString()),
                                homeTeamName = allMatches[i]["homeTeam"]["name"].ToString(),
                                awayTeamId   = int.Parse(allMatches[i]["awayTeam"]["id"].ToString()),
                                awayTeamName = allMatches[i]["awayTeam"]["name"].ToString(),
                                leagueId     = int.Parse(allMatches[i]["competition"]["id"].ToString()),
                                leagueName   = allMatches[i]["competition"]["name"].ToString(),
                                utcDate      = allMatches[i]["utcDate"].ToString()
                            };
                            if (date < DateTime.Today)
                            {
                                if (allMatches[i]["status"].ToString() == "FINISHED")
                                {
                                    fixture.finished  = true;
                                    fixture.homeScore = int.Parse(allMatches[i]["score"]["fullTime"]["homeTeam"].ToString());
                                    fixture.awayScore = int.Parse(allMatches[i]["score"]["fullTime"]["awayTeam"].ToString());
                                }
                                else
                                {
                                    fixture.postponed = true;
                                }
                            }
                            if (fixture.leagueId == 2084)
                            {
                                fixture.leagueName = "SPL";
                            }
                            else if (fixture.leagueId == 2013)
                            {
                                fixture.leagueName = "Série_A";
                            }
                            bool competitionExists = false;
                            foreach (FixtureList list in fixtureLists)
                            {
                                if (list.leagueName == fixture.leagueName)
                                {
                                    list.fixtures.Add(fixture);
                                    competitionExists = true;
                                    break;
                                }
                            }
                            if (!competitionExists || !fixtureLists.Any())
                            {
                                FixtureList fixtureList = new FixtureList();
                                fixtureList.leagueName = fixture.leagueName;
                                fixtureList.utcDate    = allMatches[i]["utcDate"].ToString();
                                fixtureList.fixtures   = new List <Fixture>();
                                fixtureList.fixtures.Add(fixture);
                                fixtureList.leagueId = fixture.leagueId;
                                fixtureLists.Add(fixtureList);
                            }
                        }
                    }

                    addFixturesToDatabase(fixtureLists);
                    return(reorderFixtureLists(fixtureLists));
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }