private FaxActivityData GetFaxData() { FaxActivityData faxData = new FaxActivityData(); faxData.FaxNumber = faxNumber_textBox.Text; faxData.PageCount = (int)faxPageCount_NumericUpDown.Value; return(faxData); }
/// <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); }
private void ConfigureControls(ContentionData data) { //Copy Tab Controls if (data.SelectedControlPanelActivities.OfType <CopyActivityData>().Any()) { copy_checkBox.Checked = true; CopyActivityData copyData = data.SelectedControlPanelActivities.OfType <CopyActivityData>().Single(); Copies_NumericUpDown.Value = copyData.Copies; copyPageCount_NumericUpDown.Value = copyData.PageCount; } else { copy_checkBox.Checked = false; } //Scan Tab Controls if (data.SelectedControlPanelActivities.OfType <ScanActivityData>().Any()) { scan_checkBox.Checked = true; ScanActivityData scanData = data.SelectedControlPanelActivities.OfType <ScanActivityData>().Single(); switch (scanData.ScanJobType) { case ContentionScanActivityTypes.Email: emailRadioButton.Checked = true; emailAddressTextBox.Text = scanData.EmailAddress; break; case ContentionScanActivityTypes.Folder: folderRadioButton.Checked = true; folderPathTextBox.Text = scanData.FolderPath; break; case ContentionScanActivityTypes.USB: usbRadioButton.Checked = true; usbNameTextBox.Text = scanData.UsbName; break; case ContentionScanActivityTypes.JobStorage: jobStorageRadioButton.Checked = true; break; } scanPageCount_NumericUpDown.Value = scanData.PageCount; } else { scan_checkBox.Checked = false; } //Fax Tab Controls if (data.SelectedControlPanelActivities.OfType <FaxActivityData>().Any()) { faxsend_checkBox.Checked = true; FaxActivityData faxData = data.SelectedControlPanelActivities.OfType <FaxActivityData>().Single(); faxNumber_textBox.Text = faxData.FaxNumber; faxPageCount_NumericUpDown.Value = faxData.PageCount; } else { faxsend_checkBox.Checked = false; } //Print Tab Controls if (data.SelectedContentionActivities.OfType <PrintActivityData>().Any()) { print_checkBox.Checked = true; PrintActivityData printData = data.SelectedContentionActivities.OfType <PrintActivityData>().Single(); queueNameTextBox.Text = printData.QueueName; } else { print_checkBox.Checked = false; } }