Esempio n. 1
0
        public BackupPageViewModel(IBackupService backupService,
                                   IBackupScheduler backupScheduler,
                                   ILocalSettingsRepository localSettingsRepository)
        {
            this.backupService           = backupService;
            this.backupScheduler         = backupScheduler;
            this.localSettingsRepository = localSettingsRepository;

            AllBackupIntervals = Enum.GetValues(typeof(BackupInterval)).Cast <BackupInterval>().ToObservableCollection();
            AllDaysOfWeek      = Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>().ToObservableCollection();

            ImportData               = new Command(DoImportData);
            ExportData               = new Command(DoExportData);
            SelectBackupFolder       = new Command(DoSelectBackupFolder);
            ActivateBackupSchedule   = new Command(DoActivateBackupSchedule);
            DeactivateBackupSchedule = new Command(DoDeactivateBackupScheldule);

            SelectedBackupInterval  = localSettingsRepository.BackupInterval;
            BackupDestinationFolder = localSettingsRepository.BackupDirectory;
            BackupTime        = localSettingsRepository.BackupTime.ToStringMinutesAndHoursOnly();
            SelectedDayOfWeek = localSettingsRepository.BackupWeekDay;
            BackupDay         = localSettingsRepository.BackUpDay.ToString();

            IsActivateButtonVisible    = false;
            IsDeactivateButtonVisible  = localSettingsRepository.BackupInterval != BackupInterval.None;
            IsBackupScheduleChangeable = localSettingsRepository.BackupInterval == BackupInterval.None;
        }
Esempio n. 2
0
        public void Start(ILocalSettingsRepository localSettingsRepository)
        {
            switch (localSettingsRepository.BackupInterval)
            {
            case BackupInterval.Dayly:
            {
                StartDayly(localSettingsRepository.BackupDirectory,
                           localSettingsRepository.BackupTime);
                break;
            }

            case BackupInterval.Weekly:
            {
                StartWeekly(localSettingsRepository.BackupDirectory,
                            localSettingsRepository.BackupTime,
                            localSettingsRepository.BackupWeekDay);
                break;
            }

            case BackupInterval.Monthly:
            {
                StartMonthly(localSettingsRepository.BackupDirectory,
                             localSettingsRepository.BackupTime,
                             localSettingsRepository.BackUpDay);
                break;
            }
            }
        }
Esempio n. 3
0
        public MedicalPracticeSelectorViewModel(ISession session,
                                                IClientMedicalPracticeRepository medicalPracticeRepository,
                                                ILocalSettingsRepository localSettingsRepository,
                                                ISharedState <Guid> selectedMedicalPracticeIdVariable,
                                                ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                                Action <string> errorCallback)
        {
            this.localSettingsRepository           = localSettingsRepository;
            this.selectedMedicalPracticeIdVariable = selectedMedicalPracticeIdVariable;
            this.appointmentModificationsVariable  = appointmentModificationsVariable;

            selectedMedicalPracticeIdVariable.StateChanged += OnSelectedMedicalPracticeIdVariableChanged;
            appointmentModificationsVariable.StateChanged  += OnAppointmentModificationVariableChanged;

            AvailableMedicalPractices = session.LoggedInUser
                                        .ListOfAccessablePractices
                                        .Select(practiceId => new MedicalPracticeDisplayData(practiceId, practiceId.ToString()))
                                        .ToObservableCollection();

            foreach (var medicalPracticeDisplayData in AvailableMedicalPractices)
            {
                medicalPracticeRepository.RequestMedicalPractice(
                    practice =>
                {
                    medicalPracticeDisplayData.PracticeName = practice.Name;
                },
                    medicalPracticeDisplayData.MedicalPracticeId,
                    errorCallback
                    );
            }

            SelectedMedicalPractice = AvailableMedicalPractices.First(practice => practice.MedicalPracticeId == selectedMedicalPracticeIdVariable.Value);

            PracticeIsSelectable = true;
        }
Esempio n. 4
0
        public LoginViewModel(ISession session,
                              ILocalSettingsRepository localSettingsRepository)
        {
            this.session = session;
            this.localSettingsRepository = localSettingsRepository;

            Login = new ParameterrizedCommand <PasswordBox>(DoLogin,
                                                            IsLoginPossible);

            Connect = new Command(DoConnect,
                                  IsConnectPossible);

            DebugConnect = new Command(DoDebugConnect,
                                       IsConnectPossible);

            Disconnect = new Command(DoDisconnect,
                                     IsDisconnectPossible);

            AutoConnectOnNextStart = localSettingsRepository.IsAutoConnectionEnabled;

            AvailableUsers = new ObservableCollection <ClientUserData>();

            ClientIpAddresses = IpAddressCatcher.GetAllAvailableLocalIpAddresses()
                                .Select(address => address.Identifier.ToString())
                                .ToObservableCollection();

            ClientAddress = ClientIpAddresses.First();

            session.ApplicationStateChanged += OnApplicationStateChanged;
            OnApplicationStateChanged(session.CurrentApplicationState);

            AreConnectionSettingsVisible = !AutoConnectOnNextStart;

            if (AutoConnectOnNextStart)
            {
                var clientIpAddress = localSettingsRepository.AutoConnectionClientAddress.ToString();

                if (ClientIpAddresses.Contains(clientIpAddress))
                {
                    ClientAddress = clientIpAddress;
                    ServerAddress = localSettingsRepository.AutoConnectionServerAddress.ToString();
                    Connect.Execute(null);
                }
            }
        }
