Exemplo n.º 1
0
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                if (this.UseJobBuild)
                {
                    options.JobBuildSegments = _data.ScanOptions.PageCount;
                }

                _usbApp.Pacekeeper = new Pacekeeper(_data.AutomationPause);
                if (_usbApp.ExecuteScanJob(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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs ScanToUsb job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="usbScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteUsbActivity(IDevice device, ScanActivityData usbScanData, 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
            IUsbApp contentionUsbApp = UsbAppFactory.Create(device);

            //Launch the Scan To Job Storage application
            UpdateStatus("ScanToUSB Activity: Launching the Scan To USB application...");
            contentionUsbApp.LaunchScanToUsb(authenticator, AuthenticationMode.Lazy);

            //Select the USB device
            UpdateStatus("ScanToUSB Activity: Selecting the USB device...");
            contentionUsbApp.SelectUsbDevice(usbScanData.UsbName);

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

            UpdateStatus("ScanToUSB Activity: Entering file name...");
            contentionUsbApp.AddJobName(FilePrefix.ToString().ToLowerInvariant());

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

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

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

                // Clean up
                try
                {
                    devicePrepManager.NavigateHome();
                    if (devicePrepManager.SignOutRequired())
                    {
                        UpdateStatus("ScanToUSB Activity: Signing Out...");
                        devicePrepManager.SignOut();
                    }
                    UpdateStatus("ScanToUSB 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 ScanToUSB activity
                ExecutionServices.SystemTrace.LogDebug("ScanToUSB activity completed");
            }

            return(result);
        }