/// <summary> /// Finish up the copy job. /// </summary> /// <param name="device">The device.</param> 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 (UseJobBuild) { options.JobBuildSegments = _data.ScanOptions.PageCount; } _jobStorageScanApp.Pacekeeper = new Pacekeeper(_data.AutomationPause); if (_jobStorageScanApp.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); }
/// <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); }