Exemplo n.º 1
0
        /// <summary>
        /// Performs Scan job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="controlPanelData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteScan(IDevice device, object controlPanelData, IAuthenticator authenticator)
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            ScanActivityData scanData = controlPanelData as ScanActivityData;

            switch (scanData.ScanJobType)
            {
            case ContentionScanActivityTypes.Email:
                UpdateStatus("Selected Control Panel Activity: Scan To Email");
                result = ExecuteEmailActivity(device, scanData, authenticator);
                break;

            case ContentionScanActivityTypes.Folder:
                UpdateStatus("Selected Control Panel Activity: Scan To Folder");
                result = ExecuteFolderActivity(device, scanData, authenticator);
                break;

            case ContentionScanActivityTypes.JobStorage:
                UpdateStatus("Selected Control Panel Activity: Scan To Job Storage");
                result = ExecuteJobStorageActivity(device, scanData, authenticator);
                break;

            case ContentionScanActivityTypes.USB:
                UpdateStatus("Selected Control Panel Activity: Scan To USB");
                result = ExecuteUsbActivity(device, scanData, authenticator);
                break;
            }
            return(result);
        }
        private ScanActivityData GetScanData()
        {
            ScanActivityData scanData = new ScanActivityData();

            scanData.ScanJobType  = emailRadioButton.Checked ? ContentionScanActivityTypes.Email : (folderRadioButton.Checked ? ContentionScanActivityTypes.Folder : (jobStorageRadioButton.Checked ? ContentionScanActivityTypes.JobStorage : ContentionScanActivityTypes.USB));
            scanData.PageCount    = (int)scanPageCount_NumericUpDown.Value;
            scanData.EmailAddress = emailAddressTextBox.Text;
            scanData.FolderPath   = folderPathTextBox.Text;
            scanData.UsbName      = usbNameTextBox.Text;
            return(scanData);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Performs ScanToFolder job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="folderScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteFolderActivity(IDevice device, ScanActivityData folderScanData, 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
            INetworkFolderApp contentionFolderApp = NetworkFolderAppFactory.Create(device);

            //Launch the Scan to Network Folder app
            UpdateStatus("ScanToFolder Activity: Launching the Scan To Folder application...");
            contentionFolderApp.Launch(authenticator, AuthenticationMode.Lazy);

            //Network credential being passed as parameter to access the folder and it is used by jediomninetworkfolderapp now
            UpdateStatus("ScanToFolder Activity: Entering folder path...");
            contentionFolderApp.AddFolderPath(folderScanData.FolderPath, ExecutionData.Credential, true);

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

            UpdateStatus("ScanToFolder Activity: Entering file name...");
            contentionFolderApp.EnterFileName(FilePrefix.ToString().ToLowerInvariant());

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

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

                //Finish the job
                UpdateStatus("ScanToFolder Activity: Finishing the activity...");
                if (contentionFolderApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
                else
                {
                    throw new DeviceWorkflowException(result.Message);
                }

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

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Performs ScanToEmail job on Control Panel
        /// </summary>
        /// <param name="device"></param>
        /// <param name="emailScanData"></param>
        /// <returns></returns>
        private PluginExecutionResult ExecuteEmailActivity(IDevice device, ScanActivityData emailScanData, 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 email application
            IEmailApp contentionEmailApp = EmailAppFactory.Create(device);

            //Launch the Scan to Email application
            UpdateStatus("ScanToEmail Activity: Launching the Scan To Email application...");
            contentionEmailApp.Launch(authenticator, AuthenticationMode.Lazy);

            //Enter subject and file name
            ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Email");
            string         fileName   = FilePrefix.ToString().ToLowerInvariant();

            contentionEmailApp.EnterSubject(fileName);
            UpdateStatus("ScanToEmail Activity: Email subject entered...");
            contentionEmailApp.EnterFileName(fileName);
            UpdateStatus("ScanToEmail Activity: File name entered...");

            List <string> emailList = new List <string>();

            emailList.Add(emailScanData.EmailAddress);
            //Enter email address
            contentionEmailApp.EnterToAddress(emailList);
            UpdateStatus("ScanToEmail Activity: Email address entered...");

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

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

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