/// <summary> /// Navigates to the home screen. (Does not sign out.) /// </summary> public void NavigateHome() { DateTime timeout = DateTime.UtcNow + TimeSpan.FromSeconds(60); string message = string.Empty; while (DateTime.UtcNow < timeout) { ScreenInfo screen = _controlPanel.GetScreenInfo(); // Check to see if the home screen is displayed // If it's SafeCom, the home screen has a different label if (screen.ScreenLabels.Contains("Home") || screen.ScreenLabels.Contains("vw_auth_blocking")) { return; } // Check to see if a soft key can be pressed if (screen.Leds[SiriusLed.Home] == LedState.On) { _controlPanel.PressKey(SiriusSoftKey.Home); } else if (screen.Leds[SiriusLed.Back] == LedState.On) { _controlPanel.PressKey(SiriusSoftKey.Back); } else if (screen.ScreenLabels.Any(n => n.Contains("warning", StringComparison.OrdinalIgnoreCase) || n.Contains("error", StringComparison.OrdinalIgnoreCase))) { SiriusUIv3PopupManager popupManager = new SiriusUIv3PopupManager(_controlPanel); message = popupManager.HandleAny(screen); if (!string.IsNullOrEmpty(message)) { //Popup was handled. break; } } else { // Nothing to do at this point - wait a second and see what changes Thread.Sleep(TimeSpan.FromSeconds(1)); } } // If we're not there after 60 seconds, we're not going to make it. // If no error message has been set, use a default. if (string.IsNullOrEmpty(message)) { message = "Unable to navigate to home screen."; } throw new DeviceWorkflowException(message); }
/// <summary> /// Determines whether the device is printing by checking for the presence of an alert with the text "Printing..." /// </summary> /// <param name="checkBy">The check by.</param> /// <returns><c>true</c> if the "Printing" alert is present; <c>false</c> otherwise.</returns> public bool IsPrinting(JobStatusCheckBy checkBy) { ScreenInfo screenInfo = _controlPanel.GetScreenInfo(); try { Widget widget = screenInfo.Widgets.FindByValue("Printing", StringMatch.StartsWith); return(widget != null); } catch (ElementNotFoundException) { // "Printing" Screen not found. Allow to return. } return(false); }
/// <summary> /// Launches the Network Folder application on the device. /// </summary> public void Launch() { try { _controlPanel.ScrollPress("sfolderview_p", "group.group.scan"); Pacekeeper.Pause(); _controlPanel.WaitForScreenLabel("Home", TimeSpan.FromSeconds(10)); //Scan To Page Pacekeeper.Pause(); _controlPanel.ScrollPress("sfolderview_p", "command.scan_folder"); Pacekeeper.Pause(); if (_controlPanel.GetScreenInfo().ScreenLabels.Contains("AnA_Login_With_Windows_Authentication") || _controlPanel.GetScreenInfo().ScreenLabels.Contains("AnA_Login_With_LDAP_Authentication")) { throw new DeviceInvalidOperationException("Network folder is Protected, launch it with authenticator"); } //_controlPanel.Press("model.0"); Pacekeeper.Pause(); } catch (ElementNotFoundException ex) { string currentScreen = _controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault(); if (currentScreen == "Scan_Status_Error") { throw new DeviceWorkflowException("Email application button was not found on device home screen.", ex); } if (currentScreen == "Scan_NetworkFolder_HomeGlass") { // The application launched successfully. This happens sometimes. } else { throw new DeviceInvalidOperationException($"Cannot launch the Email application from {currentScreen}.", ex); } } catch (SiriusInvalidOperationException ex) { switch (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault()) { case "Scan_NetworkFolder_HomeGlass": case "Scan_NetworkFolder_HomeADF": // The application launched successfully. This happens sometimes. break; case "AnA_Login_With_Windows_Authentication": case "AnA_Login_With_LDAP_Authentication": { throw new DeviceWorkflowException("Sign-in required to launch the Email application.", ex); } default: { throw new DeviceInvalidOperationException($"Could not launch Email application: {ex.Message}", ex); } } } }
/// <summary> /// Launches the Email application on the device. /// </summary> public void Launch() { try { _controlPanel.ScrollPress("sfolderview_p", "group.group.scan"); _controlPanel.WaitForScreenLabel("Home", _shortTimeSpan); //Scan To Page Pacekeeper.Pause(); _controlPanel.ScrollPress("sfolderview_p", "command.scan_email"); Pacekeeper.Pause(); _controlPanel.WaitForScreenLabel("Scan_Email_EmailPageGlass", _shortTimeSpan); //Email Page Pacekeeper.Pause(); } catch (ElementNotFoundException ex) { string currentForm = _controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault(); if (currentForm.Equals("Scan_Status_Error")) { throw new DeviceWorkflowException("Email application button was not found on device home screen.", ex); } else { throw new DeviceWorkflowException($"Cannot launch the Email application from {currentForm}.", ex); } } catch (SiriusInvalidOperationException ex) { switch (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault()) { case "Scan_Email_EmailPageGlass": // The application launched successfully. This happens sometimes. break; case "Scan_Status_Error": { throw new DeviceWorkflowException("Sign-in required to launch the Email application.", ex); } case "Scan_Email_NotSetup": { throw new DeviceWorkflowException("Scan To Email is not configured"); } default: { throw new DeviceWorkflowException($"Could not launch Email application: {ex.Message}", ex); } } } }
/// <summary> /// Gets the current control ids. /// </summary> public override void GetCurrentControlIds() { WidgetCollection wc = _controlPanel.GetScreenInfo().Widgets; ControlPanelControlIds = string.Join(",", wc.Select(x => x.Id).ToArray()); }
/// <summary> /// Executes the currently configured scan job. /// </summary> /// <param name="executionOptions">The execution options.</param> /// <param name="appMainForm">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) { string documentType = string.Empty; try { // if (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault().Equals(appMainForm)) if (_controlPanel.WaitForScreenLabel(appMainForm)) { if (_controlPanel.WaitForWidget("fb_settings", _shortWaitTimeSpan) != null) { _controlPanel.Press("fb_settings"); Thread.Sleep(_shortWaitTimeSpan); } if (_controlPanel.GetScreenInfo().ScreenLabels.Contains("Scan_Glass_Settings") || _controlPanel.GetScreenInfo().ScreenLabels.Contains("Scan_ADF_Settings")) { //_controlPanel.Press("command.save_as"); ScreenInfo screen = _controlPanel.GetScreenInfo(); Widget widget = screen.Widgets.First(n => n.Id == "command.save_as"); if (widget.Values["secondarytext"] == "JPEG") { documentType = "JPEG"; } _controlPanel.PressKey(SiriusSoftKey.Back); Thread.Sleep(_shortWaitTimeSpan); } RecordEvent(DeviceWorkflowMarker.ScanJobBegin); _controlPanel.Press("fb_start_scan"); Thread.Sleep(_shortWaitTimeSpan); while (_controlPanel.WaitForScreenLabel("Scan_Status_Connecting", _shortWaitTimeSpan)) { //wait for this screen to get over Thread.Sleep(200); } while (_controlPanel.WaitForScreenLabel("Scan_Status_ScanningPage", _shortWaitTimeSpan)) { Thread.Sleep(200); } if (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault().Equals("Scan_Status_Error")) { string exceptionMessage = string.Empty; try { Widget controlInfo = _controlPanel.GetScreenInfo().Widgets.Find("text"); if (controlInfo != null) { exceptionMessage = controlInfo.Values.FirstOrDefault().Value; } } catch (Exception) { //ignore } throw new DeviceWorkflowException($"Scan Error occurred.{exceptionMessage}"); } ExecuteScan(executionOptions, appMainForm, documentType); RecordEvent(DeviceWorkflowMarker.ScanJobEnd); } CheckForScanError(); } catch (SiriusInvalidOperationException) { if (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault().Equals("Scan_Status_Error")) { Widget controlInfo = _controlPanel.GetScreenInfo().Widgets.Find("email_error_msg"); string message = "Cannot connect to server. Check server name and address."; if (controlInfo.HasValue(message)) { throw new DeviceWorkflowException($"Could not start job: {message}"); } } return(false); } return(true); }
/// <summary> /// Presses a button within an HPCR workflow. /// </summary> /// <param name="buttonTitle"></param> private void PressPanelButton(string buttonTitle) { UpdateStatus("Pressing button that starts with '{0}'", buttonTitle); _controlPanel.WaitForWidgetByValue(buttonTitle); _controlPanel.Press(_controlPanel.GetScreenInfo().Widgets.FindByValue(buttonTitle).Id); }
/// <summary> /// Checks device against list of known popup screens. If one is found, it is handled and message text returned. /// If no known popup screens are detected, attempts to clear the screen by pressing an "OK" button if one exists. /// </summary> /// <returns>Message text if popup was handled. Empty string if no known popup was handled.</returns> public string HandleAny() { return(HandleAny(_controlPanel.GetScreenInfo())); }