private void Main_OnFacialRecognitionFailed() { FacialRecognition.Instance.OnFacialRecognitionFailed -= Main_OnFacialRecognitionFailed; FacialRecognition.Instance.OnFacialRecognitionSucceeded -= Main_OnFacialRecognitionSucceeded; FacialRecognition.Instance.OnFacialRecognitionProcessing -= Main_OnFacialRecognitionProcessing; FacialRecognition.Instance.OnCameraInitialized -= Main_OnCameraInitialized; this.Invoke((MethodInvoker)(() => { FacialRecognition.Instance.Dispose(); })); Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; string errorMessage = "User '" + user.Name + "' cannot complete facial authentication"; Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Facial authentication failed", errorMessage, EnumNotificationTypes.Error); // show message box to user CSCallJS.ShowMessage(LayerWeb, "Facial Authentication", "Facial authentication failed"); //MessageBox.Show("Facial authentication failed", "Facial Authentication", MessageBoxButtons.OK, MessageBoxIcon.Error); // navigate to smartcard login page NavigateTo(NavigatorEnums.Authentication_SmartCard); // reset counter _fingerprintFailed = 0; }
private void SmartCard_OnSmartCardFailed(string message) { // increase counter _smartCardFailed++; // exceeded max failed if (_smartCardFailed > 3) { // Send Notification to duty officer //APIUtils.SignalR.SendNotificationToDutyOfficer(message, message); // show message box to user //MessageBox.Show(message, "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error); CSCallJS.ShowMessage(LayerWeb, "Authentication Failed", message); // reset counter _smartCardFailed = 0; // display failed on UI LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');"); return; } // display failed on UI LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader. Failed: " + _smartCardFailed + "');"); }
public void NRICAuthentication(string nric) { DAL_User dal_User = new DAL_User(); var supervisee = dal_User.GetSuperviseeByNRIC(nric); if (supervisee == null) { CSCallJS.ShowMessage(_web, "NRIC " + nric + " is not registered"); System.Threading.Tasks.Task.Factory.StartNew(() => BarcodeScannerUtil.Instance.StartScanning(BarcodeScannerCallback)); return; } else { if (supervisee.Status == EnumUserStatuses.Blocked) { CSCallJS.ShowMessage(_web, "This supervisee was blocked"); System.Threading.Tasks.Task.Factory.StartNew(() => BarcodeScannerUtil.Instance.StartScanning(BarcodeScannerCallback)); return; } else { // Create a session object to store Supervisee information Session session = Session.Instance; session.IsSmartCardAuthenticated = true; session.IsFingerprintAuthenticated = true; session[CommonConstants.SUPERVISEE] = supervisee; BarcodeScannerUtil.Instance.Disconnect(); // raise succeeded event RaiseNRICSucceededEvent(); //BarcodeScannerUtil.Instance.Disconnect(); } } }
private void JSCallCS_ShowMessage(object sender, ShowMessageEventArgs e) { //MessageBox.Show(e.Message, e.Caption, e.Button, e.Icon); //_popupModel.Title = e.Caption; //_popupModel.Message = e.Message; //_popupModel.IsShowLoading = false; //_popupModel.IsShowOK = true; //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel)); CSCallJS.ShowMessage(LayerWeb, e.Caption, e.Message); }
private void JSCallCS_OnNRICFailed(object sender, NRICEventArgs e) { //MessageBox.Show(e.Message, "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //_popupModel.Title = "Authentication Failed"; //_popupModel.Message = e.Message; //_popupModel.IsShowLoading = false; //_popupModel.IsShowOK = true; //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel)); CSCallJS.ShowMessage(LayerWeb, "Authentication Failed", e.Message); }
public void NRICAuthentication(string nric) { DAL_User dal_User = new DAL_User(); var supervisee = dal_User.GetByNRIC(nric); if (supervisee == null) { CSCallJS.ShowMessage(_web, "NRIC " + nric + " is not registered"); System.Threading.Tasks.Task.Factory.StartNew(() => BarcodeScannerUtil.Instance.StartScanning(BarcodeScannerCallback)); return; } else { string RoleName = supervisee.Membership_UserRoles.FirstOrDefault().Membership_Roles.Name; if (RoleName.Equals(EnumUserRoles.USA, StringComparison.InvariantCultureIgnoreCase) || RoleName.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase) || RoleName.Equals(EnumUserRoles.DutyOfficer, StringComparison.InvariantCultureIgnoreCase)) { if (supervisee.Status.Equals(EnumUserStatuses.Blocked, StringComparison.InvariantCultureIgnoreCase)) { CSCallJS.ShowMessage(_web, "This supervisee was blocked"); System.Threading.Tasks.Task.Factory.StartNew(() => BarcodeScannerUtil.Instance.StartScanning(BarcodeScannerCallback)); return; } // Create a session object to store UserLogin information Session session = Session.Instance; session.IsSmartCardAuthenticated = true; session.IsFingerprintAuthenticated = true; session[CommonConstants.SUPERVISEE] = new Trinity.BE.User() { UserId = supervisee.UserId, Status = supervisee.Status, SmartCardId = supervisee.SmartCardId, RightThumbFingerprint = supervisee.RightThumbFingerprint, LeftThumbFingerprint = supervisee.LeftThumbFingerprint, Name = supervisee.Name, NRIC = supervisee.NRIC, Role = supervisee.Membership_UserRoles.FirstOrDefault().Membership_Roles.Name, IsFirstAttempt = supervisee.IsFirstAttempt }; BarcodeScannerUtil.Instance.Disconnect(); // raise succeeded event RaiseNRICSucceededEvent(); } else { CSCallJS.ShowMessage(_web, "NRIC " + nric + " is not have access."); } } }
private void Fingerprint_OnFingerprintFailed() { // increase counter _fingerprintFailed++; // get USER_LOGIN Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; // exceeded max failed if (_fingerprintFailed > 3) { //string message = "Unable to read your fingerprint. Please report to the Duty Officer"; string message = "Unable to read " + user.Name + "'s fingerprint."; // Send Notification to duty officer //APIUtils.SignalR.SendNotificationToDutyOfficer(message, message); // show message box to user //MessageBox.Show(message, "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error); CSCallJS.ShowMessage(LayerWeb, "Authentication Failed", message); // navigate to smartcard login page NavigateTo(NavigatorEnums.Authentication_Facial); // reset counter _fingerprintFailed = 0; return; } // display failed on UI LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your finger on the reader. Failed: " + _fingerprintFailed + "');"); // restart identification if (user != null) { List <byte[]> fingerprintTemplates = new List <byte[]>() { user.LeftThumbFingerprint, user.RightThumbFingerprint }; FingerprintReaderUtil.Instance.StartIdentification(fingerprintTemplates, Fingerprint_OnIdentificationCompleted); } else { Debug.WriteLine("Fingerprint_OnFingerprintFailed warning: USER_LOGIN is null, can not restart identification."); } }
public void BarcodeScannerCallback(string value, string error) { //MessageBox.Show("BarcodeScannerCallback"); if (string.IsNullOrEmpty(error)) { // Fill value to the textbox CSCallJS.InvokeScript(_web, "updateNRICTextValue", value.Trim()); // Execute authentication NRICAuthentication(value.Trim()); } else { LogManager.Error("BarcodeScannerCallback ERROR: " + error); //CSCallJS.ShowMessageAsync(_web, "BarcodeScanner ERROR", error); } }
/// <summary> /// Fingerprint_OnDeviceDisconnected /// </summary> /// private void Fingerprint_OnDeviceDisconnected() { // set message string message = "The fingerprint reader is not connected. Please report to the Duty Officer!"; // Send Notification to duty officer Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(null, "The fingerprint reader is not connected.", "The fingerprint reader is not connected.", EnumNotificationTypes.Error); // show message box to user CSCallJS.ShowMessage(LayerWeb, "Authentication Failed", message); //MessageBox.Show(message, "Authentication failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); // navigate to smartcard login page //NavigateTo(NavigatorEnums.Authentication_SmartCard); NavigateTo(NavigatorEnums.Authentication_Facial); }
private void BarcodeScannerCallback(string value, string error) { try { LogManager.Debug("BarcodeScannerCallback value: " + value + ", error: " + error); if (string.IsNullOrEmpty(error)) { // Fill value to the textbox //CSCallJS.ShowMessage(_web, value); CSCallJS.InvokeScript(_web, "updateLoginNRICTextValue", value.Trim()); //CSCallJS.UpdateLoginNRICTextValue(_web, value); } else { LogManager.Error("BarcodeScannerCallback ERROR: " + error); //CSCallJS.ShowMessageAsync(_web, "Manual Login ERROR", error); } } finally { LogManager.Debug("BarcodeScannerCallback Disconnect"); BarcodeScannerUtil.Instance.Disconnect(); } }
private void NavigateTo(NavigatorEnums navigatorEnum) { // navigate if (navigatorEnum == NavigatorEnums.Login) { LayerWeb.LoadPageHtml("Login.html"); } else if (navigatorEnum == NavigatorEnums.Authentication_SmartCard) { _fingerprintFailed = 0; _smartCardFailed = 0; _isSmartCardToLogin = true; LayerWeb.LoadPageHtml("Authentication/SmartCard.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');"); SmartCard.Instance.Start(); } else if (navigatorEnum == NavigatorEnums.Authentication_Fingerprint) { try { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; LayerWeb.LoadPageHtml("Authentication/FingerPrint.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your finger on the reader.');"); Fingerprint.Instance.Start(new System.Collections.Generic.List <byte[]>() { user.LeftThumbFingerprint, user.RightThumbFingerprint }); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine("File missing:\n"); Console.WriteLine(ex.FileName); } } else if (navigatorEnum == NavigatorEnums.Authentication_Facial) { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; LayerWeb.LoadPageHtml("Authentication/FacialRecognition.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please remain still as Facial Recognition Check takes place.');"); FacialRecognition.Instance.OnFacialRecognitionFailed += Main_OnFacialRecognitionFailed; FacialRecognition.Instance.OnFacialRecognitionSucceeded += Main_OnFacialRecognitionSucceeded; FacialRecognition.Instance.OnFacialRecognitionProcessing += Main_OnFacialRecognitionProcessing; if (user.User_Photo1 == null || user.User_Photo1.Length == 0) { MessageBox.Show("User photo is null"); return; } this.Invoke((MethodInvoker)(() => { Point startLocation = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - 800 / 2, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - 450 / 2); FacialRecognition.Instance.StartFacialRecognition(startLocation, new System.Collections.Generic.List <byte[]>() { user.User_Photo1, user.User_Photo2 }); })); } else if (navigatorEnum == NavigatorEnums.Queue) { _isSmartCardToLogin = false; LayerWeb.LoadPageHtml("Queue.html"); } // set current page _currentPage = navigatorEnum; // display options in Authentication_SmartCard page if (_currentPage == NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = false; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } // display options in the rest if (!_displayLoginButtonStatus && _currentPage != NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = true; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } }
private void _NavigateToFormThread(object pram) { NavigatorEnums navigatorEnum = (NavigatorEnums)pram; // navigate if (navigatorEnum == NavigatorEnums.Authentication_SmartCard) { LayerWeb.LoadPageHtml("Authentication/SmartCard.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');"); SmartCard.Instance.Start(); } else if (navigatorEnum == NavigatorEnums.Authentication_Fingerprint) { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; LayerWeb.LoadPageHtml("Authentication/FingerPrint.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your thumb print on the reader.');"); //if (user.LeftThumbFingerprint == null && user.RightThumbFingerprint == null) //{ // LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your thumb print on the reader.');"); //} //else //{ // string errMsg = user.Name + "'s Fingerprint could not be found."; // LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + errMsg + "');"); //} try { Fingerprint.Instance.Start(new System.Collections.Generic.List <byte[]>() { user.LeftThumbFingerprint, user.RightThumbFingerprint }); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (navigatorEnum == NavigatorEnums.Authentication_Facial) { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; if ((user.User_Photo1 == null || user.User_Photo1.Length == 0) && (user.User_Photo2 == null || user.User_Photo2.Length == 0)) { Trinity.BE.PopupModel popupModel = new Trinity.BE.PopupModel(); popupModel.Title = "Authorization Failed"; popupModel.Message = "User '" + user.Name + "' doesn't have any photos"; popupModel.IsShowLoading = false; popupModel.IsShowOK = true; LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(popupModel)); // navigate to smartcard login page NavigateTo(NavigatorEnums.Authentication_SmartCard); return; } LayerWeb.LoadPageHtml("Authentication/FacialRecognition.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please remain still as Facial Recognition Check takes place.');"); FacialRecognition.Instance.OnFacialRecognitionFailed += Main_OnFacialRecognitionFailed; FacialRecognition.Instance.OnFacialRecognitionSucceeded += Main_OnFacialRecognitionSucceeded; FacialRecognition.Instance.OnFacialRecognitionProcessing += Main_OnFacialRecognitionProcessing; FacialRecognition.Instance.OnCameraInitialized += Main_OnCameraInitialized; this.Invoke((MethodInvoker)(() => { Point startLocation = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - 800 / 2, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - 450 / 2); //Point startLocation = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - 400 / 2, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - 400 / 2); try { FacialRecognition.Instance.StartFacialRecognition(startLocation, new System.Collections.Generic.List <byte[]>() { user.User_Photo1, user.User_Photo2 }); } catch (Exception ex) { MessageBox.Show(ex.Message); } })); } else if (navigatorEnum == NavigatorEnums.Authentication_NRIC) { _nric.Start(); } else if (navigatorEnum == NavigatorEnums.Supervisee_Particulars) { _superviseeParticulars.Start(); //btnConfirm.Enabled = true; } else if (navigatorEnum == NavigatorEnums.Supervisee_NRIC) { _superviseeParticulars.Start(); CSCallJS.DisplayNRICLogin(LayerWeb); } // set current page _currentPage = navigatorEnum; // display options in Authentication_SmartCard page if (_displayLoginButtonStatus && _currentPage == NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = false; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } // display options in the rest if (!_displayLoginButtonStatus && _currentPage != NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = true; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } }
public void NavigateTo(NavigatorEnums navigatorEnum) { // navigate if (navigatorEnum == NavigatorEnums.Authentication_SmartCard) { LayerWeb.LoadPageHtml("Authentication/SmartCard.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_PLACE_SMARTCARD + "');"); SmartCardReaderUtil.Instance.StopSmartCardMonitor(); SmartCard.Instance.Start(); } else if (navigatorEnum == NavigatorEnums.Authentication_Fingerprint) { try { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; LayerWeb.LoadPageHtml("Authentication/FingerPrint.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_PLACE_THUMBPRINT + "');"); Fingerprint.Instance.Start(new System.Collections.Generic.List <byte[]>() { user.LeftThumbFingerprint, user.RightThumbFingerprint }); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine("File missing:\n"); Console.WriteLine(ex.FileName); } } else if (navigatorEnum == NavigatorEnums.Authentication_Facial) { Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; if ((user.User_Photo1 == null || user.User_Photo1.Length == 0) && (user.User_Photo2 == null || user.User_Photo2.Length == 0)) { //Trinity.BE.PopupModel popupModel = new Trinity.BE.PopupModel(); //popupModel.Title = "Authorization Failed"; //popupModel.Message = "User '" + user.Name + "' doesn't have any photos"; //popupModel.IsShowLoading = false; //popupModel.IsShowOK = true; //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(popupModel)); // Navigate to smartcard login page NavigateTo(NavigatorEnums.Authentication_SmartCard); return; } LayerWeb.LoadPageHtml("Authentication/FacialRecognition.html"); LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_REMAIN_YOUR_FACE_STILL + "');"); FacialRecognition.Instance.OnFacialRecognitionFailed += Main_OnFacialRecognitionFailed; FacialRecognition.Instance.OnFacialRecognitionSucceeded += Main_OnFacialRecognitionSucceeded; FacialRecognition.Instance.OnFacialRecognitionProcessing += Main_OnFacialRecognitionProcessing; FacialRecognition.Instance.OnCameraInitialized += Main_OnCameraInitialized; List <byte[]> FaceJpg = new System.Collections.Generic.List <byte[]>() { user.User_Photo1, user.User_Photo2 }; this.Invoke((MethodInvoker)(() => { Point startLocation = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - 800 / 2, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - 450 / 2); FacialRecognition.Instance.StartFacialRecognition(startLocation, FaceJpg); //LayerWeb.RunScript("$('.status-text').css('color','#000').text('Face authentication');"); })); } else if (navigatorEnum == NavigatorEnums.Authentication_NRIC) { _nric.Start(); } else if (navigatorEnum == NavigatorEnums.Supervisee) { // Handle income notifications Session session = Session.Instance; Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; if (user.Role == EnumUserRoles.Supervisee && user.Status == EnumUserStatuses.Blocked) { LayerWeb.ShowMessageAsync(Resources.INFO_YOU_HAVE_BEEN_BLOCKED); _jsCallCS.LogOut(); return; } _signalrClient = Client.Instance; _signalrClient.OnNewNotification += _signalrClient_OnNewNotification; if (this._timerCheckLogout != null) { if (this._timerCheckLogout.Enabled) { this._timerCheckLogout.Stop(); } this._timerCheckLogout.Start(); } _supervisee.Start(); } // set current page _currentPage = navigatorEnum; // display options in Authentication_SmartCard page if (_displayLoginButtonStatus && _currentPage == NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = false; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } // display options in the rest if (!_displayLoginButtonStatus && _currentPage != NavigatorEnums.Authentication_SmartCard) { _displayLoginButtonStatus = true; CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus); } }
private void OnShowMessage(object sender, ShowMessageEventArgs e) { //MessageBox.Show(e.Message, e.Caption, e.Button, e.Icon); CSCallJS.ShowMessage(LayerWeb, e.Caption, e.Message); }
private void JSCallCS_OnNRICFailed(object sender, NRICEventArgs e) { //MessageBox.Show(e.Message, "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //LayerWeb.ShowMessage("Authentication failed", e.Message); CSCallJS.ShowMessage(LayerWeb, "Authentication Failed", e.Message); }