private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            AppViewModel             appVM = DataContext as AppViewModel;
            PatientSelectorViewModel vm    = appVM.CurrentViewModel as PatientSelectorViewModel;

            vm.Filter(((TextBox)sender).Text);
        }
        public AddAppointmentDialog BuildWindow()
        {
            var selectedPatientVariable = new SharedState <Patient>();

            IPatientSelectorViewModel patientSelectorViewModel = new PatientSelectorViewModel(patientRepository,
                                                                                              selectedPatientVariable,
                                                                                              errorCallback);

            return(new AddAppointmentDialog
            {
                Owner = Application.Current.MainWindow,
                DataContext = new AddAppointmentDialogViewModel(medicalPracticeRepository,
                                                                readModelRepository,
                                                                labelRepository,
                                                                patientSelectorViewModel,
                                                                selectedPatientVariable,
                                                                selectedDateVariable.Value,
                                                                selectedMedicalPractiveVariable.Value,
                                                                appointmentViewModelBuilder,
                                                                errorCallback)
            });
        }
Ejemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            AssureAppDataDirectoriesExist();

            ///////////////////////////////////////////////////////////////////////////////////////////////////
            ////////                                                                                 //////////
            ////////                            Composition Root and Setup                           //////////
            ////////                                                                                 //////////
            ///////////////////////////////////////////////////////////////////////////////////////////////////

            var dataCenterContainer = new DataCenterContainer();

            // ConnectionService

            var connectionServiceBuilder = new ConnectionServiceBuilder(dataCenterContainer);
            var connectionService        = connectionServiceBuilder.Build();

            // Patient-Repository

            var patientPersistenceService = new XmlPatientDataStore(GlobalConstants.PatientPersistenceFile);
            var patientRepository         = new PatientRepository(patientPersistenceService, connectionService);

            patientRepository.LoadRepository();


            // Config-Repository

            var configPersistenceService = new XmlConfigurationDataStore(GlobalConstants.ConfigPersistenceFile);
            var configRepository         = new ConfigurationRepository(configPersistenceService);

            configRepository.LoadRepository();


            // LocalSettings-Repository

            var settingsPersistenceService = new LocalSettingsXmlPersistenceService(GlobalConstants.LocalServerSettingsPersistanceFile);
            var localSettingsRepository    = new LocalSettingsRepository(settingsPersistenceService);

            localSettingsRepository.LoadRepository();

            // Event-Store

            var eventStreamPersistenceService = new XmlEventStreamPersistanceService();
            var streamPersistenceService      = new StreamPersistenceService(eventStreamPersistenceService, configRepository, GlobalConstants.EventHistoryBasePath, 500);
            var metaDataPersistenceService    = new XmlPracticeMetaDataPersistanceService(GlobalConstants.MetaDataPersistanceFile);
            var metaDataService = new StreamMetaDataService(metaDataPersistenceService);

            var eventStore = new EventStore(streamPersistenceService, metaDataService, connectionService);

            eventStore.LoadRepository();

            // DataAndService

            var dataCenter = new DataCenter(configRepository, patientRepository, eventStore);

            dataCenterContainer.DataCenter = dataCenter;

            var backUpService   = new BackupService(patientRepository, configRepository, eventStore, connectionService);
            var backupScheduler = new BackupScheduler(backUpService);

            backupScheduler.Start(localSettingsRepository);

            // ViewModel-Variables

            var selectedPageVariable = new SharedState <MainPage>(MainPage.Overview);


            // sampleData-generators

            var patientNameGenerator = new PatientNameGenerator();
            var appointmentGenerator = new AppointmentGenerator(configRepository, patientRepository, eventStore);


            // ViewModels

            var selectedPatientVariable  = new SharedState <Patient>(null);
            var patientSelectorViewModel = new PatientSelectorViewModel(patientRepository, selectedPatientVariable);

            var overviewPageViewModel          = new OverviewPageViewModel(connectionService);
            var connectionsPageViewModel       = new ConnectionsPageViewModel(dataCenter, connectionService, selectedPageVariable);
            var userPageViewModel              = new UserPageViewModel(dataCenter, selectedPageVariable);
            var licencePageViewModel           = new LicencePageViewModel();
            var infrastructurePageViewModel    = new InfrastructurePageViewModel(dataCenter, selectedPageVariable, appointmentGenerator);
            var hoursOfOpeningPageViewModel    = new HoursOfOpeningPageViewModel(dataCenter, selectedPageVariable);
            var therapyPlaceTypesPageViewModel = new TherapyPlaceTypesPageViewModel(dataCenter, selectedPageVariable, connectionService);
            var labelPageViewModel             = new LabelPageViewModel(dataCenter, selectedPageVariable, connectionService);
            var patientsPageViewModel          = new PatientsPageViewModel(patientSelectorViewModel, patientRepository, selectedPatientVariable, patientNameGenerator);
            var backupPageViewModel            = new BackupPageViewModel(backUpService, backupScheduler, localSettingsRepository);
            var optionsPageViewModel           = new OptionsPageViewModel();
            var aboutPageViewModel             = new AboutPageViewModel("0.1.0.0");

            var mainWindowViewModel = new MainWindowViewModel(overviewPageViewModel,
                                                              connectionsPageViewModel,
                                                              userPageViewModel,
                                                              licencePageViewModel,
                                                              infrastructurePageViewModel,
                                                              hoursOfOpeningPageViewModel,
                                                              therapyPlaceTypesPageViewModel,
                                                              labelPageViewModel,
                                                              patientsPageViewModel,
                                                              backupPageViewModel,
                                                              optionsPageViewModel,
                                                              aboutPageViewModel,
                                                              selectedPageVariable);
            var mainWindow = new MainWindow
            {
                DataContext = mainWindowViewModel
            };

            mainWindow.ShowDialog();

            ///////////////////////////////////////////////////////////////////////////////////////////////
            ////////                                                                             //////////
            ////////             Clean Up and store data after main Window was closed            //////////
            ////////                                                                             //////////
            ///////////////////////////////////////////////////////////////////////////////////////////////

            backupScheduler.Stop();

            configRepository.PersistRepository();
            patientRepository.PersistRepository();
            eventStore.PersistRepository();
            localSettingsRepository.PersistRepository();

            connectionServiceBuilder.DisposeConnectionService(connectionService);
        }
