private bool SendFaxFinishJob(IDevice device) { // Start the job ScanExecutionOptions options = new ScanExecutionOptions(); if (this.UseJobBuild) { options.JobBuildSegments = _data.ScanOptions.PageCount; } return(_faxApp.ExecuteJob(options)); }
/// <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); }