Пример #1
0
        private void OnCardInserted(object sender, CardStatusEventArgs e)
        {
            SmartCardReaderUtil sCardMonitor = SmartCardReaderUtil.Instance;
            string cardUID = sCardMonitor.GetCardUID();

            if (!string.IsNullOrEmpty(cardUID))
            {
                // Scan smart card successfully
                DAL_User        dalUser = new DAL_User();
                Trinity.BE.User user    = dalUser.GetUserBySmartCardId(cardUID);
                if (user != null)
                {
                    MessageBox.Show("This smart card is already in used by another person. Please user another card.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Then stop Smart Card and Start to scan finger print
                sCardMonitor.StopSmartCardMonitor();
                btnScanSmartcard.Enabled = false;

                _currentUser.SmartCardId = cardUID;
                StartToScanFingerprint();

                UpdateNote("Scan smart card successfully. Please scan your finger print to continue", Color.Blue);
                return;
            }
            UpdateNote("Could not scan the smart card", Color.Red);
        }
Пример #2
0
        private void GetCardInfoSucceeded(string cardUID)
        {
            DAL_User dAL_User = new DAL_User();

            Trinity.BE.User user = dAL_User.GetUserBySmartCardId(cardUID);

            if (user != null)
            {
                // Only enrolled supervisees are allowed to login
                if (user.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase) || user.Role.Equals(EnumUserRoles.DutyOfficer, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (user.Status.Equals(EnumUserStatuses.New, StringComparison.InvariantCultureIgnoreCase))
                    {
                        SmartCard_OnSmartCardFailed("You haven't enrolled yet.", "Supervisee " + user.Name + " hasn't enrolled yet.");
                        return;
                    }
                    if (user.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var smartCard = new DAL_IssueCard().GetIssueCardBySmartCardId(cardUID);
                        if (smartCard == null)
                        {
                            SmartCard_OnSmartCardFailed("Your smart card does not exist.", "The smart card " + cardUID + " does not exist.");
                            return;
                        }
                        else if (smartCard.Status.Equals(EnumIssuedCards.Inactive, StringComparison.InvariantCultureIgnoreCase))
                        {
                            SmartCard_OnSmartCardFailed("Your smart card does not work.", "The smart card " + cardUID + " does not work.");
                            return;
                        }
                        else if ((smartCard.Status.Equals(EnumIssuedCards.Active, StringComparison.InvariantCultureIgnoreCase) && smartCard.Expired_Date < DateTime.Today) || (user.Expired_Date.HasValue && user.Expired_Date.Value < DateTime.Today))
                        {
                            SmartCard_OnSmartCardFailed("Your smart card has already expired.", "The smart card " + cardUID + " has already expired.");
                            return;
                        }
                    }
                    Session session = Session.Instance;
                    session.IsSmartCardAuthenticated    = true;
                    session[CommonConstants.USER_LOGIN] = user;
                    this.LayerWeb.RunScript("$('.status-text').css('color','#000').text('Your smart card is authenticated.');");
                    // Stop SCardMonitor
                    SmartCardReaderUtil sCardMonitor = SmartCardReaderUtil.Instance;
                    sCardMonitor.StopSmartCardMonitor();
                    // raise succeeded event

                    new DAL_ActionLog().Insert(ActionName.TabSmartCard, user.UserId, string.Empty, EnumStation.ARK);
                    SmartCard_OnSmartCardSucceeded();
                }
                else
                {
                    SmartCard_OnSmartCardFailed("You do not have permission to login to this system.", "The user " + user.Name + " tries to access ARK for which he/she is not authorized.");
                }
            }
            else
            {
                // raise failed event

                if (string.IsNullOrEmpty(cardUID))
                {
                    SmartCard_OnSmartCardFailed("Unable to retrieve smart card information.", "The smart card " + cardUID + " cannot be read.");
                }
                else
                {
                    SmartCard_OnSmartCardFailed("Your smart card does not exist.", "The smart card " + cardUID + " does not exist.");
                }
            }
        }