Ejemplo n.º 1
0
 public void AddOrReplacePlayedMatch(MatchPlayedThisEvent matchPlayed)
 {
     if (!PlayedMatchesByNumber.TryGetValue(matchPlayed.MatchNumber, out List <MatchPlayedThisEvent> playedMatches))
     {
         playedMatches = new List <MatchPlayedThisEvent>();
         PlayedMatchesByNumber[matchPlayed.MatchNumber] = playedMatches;
     }
     //
     playedMatches.RemoveAll(existing => matchPlayed.PlayNumber == existing.PlayNumber);
     playedMatches.Add(matchPlayed);
     playedMatches.Sort((m1, m2) => (int)(m2.PlayNumber - m1.PlayNumber)); // descending by play number
 }
Ejemplo n.º 2
0
        public void LoadDataAccessLayer()
        {
            foreach (var row in Tables.LeagueMeets.Rows)
            {
                if (row.EventCode.NonNullValue == ThisEventCode)
                {
                    ThisEvent thisEvent = new ThisEvent(this, row, ThisEventType, ThisEventStatus);
                    EventsByCode[thisEvent.EventCode] = thisEvent;
                }
                else
                {
                    HistoricalLeagueMeet anEvent = new HistoricalLeagueMeet(this, row, TEventType.LEAGUE_MEET, TEventStatus.ARCHIVED);
                    EventsByCode[anEvent.EventCode] = anEvent;
                }
            }

            if (!EventsByCode.ContainsKey(ThisEventCode))
            {
                // *Always* need ThisEvent to be real. Make if we didn't previously encounter. Code path taken only in non-leagues?
                var row = Tables.LeagueMeets.NewRow();
                row.EventCode.Value = ThisEventCode;
                row.Name.Value      = ThisEventName;
                row.Start.Value     = ThisEventNominalStart;
                row.End.Value       = ThisEventNominalEnd;
                ThisEvent thisEvent = new ThisEvent(this, row, ThisEventType, ThisEventStatus);
                EventsByCode[thisEvent.EventCode] = thisEvent;
            }

            foreach (var row in Tables.Team.Rows)
            {
                Team team = new Team(this, row);
                TeamsByNumber[team.TeamNumber] = team;
                TeamsById[team.FMSTeamId]      = team;
                Teams.Add(team);
            }
            Teams.Sort((a, b) => a.TeamNumber - b.TeamNumber);

            foreach (var row in Tables.ScheduleDetail.Rows)
            {
                if (row.IsEqualizationMatch(this))
                {
                    EqualizationMatch equalizationMatch = new EqualizationMatch(this, row);
                    Trace.Assert(equalizationMatch.IsEqualizationMatch);
                    LoadedEqualizationMatches.Add(equalizationMatch);
                }
                else
                {
                    ScheduledMatch scheduledMatch = new ScheduledMatch(this, row);
                    Trace.Assert(!scheduledMatch.IsEqualizationMatch);
                }
            }

            // fmsMatch
            foreach (var row in Tables.Match.Rows)
            {
                MatchPlayedThisEvent matchPlayed = new MatchPlayedThisEvent(this, row);
                AddOrReplacePlayedMatch(matchPlayed);
            }

            // psData
            foreach (var row in Tables.QualsData.Rows.Concat(Tables.ElimsData.Rows))
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psScores
            foreach (var row in Tables.QualsScores.Rows)
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }
            foreach (var row in Tables.ElimsScores.Rows)
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psGame
            foreach (var row in Tables.QualsGameSpecific.Rows.Concat(Tables.ElimsGameSpecific.Rows))
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psResult
            foreach (var row in Tables.QualsResults.Rows.Concat(Tables.ElimsResults.Rows))
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psHistory
            foreach (var row in Tables.QualsCommitHistory.Rows.Concat(Tables.ElimsCommitHistory.Rows))
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psScoresHistory
            foreach (var row in Tables.QualsScoresHistory.Rows)
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }
            foreach (var row in Tables.ElimsScoresHistory.Rows)
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            // psGameHistory
            foreach (var row in Tables.QualsGameSpecificHistory.Rows.Concat(Tables.ElimsGameSpecificHistory.Rows))
            {
                if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches))
                {
                    foreach (MatchPlayedThisEvent match in playedMatches)
                    {
                        match.Load(row);
                    }
                }
            }

            LeagueSubsystem.Load();
        }