Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        public static NRIC GetInstance(WebBrowser web)
        {
            if (_instance == null)
            {
                lock (syncRoot) // now I can claim some form of thread safety...
                {
                    if (_instance == null)
                    {
                        _instance = new NRIC(web);
                    }
                }
            }

            return(_instance);
        }