/// <summary> /// Checks error state of the device by looking at the devices banner. /// </summary> /// <returns></returns> public override bool BannerErrorState() { bool errorState = false; IEnumerable <string> controls = _controlPanel.GetControls(); foreach (string ctlr in controls) { if (ctlr.Equals("mTitleBar")) { string value = _controlPanel.GetProperty("mTitleBar", "Text"); if (value.Contains("Runtime Error")) { errorState = true; break; } } } return(errorState); }
/// <summary> /// Launches the Copy application on the device. /// </summary> public void Launch() { try { RecordEvent(DeviceWorkflowMarker.AppButtonPress, "Copy"); _controlPanel.ScrollPressNavigate("mAccessPointDisplay", "Copy", "CopyAppMainForm", true); RecordEvent(DeviceWorkflowMarker.AppShown); Pacekeeper.Pause(); } catch (ControlNotFoundException ex) { string currentForm = _controlPanel.CurrentForm(); if (currentForm == "HomeScreenForm") { throw new DeviceWorkflowException("Copy application button was not found on device home screen.", ex); } else { throw new DeviceWorkflowException($"Cannot launch the Copy application from {currentForm}.", ex); } } catch (WindjammerInvalidOperationException ex) { switch (_controlPanel.CurrentForm()) { case "CopyAppMainForm": // The application launched without prompting for credentials. RecordEvent(DeviceWorkflowMarker.AppShown); Pacekeeper.Reset(); return; case "OneButtonMessageBox": string message = _controlPanel.GetProperty("mMessageLabel", "Text"); throw new DeviceWorkflowException($"Could not launch Copy application: {message}", ex); default: throw new DeviceWorkflowException($"Could not launch Copy application: {ex.Message}", ex); } } }
/// <summary> /// Selects the file type for the scanned file. /// </summary> /// <param name="fileType">The file type to select (case sensitive).</param> public void SelectFileType(string fileType) { //var html = _controlPanel.GetControls(); ScrollToOption("FileTypeDialogButton"); Pacekeeper.Pause(); if (_controlPanel.GetProperty("FileTypeDialogButton", "Text") != fileType) { _controlPanel.PressToNavigate("FileTypeDialogButton", "DSFileTypeDialog", ignorePopups: false); Pacekeeper.Pause(); _controlPanel.ScrollPress("mFileTypeListBox", "Text", fileType); Pacekeeper.Sync(); _controlPanel.PressToNavigate("m_OKButton", _appMainForm, ignorePopups: false); Pacekeeper.Pause(); } }
/// <summary> /// Gets the Y-offset of the OXPd web browser for the specified <see cref="JediWindjammerControlPanel" />. /// </summary> /// <param name="controlPanel">The control panel.</param> /// <returns>The Y-offset of the OXPd web browser control.</returns> /// <exception cref="DeviceInvalidOperationException">An OXPd browser control could not be found.</exception> public static int GetBrowserOffset(JediWindjammerControlPanel controlPanel) { var browsers = new[] { "mWebBrowser", "WebKitBrowser" }; var controls = controlPanel.GetControls(); foreach (string browser in browsers) { if (controls.Contains(browser, StringComparer.OrdinalIgnoreCase)) { return(controlPanel.GetProperty <int>(browser, "Top")); } } throw new DeviceInvalidOperationException("No known OXPd browser control was found on the control panel."); }
/// <summary> /// Authenticates the user for HPCR. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="waitForm">desired form after action</param> /// <returns>bool</returns> private bool Authenticate(IAuthenticator authenticator, string waitForm) { bool bSuccess = false; try { authenticator.Authenticate(); if (bSuccess = _controlPanel.WaitForForm(waitForm, StringMatch.Contains, TimeSpan.FromSeconds(30)) == true) { RecordEvent(DeviceWorkflowMarker.AppShown); } } catch (WindjammerInvalidOperationException ex) { string currentForm = _controlPanel.CurrentForm(); switch (currentForm) { case "OxpUIAppMainForm": // The application launched successfully. This happens sometimes. RecordEvent(DeviceWorkflowMarker.AppShown); bSuccess = true; break; case "OneButtonMessageBox": string message = _controlPanel.GetProperty("mMessageLabel", "Text"); if (message.StartsWith("Invalid", StringComparison.OrdinalIgnoreCase)) { throw new DeviceWorkflowException(string.Format("Could not launch application: {0}", message), ex); } else { throw new DeviceInvalidOperationException(string.Format("Could not launch application: {0}", message), ex); } default: throw new DeviceInvalidOperationException(string.Format("Could not launch application: {0}", ex.Message), ex); } } return(bSuccess); }
/// <summary> /// Executes the currently configured scan job. /// </summary> /// <param name="executionOptions">The execution options.</param> /// <param name="appMainForm">The name of the application main form.</param> /// <returns><c>true</c> if the job finishes (regardless of its ending status), <c>false</c> otherwise.</returns> public bool ExecuteScanJob(ScanExecutionOptions executionOptions, string appMainForm) { bool done = false; if (executionOptions == null) { throw new ArgumentNullException(nameof(executionOptions)); } try { if (executionOptions.JobBuildSegments > 1) { RecordEvent(DeviceWorkflowMarker.JobBuildBegin); } _controlPanel.PressToNavigate("mStartButton", "BaseJobStartPopup", ignorePopups: false); } catch (WindjammerInvalidOperationException) { if (_controlPanel.CurrentForm() == "ConflictDialog") { string message = _controlPanel.GetProperty("mDetailsBrowser", "PageContent"); throw new DeviceWorkflowException($"Could not start job: {message}"); } else { // Let it flow on through. It might be another dialog we can handle. } } while (!done) { string currentForm = _controlPanel.CurrentForm(); switch (currentForm) { case "BaseJobStartPopup": done = MonitorExecutingJob(); break; case "JobBuildPrompt": if (_jobBuildSegmentsScanned < executionOptions.JobBuildSegments) { _controlPanel.PressToNavigate("m_OKButton", "BaseJobStartPopup", ignorePopups: true); SetPerformanceMarker(DeviceWorkflowMarker.ScanJobBegin.GetDescription(), ""); _jobBuildSegmentsScanned++; } else { try { RecordEvent(DeviceWorkflowMarker.JobBuildEnd); _controlPanel.PressToNavigate("mFinishButton", "BaseJobStartPopup", ignorePopups: false); } catch (WindjammerInvalidOperationException) { // Do nothing - will loop back around and try to handle the dialog } } break; case "FlatbedAutoDetectPrompt": _controlPanel.PressToNavigate("m_OKButton", "BaseJobStartPopup", ignorePopups: true); break; case "AddressBookBatchAddDialog": // Could take us to either the BaseJobStartPopup screen or the FlatbedAutoDetectPrompt _controlPanel.PressWait("m_CancelButton", "BaseJobStartPopup", TimeSpan.FromSeconds(5)); break; case "HPProgressPopup": try { _controlPanel.WaitForForm("BaseJobStartPopup", ignorePopups: false); } catch (WindjammerInvalidOperationException) { // Do nothing - will loop back around and try to handle the dialog } break; default: if (currentForm == appMainForm) { // Sometimes the main form flashes in between other screens // Only return if the form stays steady for a few seconds if (!Wait.ForChange(_controlPanel.CurrentForm, appMainForm, TimeSpan.FromSeconds(3))) { done = true; } } else { return(done); } break; } } return(done); }
/// <summary> /// Determines if authentication took place. If so, signing out is required. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool SignOutRequired() => (_controlPanel.GetProperty(_signInButton, "Text") == "Sign Out");
/// <summary> /// Launches The Hpcr solution with the given authenticator with either eager or lazy authentication. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="authenticationMode">The authentication mode.</param> /// <exception cref="System.ArgumentNullException">authenticator</exception> /// <exception cref="DeviceWorkflowException">Application button was not found on device home screen.</exception> /// <exception cref="DeviceInvalidOperationException"> /// </exception> public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { if (authenticator == null) { throw new ArgumentNullException(nameof(authenticator)); } // Press the desired HPCR Button type try { if (authenticationMode.Equals(AuthenticationMode.Eager)) { UpdateStatus("Pressing {0}", JediWindjammerLaunchHelper.SIGNIN_BUTTON); RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In"); _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM); Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM); UpdateStatus("Pressing {0}", _buttonTitle); RecordEvent(DeviceWorkflowMarker.AppButtonPress, "HPCR " + _buttonTitle); _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", _buttonTitle, JediWindjammerLaunchHelper.OxpdFormIdentifier, StringMatch.Contains, TimeSpan.FromSeconds(30)); } else // AuthenticationMode.Lazy { UpdateStatus("Pressing {0}", _buttonTitle); RecordEvent(DeviceWorkflowMarker.AppButtonPress, "HPCR " + _buttonTitle); _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", _buttonTitle, JediWindjammerLaunchHelper.SIGNIN_FORM, TimeSpan.FromSeconds(30)); Authenticate(authenticator, JediWindjammerLaunchHelper.OxpdFormIdentifier); } RecordEvent(DeviceWorkflowMarker.AppShown); } catch (ControlNotFoundException ex) { string currentForm = _controlPanel.CurrentForm(); if (currentForm == "HomeScreenForm") { throw new DeviceWorkflowException("The HPCR application button was not found on device home screen.", ex); } else { throw new DeviceInvalidOperationException(string.Format("Could not launch the HPCR application from {0}.", currentForm), ex); } } catch (WindjammerInvalidOperationException ex) { var currentForm = _controlPanel.CurrentForm(); if (currentForm.StartsWith(JediWindjammerLaunchHelper.OxpdFormIdentifier, StringComparison.OrdinalIgnoreCase)) { // The application launched without prompting for credentials. } switch (currentForm) { case "OneButtonMessageBox": string message = _controlPanel.GetProperty("mMessageLabel", "Text"); throw new DeviceInvalidOperationException(string.Format("Could not launch the HPCR application: {0}", message), ex); default: throw new DeviceInvalidOperationException(string.Format("Could not launch the HPCR application: {0}", ex.Message), ex); } } }