public void Initialize(int shooterId)
        {
            ServiceDeskConfiguration serviceDeskConfiguration =
                ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>();
            IShooterDataStore           shooterDataStore           = ServiceLocator.Current.GetInstance <IShooterDataStore>();
            IPersonDataStore            personDataStore            = ServiceLocator.Current.GetInstance <IPersonDataStore>();
            ICollectionShooterDataStore collectionShooterDataStore =
                ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();
            IShooterCollectionDataStore shooterCollectionDataStore =
                ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            IShooterParticipationDataStore shooterParticipationDataStore =
                ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>();

            // Get PrgramNumbers in which the shooter is enroled.
            List <int> programNumbers = (from sp in shooterParticipationDataStore.FindByShooterId(shooterId)
                                         select sp.ProgramNumber).ToList();

            // Get all CollectionShooters grouped by their ShooterCollections Participation ProgramNumber
            IEnumerable <IGrouping <int, CollectionShooter> > collectionShootersGroupedByProgramNumber =
                from p in programNumbers
                join sc in shooterCollectionDataStore.GetAll() on p equals sc.ProgramNumber
                join
                cs in collectionShooterDataStore.GetAll() on sc.ShooterCollectionId equals cs.ShooterCollectionId
                group cs by p;

            // Program Numbers with which the current shooter is not yet enroled as a CollectionShooter
            IEnumerable <int> programNumbersAlreadyEnroled = from scg in collectionShootersGroupedByProgramNumber
                                                             where scg.Any(x => x.ShooterId == shooterId)
                                                             select scg.Key;

            // Final list of ShooterCollections which are relevant for the current shooter
            IEnumerable <ShooterCollection> shooterCollectionsFinal = from p in programNumbers
                                                                      join sc in shooterCollectionDataStore.GetAll() on p equals sc.ProgramNumber
                                                                      where !programNumbersAlreadyEnroled.Contains(p)
                                                                      select sc;

            IEnumerable <GroupingViewModel> groupingViewModels = from sc in shooterCollectionsFinal
                                                                 join p in serviceDeskConfiguration.ParticipationDescriptions.GetAll() on sc.ProgramNumber.ToString()
                                                                 equals
                                                                 p.ProgramNumber
                                                                 select new GroupingViewModel
            {
                ShooterCollectionId = sc.ShooterCollectionId,
                GroupingName        = sc.CollectionName,
                ParticipationName   = p.ProgramName,
                Shooters            =
                    new ObservableCollection <PersonShooterViewModel>(from cs in collectionShooterDataStore.GetAll()
                                                                      join s in shooterDataStore.GetAll() on cs.ShooterId equals s.ShooterId
                                                                      join person in personDataStore.GetAll() on s.PersonId equals person.PersonId
                                                                      where cs.ShooterCollectionId == sc.ShooterCollectionId
                                                                      select new PersonShooterViewModel(person, s))
            };

            Groupings = new ObservableCollection <GroupingViewModel>(groupingViewModels);
        }
        private void LoadShooterCollections(int programNumber)
        {
            IShooterCollectionDataStore shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            ICollectionShooterDataStore collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();
            IShooterDataStore           shooterDataStore           = ServiceLocator.Current.GetInstance <IShooterDataStore>();
            IPersonDataStore            personDataStore            = ServiceLocator.Current.GetInstance <IPersonDataStore>();

            IEnumerable <ShooterCollectionViewModel> scvm = from sc in shooterCollectionDataStore.GetAll()
                                                            where sc.ProgramNumber == programNumber
                                                            select new ShooterCollectionViewModel
            {
                CollectionName      = sc.CollectionName,
                ShooterCollectionId = sc.ShooterCollectionId,
                Shooters            =
                    new ObservableCollection <UiCollectionShooter>(from cs in collectionShooterDataStore.GetAll()
                                                                   where cs.ShooterCollectionId == sc.ShooterCollectionId
                                                                   join s in shooterDataStore.GetAll() on cs.ShooterId equals s.ShooterId
                                                                   join p in personDataStore.GetAll() on s.PersonId equals p.PersonId
                                                                   orderby p.FirstName
                                                                   orderby p.LastName
                                                                   select new UiCollectionShooter
                {
                    ShooterId     = s.ShooterId,
                    PersonId      = p.PersonId,
                    FirstName     = p.FirstName,
                    LastName      = p.LastName,
                    ShooterNumber = s.ShooterNumber
                })
            };

            ShooterCollections = new ObservableCollection <ShooterCollectionViewModel>(scvm.OrderBy(_ => _.CollectionName));
        }
    public ShooterEditViewModel()
    {
            AddToAssingedParticipationCommand = new RelayCommand<ParticipationListItem>(ExecuteAddToAssignedParticipationCommand,
        CanExecuteAddtoAssignedParticipationCommand);
      RemoveFromAssingedParticipationCommand =
        new RelayCommand<ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand,
          CanExecuteRemoveFromAssignedParticipationCommand);
      CancelCommand = new RelayCommand<object>(ExecuteCloseCommand);
      AssignShooterCollectionCommand = new RelayCommand<UiShooterCollection>(ExecuteAssignShooterCommand,
        CanExecuteAssignShooterCommand);

      if (!DesignTimeHelper.IsInDesignMode)
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _participationDataStore = config.GetParticipationDataStore();
        _windowService = config.GetWindowService();
        _shooterParticipationDataStore = config.GetShooterParticipationDataStore();
        _collectionShooterDataStore = config.GetCollectionShooterDataStore();
        _personDataStore = config.GetPersonDataStore();
        _uiEvents = config.GetUIEvents();
        _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; };
        _uiEvents.RequireSelectedShooter();
        _shooterNumberService = config.GetShooterNumberService();
        _shooterDataStore = config.GetShooterDataStore();
        _shooterParticipationView = config.GetShooterParticipationView();
        _shooterCollectionDataStore = config.GetShooterCollectionDataStore();
        _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
        LoadData();

        UiShooterCollections = new ObservableCollection<UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName));
      }
    }
