Example #1
0
        private void OnDeviceStatusChanged_Handler(object sender, EventInfo e)
        {
            string station = (string)e.Source;

            if (!string.IsNullOrEmpty(station))
            {
                //DAL_DeviceStatus device = new DAL_DeviceStatus();

                //if (station == EnumStation.ALK)
                //{
                //    JSCallCS._StationColorDevice.SSAColor = device.CheckStatusDevicesStation(station);
                //}
                //if (station == EnumStation.ARK)
                //{
                //    JSCallCS._StationColorDevice.SSKColor = device.CheckStatusDevicesStation(station);
                //}
                //if (station == EnumStation.SSP)
                //{
                //    JSCallCS._StationColorDevice.ESPColor = device.CheckStatusDevicesStation(station);
                //}
                //if (station == EnumStation.SHP)
                //{
                //    JSCallCS._StationColorDevice.UHPColor = device.CheckStatusDevicesStation(station);
                //}
                LogManager.Info("OnDeviceStatusChanged_Handler: " + station);

                LayerWeb.InvokeScript("SetStationColorDevice", JsonConvert.SerializeObject(_jsCallCS.GetStationClolorDevice()));
            }
            else
            {
                LogManager.Info("OnDeviceStatusChanged_Handler: Emty");
            }
        }
Example #2
0
File: Main.cs Project: tuga1975/SSK
        private void Fingerprint_OnFingerprintSucceeded()
        {
            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            _fingerprintFailed = 0;

            Session session = Session.Instance;

            session.IsFingerprintAuthenticated = true;
            LayerWeb.RunScript("$('[status-authentication]').text('');");
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Fingerprint authentication is successful.');");

            Thread.Sleep(1000);

            // if role = 0 (duty officer), redirect to NRIC.html
            // else (supervisee), redirect to Supervisee.html
            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (user.Role == EnumUserRoles.DutyOfficer)
            {
                // navigate to Authentication_NRIC
                NavigateTo(NavigatorEnums.Authentication_NRIC);
            }
            else
            {
                // navigate to Supervisee page

                Trinity.SignalR.Client.Instance.UserLoggedIn(user.UserId);

                NavigateTo(NavigatorEnums.Supervisee);
            }
        }
Example #3
0
        //private void GetCardInfoSucceeded(string cardUID)
        //{
        //    if (_isSmartCardToLogin)
        //    {
        //        // get local user info
        //        DAL_User dAL_User = new DAL_User();
        //        var user = dAL_User.GetUserBySmartCardId(cardUID);

        //        if (user != null)
        //        {
        //            if (user.Role == EnumUserRoles.DutyOfficer)
        //            {
        //                Session session = Session.Instance;
        //                session.IsSmartCardAuthenticated = true;
        //                Session.Instance[CommonConstants.USER_LOGIN] = user;
        //                this.LayerWeb.RunScript("$('.status-text').css('color','#000').text('Your smart card is authenticated.');");
        //                // Stop SCardMonitor
        //                SmartCardReaderUtil.Instance.StopSmartCardMonitor();
        //                // raise succeeded event
        //                SmartCard_OnSmartCardSucceeded();
        //            }
        //            else
        //            {
        //                SmartCard_OnSmartCardFailed("You do not have permission to access this page");
        //            }
        //        }
        //        else
        //        {
        //            // raise failed event
        //            SmartCard_OnSmartCardFailed("Unable to read your smart card");
        //        }
        //    }
        //}

        private void Fingerprint_OnFingerprintSucceeded()
        {
            _fingerprintFailed = 0;
            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            Session session = Session.Instance;

            session.IsFingerprintAuthenticated = true;

            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (user.Role == EnumUserRoles.DutyOfficer)
            {
                LayerWeb.RunScript("$('.status-text').css('color','#000').text('Fingerprint authentication is successful.');");
                //APIUtils.SignalR.GetLatestNotifications();

                Trinity.SignalR.Client.Instance.UserLoggedIn(((Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN]).UserId);
                Thread.Sleep(400);
                NavigateTo(NavigatorEnums.Queue);
            }
            else
            {
                MessageBox.Show("You do not have permission to access this page.");
                //Logout();
                session.IsSmartCardAuthenticated      = false;
                session.IsFingerprintAuthenticated    = false;
                session[CommonConstants.USER_LOGIN]   = null;
                session[CommonConstants.PROFILE_DATA] = null;
                NavigateTo(NavigatorEnums.Authentication_SmartCard);
            }
        }
