コード例 #1
0
        private async void DoConnect()
        {
            if (AddressIdentifier.IsIpAddressIdentifier(ServerAddress))
            {
                session.TryConnect(new Address(Protocol, AddressIdentifier.GetIpAddressIdentifierFromString(ServerAddress)),
                                   new Address(Protocol, AddressIdentifier.GetIpAddressIdentifierFromString(ClientAddress)),
                                   errorMessage =>
                {
                    Application.Current.Dispatcher.Invoke(async() =>
                    {
                        var dialog = new UserDialogBox(
                            "",
                            $"Es kann keine Verbindung mit {ServerAddress} hergestellt werden",
                            MessageBoxButton.OK
                            );
                        await dialog.ShowMahAppsDialog();
                    });
                });
            }
            else
            {
                var dialog = new UserDialogBox("", $"{ServerAddress} ist keine gültige Ip-Adresse",
                                               MessageBoxButton.OK);
                await dialog.ShowMahAppsDialog();
            }

            SetAutoConnectToSettings();
        }
コード例 #2
0
        private async void DoSaveChanges()
        {
            if (!Date.IsValidDateString(PatientBirthday))
            {
                var dialog = new UserDialogBox("Error",
                                               $"{PatientBirthday} ist kein gültiges Datum.\nFormat: dd.mm.yyyy",
                                               MessageBoxButton.OK);

                await dialog.ShowMahAppsDialog();

                return;
            }

            if (string.IsNullOrWhiteSpace(PatientName))
            {
                var dialog = new UserDialogBox("Error",
                                               "Der Patientenname darf nicht leer bleiben",
                                               MessageBoxButton.OK);

                await dialog.ShowMahAppsDialog();

                return;
            }

            patientRepository.UpdatePatient(selectedPatientVariable.Value.Id,
                                            PatientName,
                                            PatientExternalId,
                                            Date.Parse(PatientBirthday),
                                            IsPatientAlive,
                                            IsPatientHidden);
            selectedPatientVariable.Value = null;
        }
コード例 #3
0
        private async void DoDeleteMedicalPractice()
        {
            var dialog = new UserDialogBox("",
                                           $"Praxis [{SelectedMedicalPractice.Name}] wirklich löschen?",
                                           MessageBoxButton.OKCancel);

            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                var practiceToDelete = SelectedMedicalPracticeObject;

                dataCenter.RemoveMedicalPractice(practiceToDelete);
                MedicalPractices.Remove(SelectedMedicalPractice);

                foreach (var user in dataCenter.GetAllUsers())
                {
                    if (user.ListOfAccessableMedicalPractices.Contains(practiceToDelete.Id))
                    {
                        var updatedUser = user.UpdateListOfAccessableMedicalPractices(
                            user.ListOfAccessableMedicalPractices.Where(medPracId => medPracId != practiceToDelete.Id)
                            .ToList()
                            );
                        dataCenter.UpdateUser(updatedUser);
                    }
                }

                SelectedMedicalPractice = null;
            }
        }
コード例 #4
0
        private async void DoRejectChanges()
        {
            var dialog = new UserDialogBox("", "Änderungen verwerfen?", MessageBoxButton.OKCancel);
            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                SelectedMedicalPractice = null;
            }
        }
コード例 #5
0
        public static async void ShowCharacterError(string name)
        {
            var dialog = new UserDialogBox("Error",
                                           $"Der Name \"{name}\" enthält unzulässige zeichen!\n" +
                                           "Die Operation wurde abgebrochen\n\n" +
                                           "Unzulässige Zeichen sind: | ; , : . # ( [ { } ] )",
                                           MessageBoxButton.OK);

            await dialog.ShowMahAppsDialog();
        }
コード例 #6
0
        private async void DoConfirmChanges()
        {
            if (AreFieldsValid())
            {
                var currentMedicalPractice = dataCenter.GetMedicalPractice(SelectedMedicalPractice.Id);
                var updatedMedicalPractice = currentMedicalPractice.SetNewHoursOfOpening(EvaluateFields());
                dataCenter.UpdateMedicalPractice(updatedMedicalPractice);

                SelectedMedicalPractice = null;
            }
            else
            {
                var dialog = new UserDialogBox("", "Felder nicht korrekt ausgefüllt!", MessageBoxButton.OK);
                await dialog.ShowMahAppsDialog();
            }
        }
