private void btnLogin_Click(object sender, RoutedEventArgs e) { try { if (chkActiveDirectory.IsChecked == true) { ADUser = new ActiveDirectoryEmployee(txtUsername.Text, txtPassword.Password); bool isAuthorised = ADUser.AuthenticateUser(); if (isAuthorised == true) { Global.ADUser = ADUser.ADPrincipal; string type = ""; if (ADUser.ADPrincipal.IsAdministrator == true) { type = "Administrator - " + txtUsername.Text; } if (ADUser.ADPrincipal.IsEmployee == true) { type = "Employee - " + txtUsername.Text; } if (ADUser.ADPrincipal.IsTechnician == true) { type = "Technician - " + txtUsername.Text; } Task.Run(() => { SystemLogins systemLogins = new SystemLogins(Guid.NewGuid(), ADUser.ADPrincipal.GUID ?? Guid.NewGuid(), DateTime.UtcNow, type, failedCount); systemLogins.insertLogin(); }).ConfigureAwait(false); NavigationService.NavigateTo(new MainScreen()); } else { // Error Message MessageBox.Show("Incorrect Credentials"); failedCount++; } } else { if (txtUsername.Text.Equals("letmein")) { Global.ADUser = new ActiveDirectoryEmployee("1234", "Marno van Niekerk", "*****@*****.**", true, Guid.NewGuid(), "Marno", "van Niekerk", DateTime.UtcNow, false, false, true); NavigationService.NavigateTo(new MainScreen()); } else { MessageBox.Show("Incorrect Credentials"); failedCount++; } } } catch (Exception exception) { ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance(); error.handle(exception, true); } }
public SystemLoginsWindow() { InitializeComponent(); SystemLogins login = new SystemLogins(); lvSystemLogins.ItemsSource = login.getAllLogings(); }