Example #4
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 + "');");
        }
Example #5
0
        private void SmartCard_OnSmartCardFailed(string errMsg, string notification)
        {
            // increase counter
            _smartCardFailed++;

            // exceeded max failed
            LayerWeb.ShowMessage("Authentication Failed", errMsg);
            if (_smartCardFailed > 3)
            {
                // Send Notification to duty officer
                LayerWeb.ShowMessage("Authentication Failed", "Unable to read your smart card.<br/>Please report to the Duty Officer.");
                Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(null, notification, notification, EnumNotificationTypes.Error);

                // show message box to user
                //MessageBox.Show(message, "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //_popupModel.Title = "Authorization Failed";
                //_popupModel.Message = message;
                //_popupModel.IsShowLoading = false;
                //_popupModel.IsShowOK = true;

                //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel));

                // reset counter
                _smartCardFailed = 0;

                // display failed on UI
                LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');");
                LayerWeb.RunScript("$('[status-authentication]').text('');");
                return;
            }

            // display failed on UI
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');");
            LayerWeb.RunScript("$('[status-authentication]').text('SmartCard Verification Failed : " + _smartCardFailed + "');");
        }
Example #6
0
        private void OnAppDisconnected_Handler(object sender, EventInfo e)
        {
            string station = (string)e.Source;

            //new DAL_DeviceStatus().RemoveDevice(station);

            LayerWeb.InvokeScript("SetStationColorDevice", JsonConvert.SerializeObject(_jsCallCS.GetStationClolorDevice()));
        }
Example #7
0
File: Main.cs Project: tuga1975/SSK
        private void LayerWeb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            LogManager.Debug("WebBrowser Document Completed");
            LayerWeb.InvokeScript("createEvent", JsonConvert.SerializeObject(_jsCallCS.GetType().GetMethods().Where(d => d.IsPublic && !d.IsVirtual && !d.IsSecuritySafeCritical).ToArray().Select(d => d.Name)));
            if (_isFirstTimeLoaded)
            {
                // Start page
                //NavigateTo(NavigatorEnums.Authentication_SmartCard);

                string startFrom = System.Configuration.ConfigurationManager.AppSettings["startFrom"];

                // 50.132
                //string superviseeId = "2FFD1A82-E5EC-4884-A5C6-1A68F661DAED";
                //string dutyOfficerId = "9903e059-7209-45b6-a889-6c4cfdfaeea3";
                // 1.120
                //string superviseeId = "BEA35A8C-097E-41F2-94BE-6EE7228DA696";
                //string dutyOfficerId = "f1748cb4-3bb5-4129-852d-2aba28bb8cec";

                string superviseeId  = System.Configuration.ConfigurationManager.AppSettings["superviseeId"];
                string dutyOfficerId = System.Configuration.ConfigurationManager.AppSettings["dutyOfficerId"];

                Session session = Session.Instance;

                if (startFrom == "Supervisee")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(superviseeId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Supervisee);
                }
                else if (startFrom == "Authentication_Fingerprint")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(superviseeId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Authentication_Fingerprint);
                }
                else if (startFrom == "Authentication_NRIC")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(dutyOfficerId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Authentication_NRIC);
                }
                else
                {
                    NavigateTo(NavigatorEnums.Authentication_SmartCard);
                }
                _isFirstTimeLoaded = false;

                // LayerWeb initiation is compeleted, update application status
                ApplicationStatusManager.Instance.LayerWebInitilizationCompleted();
            }
        }
Example #8
0
        private void checkNotification()
        {
            DbContext.SSKCentralizedEntities sSKCentralizedEntities = new DbContext.SSKCentralizedEntities();
            var unread = sSKCentralizedEntities.Notifications.Where(item => item.Read != true).Select(d => d.Id).Count();

            LayerWeb.Invoke((MethodInvoker)(() =>
            {
                LayerWeb.PushNoti(unread);
            }));
        }