コード例 #7
0
 private void DoDisconnect()
 {
     session.TryDisconnect(
         null,
         errorMessage =>
     {
         Application.Current.Dispatcher.Invoke(async() =>
         {
             var dialog = new UserDialogBox("",
                                            "Die Trennung der Verbindung konnte nicht ordnungsgemäß durchgeführt werden\n" +
                                            $">> {errorMessage} <<",
                                            MessageBoxButton.OK);
             await dialog.ShowMahAppsDialog();
         });
     }
         );
 }
コード例 #8
0
 private void DoLogOut()
 {
     session.Logout(
         () => { },
         errorMessage =>
     {
         Application.Current.Dispatcher.Invoke(async() =>
         {
             var dialog = new UserDialogBox("",
                                            "Logout nicht erfolgreich:\n" +
                                            $">> {errorMessage} <<",
                                            MessageBoxButton.OK);
             await dialog.ShowMahAppsDialog();
         });
     }
         );
 }
コード例 #9
0
        private async void UndoAction()
        {
            switch (currentButtonMode)
            {
            case ButtonMode.EditsAvailable:
            {
                currentAppointmentModifications.Undo();
                break;
            }

            case ButtonMode.StartOfEditMode:
            {
                viewModelCommunication.Send(new RejectChanges());
                break;
            }

            case ButtonMode.ViewMode:
            {
                var dialog = new UserDialogBox("",
                                               session.GetCurrentUndoActionMsg(),
                                               MessageBoxButton.OKCancel);

                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    session.Undo(
                        operationSuccessful =>
                        {
                            if (!operationSuccessful)
                            {
                                Application.Current.Dispatcher.Invoke(() =>
                                {
                                    viewModelCommunication.Send(new ShowNotification($"undo nicht möglich: eventhistory wird zurückgesetzt", 5));
                                    session.ResetUndoRedoHistory();
                                });
                            }
                        },
                        errorCallback
                        );
                }
                break;
            }
            }
        }
コード例 #10
0
        private async void DoDeleteRoom()
        {
            var dialog = new UserDialogBox("",
                                           $"Raum [{SelectedRoom.Name}] wirklich löschen?",
                                           MessageBoxButton.OKCancel);

            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                var roomToDelete = SelectedRoomObject;

                var updatedPractice = SelectedMedicalPracticeObject.RemoveRoom(roomToDelete.Id);
                UpdateMedicalPractice(updatedPractice);
                Rooms.Remove(SelectedRoom);

                SelectedRoom = null;
            }
        }
コード例 #11
0
        private async void DoDeleteTherapyPlace()
        {
            var dialog = new UserDialogBox("",
                                           $"Therapyplatz [{SelectedTherapyPlace.Name}] wirklich löschen?",
                                           MessageBoxButton.OKCancel);

            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                var therapyPlaceToDelete = SelectedTherapyPlace;

                var updatedRoom = SelectedRoomObject.RemoveTherapyPlace(therapyPlaceToDelete.PlaceId);
                UpdateRoom(updatedRoom);
                TherapyPlaces.Remove(SelectedTherapyPlace);

                SelectedTherapyPlace = null;
            }
        }
コード例 #12
0
        private void DoLogin(PasswordBox passwordBox)
        {
            localSettingsRepository.LastLoggedInUserId = selectedUser.Id;

            session.TryLogin(
                selectedUser,
                passwordBox.Password,
                errorMessage =>
            {
                Application.Current.Dispatcher.Invoke(async() =>
                {
                    var dialog = new UserDialogBox("",
                                                   $"Login nicht möglich:\n>> {errorMessage} <<",
                                                   MessageBoxButton.OK);
                    await dialog.ShowMahAppsDialog();
                });
            });

            passwordBox.Password = "";
        }
