void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MainWindow = ((Erste.SluzbenikMainWindow)(target)); return; case 2: this.image = ((System.Windows.Controls.Image)(target)); return; case 3: this.label = ((System.Windows.Controls.Label)(target)); return; case 4: this.upisButton = ((System.Windows.Controls.Button)(target)); #line 24 "..\..\SluzbenikMainWindow.xaml" this.upisButton.Click += new System.Windows.RoutedEventHandler(this.Upis_Click); #line default #line hidden return; case 5: this.pregledButton = ((System.Windows.Controls.Button)(target)); #line 25 "..\..\SluzbenikMainWindow.xaml" this.pregledButton.Click += new System.Windows.RoutedEventHandler(this.Pregled_Click); #line default #line hidden return; case 6: this.pregledCekanjeButton = ((System.Windows.Controls.Button)(target)); #line 28 "..\..\SluzbenikMainWindow.xaml" this.pregledCekanjeButton.Click += new System.Windows.RoutedEventHandler(this.KandidatiNaCekanju_Click); #line default #line hidden return; case 7: this.grupe = ((System.Windows.Controls.Label)(target)); return; case 8: this.pregledGrupa = ((System.Windows.Controls.Button)(target)); #line 32 "..\..\SluzbenikMainWindow.xaml" this.pregledGrupa.Click += new System.Windows.RoutedEventHandler(this.PregledGrupa_OnClick); #line default #line hidden return; case 9: this.kreiranjeGrupe = ((System.Windows.Controls.Button)(target)); #line 33 "..\..\SluzbenikMainWindow.xaml" this.kreiranjeGrupe.Click += new System.Windows.RoutedEventHandler(this.DodajNovuGrupu_OnClick); #line default #line hidden return; case 10: this.label1 = ((System.Windows.Controls.Label)(target)); return; case 11: this.rasporedButton = ((System.Windows.Controls.Button)(target)); #line 35 "..\..\SluzbenikMainWindow.xaml" this.rasporedButton.Click += new System.Windows.RoutedEventHandler(this.Raspored_Click); #line default #line hidden return; case 12: this.noviTerminButton = ((System.Windows.Controls.Button)(target)); #line 36 "..\..\SluzbenikMainWindow.xaml" this.noviTerminButton.Click += new System.Windows.RoutedEventHandler(this.DodajNoviTermin_Click); #line default #line hidden return; case 13: this.label2 = ((System.Windows.Controls.Label)(target)); return; case 14: this.odjavaButton = ((System.Windows.Controls.Button)(target)); #line 40 "..\..\SluzbenikMainWindow.xaml" this.odjavaButton.Click += new System.Windows.RoutedEventHandler(this.LogOff_Click); #line default #line hidden return; case 15: this.button4 = ((System.Windows.Controls.Button)(target)); #line 41 "..\..\SluzbenikMainWindow.xaml" this.button4.Click += new System.Windows.RoutedEventHandler(this.Exit_Click); #line default #line hidden return; case 16: this.GridZaPrikaz = ((System.Windows.Controls.Grid)(target)); return; } this._contentLoaded = true; }
private async void Prijava_Click(object sender, RoutedEventArgs e) { await Task.Run(async() => { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { usernameBox.IsEnabled = false; passwordBox.IsEnabled = false; NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x6D, 0xCE, 0xF9)); NapomenaBox.Text = "Molimo sačekajte..."; }); } string username = "", password = ""; if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { username = usernameBox.Text; password = passwordBox.Password; }); } if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) { if (string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password)) { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xEF, 0x3D, 0x4A)); usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Text = "Unesite korisničko ime i lozinku."; }); } return; } if (string.IsNullOrEmpty(username)) { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xEF, 0x3D, 0x4A)); usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Text = "Unesite korisničko ime."; }); } return; } else { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xEF, 0x3D, 0x4A)); usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Text = "Unesite lozinku."; }); } return; } } HashGenerator hashGenerator = new HashGenerator(); string hash = hashGenerator.ComputeHash(password); //slanje podataka na server i login using (ErsteModel context = new ErsteModel()) { var administators = await(from a in context.administratori where a.KorisnickoIme.Equals(username) select a) .ToListAsync(); if (administators.Count != 0 && hash.Equals(administators[0].LozinkaHash)) { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Foreground = new SolidColorBrush(Colors.White); NapomenaBox.Background = new SolidColorBrush(Colors.LightGreen); usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Text = "Uspješno ste se prijavili. Sačekajte da se učita novi prozor."; }); } await Task.Delay(1500); if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { AdminMainWindow window = new AdminMainWindow(); window.Show(); Close(); }); } return; } var employees = await(from a in context.sluzbenici where a.KorisnickoIme.Equals(username) select a) .ToListAsync(); if (employees.Count != 0 && hash.Equals(employees[0].LozinkaHash)) { if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Text = "Uspješno ste se prijavili. Sačekajte da se učita novi prozor."; usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Foreground = new SolidColorBrush(Colors.White); NapomenaBox.Background = new SolidColorBrush(Colors.LightGreen); }); } await Task.Delay(1500); if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { SluzbenikMainWindow window = new SluzbenikMainWindow { Owner = null }; window.Show(); Hide(); }); } return; } } if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Visible; NapomenaBox.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xEF, 0x3D, 0x4A)); usernameBox.IsEnabled = true; passwordBox.IsEnabled = true; NapomenaBox.Text = "Nalog sa tim korisničkim imenom i lozinkom ne postoji."; }); } await Task.Delay(5000); }).ContinueWith(async a => { await Task.Delay(5000); if (Dispatcher != null) { await Dispatcher?.InvokeAsync(() => { NapomenaBox.Visibility = Visibility.Collapsed; }); } }); }