Пример #1
0
        /// <summary>
        /// constructeur
        /// </summary>
        public CreateUserSuccessViewModel(Page lkView)
        {
            _linkedView = lkView;

            _loginCommand = new RelayCommand(param => ToFirstLogin(), param => true);

            ServiceUser.User createdUser = NavigationMessenger.GetInstance().TransitCreatedUser;

            _name      = createdUser.Name;
            _firstname = createdUser.Firstname;
            _login     = createdUser.Login;
            _password  = createdUser.Pwd;
            _role      = createdUser.Role;
        }
Пример #2
0
        /// <summary>
        /// La creation de compte va appeller un webservice dans un
        /// BackgroundWorker pour laisser l'UI disponible
        /// </summary>
        private void CreateAccount()
        {
            BackgroundWorker worker = new BackgroundWorker();

            ServiceUser.User newUser = new ServiceUser.User();

            newUser.Name      = _name;
            newUser.Firstname = _firstname;
            newUser.Connected = false;
            newUser.Picture   = _imagebyte;
            newUser.Login     = _login;
            newUser.Pwd       = _password;
            newUser.Role      = _role;

            worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) =>
            {
                ServiceUser.ServiceUserClient serviceUser = new ServiceUser.ServiceUserClient();

                Debug.WriteLine("DEBUT");
                _iscreatingaccount = true;

                BackgroundWorker bg = s as BackgroundWorker;
                e.Result            = serviceUser.AddUser(newUser);
            });

            // TODO penser a mettre un comportement en fonction des differents cas notamment en cas de fail
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) =>
            {
                Debug.WriteLine("FIN");
                _iscreatingaccount = false;
                WaitingMessage     = "";

                if (e.Cancelled)
                {
                    Debug.WriteLine("CANCELLED");
                    WaitingMessage = "L'opération a été annulée.";
                }
                if (e.Error != null)
                {
                    Debug.WriteLine("ERROR");
                    WaitingMessage = "Erreur lors de la création : " + e.Error.Message;
                }
                bool?res = e.Result as bool?;

                if (res == null)
                {
                    Debug.WriteLine("ERREUR COTE SERVEUR");
                    WaitingMessage = "Erreur côté serveur lors de la création. Veuillez recommencer";
                }
                if (res == true)
                {
                    /// Juste avant de creer la page de confirmation il faut
                    /// enregister les informations dans le NavigationMessenger
                    NavigationMessenger.GetInstance().TransitCreatedUser = newUser;
                    WaitingMessage = "Création réussie";

                    View.CreateUserSuccessView window       = new View.CreateUserSuccessView();
                    ViewModel.CreateUserSuccessViewModel vm = new CreateUserSuccessViewModel(window);
                    window.DataContext = vm;

                    _ns = NavigationService.GetNavigationService(_linkedView);
                    _ns.Navigate(window);
                    WaitingMessage = "";
                }
                else
                {
                    Debug.WriteLine("ECHEC DE L'INSCRIPTION");
                    WaitingMessage = "L'inscription a échoué. Veuillez recommencer.";
                }
            });

            worker.RunWorkerAsync();
            WaitingMessage = "Création du compte";
        }
Пример #3
0
        /// <summary>
        /// constructeur
        /// </summary>
        public PatientBrowserViewModel(Page lkView)
        {
            _linkedView = lkView;

            _imageCommand = new RelayCommand(param => ImageAccess(param), param => true);

            _createObservationCommand = new RelayCommand(param => NavigateToCreateObservation(param), param => IsButtonAvailable());
            _addPatientCommand        = new RelayCommand(param => ClickAddPatient(), param => true);
            _navigateToHomeCommand    = new RelayCommand(param => NavigateToHome(), param => true);
            _deletePatientCommand     = new RelayCommand(param => NavigateToDeletePatient(param), param => IsButtonAvailable());

            /// Definit si les bouton de creation/suppression est disponible ou non
            if (NavigationMessenger.GetInstance().IsRWAccount)
            {
                IsAvailableRW = Visibility.Visible;
            }
            else
            {
                IsAvailableRW = Visibility.Hidden;
            }


            _listPatient = new ObservableCollection <ServicePatient.Patient>();

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) =>
            {
                Debug.WriteLine("DEBUT");
                ServicePatient.ServicePatientClient patientService = new ServicePatient.ServicePatientClient();
                e.Result = patientService.GetListPatient();
            });

            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) =>
            {
                Debug.WriteLine("FIN");
                if (e.Cancelled)
                {
                }
                if (e.Error != null)
                {
                }
                if (e.Result == null)
                {
                }
                else
                {
                    ServicePatient.Patient[] res = e.Result as ServicePatient.Patient[];
                    if (res != null)
                    {
                        foreach (ServicePatient.Patient item in res)
                        {
                            _listPatient.Add(item);
                        }
                    }
                    else
                    {
                    }
                }
            });

            worker.RunWorkerAsync();
        }
Пример #4
0
        /// <summary>
        /// le clic de connection au compte
        /// </summary>
        private void ClickConnect()
        {
            /// Le bgw servant a verifier si le compte existe
            BackgroundWorker worker = new BackgroundWorker();

            /// le bgw servant a determiner le role
            BackgroundWorker workerFetchRole = new BackgroundWorker();

            ServiceUser.ServiceUserClient userService = new ServiceUser.ServiceUserClient();

            worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) =>
            {
                _ischecking = true;
                e.Result    = userService.Connect(_login, _password);
            });

            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) =>
            {
                EndWaitingSequence();
                _ischecking = false;
                // TODO voir le CreateUserViewModel pour l'implementation erreur
                if (e.Cancelled)
                {
                    WaitingMessage = "L'opération a été annulée.";
                }
                if (e.Error != null)
                {
                    WaitingMessage = "Erreur lors de l'authentification : " + e.Error.Message;
                }
                bool?res = e.Result as bool?;
                if (res == null)
                {
                    WaitingMessage = "Erreur côté serveur lors de l'authentification. Veuillez recommencer";
                }
                if (res == true)
                {
                    /// Le webservice nous indique que le compte est valide mais on ne connait
                    /// pas encore le role de l'utilisateur On doit donc faire appel a un
                    /// autre webservice
                    workerFetchRole.RunWorkerAsync();

                    View.HomeView window       = new View.HomeView();
                    ViewModel.HomeViewModel vm = new HomeViewModel(window);
                    window.DataContext         = vm;

                    _ns = NavigationService.GetNavigationService(_linkedView);
                    _ns.Navigate(window);
                }
                else
                {
                    Debug.WriteLine("NON ENREGISTRE");
                    WaitingMessage = "Erreur de login ou mot de passe.";
                }
            });

            workerFetchRole.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) =>
            {
                e.Result = userService.GetRole(_login);
            });

            workerFetchRole.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) =>
            {
                if (e.Cancelled)
                {
                    WaitingMessage = "L'opération a été annulée.";
                }
                if (e.Error != null)
                {
                    WaitingMessage = "Erreur lors de l'authentification : " + e.Error.Message;
                }
                string res = e.Result as string;
                if (res == null)
                {
                    WaitingMessage = "Erreur côté serveur lors de l'authentification. Veuillez recommencer";
                }
                if ((res == "Chirurgien") || (res == "Medecin") || (res == "Radiologue"))
                {
                    NavigationMessenger.GetInstance().IsRWAccount = true;
                }
                else
                {
                    NavigationMessenger.GetInstance().IsRWAccount = false;
                }
            });

            worker.RunWorkerAsync();

            BeginWaitingSequence();
        }