/// <summary>
        /// Scans the proximity card.
        /// </summary>
        private void ScanCard()
        {
            RobotControllerClient badgeBox         = new RobotControllerClient(Credential.BadgeBoxInfo.Address);
            RfidSwitch            badgeBoxEndPoint = badgeBox.GetEndpoint <RfidSwitch>();
            RfidActivateResult    scanResult       = null;

            LogDebug("Entering Badge Scan.");
            try
            {
                //Check card with user
                BadgeInfo badge = Credential.BadgeBoxInfo.Badges.FirstOrDefault(x => x.UserName.EqualsIgnoreCase(Credential.UserName));
                if (badge == null)
                {
                    throw new DeviceWorkflowException($"Unable fo find badge info for User {Credential.UserName}");
                }

                LogDebug($"Swiping badge for user {badge.UserName}. (index {badge.Index})");
                scanResult = badgeBoxEndPoint.Activate(badge.Index);

                if (scanResult.DetectionOffset != null)
                {
                    LogDebug("Badge Scan Successful.");
                }
                else
                {
                    LogDebug("Badge Scan Failed.");
                }

                //Handle Notification Screen, if present.  It may not be present for all cases.
                Widget okButton = ControlPanel.WaitForWidgetByValue("OK", TimeSpan.FromSeconds(1));
                if (okButton != null)
                {
                    ControlPanel.Press(okButton);
                    Pacekeeper.Sync();
                }

                if (ValidateAuthentication())
                {
                    LogDebug("Login Successful.");
                }
                else
                {
                    throw new DeviceWorkflowException("No 'Sign Out' button detected.");
                }

                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                throw new DeviceWorkflowException($"Unable to authenticate badge scan.", ex);
            }
        }
        /// <summary>
        /// Scans the proximity card.
        /// </summary>
        private void ScanCard()
        {
            RobotControllerClient badgeBox         = new RobotControllerClient(Credential.BadgeBoxInfo.Address);
            RfidSwitch            badgeBoxEndPoint = badgeBox.GetEndpoint <RfidSwitch>();

            Framework.Logger.LogDebug("Entering Badge Scan.");
            try
            {
                //Check card with user
                Framework.Assets.BadgeInfo badge = Credential.BadgeBoxInfo.Badges.FirstOrDefault(x => x.UserName.Equals(Credential.UserName, StringComparison.OrdinalIgnoreCase));
                if (badge == null)
                {
                    throw new DeviceInvalidOperationException($"Unable fo find badge info for User {Credential.UserName}");
                }

                Framework.Logger.LogDebug($"Swiping badge for user {badge.UserName}. (index {badge.Index})");
                var scanResult = badgeBoxEndPoint.Activate(badge.Index);
                if (ControlPanel.CurrentForm() != JediWindjammerLaunchHelper.HOMESCREEN_FORM)
                {
                    ControlPanel.WaitForForm(JediWindjammerLaunchHelper.HOMESCREEN_FORM, true);
                }
                ControlPanel.WaitForPropertyValue(JediWindjammerLaunchHelper.SIGNIN_BUTTON, "Text", "Sign Out", TimeSpan.FromSeconds(3));

                var cpResult = ValidateAuthentication();

                Framework.Logger.LogDebug(scanResult.DetectionOffset != null ? "Badge Scan Successful." : "Badge Scan Failed...");

                if (cpResult)
                {
                    // If the card does not scan, we may get a false pass after ValidateAuthentication.
                    // Do an extra check to be sure that we are not still on the home screen & not signed in.
                    if (ControlPanel.CurrentForm() == JediWindjammerLaunchHelper.HOMESCREEN_FORM &&
                        ControlPanel.GetProperty(JediWindjammerLaunchHelper.SIGNIN_BUTTON, "Text") != "Sign Out")
                    {
                        throw new DeviceInvalidOperationException("No 'Sign Out' button detected.");
                    }
                    else
                    {
                        Framework.Logger.LogDebug("Login Successful");
                    }
                }
                else
                {
                    throw new DeviceInvalidOperationException("Sign in was not successful.");
                }
            }
            catch (Exception ex)
            {
                throw new DeviceInvalidOperationException($"Unable to authenticate badge scan.", ex);
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniCardAuthenticator" /> class.
        /// </summary>
        /// <param name="controlPanel">The <see cref="JediOmniControlPanel"/> object.</param>
        /// <param name="credential">The <see cref="AuthenticationCredential"/> object.</param>
        /// <param name="pacekeeper">The <see cref="Pacekeeper"/> object.</param>
        public JediOmniCardAuthenticator(JediOmniControlPanel controlPanel, AuthenticationCredential credential, Pacekeeper pacekeeper)
            : base(controlPanel, credential, pacekeeper)
        {
            //Check card with user
            _badge = Credential.BadgeBoxInfo.Badges.FirstOrDefault(x => x.UserName.Equals(Credential.UserName, StringComparison.OrdinalIgnoreCase));
            if (_badge == null)
            {
                throw new DeviceInvalidOperationException($"Unable to find badge info for User {Credential.UserName}");
            }

            RobotControllerClient badgeBox = new RobotControllerClient(Credential.BadgeBoxInfo.Address);

            _badgeBoxEndPoint = badgeBox.GetEndpoint <RfidSwitch>();
        }