예제 #1
0
        public Main()
        {
            InitializeComponent();

            // Check if another instance of ALK is running
            if (CommonUtil.CheckIfAnotherInstanceIsRunning("ALK"))
            {
                MessageBox.Show("An instance of ALK is already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
            APIUtils.Start();
            //Notification
            Trinity.SignalR.Client signalrClient = Trinity.SignalR.Client.Instance;
            // setup variables
            _smartCardFailed          = 0;
            _fingerprintFailed        = 0;
            _displayLoginButtonStatus = false;
            _popupModel = new Trinity.BE.PopupModel();

            #region Initialize and register events
            double _sessionTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["session_timeout"]);
            if (_sessionTimeout > 0)
            {
                this._timerCheckLogout           = new System.Timers.Timer();
                this._timerCheckLogout.AutoReset = true;
                this._timerCheckLogout.Interval  = _sessionTimeout * 1000;
                this._timerCheckLogout.Elapsed  += TimeCheckLogout_EventHandler;
            }
            // _jsCallCS
            _jsCallCS = new JSCallCS(this.LayerWeb, this);
            _jsCallCS.OnNRICFailed      += JSCallCS_OnNRICFailed;
            _jsCallCS.OnShowMessage     += JSCallCS_ShowMessage;
            _jsCallCS.OnLogOutCompleted += JSCallCS_OnLogOutCompleted;

            // SmartCard
            SmartCard.Instance.GetCardInfoSucceeded += GetCardInfoSucceeded;
            // Fingerprint
            Fingerprint.Instance.OnIdentificationCompleted += Fingerprint_OnIdentificationCompleted;
            Fingerprint.Instance.OnDeviceDisconnected      += Fingerprint_OnDeviceDisconnected;

            // NRIC
            _nric = CodeBehind.Authentication.NRIC.GetInstance(LayerWeb);
            _nric.OnNRICSucceeded += NRIC_OnNRICSucceeded;
            _nric.OnShowMessage   += OnShowMessage;

            // Supervisee
            _superviseeParticulars = new CodeBehind.SuperviseeParticulars(LayerWeb, _jsCallCS, this);

            _eventCenter             = EventCenter.Default;
            _eventCenter.OnNewEvent += EventCenter_OnNewEvent;
            #endregion


            Lib.LayerWeb = LayerWeb;
            LayerWeb.Url = new Uri(String.Format("file:///{0}/View/html/Layout.html", CSCallJS.curDir));
            LayerWeb.ObjectForScripting = _jsCallCS;
        }
예제 #2
0
파일: Main.cs 프로젝트: tuga1975/SSK
        public Main()
        {
            InitializeComponent();

            // Check if another instance of ARK is running
            if (CommonUtil.CheckIfAnotherInstanceIsRunning("ARK"))
            {
                MessageBox.Show("An instance of ARK is already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
            APIUtils.Start();
            //Notification
            Trinity.SignalR.Client.Instance.OnQueueCompleted      += OnQueueCompleted_Handler;
            Trinity.SignalR.Client.Instance.OnDOUnblockSupervisee += DOUnblockSupervisee_Handler;
            Trinity.SignalR.Client.Instance.OnAppointmentBooked   += OnAppointmentBooked_Handler;
            // setup variables
            _smartCardFailed          = 0;
            _fingerprintFailed        = 0;
            _displayLoginButtonStatus = false;

            #region Initialize and register events

            double _sessionTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["session_timeout"]);
            if (_sessionTimeout > 0)
            {
                this._timerCheckLogout           = new System.Timers.Timer();
                this._timerCheckLogout.AutoReset = true;
                this._timerCheckLogout.Interval  = _sessionTimeout * 1000;
                this._timerCheckLogout.Elapsed  += TimeCheckLogout_EventHandler;
            }
            // _jsCallCS
            _jsCallCS = new JSCallCS(this.LayerWeb, this);
            _jsCallCS.OnNRICFailed      += JSCallCS_OnNRICFailed;
            _jsCallCS.OnShowMessage     += JSCallCS_ShowMessage;
            _jsCallCS.OnLogOutCompleted += JSCallCS_OnLogOutCompleted;

            // SmartCard
            SmartCard.Instance.GetCardInfoSucceeded += GetCardInfoSucceeded;
            // Fingerprint
            Fingerprint.Instance.OnIdentificationCompleted += Fingerprint_OnIdentificationCompleted;
            Fingerprint.Instance.OnDeviceDisconnected      += Fingerprint_OnDeviceDisconnected;


            // NRIC
            _nric = CodeBehind.Authentication.NRIC.GetInstance(LayerWeb);
            _nric.OnNRICSucceeded += NRIC_OnNRICSucceeded;
            _nric.OnShowMessage   += OnShowMessage;

            // Supervisee
            _supervisee = new CodeBehind.Supervisee(LayerWeb);

            _eventCenter = EventCenter.Default;

            _eventCenter.OnNewEvent += EventCenter_OnNewEvent;

            #endregion


            Lib.LayerWeb = LayerWeb;
            LayerWeb.Url = new Uri(String.Format("file:///{0}/View/html/Layout.html", CSCallJS.curDir));
            LayerWeb.ObjectForScripting = _jsCallCS;

            //
            // For testing purpose only
            //
            //Trinity.DAL.DAL_User dalUser = new Trinity.DAL.DAL_User();
            //Trinity.BE.User localUser = dalUser.GetUserBySmartCardId("123456789", true);
            //Trinity.BE.User centralizedUser = dalUser.GetUserBySmartCardId("999", false);
            //Trinity.DAL.DAL_Notification dalNotification = new Trinity.DAL.DAL_Notification();
            //List<Trinity.BE.Notification> myLocaNotifications = dalNotification.GetMyNotifications("dfkkmdkg", true);
            //List<Trinity.BE.Notification> myCentralizedNotifications = dalNotification.GetMyNotifications("minhdq", false);
            //Trinity.SignalR.Client.SignalR.Instance.SendNotificationToDutyOfficer("Hello Mr. Duty Officer!", "Hello Mr. Duty Officer! I'm a Supervisee");
        }