Example #9
0
        private void TimeCheckLogout_EventHandler(object sender, System.Timers.ElapsedEventArgs e)
        {
            long   time  = long.Parse(LayerWeb.InvokeScript("getTimeActionApp").ToString());
            object soure = LayerWeb.InvokeScript("getSoure");

            if (_timeActionApp.HasValue && time - _timeActionApp.Value == 0 && (Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN] != null && soure != null && soure.ToString() == "SuperviseeParticulars.html" && !_isPrintingMUBTT)
            {
                _jsCallCS.LogOut();
            }
            _timeActionApp = time;
        }
Example #10
0
File: Main.cs Project: tuga1975/SSK
        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)
            {
                // set message
                string errorMessage = "Unable to read " + user.Name + "'s fingerprint.";

                // Send Notification to duty officer
                Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Fingerprint Authentication failed", errorMessage, EnumNotificationTypes.Error);

                //NavigateTo(NavigatorEnums.Authentication_SmartCard);
                //LayerWeb.ShowMessage("Authentication failed", "Fingerprint's Authenication failed!<br /> Please contact your officer.");

                //for testing purpose
                // Pause for 1 second and goto Facial Login Screen
                //Thread.Sleep(1000);
                _fingerprintFailed = 0;

                // Navigate to next page: Facial Authentication
                NavigateTo(NavigatorEnums.Authentication_Facial);

                return;
            }

            // display failed on UI
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your finger on the reader');");
            LayerWeb.RunScript("$('[status-authentication]').text('FingerPrint Verification 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.");
            }
        }
Example #11
0
        private void Fingerprint_OnFingerprintFailed()
        {
            // Increase failed counter
            _fingerprintFailed++;

            Trinity.BE.User user = (Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN];

            // exceeded max failed
            if (_fingerprintFailed > 3)
            {
                // set message
                string errorMessage = "Unable to read " + user.Name + "'s fingerprint.";

                // Send Notification to duty officer
                Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Fingerprint Authentication failed", errorMessage, EnumNotificationTypes.Error);

                //Trinity.BE.PopupModel popupModel = new Trinity.BE.PopupModel();
                //popupModel.Title = "Authorization Failed";
                //popupModel.Message = "Unable to read your fingerprint.\nPlease report to the Duty Officer";
                //popupModel.IsShowLoading = false;
                //popupModel.IsShowOK = true;

                //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(popupModel));

                // Reset failed count
                _fingerprintFailed = 0;

                // Navigate to next page: Facial Authentication
                // Facial SDK has a trouble. Bypass temporarily
                NavigateTo(NavigatorEnums.Authentication_Facial);
                //NavigateTo(NavigatorEnums.Authentication_SmartCard);
                return;
            }

            // display failed on UI
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your finger on the reader');");
            LayerWeb.RunScript("$('[status-authentication]').text('FingerPrint Verification 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.");
            }
        }
Example #12
0
File: Main.cs Project: tuga1975/SSK
        private void SmartCard_OnSmartCardSucceeded()
        {
            // Set application status is busy
            ApplicationStatusManager.Instance.IsBusy = true;
            LayerWeb.RunScript("$('[status-authentication]').text('');");
            // Pause for 1 second and goto Fingerprint Login Screen
            Thread.Sleep(1000);

            // navigate to next page: Authentication_Fingerprint
            NavigateTo(NavigatorEnums.Authentication_Fingerprint);

            // Testing purpose
            //NavigateTo(NavigatorEnums.Authentication_Facial);
        }