Ejemplo n.º 4
0
        private RankingReport BuildCollectionRankingReport()
        {
            IShooterCollectionDataStore shooterCollectionDataStore =
                ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            ICollectionShooterDataStore collectionShooterDataStore =
                ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();

            CollectionRankingReport report = new CollectionRankingReport();
            int progamNumber = _rankingConfiguration.ProgramNumber;
            IEnumerable <Tuple <Person, int, decimal, decimal> > bestResults = GetBestResults(progamNumber);

            foreach (Tuple <Person, int, decimal, decimal> result in bestResults)
            {
                int shooterId = result.Item2;
                ShooterCollection shooterCollection = (from sc in shooterCollectionDataStore.GetAll()
                                                       join cs in collectionShooterDataStore.GetAll() on sc.ShooterCollectionId equals
                                                       cs.ShooterCollectionId
                                                       where cs.ShooterId == shooterId && sc.ProgramNumber == progamNumber
                                                       select sc).FirstOrDefault();

                if (shooterCollection != null)
                {
                    report.Add(result.Item1, result.Item3, shooterCollection);
                }
            }

            return(report);
        }
Ejemplo n.º 5
0
        private IEnumerable <GroupingViewModel> FetchGroupsByShooter(Shooter shooter)
        {
            ServiceDeskConfiguration           sdk            = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>();
            ParticipationDescriptionCollection participations = sdk.ParticipationDescriptions;

            return(from collectionShooter in _collectionShooterDataStore.FindByShooterId(shooter.ShooterId)
                   join shooterCollection in _shooterCollectionDataStore.GetAll() on collectionShooter.ShooterCollectionId equals shooterCollection.ShooterCollectionId
                   join participation in participations.GetAll() on shooterCollection.ProgramNumber.ToString()
                   equals
                   participation.ProgramNumber
                   orderby shooterCollection.CollectionName
                   select new GroupingViewModel
            {
                ShooterCollectionId = collectionShooter.CollectionShooterId,
                GroupingName = shooterCollection.CollectionName,
                ParticipationName = participation.ProgramName
            });
        }
        public void Initialize(int programNumber)
        {
            IPersonDataStore               personDataStore               = ServiceLocator.Current.GetInstance <IPersonDataStore>();
            IShooterDataStore              shooterDataStore              = ServiceLocator.Current.GetInstance <IShooterDataStore>();
            ICollectionShooterDataStore    collectionShooterDataStore    = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();
            IShooterCollectionDataStore    shooterCollectionDataStore    = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            IShooterParticipationDataStore shooterParticipationDataStore =
                ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>();

            // ShooterIds enroled in ProgramNumber
            IEnumerable <int> shooters = from sp in shooterParticipationDataStore.FindByProgramNumber(programNumber)
                                         select sp.ShooterId;

            // ShooterIds with a ShooterCollection participating in ProgramNumber
            IEnumerable <int> shootersWithCollectionInProgramNumber = from cs in collectionShooterDataStore.GetAll()
                                                                      join sc in shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId
                                                                      where sc.ProgramNumber == programNumber
                                                                      select cs.ShooterId;

            IEnumerable <int> shootersFinal = shooters.Except(shootersWithCollectionInProgramNumber);

            IEnumerable <PersonShooterViewModel> result = from shooterId in shootersFinal
                                                          join s in shooterDataStore.GetAll() on shooterId equals s.ShooterId
                                                          join p in personDataStore.GetAll() on s.PersonId equals p.PersonId
                                                          select
                                                          new PersonShooterViewModel
            {
                PersonId      = p.PersonId,
                FirstName     = p.FirstName,
                LastName      = p.LastName,
                DateOfBirth   = p.DateOfBirth,
                ShooterId     = s.ShooterId,
                ShooterNumber = s.ShooterNumber
            };

            Shooters = new ObservableCollection <PersonShooterViewModel>(result);
        }
