コード例 #1
0
        private PluginExecutionResult RunTwain(IDevice device, PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            _activityData = _executionData.GetMetadata <TwainDriverActivityData>();
            var preparationManager = DevicePreparationManagerFactory.Create(device);

            preparationManager.InitializeDevice(true);
            TopCatUIAutomation.Initialize();

            if (_activityData.TwainOperation == TwainOperation.Install)
            {
                InstallTwainDriver(device);
            }
            else if (_activityData.TwainOperation == TwainOperation.DeviceAddition)
            {
                DeviceAddition(device);
            }
            else
            {
                ConfigureSettings(device, executionData.SessionId, executionData.Credential.UserName);
            }

            preparationManager.Reset();
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the device.
        /// </summary>
        protected virtual void InitializeDevice()
        {
            try
            {
                Device = DeviceConstructor.Create(DeviceInfo);
                var preparationManager = DevicePreparationManagerFactory.Create(Device);
                preparationManager.InitializeDevice(AuthProvider != AuthenticationProvider.Skip);
                _collectMemoryManager = new CollectMemoryManager(Device, DeviceInfo);
            }
            catch (Exception ex)
            {
                // Make sure the device is disposed, if necessary
                if (Device != null)
                {
                    Device.Dispose();
                    Device = null;
                }

                ExecutionServices.SessionRuntime.ReportAssetError(DeviceInfo);

                // Log the error and re-throw.
                ExecutionServices.SystemTrace.LogError(ex);
                throw;
            }
        }
コード例 #3
0
        /// <summary>
        /// The sign-out operation desired.
        /// </summary>
        /// <param name="signOut">The sign out.</param>
        public void SignOut(DeviceSignOutMethod signOut, IDevice device)
        {
            IDevicePreparationManager dpm = DevicePreparationManagerFactory.Create(device);

            dpm.WorkflowLogger = _workflowLogger;
            dpm.SignOut(signOut);
        }
コード例 #4
0
        /// <summary>
        /// Navigates to the home screen.
        /// </summary>
        protected override void SignOut()
        {
            if (_linkScanApp != null)
            {
                RecordEvent(DeviceWorkflowMarker.DeviceSignOutBegin);
                _linkScanApp.BacktoHomeScreen();
                RecordEvent(DeviceWorkflowMarker.DeviceSignOutEnd);
            }

            if (_device != null)
            {
                var devicePrepManager = DevicePreparationManagerFactory.Create(_device);
                devicePrepManager.NavigateHome();
            }
        }
コード例 #5
0
        public PluginExecutionResult RunJetAdvantage()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            try
            {
                SetDataLogger();
                _jetAdvantageApp = JetAdvantageFactory.Create(_device);
                _jetAdvantageApp.WorkflowLogger = WorkflowLogger;

                IDevicePreparationManager dpm = DevicePreparationManagerFactory.Create(_device);
                dpm.InitializeDevice(true);
                dpm.WorkflowLogger = WorkflowLogger;

                _jetAdvantageApp.ActivityStatusChange += _jetAdvantageApp_ActivityStatusChange;
                LaunchJetAdvantage();
                _jetAdvantageApp.RunHPJetAdvantage(_activityData.PrintAllDocuments, _activityData.DeleteAfterPrint);

                RecordEvent(DeviceWorkflowMarker.DeviceSignOutBegin);
                _jetAdvantageApp.Logout();
                RecordEvent(DeviceWorkflowMarker.DeviceSignOutEnd);

                if (!_jetAdvantageApp.DocumentPrinted)
                {
                    string logText = string.Format("No print jobs found to pull; user {0}", _activityData.JetAdvantageLoginId);
                    result = new PluginExecutionResult(PluginResult.Skipped, logText);
                    OnStatusUpdate(logText);
                }

                UpdateDataLogger(result);

                dpm.NavigateHome();
                dpm.SignOut();
            }
            catch (Exception ex)
            {
                string message = ex.ToString();
                if (!string.IsNullOrEmpty(message) && message.Length > 1024)
                {
                    message = message.Substring(0, 1024);
                }
                result = new PluginExecutionResult(PluginResult.Failed, message, "JetAdvantage Error");

                UpdateDataLogger(result);
                throw;
            }
            return(result);
        }