Example #13
0
 private void EventCenter_OnNewEvent(object sender, EventInfo e)
 {
     if (e.Name == EventNames.LOGIN_SUCCEEDED)
     {
         Trinity.SignalR.Client.Instance.UserLoggedIn(((Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN]).UserId);
         NavigateTo(NavigatorEnums.Queue);
         LayerWeb.InvokeScript("getRealtimeNotificationServer");
     }
     else if (e.Name.Equals(EventNames.LOGIN_FAILED))
     {
         //NavigateTo(NavigatorEnums.Authentication_NRIC);
         MessageBox.Show(e.Message, "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #14
0
        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.");
            }
        }
Example #15
0
        private void Main_OnFacialRecognitionFailed()
        {
            Session session = Session.Instance;

            if (!session.IsFacialAuthenticated)
            {
                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();
                }));

                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
                //MessageBox.Show("Facial authentication failed", "Facial Authentication", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Trinity.BE.PopupModel popupModel = new Trinity.BE.PopupModel();
                popupModel.Title         = "Authorization Failed";
                popupModel.Message       = "Facial Recognition failed.\nPlease report to the Duty Officer";
                popupModel.IsShowLoading = false;
                popupModel.IsShowOK      = true;

                LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(popupModel));

                // navigate to smartcard login page
                NavigateTo(NavigatorEnums.Authentication_SmartCard);

                // reset counter
                _fingerprintFailed = 0;
            }
            try
            {
                StackTrace trace  = new StackTrace();
                int        caller = 1;

                StackFrame frame = trace.GetFrame(caller);

                string callerName = frame.GetMethod().Name;
                LogManager.Debug("Main_OnFacialRecognitionFailed: " + callerName);
            }
            catch (Exception)
            {
            }
        }
Example #16
0
 private void EventCenter_OnNewEvent(object sender, EventInfo e)
 {
     if (e.Name == EventNames.LOGIN_SUCCEEDED)
     {
         NavigateTo(NavigatorEnums.Authentication_NRIC);
     }
     else if (e.Name.Equals(EventNames.LOGIN_FAILED))
     {
         //NavigateTo(NavigatorEnums.Authentication_NRIC);
         //MessageBox.Show(e.Message, "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
         _popupModel.Title         = "Login Failed";
         _popupModel.Message       = e.Message;
         _popupModel.IsShowLoading = false;
         _popupModel.IsShowOK      = true;
         LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel));
     }
 }
Example #17
0
        private void Main_OnFacialRecognitionSucceeded()
        {
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('You have been authenticated.');");
            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();
            }));

            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            Session session = Session.Instance;

            session.IsFacialAuthenticated = true;

            Thread.Sleep(200);

            // if role = 0 (duty officer), redirect to NRIC.html
            // else (supervisee), redirect to Supervisee.html
            Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (currentUser.Role == EnumUserRoles.DutyOfficer)
            {
                // navigate to Authentication_NRIC
                NavigateTo(NavigatorEnums.Authentication_NRIC);
            }
            else if (currentUser.Role.Equals(EnumUserRoles.USA, StringComparison.InvariantCultureIgnoreCase) || currentUser.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase))
            {
                // navigate to SuperviseeParticulars page
                Trinity.SignalR.Client.Instance.UserLoggedIn(currentUser.UserId);
                NavigateTo(NavigatorEnums.Supervisee_Particulars);
            }
            else
            {
                _popupModel.Title         = "Login Failed";
                _popupModel.Message       = "You do not have permission to access this page.";
                _popupModel.IsShowLoading = false;
                _popupModel.IsShowOK      = true;
                LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel));
            }
        }
Example #18
0
        private void Fingerprint_OnFingerprintSucceeded()
        {
            try
            {
                //
                // Login successfully
                //
                // Create a session object to store UserLogin information
                Session session = Session.Instance;
                session.IsFingerprintAuthenticated = true;
                LayerWeb.RunScript("$('[status-authentication]').text('');");
                LayerWeb.RunScript("$('.status-text').css('color','#000').text('Fingerprint authentication is successful.');");

                Thread.Sleep(200);

                // if role = 0 (duty officer), redirect to NRIC.html
                // else (supervisee), redirect to Supervisee.html
                Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                if (currentUser.Role == EnumUserRoles.DutyOfficer)
                {
                    // navigate to Authentication_NRIC
                    NavigateTo(NavigatorEnums.Authentication_NRIC);
                }
                else if (currentUser.Role.Equals(EnumUserRoles.USA, StringComparison.InvariantCultureIgnoreCase) || currentUser.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase))
                {
                    // navigate to SuperviseeParticulars page
                    Trinity.SignalR.Client.Instance.UserLoggedIn(currentUser.UserId);
                    NavigateTo(NavigatorEnums.Supervisee_Particulars);
                }
                else
                {
                    _popupModel.Title         = "Login Failed";
                    _popupModel.Message       = "You do not have permission to access this page.";
                    _popupModel.IsShowLoading = false;
                    _popupModel.IsShowOK      = true;
                    LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Fingerprint_OnFingerprintSucceeded. Details:" + ex.Message);
            }
        }
