public void LastTarget_FirstTeam()
        {
            var settings = TestDataHelper.GetSettings("FeltAdminTest.TestData.FeltAdmin2OrionPauses.xml");

            var leonPerson = new LeonPerson
            {
                Class     = "4",
                ClubName  = "Bodø Østre",
                Name      = "Roald Parelius",
                Range     = 2,
                ShooterId = 123,
                SumIn     = 0,
                Target    = 4,
                Team      = 1
            };

            var result = OrionGenerate.GenerateOrionForShooter(leonPerson, settings.OrionSetting);

            Assert.IsTrue(result.Count == 6);
            this.AssertRegistration(result[0], 1, 1, 4, 123);
            this.AssertRegistration(result[1], 1, 3, 8, 123);
            this.AssertRegistration(result[2], 1, 5, 12, 123);
            this.AssertRegistration(result[3], 2, 1, 4, 123);
            this.AssertRegistration(result[4], 3, 1, 4, 123);
            this.AssertRegistration(result[5], 4, 1, 4, 123);
        }
        public void FirstTarget_FirstTeam()
        {
            var settings = TestDataHelper.GetSettings("FeltAdminTest.TestData.FeltAdmin2OrionPauses.xml");

            var leonPerson = new LeonPerson
            {
                Class     = "4",
                ClubName  = "Bodø Østre",
                Name      = "Roald Parelius",
                Range     = 1,
                ShooterId = 123,
                SumIn     = 0,
                Target    = 1,
                Team      = 1
            };

            foreach (var orionView in settings.OrionSetting.OrionViewModels)
            {
                foreach (var range in orionView.RangeViews)
                {
                    range.Parent = orionView;
                }
            }

            //AssertRegistration(OrionRegistration registration, int orionid, int team, int target, int shooterid)

            var result = OrionGenerate.GenerateOrionForShooter(leonPerson, settings.OrionSetting);

            Assert.IsTrue(result.Count == 5);
            this.AssertRegistration(result[0], 2, 1, 1, 123);
            this.AssertRegistration(result[1], 2, 3, 5, 123);
            this.AssertRegistration(result[2], 3, 5, 1, 123);
            this.AssertRegistration(result[3], 3, 7, 4, 123);
            this.AssertRegistration(result[4], 2, 9, 14, 123);
        }
Esempio n. 3
0
        public void GenerateOrionTeamsExecute()
        {
            var allOrionRegistrations = new List <OrionRegistration>();
            var leonpersons           = m_leonViewModel.LeonPersons;

            foreach (var leonperson in leonpersons)
            {
                var orionRegsForPerson = OrionGenerate.GenerateOrionForShooter(leonperson, m_orionSetupViewModel);
                allOrionRegistrations.AddRange(orionRegsForPerson);
            }

            m_orionRegistrations = allOrionRegistrations;
            this.OnPropertyChanged("OrionRegistrations");
            this.BuildLists();
        }
Esempio n. 4
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);
        }