Ejemplo n.º 7
0
        public ShooterEditViewModel()
        {
            AddToAssingedParticipationCommand = new RelayCommand <ParticipationListItem>(ExecuteAddToAssignedParticipationCommand,
                                                                                         CanExecuteAddtoAssignedParticipationCommand);
            RemoveFromAssingedParticipationCommand =
                new RelayCommand <ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand,
                                                                CanExecuteRemoveFromAssignedParticipationCommand);
            CancelCommand = new RelayCommand <object>(ExecuteCloseCommand);
            AssignShooterCollectionCommand = new RelayCommand <UiShooterCollection>(ExecuteAssignShooterCommand,
                                                                                    CanExecuteAssignShooterCommand);

            if (!DesignTimeHelper.IsInDesignMode)
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _participationDataStore        = config.GetParticipationDataStore();
                _windowService                 = config.GetWindowService();
                _shooterParticipationDataStore = config.GetShooterParticipationDataStore();
                _collectionShooterDataStore    = config.GetCollectionShooterDataStore();
                _personDataStore               = config.GetPersonDataStore();
                _uiEvents = config.GetUIEvents();
                _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; };
                _uiEvents.RequireSelectedShooter();
                _shooterNumberService       = config.GetShooterNumberService();
                _shooterDataStore           = config.GetShooterDataStore();
                _shooterParticipationView   = config.GetShooterParticipationView();
                _shooterCollectionDataStore = config.GetShooterCollectionDataStore();
                _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
                LoadData();

                UiShooterCollections = new ObservableCollection <UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName));
            }
        }
Ejemplo n.º 8
0
        private void PrintBarcode()
        {
            if (SelectedShooter != null)
            {
                var personShooter = (from shooter in _shooterDataStore.GetAll()
                                     join person in _personDataStore.GetAll() on shooter.PersonId equals person.PersonId
                                     where shooter.ShooterId == SelectedShooter.Shooter.ShooterId
                                     select new
                {
                    person.FirstName,
                    person.LastName,
                    person.DateOfBirth,
                    shooter.ShooterNumber
                }).Single();

                IBarcodeBuilderService barcodeBuilderService = ServiceLocator.Current.GetInstance <IBarcodeBuilderService>();
                string barcode = barcodeBuilderService.BuildBarcode(personShooter.ShooterNumber, 0);


                var shooterCollections = from sc in _shooterCollectionDataStore.GetAll()
                                         join cs in _collectionShooterDataStore.GetAll() on
                                         sc.ShooterCollectionId equals cs.ShooterCollectionId
                                         join p in _serviceDeskConfiguration.ParticipationDescriptions.GetAll() on
                                         sc.ProgramNumber.ToString() equals p.ProgramNumber
                                             where p.AllowShooterCollectionParticipation && cs.ShooterId == SelectedShooter.Shooter.ShooterId
                                         select new
                {
                    sc.CollectionName,
                    p.ProgramName,
                    p.ProgramNumber
                };

                Dictionary <string, Tuple <string, string> > grouped = (from sc in shooterCollections
                                                                        group sc by sc.ProgramNumber
                                                                        into g
                                                                        select new
                {
                    ProgramNumber = g.Key,
                    CollectionName = g.Single().CollectionName,
                    ProgramName = g.Single().ProgramName
                }).ToDictionary(x => x.ProgramNumber,
                                x => new Tuple <string, string>(x.ProgramName, x.CollectionName));

                IBarcodePrintService barcodeService = ServiceLocator.Current.GetInstance <IBarcodePrintService>();

                GenericBarcode_20150909 genericBarcode = new GenericBarcode_20150909
                {
                    FirstName   = personShooter.FirstName,
                    LastName    = personShooter.LastName,
                    DateOfBirth = personShooter.DateOfBirth,
                    Barcode     = barcode,
                    ParticipationTypeToCollectionName = grouped.Values.Take(2).ToList(),
                    Participations = _serviceDeskConfiguration.ParticipationDescriptions.GetAll().Select(x => x.ProgramName).Take(5).ToList()
                };

                try
                {
                    barcodeService.Print(genericBarcode);
                }
                catch (Exception e)
                {
                    MessengerInstance.Send(new DialogMessage("Barcode Print Error",
                                                             "Fehler beim Drucken des Barcodes.\r\n\r\n" + e.ToString(),
                                                             MessageIcon.Error));
                }
            }
        }
