private List <Result> GetResults200m(string competition)
        {
            DatabaseApi.SelectCompetition200m(competition);
            var settings      = SettingsHelper.GetSettings();
            var rawResults    = DatabaseApi.LoadCompetitionFromTable(TableName.OrionResult);
            var registrations = DatabaseApi.LoadCompetitionFromTable(TableName.LeonRegistration);
            var actualResults = this.AddNewResults(rawResults.OfType <OrionResult>().ToList(), settings);
            var results       = BuildResultObjects(actualResults);

            foreach (var item in results)
            {
                if (registrations.Any())
                {
                    var registration = registrations.OfType <LeonPerson>().Last(r => r.ShooterId == item.ShooterId);
                    if (registration != null)
                    {
                        item.Name     = registration.Name;
                        item.Class    = registration.Class;
                        item.ClubName = registration.ClubName;
                    }
                }
            }

            return(results);
        }
        private List <Result> GetResults100m(string competition)
        {
            DatabaseApi.SelectCompetition100m(competition);
            var settings      = SettingsHelper.GetSettings();
            var rawResults    = DatabaseApi.LoadCompetitionFromTable(TableName.OrionResult);
            var actualResults = this.AddNewResults(rawResults.OfType <OrionResult>().ToList(), settings);

            return(BuildResultObjects(actualResults));
        }
Exemple #3
0
        public void LoadFromCache_LeonRegistrations()
        {
            this.InitTestDatabase("TestStevne", new DateTime(2016, 2, 26));
            this.SaveLeonPersons(10);

            var result = DatabaseApi.LoadCompetitionFromTable(TableName.LeonRegistration);

            Assert.IsTrue(result.Count == 10);
        }
Exemple #4
0
        void OrionResultViewModel_NewOrionResults(object sender, Orion.OrionResultsEventArgs e)
        {
            var        newResults = e.NewResults;
            List <int> finishedShooters;
            var        updatedRegistrations = m_orionResultUpdater.GetUpdatedRegistrationsAfterResultRegistration(
                newResults,
                this.OrionTeamsSetupViewModel.OrionRegistrations,
                this.OrionResultViewModel.OrionResults,
                out finishedShooters);

            if (finishedShooters.Any())
            {
                var finishedPersons       = Leon.LeonPersons.Where(l => finishedShooters.Contains(l.ShooterId));
                var maxTeamNumber         = finishedPersons.Max(f => f.Team);
                var shouldBeFinished      = Leon.LeonPersons.Where(l => l.Team <= maxTeamNumber).Select(l => l.ShooterId);
                var finishedRegistrations =
                    DatabaseApi.LoadCompetitionFromTable(TableName.FinishedShooter).OfType <FinishedPerson>().Select(f => f.ShooterId);
                var missingPersons = shouldBeFinished.Except(finishedRegistrations).Except(finishedShooters);
                finishedShooters.AddRange(missingPersons);
            }

            this.OrionCommunicationViewModel.UpdateChangesToOrion(updatedRegistrations);
            this.OrionResultViewModel.AddNewRegistrations(newResults);

            if (finishedShooters != null && finishedShooters.Any())
            {
                if (m_minneViewModel != null && m_minneViewModel.MinneRegistrations != null)
                {
                    LeonWriter.WriteLeonResults(
                        finishedShooters,
                        this.OrionResultViewModel.OrionResults,
                        this.MainOrionViewModel,
                        this.Leon.LeonPersons,
                        this.m_minneViewModel.MinneRegistrations);
                }
                else
                {
                    LeonWriter.WriteLeonResults(
                        finishedShooters,
                        this.OrionResultViewModel.OrionResults,
                        this.MainOrionViewModel,
                        this.Leon.LeonPersons,
                        null);
                }
            }
        }
        private List <Registration> GetRegistrations200m(string competition)
        {
            DatabaseApi.SelectCompetition200m(competition);
            var rawResults = DatabaseApi.LoadCompetitionFromTable(TableName.LeonRegistration);
            var actualRegs = this.AddNewRegistrations(rawResults.OfType <LeonPerson>().ToList());
            var results    = this.GetResults200m(competition);

            foreach (var result in results)
            {
                var reg = actualRegs.SingleOrDefault(r => r.ShooterId == result.ShooterId);
                if (reg != null)
                {
                    reg.Result = result;
                }
            }

            return(actualRegs);
        }