Ejemplo n.º 4
0
        public IMainViewModel Build(Action <string> errorCallback, Size initialSize = null)
        {
            // Register Global ViewModelVariables

            var firstDispayedDate = TimeTools.Today();          // TODO find last open

            gridSizeVariable = new SharedState <Size>(initialSize ?? new Size(new Width(400), new Height(400)));
            var selectedDateVariable = new SharedState <Date>(firstDispayedDate);
            var selectedMedicalPracticeIdVariable = new SharedState <Guid>(Guid.Empty);
            var roomFilterVariable = new SharedState <Guid?>();
            var appointmentModificationsVariable = new SharedState <AppointmentModifications>();

            var selectedPatientForAppointmentSearchVariable = new SharedState <Patient>();


            // Create ViewModelCollection

            viewModelCommunication.CreateViewModelCollection <ITherapyPlaceRowViewModel, TherapyPlaceRowIdentifier>(
                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <ITimeGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.TimeGridViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <IAppointmentViewModel, Guid>(
                Constants.ViewModelCollections.AppointmentViewModelCollection
                );

            // build factorys

            var appointmentModificationsBuilder = new AppointmentModificationsBuilder(medicalPracticeRepository,
                                                                                      readModelRepository,
                                                                                      viewModelCommunication,
                                                                                      selectedDateVariable,
                                                                                      gridSizeVariable);

            var appointmentViewModelBuilder = new AppointmentViewModelBuilder(viewModelCommunication,
                                                                              labelRepository,
                                                                              commandService,
                                                                              appointmentModificationsVariable,
                                                                              selectedDateVariable,
                                                                              adornerControl,
                                                                              appointmentModificationsBuilder);

            var therapyPlaceRowViewModelBuilder = new TherapyPlaceRowViewModelBuilder(viewModelCommunication,
                                                                                      medicalPracticeRepository,
                                                                                      therapyPlaceTypeRepository,
                                                                                      adornerControl,
                                                                                      appointmentModificationsVariable,
                                                                                      gridSizeVariable);

            var appointmentGridViewModelBuilder = new AppointmentGridViewModelBuilder(medicalPracticeRepository,
                                                                                      readModelRepository,
                                                                                      viewModelCommunication,
                                                                                      gridSizeVariable,
                                                                                      roomFilterVariable,
                                                                                      selectedMedicalPracticeIdVariable,
                                                                                      appointmentModificationsVariable,
                                                                                      appointmentViewModelBuilder,
                                                                                      therapyPlaceRowViewModelBuilder);

            var addAppointmentDialogWindowBuilder = new AddAppointmentDialogWindowBuilder(patientRepository,
                                                                                          readModelRepository,
                                                                                          medicalPracticeRepository,
                                                                                          labelRepository,
                                                                                          selectedMedicalPracticeIdVariable,
                                                                                          selectedDateVariable,
                                                                                          appointmentViewModelBuilder,
                                                                                          errorCallback);

            var printDialogWindowBuilder = new PrintDialogWindowBuilder(medicalPracticeRepository,
                                                                        readModelRepository,
                                                                        errorCallback);

            // build stand-alone viewModelMessageHandler

            confirmChangesMessageHandler = new ConfirmChangesMessageHandler(viewModelCommunication,
                                                                            commandService,
                                                                            appointmentModificationsVariable,
                                                                            errorCallback);

            rejectChangesMessageHandler = new RejectChangesMessageHandler(viewModelCommunication,
                                                                          appointmentModificationsVariable);


            // build factories



            // create permanent ViewModels

            var dateDisplayViewModel = new DateDisplayViewModel(selectedDateVariable);

            var medicalPracticeSelectorViewModel = new MedicalPracticeSelectorViewModel(session,
                                                                                        medicalPracticeRepository,
                                                                                        localSettingsRepository,
                                                                                        selectedMedicalPracticeIdVariable,
                                                                                        appointmentModificationsVariable,
                                                                                        errorCallback);

            var roomSelectorViewModel = new RoomFilterViewModel(medicalPracticeRepository,
                                                                roomFilterVariable,
                                                                selectedDateVariable,
                                                                selectedMedicalPracticeIdVariable,
                                                                appointmentModificationsVariable,
                                                                errorCallback);

            var dateSelectorViewModel = new DateSelectorViewModel(selectedDateVariable);

            var gridContainerViewModel = new GridContainerViewModel(viewModelCommunication,
                                                                    medicalPracticeRepository,
                                                                    selectedDateVariable,
                                                                    selectedMedicalPracticeIdVariable,
                                                                    gridSizeVariable,
                                                                    new List <AggregateIdentifier>(),
                                                                    50,
                                                                    appointmentGridViewModelBuilder,
                                                                    errorCallback);

            var undoRedoViewModel = new UndoRedoViewModel(viewModelCommunication,
                                                          appointmentModificationsVariable,
                                                          session,
                                                          errorCallback);

            var overviewPageViewModel = new OverviewPageViewModel(viewModelCommunication,
                                                                  dateDisplayViewModel,
                                                                  medicalPracticeSelectorViewModel,
                                                                  roomSelectorViewModel,
                                                                  dateSelectorViewModel,
                                                                  gridContainerViewModel,
                                                                  undoRedoViewModel,
                                                                  addAppointmentDialogWindowBuilder,
                                                                  printDialogWindowBuilder,
                                                                  appointmentModificationsVariable,
                                                                  selectedMedicalPracticeIdVariable,
                                                                  selectedDateVariable,
                                                                  medicalPracticeRepository,
                                                                  errorCallback);

            var patientSelectorViewModel = new PatientSelectorViewModel(patientRepository,
                                                                        selectedPatientForAppointmentSearchVariable,
                                                                        errorCallback);

            var searchPageViewModel = new SearchPageViewModel(patientSelectorViewModel,
                                                              selectedPatientForAppointmentSearchVariable,
                                                              selectedDateVariable,
                                                              viewModelCommunication,
                                                              commandService,
                                                              readModelRepository,
                                                              medicalPracticeRepository,
                                                              errorCallback);

            var optionsPageViewModel = new OptionsPageViewModel();

            var mainViewModel = new ViewModels.MainView.MainViewModel(viewModelCommunication,
                                                                      overviewPageViewModel,
                                                                      searchPageViewModel,
                                                                      optionsPageViewModel,
                                                                      appointmentModificationsVariable);

            viewModelCommunication.RegisterViewModelMessageHandler <AsureDayIsLoaded>(gridContainerViewModel);
            viewModelCommunication.RegisterViewModelMessageHandler <ShowPage>(mainViewModel);
            viewModelCommunication.RegisterViewModelMessageHandler(confirmChangesMessageHandler);
            viewModelCommunication.RegisterViewModelMessageHandler(rejectChangesMessageHandler);

            return(mainViewModel);
        }
Ejemplo n.º 5
0
        public void BuildAndStart(StartupEventArgs startupEventArgs)
        {
#if DEBUG
            var listener = new OnkoTePlaDebugListener();
            Debug.Listeners.Add(listener);
#endif

            AssureAppDataDirectoriesExist();

            var dataCenterContainer = new DataCenterContainer();

            // ConnectionService

            connectionServiceBuilder = new ConnectionServiceBuilder(dataCenterContainer);
            connectionService        = connectionServiceBuilder.Build();

            // Patient-Repository

            var patientPersistenceService = new XmlPatientDataStore(GlobalConstants.PatientPersistenceFile);

            patientRepository = new PatientRepository(patientPersistenceService, connectionService);
            patientRepository.LoadRepository();


            // Config-Repository

            var configPersistenceService = new XmlConfigurationDataStore(GlobalConstants.ConfigPersistenceFile);
            configRepository = new ConfigurationRepository(configPersistenceService);
            configRepository.LoadRepository();


            // LocalSettings-Repository

            var settingsPersistenceService = new LocalSettingsXmlPersistenceService(GlobalConstants.LocalServerSettingsPersistanceFile);

            localSettingsRepository = new LocalSettingsRepository(settingsPersistenceService);
            localSettingsRepository.LoadRepository();

            // Event-Store

            var eventStreamPersistenceService = new XmlEventStreamPersistanceService();
            var streamPersistenceService      = new StreamPersistenceService(eventStreamPersistenceService, configRepository, GlobalConstants.EventHistoryBasePath, 500);
            var metaDataPersistenceService    = new XmlPracticeMetaDataPersistanceService(GlobalConstants.MetaDataPersistanceFile);
            var metaDataService = new StreamMetaDataService(metaDataPersistenceService);


            eventStore = new EventStore(streamPersistenceService, metaDataService, connectionService);
            eventStore.LoadRepository();

            // DataAndService

            var dataCenter = new DataCenter(configRepository, patientRepository, eventStore);
            dataCenterContainer.DataCenter = dataCenter;

            var backUpService = new BackupService(patientRepository, configRepository, eventStore, connectionService);

            backupScheduler = new BackupScheduler(backUpService);
            backupScheduler.Start(localSettingsRepository);

            // ViewModel-Variables

            var selectedPageVariable = new SharedState <MainPage>(MainPage.Overview);


            // sampleData-generators

            var patientNameGenerator = new PatientNameGenerator();
            var appointmentGenerator = new AppointmentGenerator(configRepository, patientRepository, eventStore);


            // ViewModels

            var selectedPatientVariable  = new SharedState <Patient>(null);
            var patientSelectorViewModel = new PatientSelectorViewModel(patientRepository, selectedPatientVariable, null);

            var overviewPageViewModel          = new OverviewPageViewModel(connectionService);
            var connectionsPageViewModel       = new ConnectionsPageViewModel(dataCenter, connectionService, selectedPageVariable);
            var userPageViewModel              = new UserPageViewModel(dataCenter, selectedPageVariable);
            var licencePageViewModel           = new LicencePageViewModel();
            var infrastructurePageViewModel    = new InfrastructurePageViewModel(dataCenter, selectedPageVariable, appointmentGenerator);
            var hoursOfOpeningPageViewModel    = new HoursOfOpeningPageViewModel(dataCenter, selectedPageVariable);
            var therapyPlaceTypesPageViewModel = new TherapyPlaceTypesPageViewModel(dataCenter, selectedPageVariable, connectionService);
            var labelPageViewModel             = new LabelPageViewModel(dataCenter, selectedPageVariable, connectionService);
            var patientsPageViewModel          = new PatientsPageViewModel(patientSelectorViewModel, patientRepository, selectedPatientVariable, patientNameGenerator);
            var backupPageViewModel            = new BackupPageViewModel(backUpService, backupScheduler, localSettingsRepository);
            var optionsPageViewModel           = new OptionsPageViewModel();
            var aboutPageViewModel             = new AboutPageViewModel();

            var mainWindowViewModel = new MainWindowViewModel(overviewPageViewModel,
                                                              connectionsPageViewModel,
                                                              userPageViewModel,
                                                              licencePageViewModel,
                                                              infrastructurePageViewModel,
                                                              hoursOfOpeningPageViewModel,
                                                              therapyPlaceTypesPageViewModel,
                                                              labelPageViewModel,
                                                              patientsPageViewModel,
                                                              backupPageViewModel,
                                                              optionsPageViewModel,
                                                              aboutPageViewModel,
                                                              selectedPageVariable);
            var mainWindow = new Visualization.MainWindow
            {
                DataContext = mainWindowViewModel
            };

            mainWindow.Show();

#if DEBUG
            var debugOutputWindowViewModel = new DebugOutputWindowViewModel(listener);
            var debugWindow = new DebugOutputWindow
            {
                Owner       = mainWindow,
                DataContext = debugOutputWindowViewModel
            };

            debugWindow.Show();
#endif
        }