Beispiel #1
0
        /// <summary>
        /// Enables print notification for this job.
        /// </summary>
        /// <param name="condition">The condition under which to send notification.</param>
        /// <param name="thumbNail">if set to<c>true>enable thumbnail;otherwise,disable it</c></param>//We have added thumbnail parameter but not yet implemented it
        public void EnablePrintNotification(NotifyCondition condition, bool thumbNail)
        {
            ScrollToOption("NotificationDialogButton");
            Pacekeeper.Pause();

            try
            {
                _controlPanel.PressToNavigate("NotificationDialogButton", "DSNotificationDialog", ignorePopups: false);
            }
            catch (WindjammerInvalidOperationException)
            {
                // Form name is different on some firmware versions
                if (_controlPanel.CurrentForm() != "DSNotificationSettingsDialog")
                {
                    throw;
                }
            }
            Pacekeeper.Pause();
            _controlPanel.Press(condition == NotifyCondition.OnlyIfJobFails ? "AllErrors" : "Always");
            Pacekeeper.Sync();

            // Select the print option and exit
            _controlPanel.Press("Print");
            Pacekeeper.Sync();
            _controlPanel.PressToNavigate("m_OKButton", _appMainForm, ignorePopups: false);
            Pacekeeper.Pause();
        }
        /// <summary>
        /// Navigates to the home screen.  (Does not sign out.)
        /// </summary>
        public void NavigateHome()
        {
            if (_controlPanel.CurrentForm() == _homeScreenForm)
            {
                return;
            }

            // Press the menu (home) button, then wait until the home screen appears
            // If there is a job running, we might have to press it a couple times.
            for (int i = 0; i < 10; i++)
            {
                if (_controlPanel.PressKeyWait(JediHardKey.Menu, _homeScreenForm, TimeSpan.FromSeconds(3)))
                {
                    return;
                }
            }

            // If we're not there after 10 tries, we're not going to make it.
            throw new DeviceWorkflowException("Unable to navigate to home screen.");
        }
        /// <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>
        /// Authenticates the user for PaperCut.
        /// </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);
        }
Beispiel #6
0
        /// <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);
                }
            }
        }