Esempio n. 1
0
        /// <summary>
        /// Finish up the copy job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            // Start the job
            try
            {
                _copyApp.WorkflowLogger = WorkflowLogger;
                ScanExecutionOptions options = new ScanExecutionOptions();
                if (this.UseJobBuild)
                {
                    options.JobBuildSegments = _data.PageCount;
                }

                if (_copyApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
Esempio n. 2
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);
        }