コード例 #6
0
        private PluginExecutionResult EvaluateByControlPanel()
        {
            try
            {
                //navigate to message center
                var jediDevice = _device as JediOmniDevice;
                if (jediDevice == null)
                {
                    return(new PluginExecutionResult(PluginResult.Skipped, "Only Jedi Omni devices supported"));
                }
                var preparationManager = DevicePreparationManagerFactory.Create(jediDevice);
                preparationManager.WakeDevice();
                jediDevice.ControlPanel.PressHome();
                if (!jediDevice.ControlPanel.WaitForState(".hp-button-message-center", OmniElementState.Useable,
                                                          TimeSpan.FromSeconds(5)))
                {
                    //if message center is not available it means that we might not have any events. check if we are checking for presence or absence of message here and pass or fail the activity accordingly
                    controlPanel_pictureBox.Image = jediDevice.ControlPanel.ScreenCapture();
                    return(!_activityData.Presence
                        ? new PluginExecutionResult(PluginResult.Passed,
                                                    "Messege center is not active, no warning or errors found. Passing the activity.")
                        : new PluginExecutionResult(PluginResult.Failed,
                                                    "Message center is not active, no warning or errors found. Failing the activity."));
                }

                jediDevice.ControlPanel.PressWait(".hp-button-message-center", "#hpid-message-center-screen",
                                                  TimeSpan.FromSeconds(5));
                controlPanel_pictureBox.Image = jediDevice.ControlPanel.ScreenCapture();

                var description   = _activityData.Message.GetDescription();
                var foundMessage  = FindMessage(jediDevice, description);
                var resultMessage = _activityData.Presence
                    ? $"Checked for presence of {_activityData.Message}"
                    : $"Checked for absence of {_activityData.Message}";
                jediDevice.ControlPanel.PressHome();
                return(foundMessage == _activityData.Presence
                    ? new PluginExecutionResult(PluginResult.Passed, resultMessage)
                    : new PluginExecutionResult(PluginResult.Failed, resultMessage));
            }
            catch (OmniInvalidOperationException e)
            {
                return(new PluginExecutionResult(PluginResult.Failed, e));
            }
            catch (DeviceCommunicationException d)
            {
                return(new PluginExecutionResult(PluginResult.Failed, d));
            }
        }
コード例 #7
0
        /// <summary>
        /// Sets up the CloudConnector scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override void SetupJob(IDevice device)
        {
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            _UdocxScanApp = UdocxScanAppFactory.Create(device);
            _UdocxScanApp.WorkflowLogger = WorkflowLogger;
            devicePrepManager.Reset();
            InitializeAuthenticator(_activityData.AuthProvider, device, ExecutionData);
            AuthenticationMode am = (_activityData.UdocxScanAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

            Launch();
        }
コード例 #8
0
        /// <summary>
        /// Signs the user out of the device.
        /// </summary>
        /// <param name="_pullPrintApp"></param>
        protected void SignOut(IDeviceWorkflowLogSource _pullPrintApp)
        {
            DateTime startTime = DateTime.Now;

            try
            {
                IDevicePreparationManager manager = DevicePreparationManagerFactory.Create(Device);
                manager.WorkflowLogger = _pullPrintApp.WorkflowLogger;
                manager.NavigateHome();
                manager.SignOut();
            }
            catch (Exception ex)
            {
                OnStatusUpdate(ex.Message);
                ExecutionServices.SystemTrace.LogError(ex.ToString());
            }

            OnTimeStatusUpdate("SignOut", startTime, DateTime.Now);
        }
コード例 #9
0
ファイル: SafecomJedi.cs プロジェクト: ProjectAgri20/newrepo
        /// <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}");
            }
        }
