private void onNext(MonitorEvent ev) { try { sp.isoReaderInit(); if (ev.ToString() == "PCSC.Reactive.Events.CardInserted") { var user = sp.ReadBlock(0x00, BlockId); var pass = sp.ReadBlockRange(0x00, BlockPasswordFrom, BlockPasswordTo); if (cmd.Login(Util.ToASCII(user, 0, user.Length, false), Util.ToASCII(pass, 0, pass.Length, false))) { Dispatcher.Invoke(() => { sh(); }); } else { MessageBox.Show("Staf Pendaftaran tidak terdaftar, hubungi administrator untuk mendaftar.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception) { MessageBox.Show("Pastikan reader sudah terpasang dan kartu sudah berada pada jangkauan reader.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); sp.isoReaderInit(); } }
private void onNext(MonitorEvent ev) { try { if (ev.ToString() == "PCSC.Reactive.Events.CardInserted") { //Debug.WriteLine(ev.ToString()); var user = sp.ReadBlock(0x00, BlockId); var user2 = sp.ReadBlock(0x00, BlockId2); var pass = sp.ReadBlockRange(0x00, BlockPasswordFrom, BlockPasswordTo); var pass2 = sp.ReadBlockRange(0x00, BlockPasswordFrom2, BlockPasswordTo2); //MessageBox.Show(Utils.Util.ToASCII(user2, 0, user.Length, false)); //MessageBox.Show(Utils.Util.ToASCII(pass2, 0, pass2.Length, false)); if (cmd.Login(Util.ToASCII(user, 0, user.Length), Util.ToASCII(pass, 0, pass.Length))) { Settings.Default.role = "admin"; Dispatcher.Invoke(() => { sh(); }); } else { if (cmd.LoginK(Util.ToASCII(user2, 0, user2.Length), Util.ToASCII(pass2, 0, pass2.Length))) { Settings.Default.role = "keuangan"; Dispatcher.Invoke(() => { sh(); }); } else { MessageBox.Show("Admin tidak terdaftar, hubungi administrator untuk mendaftar.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } } catch (Exception ex) { //MessageBox.Show("Pastikan reader sudah terpasang dan kartu sudah berada pada jangkauan reader.", // "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show(ex.Message); sp.isoReaderInit(); } }