Exemplo n.º 1
0
        /// <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();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logs in to the Safecom on the device control panel using ID CODE
        /// </summary>
        /// <param name="pin">PIN</param>
        /// <returns></returns>
        public void AuthenticateSafecom(string pin)
        {
            try
            {
                var preparationManager = DevicePreparationManagerFactory.Create(_device);
                preparationManager.WakeDevice();

                //Go to Home Screen
                _controlPanel.PressKey(JediHardKey.Menu);

                //Enter Credentials
                _controlPanel.PressToNavigate("b7396880-ec17-11df-98cf-0800200c9a66", "SignInForm", true);
                _controlPanel.PressToNavigate("m_textBox", "SignInKeyboardForm", true);
                // SafeCom ID authenticiation uses a unique personal identification code (PIC) that has been assigned to each user.  Our convention is that it's the username with the u lopped off
                // e.g. u00001  =>  00001; u00038 => 00038
                _controlPanel.TypeOnVirtualKeyboard("mKeyboard", _credential.UserName.Substring(1)); //Enter Username as ID CODE
                _controlPanel.PressToNavigate("ok", "SignInForm", true);
                _controlPanel.PressToNavigate("mOkButton", "OxpUIAppMainForm800X300", true);         //Sign In
            }
            catch (Exception ex)
            {
                throw new Exception($"Safecom navigation failed with exception:{ex.Message}");
            }
        }
        /// <summary>
        /// Launches SafeCom with the specified authenticator using the given authentication mode
        /// </summary>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="authenticationMode">The authentication mode, eager or lazy.</param>
        public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
        {
            if (authenticationMode.Equals(AuthenticationMode.Eager))
            {
                RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
                _controlPanel.PressToNavigate(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM, true);
                Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);

                RecordEvent(DeviceWorkflowMarker.AppButtonPress, "SafeCom " + SolutionButtonTitle);
                _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", SolutionButtonTitle, JediWindjammerLaunchHelper.OxpdFormIdentifier, StringMatch.Contains, TimeSpan.FromSeconds(30));
            }
            else // AuthenticationMode.Lazy
            {
                RecordEvent(DeviceWorkflowMarker.AppButtonPress, "SafeCom " + SolutionButtonTitle);
                //_controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", SolutionButtonTitle, JediWindjammerLaunchHelper.SIGNIN_FORM, TimeSpan.FromSeconds(30));
                _controlPanel.ScrollPressNavigate("mAccessPointDisplay", "Title", SolutionButtonTitle, JediWindjammerLaunchHelper.SIGNIN_FORM, true);
                Authenticate(authenticator, JediWindjammerLaunchHelper.OxpdFormIdentifier);
            }
        }
        /// <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);
        }