コード例 #13
0
        private async void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            var viewModel = DataContext as IMainWindowViewModel;

            if (viewModel.CheckWindowClosing)
            {
                e.Cancel = true;
            }

            if (viewModel.CheckWindowClosing)
            {
                var dialog = new UserDialogBox("Programm beenden.", "Wollen Sie das Programm wirklich beenden?",
                                               MessageBoxButton.OKCancel);

                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    viewModel.CloseWindow.Execute(null);
                }
            }
        }
コード例 #14
0
        private async void DoDeleteAppointment(DisplayAppointmentData appointment)
        {
            var dialog = new UserDialogBox("", "Wollen Sie den Termin wirklich löschen?",
                                           MessageBoxButton.OKCancel);
            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                medicalPracticeRepository.RequestPraticeVersion(
                    practiceVersion =>
                {
                    commandService.TryDeleteAppointment(
                        operationSuccessful =>
                    {
                        if (!operationSuccessful)
                        {
                            viewModelCommunication.Send(new ShowNotification("Termin kann nicht gelöscht werden", 5));
                        }
                    },
                        new AggregateIdentifier(appointment.Day,
                                                appointment.AppointmentRawData.MedicalPracticeId,
                                                practiceVersion),
                        appointment.AppointmentRawData.PatientId,
                        appointment.AppointmentRawData.Id,
                        appointment.Description,
                        appointment.AppointmentRawData.StartTime,
                        appointment.AppointmentRawData.EndTime,
                        appointment.AppointmentRawData.TherapyPlaceId,
                        appointment.AppointmentRawData.LabelId,
                        ActionTag.RegularAction,
                        errorCallBack);
                },
                    appointment.AppointmentRawData.MedicalPracticeId,
                    appointment.Day,
                    errorCallBack
                    );
            }
        }
コード例 #15
0
        private async void ProcessMesageAsync()
        {
            var currentMods = appointmentModificationsVariable.Value;
            var original    = appointmentModificationsVariable.Value.OriginalAppointment;

            if (currentMods.BeginTime == original.StartTime &&
                currentMods.EndTime == original.EndTime &&
                currentMods.Description == original.Description &&
                currentMods.CurrentLocation == currentMods.InitialLocation)
            {
                RejectChanges();
            }
            else
            {
                var dialog = new UserDialogBox("", "Wollen Sie alle Änderungen verwerfen?",
                                               MessageBoxButton.OKCancel);
                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    RejectChanges();
                }
            }
        }
コード例 #16
0
        public AppointmentViewModel(Appointment appointment,
                                    ICommandService commandService,
                                    IViewModelCommunication viewModelCommunication,
                                    TherapyPlaceRowIdentifier initialLocalisation,
                                    ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                    ISharedState <Date> selectedDateVariable,
                                    IAppointmentModificationsBuilder appointmentModificationsBuilder,
                                    IWindowBuilder <EditDescription> editDescriptionWindowBuilder,
                                    AdornerControl adornerControl,
                                    Action <string> errorCallback)
        {
            this.appointment         = appointment;
            this.initialLocalisation = initialLocalisation;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.selectedDateVariable             = selectedDateVariable;
            ViewModelCommunication = viewModelCommunication;
            AdornerControl         = adornerControl;

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

            SwitchToEditMode = new ParameterrizedCommand <bool>(
                isInitalAdjusting =>
            {
                if (appointmentModificationsVariable.Value == null)
                {
                    CurrentAppointmentModifications = appointmentModificationsBuilder.Build(appointment,
                                                                                            initialLocalisation.PlaceAndDate.MedicalPracticeId,
                                                                                            isInitalAdjusting,
                                                                                            errorCallback);

                    CurrentAppointmentModifications.PropertyChanged += OnAppointmentModificationsPropertyChanged;
                    appointmentModificationsVariable.Value           = CurrentAppointmentModifications;
                    OperatingMode = OperatingMode.Edit;
                    appointmentModificationsVariable.StateChanged += OnCurrentModifiedAppointmentChanged;
                }
            }
                );

            DeleteAppointment = new Command(
                async() =>
            {
                var dialog = new UserDialogBox("", "Wollen Sie den Termin wirklich löschen?",
                                               MessageBoxButton.OKCancel);
                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    if (appointmentModificationsVariable.Value.IsInitialAdjustment)
                    {
                        viewModelCommunication.SendTo(                                                                                  //
                            Constants.ViewModelCollections.AppointmentViewModelCollection,                                              // do nothing but
                            appointmentModificationsVariable.Value.OriginalAppointment.Id,                                              // deleting the temporarly
                            new Dispose()                                                                                               // created Appointment
                            );                                                                                                          //
                    }
                    else
                    {
                        commandService.TryDeleteAppointment(
                            operationSuccessful =>
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                if (!operationSuccessful)
                                {
                                    Process(new RestoreOriginalValues());
                                    viewModelCommunication.Send(new ShowNotification("löschen des Termins fehlgeschlagen; bearbeitung wurde zurückgesetzt", 5));
                                }
                            });
                        },
                            currentLocation.PlaceAndDate,
                            appointment.Patient.Id,
                            appointment.Id,
                            appointment.Description,
                            appointment.StartTime,
                            appointment.EndTime,
                            appointment.TherapyPlace.Id,
                            appointment.Label.Id,
                            ActionTag.RegularAction,
                            errorCallback
                            );
                    }

                    appointmentModificationsVariable.Value = null;
                }
            }
                );

            EditDescription = new Command(
                () =>
            {
                viewModelCommunication.Send(new ShowDisabledOverlay());

                var dialog = editDescriptionWindowBuilder.BuildWindow();
                dialog.ShowDialog();

                viewModelCommunication.Send(new HideDisabledOverlay());
            }
                );

            ConfirmChanges = new Command(() => viewModelCommunication.Send(new ConfirmChanges()));
            RejectChanges  = new Command(() => viewModelCommunication.Send(new RejectChanges()));

            BeginTime   = appointment.StartTime;
            EndTime     = appointment.EndTime;
            Description = appointment.Description;
            LabelColor  = appointment.Label.Color;

            ShowDisabledOverlay = false;

            SetNewLocation(initialLocalisation, true);
        }