Example #19
0
        private void LayerWeb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            LogManager.Debug("Document Completed");
            if (_isFirstTimeLoaded)
            {
                LayerWeb.InvokeScript("createEvent", JsonConvert.SerializeObject(_jsCallCS.GetType().GetMethods().Where(d => (d.IsPublic && !d.IsVirtual && !d.IsSecuritySafeCritical) || (d.IsPublic && d.IsSecurityCritical)).ToArray().Select(d => d.Name)));
                NavigateTo(NavigatorEnums.Login);
                _isFirstTimeLoaded = false;
            }

            // For testing purpose
            //Session session = Session.Instance;
            //// Duty Officer
            //Trinity.BE.User user = new DAL_User().GetUserByUserId("dfbb2a6a-9e45-4a76-9f75-af1a7824a947").Data;
            //session[CommonConstants.USER_LOGIN] = user;
            //session.IsSmartCardAuthenticated = true;
            //session.IsFingerprintAuthenticated = true;

            //NavigateTo(NavigatorEnums.Queue);
            //Trinity.SignalR.Client.Instance.UserLoggedIn(((Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN]).UserId);
        }
Example #20
0
File: Main.cs Project: tuga1975/SSK
 private void NRIC_OnNRICSucceeded()
 {
     // navigate to Supervisee page
     Trinity.BE.User currentUser = (Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN];
     Trinity.BE.User supervisee  = currentUser;
     if (currentUser.Role == EnumUserRoles.DutyOfficer)
     {
         supervisee = (Trinity.BE.User)Session.Instance[CommonConstants.SUPERVISEE];
     }
     if (supervisee != null)
     {
         if (supervisee.Status == EnumUserStatuses.Blocked)
         {
             LayerWeb.ShowMessage("This supervisee was blocked");
         }
         else
         {
             Trinity.SignalR.Client.Instance.UserLoggedIn(supervisee.UserId);
             NavigateTo(NavigatorEnums.Supervisee);
         }
     }
 }
Example #21
0
File: Main.cs Project: tuga1975/SSK
        private void Main_OnFacialRecognitionSucceeded()
        {
            _fingerprintFailed = 0;
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('You have been authenticated.');");
            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();
            }));

            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            Session session = Session.Instance;

            session.IsFacialAuthenticated = true;


            Thread.Sleep(1000);

            // if role = 0 (duty officer), redirect to NRIC.html
            // else (supervisee), redirect to Supervisee.html
            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (user.Role == EnumUserRoles.DutyOfficer)
            {
                // navigate to Authentication_NRIC
                NavigateTo(NavigatorEnums.Authentication_NRIC);
            }
            else
            {
                Trinity.SignalR.Client.Instance.UserLoggedIn(user.UserId);
                // navigate to Supervisee page
                NavigateTo(NavigatorEnums.Supervisee);
            }
        }
Example #22
0
File: Main.cs Project: tuga1975/SSK
 private void EventCenter_OnNewEvent(object sender, EventInfo e)
 {
     if (e.Name == EventNames.ALERT_MESSAGE)
     {
         LayerWeb.InvokeScript("alertBookAppointment", e.Message);
     }
     else if (e.Name == EventNames.ABSENCE_LESS_THAN_3)
     {
         LayerWeb.InvokeScript("alertBookAppointment", e.Message);
     }
     else if (e.Name == EventNames.ABSENCE_MORE_THAN_3)
     {
         LayerWeb.InvokeScript("alertBookAppointment", e.Message);
     }
     else if (e.Name == EventNames.LOGIN_SUCCEEDED)
     {
         NavigateTo(NavigatorEnums.Authentication_NRIC);
     }
     else if (e.Name.Equals(EventNames.LOGIN_FAILED))
     {
         LayerWeb.ShowMessage("Login Failed", e.Message);
     }
 }