Esempio n. 5
0
 public MainWindowBuilder(ILocalSettingsRepository localSettingsRepository,
                          IClientPatientRepository patientRepository,
                          IClientMedicalPracticeRepository medicalPracticeRepository,
                          IClientReadModelRepository readModelRepository,
                          IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                          IClientLabelRepository labelRepository,
                          ICommandService commandService,
                          IViewModelCommunication viewModelCommunication,
                          ISession session,
                          Action <string> errorCallback)
 {
     this.localSettingsRepository    = localSettingsRepository;
     this.patientRepository          = patientRepository;
     this.medicalPracticeRepository  = medicalPracticeRepository;
     this.readModelRepository        = readModelRepository;
     this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
     this.labelRepository            = labelRepository;
     this.commandService             = commandService;
     this.viewModelCommunication     = viewModelCommunication;
     this.session       = session;
     this.errorCallback = errorCallback;
 }
 public MainViewModelBuilder(IClientMedicalPracticeRepository medicalPracticeRepository,
                             IClientReadModelRepository readModelRepository,
                             IClientPatientRepository patientRepository,
                             IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                             IClientLabelRepository labelRepository,
                             ICommandService commandService,
                             ILocalSettingsRepository localSettingsRepository,
                             IViewModelCommunication viewModelCommunication,
                             ISession session,
                             AdornerControl adornerControl)
 {
     this.medicalPracticeRepository  = medicalPracticeRepository;
     this.readModelRepository        = readModelRepository;
     this.patientRepository          = patientRepository;
     this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
     this.labelRepository            = labelRepository;
     this.commandService             = commandService;
     this.localSettingsRepository    = localSettingsRepository;
     this.viewModelCommunication     = viewModelCommunication;
     this.session        = session;
     this.adornerControl = adornerControl;
 }
 public LoginViewModelBuilder(ISession session,
                              ILocalSettingsRepository localSettingsRepository)
 {
     this.session = session;
     this.localSettingsRepository = localSettingsRepository;
 }
Esempio n. 8
0
        public void BuildAndStart(StartupEventArgs startupEventArgs)
        {
#if DEBUG
            var listener = new OnkoTePlaDebugListener();

            Debug.Listeners.Add(listener);
#endif

            AssureAppDataDirectoriesExist();

            connectionService = new ConnectionService();
            var eventBus = new ClientEventBus(connectionService);

            var commandHandlerCollection = new SingleHandlerCollection <DomainCommand>();
            var commandMessageBus        = new LocalMessageBus <DomainCommand>(commandHandlerCollection);
            var commandBus = new CommandBus(commandMessageBus);

            var persistenceService = new LocalSettingsXMLPersistenceService(GlobalConstants.LocalSettingsPersistenceFile);

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

            var clientMedicalPracticeRepository  = new ClientMedicalPracticeRepository(connectionService);
            var clientPatientRepository          = new ClientPatientRepository(connectionService);
            var clienttherapyPlaceTypeRepository = new ClientTherapyPlaceTypeRepository(connectionService);
            var clientLabelRepository            = new ClientLabelRepository(connectionService);
            var clientReadmodelRepository        = new ClientReadModelRepository(eventBus, clientPatientRepository, clientMedicalPracticeRepository, clientLabelRepository, connectionService);


            var workFlow = new ClientWorkflow();
            var session  = new Session(connectionService, workFlow);

            var fatalErrorHandler = new FatalErrorHandler(session);

            var commandService = new CommandService(session, clientReadmodelRepository, commandBus);


            var userActionBuilder = new UserActionBuilder(commandService);

            // CommandHandler

            var addAppointmentCommandHandler     = new     AddAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError);
            var deleteAppointmentCommandHandler  = new  DeleteAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError);
            var replaceAppointmentCommandHandler = new ReplaceAppointmentCommandHandler(connectionService, session, clientPatientRepository, clientMedicalPracticeRepository, userActionBuilder, fatalErrorHandler.HandleFatalError);

            commandBus.RegisterCommandHandler(addAppointmentCommandHandler);
            commandBus.RegisterCommandHandler(deleteAppointmentCommandHandler);
            commandBus.RegisterCommandHandler(replaceAppointmentCommandHandler);


            // initiate ViewModelCommunication

            var handlerCollection = new MultiHandlerCollection <ViewModelMessage>();
            IMessageBus <ViewModelMessage> viewModelMessageBus  = new LocalMessageBus <ViewModelMessage>(handlerCollection);
            IViewModelCollectionList       viewModelCollections = new ViewModelCollectionList();

            IViewModelCommunication viewModelCommunication = new ViewModelCommunication(viewModelMessageBus,
                                                                                        viewModelCollections);


            var mainWindowBuilder = new MainWindowBuilder(localSettingsRepository,
                                                          clientPatientRepository,
                                                          clientMedicalPracticeRepository,
                                                          clientReadmodelRepository,
                                                          clienttherapyPlaceTypeRepository,
                                                          clientLabelRepository,
                                                          commandService,
                                                          viewModelCommunication,
                                                          session,
                                                          fatalErrorHandler.HandleFatalError);

            var mainWindow = mainWindowBuilder.BuildWindow();

            mainWindow.Show();

#if DEBUG
            var debugOutputWindowViewModel = new DebugOutputWindowViewModel(listener);

            var debugWindow = new DebugOutputWindow
            {
                Owner       = mainWindow,
                DataContext = debugOutputWindowViewModel
            };

            debugWindow.Show();
#endif
        }
        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
        }