Ejemplo n.º 9
0
        private void ExecutePrintBarcodeCommand(UiShooter uiShooter)
        {
            try
            {
                bool isNachwuchs = (from sp in _shooterParticipationDataStore.GetAll()
                                    join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId
                                    where p.ParticipationName == "Nachwuchsstich" && sp.ShooterId == uiShooter.ShooterId
                                    select p.ParticipationId).
                                   Any();

                bool isGruppe = (from sp in _shooterParticipationDataStore.GetAll()
                                 join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId
                                 where p.ParticipationName == "Gruppenstich" && sp.ShooterId == uiShooter.ShooterId
                                 select p.ParticipationId).
                                Any();

                bool isSieUndEr = (from sp in _shooterParticipationDataStore.GetAll()
                                   join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId
                                   where p.ParticipationName == "Sie & Er" && sp.ShooterId == uiShooter.ShooterId
                                   select p.ParticipationId).
                                  Any();

                bool isWorschtUndBrot = (from sp in _shooterParticipationDataStore.GetAll()
                                         join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId
                                         where p.ParticipationName == "Worscht & Brot" && sp.ShooterId == uiShooter.ShooterId
                                         select p.ParticipationId).
                                        Any();

                string groupName = (from cs in _collectionShooterDataStore.GetAll()
                                    join sc in _shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId
                                    join scp in _shooterCollectionParticipationDataStore.GetAll() on cs.ShooterCollectionId equals
                                    scp.ShooterCollectionId
                                    join p in _participationDataStore.GetAll() on scp.ParticipationId equals p.ParticipationId
                                    where p.ParticipationName == "Gruppenstich" && cs.ShooterId == uiShooter.ShooterId
                                    select sc.CollectionName).SingleOrDefault();

                string sieUndErName = (from cs in _collectionShooterDataStore.GetAll()
                                       join sc in _shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId
                                       join scp in _shooterCollectionParticipationDataStore.GetAll() on cs.ShooterCollectionId equals
                                       scp.ShooterCollectionId
                                       join p in _participationDataStore.GetAll() on scp.ParticipationId equals p.ParticipationId
                                       where p.ParticipationName == "Sie & Er" && cs.ShooterId == uiShooter.ShooterId
                                       select sc.CollectionName).SingleOrDefault();

                Person person = uiShooter.PersonId == null
          ? new Person()
                {
                    FirstName = "unknown", LastName = "unknown"
                }
          : _personDataStore.FindById((int)uiShooter.PersonId);
                BarcodeHerbstschiessen barcodeInfo = new BarcodeHerbstschiessen
                {
                    FirstName        = person.FirstName,
                    LastName         = person.LastName,
                    DateOfBirth      = person.DateOfBirth,
                    Gruppenstich     = groupName ?? string.Empty,
                    SieUndEr         = sieUndErName ?? string.Empty,
                    Barcode          = _barcodeBuilderService.BuildBarcode(uiShooter.ShooterNumber, uiShooter.Legalization),
                    IsGruppenstich   = isGruppe,
                    IsNachwuchsstich = isNachwuchs,
                    IsWorschtUndBrot = isWorschtUndBrot,
                    IsSieUndEr       = isSieUndEr
                };

                _barcodePrintService.Print(barcodeInfo);
            }
            catch (Exception e)
            {
                ReportException(e);
            }
        }