Example #23
0
File: Main.cs Project: tuga1975/SSK
 private void SmartCard_OnSmartCardFailed(string errMsg, string notification)
 {
     // increase counter
     _smartCardFailed++;
     LayerWeb.ShowMessage("Authentication Failed", errMsg);
     // exceeded max failed
     if (_smartCardFailed > 3)
     {
         // Send Notification to duty officer
         LayerWeb.ShowMessage("Authentication Failed", "Unable to read your smart card.<br/>Please report to the Duty Officer.");
         Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(null, notification, notification, EnumNotificationTypes.Error);
         _smartCardFailed = 0;
         // display failed on UI
         LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');");
         LayerWeb.RunScript("$('[status-authentication]').text('');");
         return;
     }
     else
     {
         // display failed on UI
         LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your smart card on the reader.');");
         LayerWeb.RunScript("$('[status-authentication]').text('SmartCard Verification Failed : " + _smartCardFailed + "');");
     }
 }
Example #24
0
        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);
            }
        }
Example #25
0
 private void Main_OnFacialRecognitionProcessing()
 {
     LayerWeb.RunScript("$('.status-text').css('color','#000').text('Scanning your face...');");
 }
Example #26
0
 private void Fingerprint_OnDeviceDisconnected()
 {
     LayerWeb.RunScript("alert('The fingerprint does not work');");
 }
Example #27
0
File: Main.cs Project: tuga1975/SSK
        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);
            }
        }
Example #28
0
        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);
            }
        }
Example #29
0
        private void LayerWeb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            LayerWeb.InvokeScript("createEvent", JsonConvert.SerializeObject(_jsCallCS.GetType().GetMethods().Where(d => d.IsPublic && !d.IsVirtual && !d.IsSecuritySafeCritical).ToArray().Select(d => d.Name)));

            if (_isFirstTimeLoaded)
            {
                _isFirstTimeLoaded = false;
                // Start page
                //NavigateTo(NavigatorEnums.Authentication_SmartCard);

                string startFrom = System.Configuration.ConfigurationManager.AppSettings["startFrom"];

                // 50.132
                //string superviseeId = "06a91b1b-99c3-428d-8a55-83892c2adf4c";
                //string dutyOfficerId = "f1748cb4-3bb5-4129-852d-2aba28bb8cec";
                // 1.120
                //string superviseeId = "9043d88e-94d1-4c01-982a-02d41965a621";
                //string dutyOfficerId = "f1748cb4-3bb5-4129-852d-2aba28bb8cec";

                string superviseeId  = System.Configuration.ConfigurationManager.AppSettings["superviseeId"];
                string dutyOfficerId = System.Configuration.ConfigurationManager.AppSettings["dutyOfficerId"];

                Session session = Session.Instance;

                if (startFrom == "Supervisee_Particulars")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(superviseeId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Supervisee_Particulars);
                }
                else if (startFrom == "Authentication_Fingerprint")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(superviseeId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Authentication_Fingerprint);
                }
                else if (startFrom == "Authentication_NRIC")
                {
                    Trinity.BE.User user = new DAL_User().GetUserByUserId(dutyOfficerId).Data;
                    session[CommonConstants.USER_LOGIN] = user;
                    session.IsSmartCardAuthenticated    = true;
                    session.IsFingerprintAuthenticated  = true;
                    NavigateTo(NavigatorEnums.Authentication_NRIC);
                }
                else
                {
                    NavigateTo(NavigatorEnums.Authentication_SmartCard);
                }
            }
            // ALK is ready to use - all is well
            // Turn on GREEN Light
            //if (LEDStatusLightingUtil.Instance.IsPortOpen)
            //{
            //    LEDStatusLightingUtil.Instance.TurnOffAllLEDs();
            //    LEDStatusLightingUtil.Instance.SwitchGREENLightOnOff(true);
            //}

            // LayerWeb initiation is compeleted, update application status
            ApplicationStatusManager.Instance.LayerWebInitilizationCompleted();
        }