Esempio n. 1
0
        internal static void LaunchApp(IDevice device, string appName, IAuthenticator auth)
        {
            switch (appName)
            {
            case "E-mail":
                var app = EmailAppFactory.Create(device);
                app.Launch(auth, AuthenticationMode.Lazy);
                break;

            case "Fax":
                var appFax = FaxAppFactory.Create(device);
                appFax.Launch(auth, AuthenticationMode.Lazy);
                break;

            case "Workflow":
                var appWorkflow = DssWorkflowAppFactory.Create(device);
                appWorkflow.Launch(auth, AuthenticationMode.Lazy);
                break;

            case "Save to Network Folder":
                var appFolder = NetworkFolderAppFactory.Create(device);
                appFolder.Launch(auth, AuthenticationMode.Lazy);
                break;

            case "Copy":
                var app1 = CopyAppFactory.Create(device);
                app1.Launch(auth, AuthenticationMode.Lazy);
                break;

            default:
                throw new DeviceWorkflowException($"Unknown application: {appName}");
            }
        }
Esempio n. 2
0
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            // Start the job
            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions();
                if (UseJobBuild)
                {
                    options.JobBuildSegments = _data.ScanOptions.PageCount;
                }
                options.ImagePreview = (ImagePreviewOption)_data.ImagePreviewOptions;

                _emailApp = EmailAppFactory.Create(device);

                // Special handling for Sirius/Phoenix
                var emailAppWithAddressSource = _emailApp as IEmailAppWithAddressSource;
                if (emailAppWithAddressSource != null)
                {
                    emailAppWithAddressSource.AddressSource = _data.AddressSource;
                    emailAppWithAddressSource.FromAddress   = ExecutionData.Credential.UserName;
                }

                _emailApp.WorkflowLogger = WorkflowLogger;
                _emailApp.Pacekeeper     = new Pacekeeper(_data.AutomationPause);
                if (_emailApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                    ScanLog.JobEndStatus = "Success";
                }
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
        /// <summary>
        /// Emails via the lazy authentication.
        /// </summary>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="device">The device.</param>
        protected void EmailLazyAuth(IAuthenticator authenticator, IDevice device)
        {
            IEmailApp emailApp = EmailAppFactory.Create(device);

            emailApp.Launch(authenticator, AuthenticationMode.Lazy);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// Sets up the scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override void SetupJob(IDevice device)
        {
            ScanLog.JobEndStatus = "Failed";
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");

            InitializeAuthenticator(_data.AuthProvider, device, ExecutionData);

            // Load the email application
            _emailApp = EmailAppFactory.Create(device);

            // need to add the ability for user to set eager or lazy authentication
            AuthenticationMode am = (_data.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

            // Special handling for Sirius/Phoenix
            var emailAppWithAddressSource = _emailApp as IEmailAppWithAddressSource;

            if (emailAppWithAddressSource != null)
            {
                emailAppWithAddressSource.AddressSource = _data.AddressSource;
                emailAppWithAddressSource.FromAddress   = ExecutionData.Credential.UserName;
            }

            _emailApp.WorkflowLogger = Authenticator.WorkflowLogger = WorkflowLogger;
            _emailApp.Pacekeeper     = Authenticator.Pacekeeper = new Pacekeeper(_data.AutomationPause);
            if (_data.UseQuickset)
            {
                if (!_data.LaunchQuicksetFromApp)
                {
                    _emailApp.LaunchFromQuickSet(Authenticator, am, _data.QuickSetName);
                }
                else
                {
                    _emailApp.Launch(Authenticator, am);
                    _emailApp.SelectQuickset(_data.QuickSetName);
                }
                EnterFileName();
            }
            else
            {
                _emailApp.Launch(Authenticator, am);

                // Apply settings from the configuration
                List <string> emailAddresses = new List <string>();
                string        emailAddress   = string.Empty;
                string[]      emailsList     = _data.EmailAddress.Split(';');
                foreach (string email in emailsList)
                {
                    emailAddress = email;
                    if (emailAddress != string.Empty)
                    {
                        if (!IsValidEmail(emailAddress))
                        {
                            emailAddress = new EmailBuilder(emailAddress, ExecutionData).ToString();
                        }

                        emailAddresses.Add(emailAddress);
                    }
                }

                _emailApp.EnterToAddress(emailAddresses);
                EnterFileName();

                // Select the appropriate file type
                // emailApp.Options.SelectFileType(_data.UseOcr ? "Searchable PDF (OCR)" : "PDF");
                //Sets the scan job options
                SetOptions(_data.ScanOptions, _emailApp.Options.GetType(), _emailApp.GetType(), device);
            }

            ScanLog.Ocr = _data.UseOcr;

            // Set job build
            _emailApp.Options.SetJobBuildState(UseJobBuild);
        }