public bool Authenticate(ExtendedApplicationBase app) { AuthenticationWindow loadingWindow = new AuthenticationWindow(); loadingWindow.Show(); var account = app.Properties[app.PROPERTY_ACCOUNT]; var password = app.Properties[app.PROPERTY_PASSWORD]; if (account == null || password == null) { loadingWindow.Close(); return(false); } if (Authenticate(account.ToString(), password.ToString())) { //1. 获取用户信息 UserWorkRequest request = new UserWorkRequest(); var identity = new Identity(account.ToString(), true); app.Context.User = new Principal(request, identity); Thread.Sleep(5000); loadingWindow.Close(); return(true); } loadingWindow.Close(); return(false); }
private void ShowAuthenticationView() { IView authenticationWindow = null; AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); authenticationWindow = new AuthenticationWindow(viewModel); viewModel.settoClose(authenticationWindow); authenticationWindow.Show(); viewToClose.Close(); }
private void LogOutExecute() { try { AuthenticationWindow aw = new AuthenticationWindow(); man.Close(); aw.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected override void OnStartup(StartupEventArgs e) { CustomPrincipal customPrincipal = new CustomPrincipal(); AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal); base.OnStartup(e); IView authenticationWindow = null; AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); authenticationWindow = new AuthenticationWindow(viewModel); viewModel.settoClose(authenticationWindow); authenticationWindow.Show(); }
public void OpenAuthWindow() { if (AuthenticationWindow == null) { AuthenticationWindow = new AuthenticationWindow(jirnalCore_) { Owner = MainWindow }; AuthenticationWindow.Closed += (sender, args) => AuthenticationWindow = null; AuthenticationWindow.Show(); } AuthenticationWindow.Activate(); }
public void ShowView(object parameter) { if (AdminRights) { AdminViewModel adminViewModel = new AdminViewModel(); IView adminView = new AdminWindow(adminViewModel); adminViewModel.settoClose(adminView); adminView.Show(); toClose.Close(); } else if (DoctorRights) { DoctorViewModel doctorViewModel = new DoctorViewModel(); IView doctorView = new DoctorWindow(doctorViewModel); doctorViewModel.settoClose(doctorView); doctorView.Show(); toClose.Close(); } else if (PatientRights) { PatientViewModel patientViewModel = new PatientViewModel(); IView patientView = new PatientWindow(patientViewModel); patientViewModel.settoClose(patientView); patientView.Show(); toClose.Close(); } else { IView authenticationWindow = null; AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); authenticationWindow = new AuthenticationWindow(viewModel); viewModel.settoClose(authenticationWindow); authenticationWindow.Show(); toClose.Close(); } }
public void Register(object parameter) { ComboBox comboRole = parameter as ComboBox; int role = Int32.Parse(((ComboBoxItem)comboRole.SelectedItem).Tag.ToString()); var context = new MedicalDBEntities(); var users = context.Users; User user = new User(); User user1 = new User(); if (Email != null && Name != null && Surname != null && CNP != null && Password != null && Telephone != null && _validationErrors.Values.Count == 0) { if (this.CheckUser(Email)) { user.email = Email; user.nameUser = Name; user.surnameUser = Surname; user.password = Password; user.telephone = Telephone; user.roleUser = role; user.CNP = CNP; users.Add(user); if (user.roleUser == 2 && SelectedSpecialization != null) { var doctors = context.Doctors; Doctor doctor = new Doctor(); doctor.idSpecialization = SelectedSpecialization.idSpecialization; doctor.idUser = user.idUser; doctors.Add(doctor); } context.SaveChanges(); MessageBox.Show("Contul dumneavoastra a fost inregistrat cu succes"); IView authenticationWindow = null; if (AdminRights) { AdminViewModel adminViewModel = new AdminViewModel(); IView adminView = new AdminWindow(adminViewModel); adminViewModel.settoClose(adminView); adminView.Show(); toClose.Close(); } else { AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); authenticationWindow = new AuthenticationWindow(viewModel); viewModel.settoClose(authenticationWindow); authenticationWindow.Show(); toClose.Close(); } } else { MessageBox.Show("Exista deja un cont cu acest email"); } } else { MessageBox.Show("Va rugăm să introduceți toate datele"); } }