コード例 #10
0
        /// <summary>
        /// Performs ScanToJobStorage job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="jobStorageScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteJobStorageActivity(IDevice device, ScanActivityData jobStorageScanData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            // Make sure the device is in a good state
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            devicePrepManager.WorkflowLogger = WorkflowLogger;
            devicePrepManager.InitializeDevice(true);

            // Load the Job storage application
            IJobStorageScanApp contentionJobStorageApp = ScanJobStorageAppFactory.Create(device);

            //Launch the Scan To Job Storage application
            UpdateStatus("ScanToJobStorage Activity: Launching the Scan To Job Storage application...");
            contentionJobStorageApp.Launch(authenticator, AuthenticationMode.Lazy);

            //Enter the job name
            ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Job Storage");

            FilePrefix.MaxLength = 16;
            UpdateStatus("ScanToJobStorage Activity: Entering job name...");
            contentionJobStorageApp.AddJobName(FilePrefix.ToString().ToLowerInvariant());

            // Set job build
            contentionJobStorageApp.Options.SetJobBuildState((jobStorageScanData.PageCount > 1) ? true : false);

            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                options.ValidateJobExecution = false;
                if (jobStorageScanData.PageCount > 1)
                {
                    options.JobBuildSegments = jobStorageScanData.PageCount;
                }

                //Finish the job
                UpdateStatus("ScanToJobStorage Activity: Finishing the activity...");
                if (contentionJobStorageApp.ExecuteScanJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("ScanToJobStorage Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                    UpdateStatus("ScanToJobStorage Activity: Activity finished");
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}");
                }
            }
            finally
            {
                // End of ScanToJobStorage activity
                ExecutionServices.SystemTrace.LogDebug("ScanToJobStorage activity completed");
            }

            return(result);
        }
