Esempio n. 1
0
        public DefaultConfiguration()
        {
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Documents\My Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20130914_132912.log");
            //_shootingRange = new SiusApiProvider("http://192.168.1.4");
            _shootingRange = new SiusDataSocketProvider("127.0.0.1", 4000);
            _events        = new ShootingRangeEvents();
            _uiEvents      = new UIEvents();
            ShootingRangeEntities entities = new ShootingRangeEntities();

            _personRepository                        = new PersonDataStore(entities);
            _shooterRepository                       = new ShooterDataStore(entities);
            _participationDataStore                  = new ParticipationDataStore(entities);
            _sessionDataStore                        = new SessionDataStore(entities);
            _shotDataStore                           = new ShotDataStore(entities);
            _sessionDetailsView                      = new SessionDetailsView(entities);
            _shooterNumberConfigDataStore            = new ShooterNumberConfigDataStore(entities);
            _shooterParticipationDataStore           = new ShooterParticipationDataStore(entities);
            _sessionSubtotalDataStore                = new SessionSubtotalDataStore(entities);
            _programItemDataStore                    = new ProgramItemDataStore(entities);
            _groupMemberDetailsView                  = new GroupMemberDetailsView(entities);
            _groupDetailsView                        = new GroupDetailsView(entities);
            _shooterParticipationView                = new ShooterParticipationView(entities);
            _windowService                           = new WindowService();
            _barcodePrintService                     = new PtouchBarcodePrinter();
            _barcodeBuilderService                   = new Barcode2Of5InterleavedService();
            _shooterNumberService                    = new ShooterNumberService(_shooterNumberConfigDataStore);
            _shooterCollectionParticipationDataStore = new ShooterCollectionParticipationDataStore(entities);
            _shooterCollectionDataStore              = new ShooterCollectionDataStore(entities);
            _collectionShooterDataStore              = new CollectionShooterDataStore(entities);
            _ssvShooterDataWriterService             = new SsvFileWriter(@"C:\Sius\SiusData\SSVDaten\SSV_schuetzen.txt");
        }
