/// <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); }