コード例 #11
0
        private PluginExecutionResult RunApp(IDevice device)
        {
            try
            {
                PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed);

                _activityData = _executionData.GetMetadata <PrintFromJobStorageActivityData>();

                IJobStoragePrintApp jobStorageApp = JobStoragePrintAppFactory.Create(device);
                IAuthenticator      authenticator = GetAuthenticator(_activityData.AuthProvider, device);

                AuthenticationMode am = (_activityData.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

                var preparationManager = DevicePreparationManagerFactory.Create(device);
                preparationManager.InitializeDevice(true);

                jobStorageApp.Pacekeeper = authenticator.Pacekeeper = new Pacekeeper(TimeSpan.FromSeconds(2));
                jobStorageApp.Launch(authenticator, am);
                UpdateStatus("The Print From Job Storage app is launched");

                jobStorageApp.SelectFolder(_activityData.FolderName);
                UpdateStatus($"The Selected Folder: '{_activityData.FolderName}'");

                if (_activityData.PrintAll)
                {
                    bool allJobsSelected;
                    allJobsSelected = jobStorageApp.SelectAllJobs(_activityData.Pin, _activityData.FolderName);
                    if (allJobsSelected)
                    {
                        jobStorageApp.ExecutePrintJob();
                        UpdateStatus("All jobs are selected and printed");
                        if (_activityData.DeleteJobAfterPrint)
                        {
                            try
                            {
                                jobStorageApp.DeletePrintedJob();
                                UpdateStatus("All Selected Jobs were deleted");
                            }
                            catch (JobStorageDeleteJobExeception ex)
                            {
                                string message = $"The selected Job was not deleted. {ex.ToString()}";
                                LogDebug(message);
                                UpdateStatus(message);
                            }
                        }
                        result = new PluginExecutionResult(PluginResult.Passed);
                    }
                }
                else
                {
                    jobStorageApp.SelectFirstJob(_activityData.Pin, _activityData.NumberOfCopies, _activityData.FolderName);
                    UpdateStatus("The first job is selected");
                    jobStorageApp.ExecutePrintJob();
                    UpdateStatus("The first job is printed");
                    if (_activityData.DeleteJobAfterPrint)
                    {
                        try
                        {
                            jobStorageApp.DeletePrintedJob();
                            UpdateStatus("The Selected job was deleted");
                        }
                        catch (JobStorageDeleteJobExeception ex)
                        {
                            string message = $"The selected Job was not deleted. {ex.ToString()}";
                            LogDebug(message);
                            UpdateStatus(message);
                        }
                    }
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
                preparationManager.Reset();
                return(result);
            }
            catch (DeviceCommunicationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
            }
            catch (Exception ex)
            {
                GatherTriageData(device, ex.ToString());
                throw;
            }
        }
コード例 #12
0
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceInspectorActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(5);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(5);
            ConcurrentDictionary <string, DataPair <string> > verifiedResults = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                return(new PluginExecutionResult(PluginResult.Failed, "There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(),asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }


                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var verifiedResult = UpdateDevice(device, asset);
                            verifiedResults.AddOrUpdate(asset.AssetId, verifiedResult, (key, oldvalue) => UpdateDevice(device, asset));
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                                    (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                                    (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        device?.Dispose();
                    }
                }
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var verifiedResult in verifiedResults)
            {
                UpdateStatus($"Device: {verifiedResult.Key} Result: {verifiedResult.Value.Value}, {verifiedResult.Value.Key}");
            }

            if (verifiedResults.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }
コード例 #13
0
        /// <summary>
        /// Device side operation for Twain Scan
        /// </summary>
        /// <param name="twainDriver"></param>
        /// <param name="deviceDetails"></param>
        public static void ExecuteJob(IDevice deviceDetails, TwainDriverActivityData twainDriver)
        {
            JediOmniDevice            device             = (JediOmniDevice)deviceDetails;
            IDevicePreparationManager preparationManager = DevicePreparationManagerFactory.Create(device);

            preparationManager.WakeDevice();
            //Checking For Home Screen
            if (!device.ControlPanel.WaitForState("#hpid-homescreen-logo-icon", OmniElementState.VisibleCompletely, TimeSpan.FromSeconds(1)))
            {
                preparationManager.NavigateHome();
            }

            device.ControlPanel.ScrollPress("#hpid-scan-homescreen-button");
            if (device.ControlPanel.WaitForState("#hpid-remoteScanRequest-homescreen-button", OmniElementState.Exists))
            {
                device.ControlPanel.ScrollToItem("#hpid-remoteScanRequest-homescreen-button");
                device.ControlPanel.PressWait("#hpid-remoteScanRequest-homescreen-button", "#hpid-remote-scan-request-landing-page");
                if (device.ControlPanel.WaitForState("#hpid-remote-scan-request-job-list-item", OmniElementState.Exists))
                {
                    if (device.ControlPanel.WaitForState("#hpid-remote-scan-request-job-list-item", OmniElementState.Useable, ScreenWaitTimeout))
                    {
                        device.ControlPanel.Press("#hpid-remote-scan-request-job-list-item:first");
                    }
                    else
                    {
                        device.ControlPanel.Press("#hpid-remote-scan-request-unlock-private-jobs:first");
                        if (device.ControlPanel.CheckState("#undefined", OmniElementState.Exists))
                        {
                            device.ControlPanel.PressWait("#hpid-pin-to-unlock-job-textbox", "#hpid-keyboard", ShortScreenWaitTimeout);
                            device.ControlPanel.TypeOnVirtualKeyboard(twainDriver.Pin);
                            //Check for 4.3 inch control panel where the keypad/keyboard hides the 'OK' button after entering the Pin/Password.
                            //Close the numeric keypad after PIN is entered
                            if (device.ControlPanel.CheckState("#hpid-keypad-key-close", OmniElementState.Exists))
                            {
                                device.ControlPanel.Press("#hpid-keypad-key-close");
                            }
                            //Close the virtual keyboard after PIN/Password is entered
                            else if (device.ControlPanel.CheckState("#hpid-keyboard-key-done", OmniElementState.Exists))
                            {
                                device.ControlPanel.Press("#hpid-keyboard-key-done");
                            }
                            device.ControlPanel.Press("#hpid-button-ok");
                            //Automatic selection of job was not happening when reservation was enabled and a password is set for Remote Scan Request using Twain driver in the previous device firmware.Now the issue is fixed in device firmware 2458466 and above
                            //Hence commenting the below line of code
                            //device.ControlPanel.Press("#hpid-remote-scan-request-job-list-item:first");

                            if (device.ControlPanel.CheckState(".hp-popup-modal-overlay", OmniElementState.Exists))
                            {
                                throw new DeviceWorkflowException("Invalid Pin/Pin Not Entered");
                            }
                        }
                    }

                    if (device.ControlPanel.WaitForState("#hpid-button-remote-scan-request-start", OmniElementState.Useable, ScreenWaitTimeout))
                    {
                        device.ControlPanel.Press("#hpid-button-remote-scan-request-start");
                        if (device.ControlPanel.WaitForState("#hpid-button-ok", OmniElementState.Exists, ShortScreenWaitTimeout))
                        {
                            device.ControlPanel.Press("#hpid-button-ok");
                            device.ControlPanel.Press("#hpid-button-remote-scan-request-start");
                        }
                    }
                }
                else
                {
                    throw new DeviceWorkflowException("No Remote scan jobs found.");
                }
            }
            else
            {
                throw new DeviceWorkflowException("Remote Scan Request was not found in the scan folder.");
            }

            if (device.ControlPanel.WaitForState("#hpid-message-center-screen", OmniElementState.Exists, ShortScreenWaitTimeout))
            {
                throw new DeviceWorkflowException("There is an error displayed on the device, Please check the device and try again");
            }
        }
コード例 #14
0
        protected override PluginExecutionResult ExecuteLinkScan(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                // Make sure the device is in a good state
                var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                devicePrepManager.InitializeDevice(false);

                if (_data.SIO.Equals(SIOMethod.NoneSIO))
                {
                    devicePrepManager.Reset();
                }

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");
                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                // Clean up
                try
                {
                    SignOut();
                    //NavigateHome();
                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);

                    try
                    {
                        CollectJetAdvantagelinkMemoryMonitoring(deviceInfo);
                    }
                    catch (Exception ex)
                    {
                        SubmitConnectorLog(result.Result.ToString());
                        return(result);
                    }
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData) && ex.Data[_exceptionCategoryData].Equals(ConnectorExceptionCategory.EnvironmentError.GetDescription()))
                {
                    result = new PluginExecutionResult(PluginResult.Error, ex, $"Webview communication error - You need check \"Debuggable option enable\" to hpk file: {ex.Message}");
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, $"Device communication error: {ex.Message}");
                }
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, $"Device automation error: {ex.Message}");
            }
            catch (DeviceWorkflowException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData))
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, ex.Data[_exceptionCategoryData].ToString());
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                }

                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            SubmitConnectorLog(result.Result.ToString());
            return(result);
        }