Exemple #6
0
        public void LoadFromDb()
        {
            var leonPersons = DatabaseApi.LoadCompetitionFromTable(TableName.LeonRegistration);

            this.AddNewRegistrations(leonPersons.OfType <LeonPerson>().ToList(), false);
        }
Exemple #7
0
        public void LoadFromDB()
        {
            var minneRegistrations = DatabaseApi.LoadCompetitionFromTable(TableName.MinneRegistration);

            this.AddNewRegistrations(minneRegistrations.OfType <MinneRegistration>().ToList(), false);
        }
Exemple #8
0
        public List <OrionRegistration> AddNewRegistrations(List <LeonPerson> newRegistrations)
        {
            if (m_newRegistrations == null)
            {
                m_newRegistrations = new List <OrionRegistration>();
            }

            if (m_newRegistrationsThatMustSelectFirstRange == null)
            {
                m_newRegistrationsThatMustSelectFirstRange = new List <OrionRegistration>();
            }

            var results = DatabaseApi.LoadCompetitionFromTable(TableName.OrionResult).OfType <OrionResult>();

            foreach (var newRegistration in newRegistrations)
            {
                if (newRegistration.IsEmpty)
                {
                    var firstOrionId = m_orionSetupViewModel.OrionViewModels.First().OrionId;
                    var firstRegs    =
                        m_orionRegistrations.Where(
                            o => o.OrionId == firstOrionId && o.Team == newRegistration.Team && o.Target == newRegistration.Target);

                    if (firstRegs != null && firstRegs.Count() > 1)
                    {
                    }

                    var firstReg = firstRegs.FirstOrDefault();

                    if (firstReg != null && m_orionRegistrations.Any(o => o.ShooterId == firstReg.ShooterId))
                    {
                        var deleteRegistrations = m_orionRegistrations.Where(o => o.ShooterId == firstReg.ShooterId).ToList();
                        foreach (var deleteRegistration in deleteRegistrations)
                        {
                            if (results.Any(r => r.OrionId == deleteRegistration.OrionId && r.Team == deleteRegistration.Team))
                            {
                                continue;
                            }
                            else
                            {
                                deleteRegistration.Deleted = true;
                                m_newRegistrations.Add(deleteRegistration);
                                m_orionRegistrations.Remove(deleteRegistration);
                            }
                        }
                    }
                }
                else
                {
                    if (m_orionRegistrations.Any(o => o.ShooterId == newRegistration.ShooterId))
                    {
                        var deleteRegistrations = m_orionRegistrations.Where(o => o.ShooterId == newRegistration.ShooterId).ToList();
                        foreach (var deleteRegistration in deleteRegistrations)
                        {
                            if (results.Any(r => r.OrionId == deleteRegistration.OrionId && r.Team == deleteRegistration.Team))
                            {
                                continue;
                            }
                            else
                            {
                                deleteRegistration.Deleted = true;
                                m_newRegistrations.Add(deleteRegistration);
                                m_orionRegistrations.Remove(deleteRegistration);
                            }
                        }
                    }

                    var orionRegsForPerson = OrionGenerate.GenerateOrionForShooter(newRegistration, m_orionSetupViewModel);
                    foreach (var orionRegistration in orionRegsForPerson)
                    {
                        if (results.Any(r => r.OrionId == orionRegistration.OrionId && r.Team == orionRegistration.Team))
                        {
                            continue;
                        }
                        else
                        {
                            if (results.Any(r => r.ShooterId == orionRegistration.ShooterId))
                            {
                                m_newRegistrationsThatMustSelectFirstRange.Add(orionRegistration);
                            }
                            else
                            {
                                m_orionRegistrations.Add(orionRegistration);
                                m_newRegistrations.Add(orionRegistration);
                            }
                        }
                    }
                }
            }

            if (m_newRegistrationsThatMustSelectFirstRange.Any())
            {
                this.OnPropertyChanged("MovedOrionRegistrations");
            }

            this.OnPropertyChanged("OrionRegistrations");
            this.BuildLists();

            return(m_newRegistrations);
        }
Exemple #9
0
        internal void LoadFromDb()
        {
            var orionResults = DatabaseApi.LoadCompetitionFromTable(TableName.OrionResult);

            this.AddNewRegistrations(orionResults.OfType <OrionResult>().ToList());
        }