コード例 #17
0
        private void OnApplicationStateChanged(ApplicationState applicationState)
        {
            if (applicationState == ApplicationState.DisconnectedFromServer)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    AvailableUsers.Clear();
                    AreConnectionSettingsVisible = true;
                    SelectedUser        = null;
                    IsUserListAvailable = false;
                });
            }

            if (applicationState == ApplicationState.ConnectedButNotLoggedIn)
            {
                AreConnectionSettingsVisible = false;

                session.RequestUserList(
                    userList =>
                {
                    Application.Current.Dispatcher.Invoke(async() =>
                    {
                        AvailableUsers.Clear();
                        userList.Do(userData => AvailableUsers.Add(userData));
                        IsUserListAvailable = true;

                        if (AvailableUsers.Count > 0)
                        {
                            SelectedUser = AvailableUsers.Any(user => user.Id == localSettingsRepository.LastLoggedInUserId)
                                                                                                        ? AvailableUsers.First(user => user.Id == localSettingsRepository.LastLoggedInUserId)
                                                                                                        : AvailableUsers.First();
                        }
                        else
                        {
                            var dialog = new UserDialogBox("",
                                                           "Es sind keine verfügbaren User vorhanden\n" +
                                                           "Die Verbindung wird getrennt!",
                                                           MessageBoxButton.OK);
                            await dialog.ShowMahAppsDialog();
                            Disconnect.Execute(null);
                        }
                    });
                },
                    errorMessage =>
                {
                    Application.Current.Dispatcher.Invoke(async() =>
                    {
                        var dialog = new UserDialogBox("",
                                                       "Die Userliste kann nicht vom Server abgefragt werden:\n" +
                                                       $">> {errorMessage} <<\n" +
                                                       "Die Verbindung wird getrennt - versuchen Sie es erneut",
                                                       MessageBoxButton.OK);
                        await dialog.ShowMahAppsDialog();
                        Disconnect.Execute(null);
                    });
                }
                    );
            }


            Application.Current.Dispatcher.Invoke(() =>
            {
                ((ParameterrizedCommand <PasswordBox>)Login).RaiseCanExecuteChanged();
                ((Command)Connect).RaiseCanExecuteChanged();
                ((Command)DebugConnect).RaiseCanExecuteChanged();
                ((Command)Disconnect).RaiseCanExecuteChanged();
            });
        }