コード例 #15
0
        /// <summary>
        /// Executes the scan job using the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">The device information.</param>
        /// <returns>The result of execution.</returns>
        protected virtual PluginExecutionResult ExecuteScan(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                // Make sure the device is in a good state
                var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                devicePrepManager.InitializeDevice(true);

                // Configure the device (apply settings, load simulator ADF, etc.)
                UpdateStatus("Configuring device...");
                ConfigureDevice(deviceInfo);
                ScanLog.PageCount = (short)ScanOptions.PageCount;
                ScanLog.Sender    = ExecutionData.Credential.UserName;

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");
                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();

                    if (devicePrepManager.SignOutRequired())
                    {
                        devicePrepManager.SignOut();
                    }
                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    LogWarn("Device could not return to home screen.");
                    GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            return(result);
        }
コード例 #16
0
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            //bool result = false;
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceConfigurationActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(10);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(20);
            ConcurrentDictionary <string, DataPair <string> > results = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                return(new PluginExecutionResult(PluginResult.Failed, "There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(), asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        //DeviceConfigResultLog log = new DeviceConfigResultLog(_executionData, asset.AssetId);
                        SetDefaultPassword(asset.Address, asset.AdminPassword);

                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }

                        //devicePrepManager.PerformanceLogger = PerformanceLogger;

                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var result = UpdateDevice(device, (AssetInfo)asset, _executionData);
                            results.AddOrUpdate(asset.AssetId, result,
                                                (key, oldValue) => UpdateDevice(device, (AssetInfo)asset, _executionData));
                            device?.Dispose();
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        results.AddOrUpdate(asset.AssetId,
                                            new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                            (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        results.AddOrUpdate(asset.AssetId,
                                            new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                            (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        //[Veda]:we had few in use inspection pages error in subsequent plugin/activities, which was as a result of this plugin failing
                        //eg: invalid xml content. disposing the device to avoid those problems
                        device?.Dispose();
                    }
                }//);
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var item in results)
            {
                UpdateStatus($"Device {item.Key}: Result: {item.Value.Value}, {item.Value.Key}");
            }

            if (results.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }
コード例 #17
0
        /// <summary>
        /// Executes the scan job using the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">The device information.</param>
        /// <returns>The result of execution.</returns>
        protected override PluginExecutionResult ExecuteLinkPrint(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                // Make sure the device is in a good state
                var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                //devicePrepManager.InitializeDevice();

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");

                _regusKioskApp = new RegusKioskApp(device);
                _regusKioskApp.WorkflowLogger = WorkflowLogger;
                _regusKioskApp.DeviceInfo     = deviceInfo;

                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                // Clean up
                try
                {
                    UpdateStatus("SignOut Start");
                    SignOut();
                    UpdateStatus("SignOut finished");

                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);

                    try
                    {
                        CollectJetAdvantagelinkMemoryMonitoring(deviceInfo);
                    }
                    catch (Exception ex)
                    {
                        UpdateStatus(ex.ToString());

                        SubmitConnectorLog(result.Result.ToString());
                        return(result);
                    }
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    UpdateStatus("Device could not return to home screen.");
                    GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error.");
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error.");
            }
            catch (DeviceWorkflowException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData))
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, ex.Data[_exceptionCategoryData].ToString());
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                }

                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            SubmitConnectorLog(result.Result.ToString());
            return(result);
        }
