Esempio n. 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");
            }
        }
Esempio n. 2
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()));
        }
Esempio n. 3
0
File: Main.cs Progetto: 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();
            }
        }
Esempio n. 4
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;
        }
Esempio n. 5
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);
     }
 }
Esempio n. 6
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)
            {
            }
        }
Esempio n. 7
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));
     }
 }
Esempio n. 8
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));
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
File: Main.cs Progetto: 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);
     }
 }
Esempio n. 12
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);
            }
        }
Esempio n. 13
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();
        }