public JudgementListViewModel(Tournament tournament, int roundNo) : this()
        {
            var round = tournament.GetRoundNoGuarded(roundNo);

            RoundNo          = roundNo;
            TournamentName   = tournament.Name;
            TournamentId     = tournament.Id;
            RoundTitle       = round.Title;
            HasNextRound     = RoundNo < tournament.Rounds.Count;
            HasPreviousRound = RoundNo > 1;
            Criteria         = tournament.JudgingCriteria.OrderBy(p => p.Id).ToList();
            // Todo: Profile and Optimize. This generates X number of selects on RoundContestant and Y number of selects on Contestant table.
            var allRunJudgings     = round.ContestantEntries.SelectMany(p => p.RunJudgings).OrderBy(p => p.JudgeId).ToList();
            var roundContestantIds = round.ContestantEntries.Select(p => p.Id).Distinct().ToList();
            var judgeIds           = tournament.Judges.Select(p => p.Id).ToList();

            foreach (var judgeId in judgeIds)
            {
                var judge = tournament.Judges.FirstOrDefault(p => p.Id == judgeId);
                foreach (var rcId in roundContestantIds)
                {
                    var rc = round.ContestantEntries.FirstOrDefault(p => p.Id == rcId);
                    for (int runNo = 1; runNo <= round.RunsPerContestant; runNo++)
                    {
                        var scoreList = allRunJudgings.Where(p => p.RunNo == runNo && p.JudgeId == judgeId && p.RoundContestantId == rcId).OrderBy(p => p.CriterionId).ToList();
                        var modelLine = new RunJudgementViewModel(scoreList, judge, rc, runNo);
                        Judgements.Add(modelLine);
                    }
                }
            }
        }
示例#2
0
        public void ReadStreamData(BinaryReader reader)
        {
            Reset();

            Time = reader.ReadSingle();

            IsSkipped = reader.ReadBoolean();

            int inputCount = reader.ReadInt32();

            for (int i = 0; i < inputCount; i++)
            {
                var input = replayInputRecycler.GetNext();
                input.ReadStreamData(reader);
                Inputs.Add(input);
            }

            int holdFlagCount = reader.ReadInt32();

            for (int i = 0; i < holdFlagCount; i++)
            {
                DraggerHoldFlags.Add(new KeyValuePair <int, bool>(reader.ReadInt32(), reader.ReadBoolean()));
            }

            int judgementCount = reader.ReadInt32();

            for (int i = 0; i < judgementCount; i++)
            {
                var judgement = replayJudgementRecycler.GetNext();
                judgement.ReadStreamData(reader);
                Judgements.Add(judgement);
            }
        }
示例#3
0
        /// <summary>
        /// Adds a new replayable judgement result data to the frame and returns it.
        /// </summary>
        public ReplayableJudgement AddJudgement(Action <ReplayableJudgement> initializer)
        {
            var judgement = replayJudgementRecycler.GetNext();

            initializer.Invoke(judgement);
            Judgements.Add(judgement);
            return(judgement);
        }