コード例 #18
0
        /// <summary>
        /// Performs ScanToFolder job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="folderScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteFolderActivity(IDevice device, ScanActivityData folderScanData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            // Make sure the device is in a good state
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            devicePrepManager.WorkflowLogger = WorkflowLogger;
            devicePrepManager.InitializeDevice(true);

            // Load the network folder application
            INetworkFolderApp contentionFolderApp = NetworkFolderAppFactory.Create(device);

            //Launch the Scan to Network Folder app
            UpdateStatus("ScanToFolder Activity: Launching the Scan To Folder application...");
            contentionFolderApp.Launch(authenticator, AuthenticationMode.Lazy);

            //Network credential being passed as parameter to access the folder and it is used by jediomninetworkfolderapp now
            UpdateStatus("ScanToFolder Activity: Entering folder path...");
            contentionFolderApp.AddFolderPath(folderScanData.FolderPath, ExecutionData.Credential, true);

            // Enter the file name
            ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Folder");

            UpdateStatus("ScanToFolder Activity: Entering file name...");
            contentionFolderApp.EnterFileName(FilePrefix.ToString().ToLowerInvariant());

            // Set job build
            contentionFolderApp.Options.SetJobBuildState((folderScanData.PageCount > 1) ? true : false);

            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                options.ValidateJobExecution = false;
                if (folderScanData.PageCount > 1)
                {
                    options.JobBuildSegments = folderScanData.PageCount;
                }

                //Finish the job
                UpdateStatus("ScanToFolder Activity: Finishing the activity...");
                if (contentionFolderApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
                else
                {
                    throw new DeviceWorkflowException(result.Message);
                }

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("ScanToFolder Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                    UpdateStatus("ScanToFolder Activity: Activity finished");
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}");
                }
            }
            finally
            {
                // End of ScanToFolder activity
                ExecutionServices.SystemTrace.LogDebug("ScanToFolder activity completed");
            }

            return(result);
        }
コード例 #19
0
        /// <summary>
        /// Performs ScanToEmail job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="emailScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteEmailActivity(IDevice device, ScanActivityData emailScanData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            // Make sure the device is in a good state
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            devicePrepManager.WorkflowLogger = WorkflowLogger;
            devicePrepManager.InitializeDevice(true);

            // Load the email application
            IEmailApp contentionEmailApp = EmailAppFactory.Create(device);

            //Launch the Scan to Email application
            UpdateStatus("ScanToEmail Activity: Launching the Scan To Email application...");
            contentionEmailApp.Launch(authenticator, AuthenticationMode.Lazy);

            //Enter subject and file name
            ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Email");
            string         fileName   = FilePrefix.ToString().ToLowerInvariant();

            contentionEmailApp.EnterSubject(fileName);
            UpdateStatus("ScanToEmail Activity: Email subject entered...");
            contentionEmailApp.EnterFileName(fileName);
            UpdateStatus("ScanToEmail Activity: File name entered...");

            List <string> emailList = new List <string>();

            emailList.Add(emailScanData.EmailAddress);
            //Enter email address
            contentionEmailApp.EnterToAddress(emailList);
            UpdateStatus("ScanToEmail Activity: Email address entered...");

            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                options.ValidateJobExecution = false;
                if (emailScanData.PageCount > 1)
                {
                    options.JobBuildSegments = emailScanData.PageCount;
                }

                //Finish the job
                UpdateStatus("ScanToEmail Activity: Finishing the activity...");
                if (contentionEmailApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("ScanToEmail Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                    UpdateStatus("ScanToEmail Activity: Activity finished");
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}");
                }
            }
            finally
            {
                // End of ScanToEmail activity
                ExecutionServices.SystemTrace.LogDebug("ScanToEmail activity completed");
            }

            return(result);
        }