Esempio n. 2
0
        public void ConfigureContainer()
        {
            ShootingRangeEntities entities = new ShootingRangeEntities();

            _messenger = new Messenger();
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterInstance(_messenger).As <IMessenger>();

            IShooterNumberService          shooterNumberService          = new ShooterNumberService(new ShooterNumberConfigDataStore(entities));
            IPersonDataStore               personDataStore               = new PersonDataStore(entities);
            IShooterCollectionDataStore    shooterCollectionDataStore    = new ShooterCollectionDataStore(entities);
            ICollectionShooterDataStore    collectionShooterDataStore    = new CollectionShooterDataStore(entities);
            IShooterDataStore              shooterDataStore              = new ShooterDataStore(entities);
            IShooterParticipationDataStore shooterParticipationDataStore = new ShooterParticipationDataStore(entities);
            ISessionDataStore              sessionDataStore              = new SessionDataStore(entities);
            ISessionSubtotalDataStore      sessionSubtotalDataStore      = new SessionSubtotalDataStore(entities);
            IShotDataStore shotDataStore = new ShotDataStore(entities);

            IBarcodePrintService         barcodePrinter    = new PtouchBarcodePrinter();
            IBarcodeBuilderService       barcodeBuilder    = new Barcode2Of5InterleavedService();
            ISsvShooterDataWriterService shooterDataWriter = new SsvFileWriter(@"C:\Sius\SiusData\SSVDaten\SSV_schuetzen.txt");

            builder.RegisterInstance(shooterNumberService).As <IShooterNumberService>();
            builder.RegisterInstance(personDataStore).As <IPersonDataStore>();
            builder.RegisterInstance(shooterDataStore).As <IShooterDataStore>();
            builder.RegisterInstance(new ShooterParticipationDataStore(entities)).As <IShooterParticipationDataStore>();
            builder.RegisterInstance(shooterCollectionDataStore).As <IShooterCollectionDataStore>();
            builder.RegisterInstance(collectionShooterDataStore).As <ICollectionShooterDataStore>();
            builder.RegisterInstance(sessionDataStore).As <ISessionDataStore>();
            builder.RegisterInstance(sessionSubtotalDataStore).As <ISessionSubtotalDataStore>();
            builder.RegisterInstance(shotDataStore).As <IShotDataStore>();

            builder.RegisterInstance(barcodePrinter).As <IBarcodePrintService>();
            builder.RegisterInstance(barcodeBuilder).As <IBarcodeBuilderService>();
            builder.RegisterInstance(shooterDataWriter).As <ISsvShooterDataWriterService>();

            _vs = new ViewService();
            ViewServiceHandler vsh = new ViewServiceHandler();

            #region Windows and Dialogs

            _vs.RegisterFunction <MainWindowViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <MainWindow>((Window)window, model));

            #endregion

            _vs.RegisterFunction <PersonsPageViewModel, IPage>(
                (window, model) => vsh.GetUserControl <UcPersons>((Window)window, model));
            _vs.RegisterFunction <GroupsPageViewModel, IPage>(
                (window, model) => vsh.GetUserControl <UcGroups>((Window)window, model));
            _vs.RegisterFunction <ResultsPageViewModel, IPage>(
                (window, model) => vsh.GetUserControl <UcResults>((Window)window, model));
            _vs.RegisterFunction <RankViewModel, IPage>(
                (window, model) => vsh.GetUserControl <UcRankings>((Window)window, model));

            _vs.RegisterFunction <CreatePersonViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <CreatePerson>((Window)window, model));
            _vs.RegisterFunction <CreateGroupingViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <CreateGrouping>((Window)window, model));
            _vs.RegisterFunction <EditGroupingViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <EditGrouping>((Window)window, model));
            _vs.RegisterFunction <SelectParticipationViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <AddParticipationToShooterDialog>((Window)window, model));
            _vs.RegisterFunction <SelectGroupingViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <AddGroupingToShooterDialog>((Window)window, model));
            _vs.RegisterFunction <SelectShooterViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <AddShooterToGroupingDialog>((Window)window, model));
            _vs.RegisterFunction <ReassignSessionViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <ReassignSessionDialog>((Window)window, model));
            _vs.RegisterFunction <ReassignProgramNumberViewModel, IWindow>(
                (window, model) => vsh.GetOwnedWindow <ReassignProgramNumber>((Window)window, model));

            _vs.RegisterFunction <YesNoMessageBoxViewModel, IWindow>(
                (w, m) => vsh.GetOwnedWindow <YesNoMessageBox>((Window)w, m));
            _vs.RegisterFunction <MessageBoxViewModel, IWindow>((w, m) => vsh.GetOwnedWindow <OkMessageBox>((Window)w, m));

            InitializeServiceDeskConfiguration();
            _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ServiceDeskConfiguration serviceDeskConfiguration =
                _config.GetSection("ServiceDeskConfiguration") as ServiceDeskConfiguration;

            if (serviceDeskConfiguration == null)
            {
                serviceDeskConfiguration = new ServiceDeskConfiguration();
                _config.Sections.Add("ServiceDeskConfiguration", serviceDeskConfiguration);
            }

            builder.Register(c => serviceDeskConfiguration);

            IContainer container = builder.Build();
            ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(container));

            PersonsPageViewModel personsPageViewModel = new PersonsPageViewModel();
            personsPageViewModel.Initialize();

            GroupsPageViewModel groupsPageViewModel = new GroupsPageViewModel();
            groupsPageViewModel.Initialize();

            ResultsPageViewModel resultsPageViewModel = new ResultsPageViewModel();
            resultsPageViewModel.Initialize();

            RankViewModel rankViewModel = new RankViewModel();
            rankViewModel.Initialize();

            RegisterCreatePersonDialog(personDataStore);
            RegisterEditPersonDialog(personDataStore);
            RegisterCreateGroupingDialog(shooterCollectionDataStore, serviceDeskConfiguration);
            RegisterEditGroupingDialog(shooterCollectionDataStore);
            RegisterDeletePersonDialog(personDataStore);
            RegisterDeleteGroupingDialog(shooterCollectionDataStore);
            RegisterAddShooterToGroupingDialog(collectionShooterDataStore);
            RegisterDeleteShooterDialog(shooterDataStore);
            RegisterAddGroupingToShooterDialog(collectionShooterDataStore);
            RegisterRemoveGroupingFromShooterDialog(collectionShooterDataStore);
            RegisterAddParticipationToShooterDialog(shooterParticipationDataStore);
            RegisterRemoveParticipationFromShooterDialog(shooterParticipationDataStore);
            RegisterMessageBoxDialog();
            RegisterReassignSessionDialog(sessionDataStore);
            RegisterReassignShooterNumberDialog(sessionDataStore);

            RegisterShowShooterPageMessage(personsPageViewModel);
            RegisterShowGroupsPageMessage(groupsPageViewModel);
            // RegisterShowResultsPageMessage(resultsPageViewModel);
            RegisterShowRankingsPageMessage(rankViewModel);
        }