/// <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> /// 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); }