コード例 #20
0
        /// <summary>
        /// Performs Copy job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="controlPanelData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteCopy(IDevice device, object controlPanelData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            CopyActivityData copyData = controlPanelData as CopyActivityData;

            // Make sure the device is in a good state
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            devicePrepManager.WorkflowLogger = WorkflowLogger;
            devicePrepManager.InitializeDevice(true);

            // Load the copy application
            ICopyApp contentionCopyApp = CopyAppFactory.Create(device);

            //Launch the Copy application
            UpdateStatus("Copy Activity: Launching the Copy application...");
            contentionCopyApp.Launch(authenticator, AuthenticationMode.Lazy);

            //set number of copies
            contentionCopyApp.Options.SetNumCopies(copyData.Copies);
            UpdateStatus("Copy Activity: Number of Copies has been set...");

            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                options.ValidateJobExecution = false;
                if (copyData.PageCount > 1)
                {
                    options.JobBuildSegments = copyData.PageCount;
                }

                //Finish the job
                UpdateStatus("Copy Activity: Finishing the activity...");
                if (contentionCopyApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("Copy Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                    UpdateStatus("Copy Activity: Activity finished");
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}");
                }
            }
            finally
            {
                // End of Copy activity
                ExecutionServices.SystemTrace.LogDebug("Copy Activity Completed");
            }

            return(result);
        }
コード例 #21
0
        private PluginExecutionResult RunApp(IDevice device)
        {
            try
            {
                PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed);

                _activityData = _executionData.GetMetadata <PrintFromUsbActivityData>();

                IUsbApp        usbApp = UsbAppFactory.Create(device);
                IAuthenticator auth   = AuthenticatorFactory.Create(device, _executionData.Credential, AuthenticationProvider.Auto);

                usbApp.WorkflowLogger = auth.WorkflowLogger = _workflowLogger;

                var preparationManager = DevicePreparationManagerFactory.Create(device);
                preparationManager.InitializeDevice(true);
                preparationManager.WorkflowLogger = _workflowLogger;

                // need to add the ability for user to set eager or lazy authentication
                //AuthenticationMode am = (_data.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

                usbApp.Pacekeeper = auth.Pacekeeper = new Pacekeeper(TimeSpan.FromSeconds(2));
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                usbApp.LaunchPrintFromUsb(auth, AuthenticationMode.Lazy);
                UpdateStatus("The Print From USB app is launched");

                usbApp.SelectUsbPrint(_activityData.UsbName);
                UpdateStatus("The USB is selected");

                usbApp.SelectFile();
                UpdateStatus("File to Print is selected");

                if (usbApp.ExecutePrintJob())
                {
                    UpdateStatus("The selected file is printed");
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                preparationManager.NavigateHome();
                if (preparationManager.SignOutRequired())
                {
                    preparationManager.SignOut();
                }
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityEnd);
                return(result);
            }
            catch (DeviceCommunicationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
            }
            catch (Exception ex)
            {
                GatherTriageData(device, ex.ToString());
                throw;
            }
        }
コード例 #22
0
        /// <summary>
        /// Performs Fax job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="controlPanelData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteFax(IDevice device, object controlPanelData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            FaxActivityData faxData = controlPanelData as FaxActivityData;

            // Make sure the device is in a good state
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            devicePrepManager.WorkflowLogger = WorkflowLogger;
            devicePrepManager.InitializeDevice(true);

            // Load the fax application
            IFaxApp contentionFaxApp = FaxAppFactory.Create(device);

            //Launch the Fax application
            UpdateStatus("Fax Activity: Launching the Fax application...");
            contentionFaxApp.Launch(authenticator, AuthenticationMode.Lazy);

            ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Fax");

            UpdateStatus("Fax Activity: Entering recipient fax number...");
            if (string.IsNullOrEmpty(faxData.FaxNumber) || string.IsNullOrWhiteSpace(faxData.FaxNumber))
            {
                // Apply settings from configuration
                contentionFaxApp.AddRecipient(FilePrefix.ToFaxCode());
            }
            else
            {
                contentionFaxApp.AddRecipient(faxData.FaxNumber);
            }

            //Set job build
            contentionFaxApp.Options.SetJobBuildState((faxData.PageCount > 1) ? true : false);

            try
            {
                // Start the job
                ScanExecutionOptions options = new ScanExecutionOptions();
                options.ValidateJobExecution = false;
                if (faxData.PageCount > 1)
                {
                    options.JobBuildSegments = faxData.PageCount;
                }

                //Finish the job
                UpdateStatus("Fax Activity: Finishing the activity...");
                if (contentionFaxApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("Fax Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}");
                }
            }
            finally
            {
                // End of fax activity
                ExecutionServices.SystemTrace.LogDebug("Fax activity completed");
            }

            return(result);
        }