/// <summary> /// Activating the badge box for card authentication /// </summary> /// <param name="parameters"></param> /// <exception cref="DeviceInvalidOperationException"></exception> public override void ApplyParameters(Dictionary <string, object> parameters) { Framework.Logger.LogDebug($"Swiping badge for user {_badge.UserName}. (index {_badge.Index})"); var scanResult = _badgeBoxEndPoint.Activate(_badge.Index); Framework.Logger.LogDebug(scanResult.DetectionOffset != null ? "Badge Scan Successful." : "Badge Scan Failed..."); }
/// <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); } }