/// <summary> /// Resets the device, ensuring it is at the home screen and no user is signed in. /// </summary> public void Reset() { _controlPanel.PressKeyWait(JediHardKey.Reset, _homeScreenForm); Thread.Sleep(1000); if (_controlPanel.CurrentForm().Equals("TimedMessageBox")) { _controlPanel.WaitForForm(_homeScreenForm, true); } }
/// <summary> /// Presses the Hpec the scan button. /// </summary> /// <exception cref="DeviceInvalidOperationException"> /// </exception> public void HpecStartScan(int pageCount) { var pages = 1; _engine.PressElementById("NEXT_BUTTON"); if (pageCount > 1) { RecordEvent(DeviceWorkflowMarker.JobBuildBegin); } RecordEvent(DeviceWorkflowMarker.ScanJobBegin); var searchFormNames = "JobBuildPrompt"; if (_controlPanel.WaitForForm(searchFormNames, StringMatch.Regex, TimeSpan.FromSeconds(45))) { while (pages < pageCount) { RecordEvent(DeviceWorkflowMarker.ScanJobEnd); RecordEvent(DeviceWorkflowMarker.ScanJobBegin); _controlPanel.Press("m_OKButton"); pages++; if (!_controlPanel.WaitForForm(searchFormNames, StringMatch.Regex, TimeSpan.FromSeconds(45))) { throw new DeviceInvalidOperationException(string.Format("Unexpected form: expecting {0}, got {1}", searchFormNames, _engine.GetBrowserHtml())); } } } else { throw new DeviceInvalidOperationException(string.Format("Unexpected form: expecting {0}", searchFormNames)); } RecordEvent(DeviceWorkflowMarker.ScanJobEnd); if (pageCount > 1) { RecordEvent(DeviceWorkflowMarker.JobBuildEnd); } _controlPanel.Press("mFinishButton"); }
/// <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 { UpdateStatus("Authenticating..."); authenticator.Authenticate(); bSuccess = _controlPanel.WaitForForm(waitForm, StringMatch.Contains, TimeSpan.FromSeconds(30)); } 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> /// Presses the copy with quickset. /// </summary> /// <param name="quickSetName">Name of the quick set.</param> /// <returns></returns> /// <exception cref="DeviceWorkflowException"> /// Could not launch copy application. /// or /// Copy application button was not found on device home screen. /// or /// or /// or /// </exception> private bool PressCopyWithQuickset(string quickSetName) { bool signInScreenLoaded; try { if (!string.IsNullOrEmpty(quickSetName)) { if (ExistQuickSetButton(quickSetName)) { // on a front page signInScreenLoaded = _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", quickSetName, JediWindjammerLaunchHelper.SIGNIN_FORM, TimeSpan.FromSeconds(7)); } else // in the quickset folder { _controlPanel.PressToNavigate("NLevelApp", "NLevelHomeScreenForm", true); signInScreenLoaded = _controlPanel.PressWait(quickSetName, "SignInForm", TimeSpan.FromSeconds(7)); } } else { signInScreenLoaded = _controlPanel.PressWait("CopyApp", "SignInForm", TimeSpan.FromSeconds(1)); } if (!signInScreenLoaded) { if (!_controlPanel.WaitForForm("CopyAppMainForm", TimeSpan.FromSeconds(3))) { throw new DeviceWorkflowException("Could not launch copy application."); } } RecordEvent(DeviceWorkflowMarker.QuickSetListReady); } 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(false); 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); } } return(signInScreenLoaded); }