Ejemplo 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}");
            }
        }
Ejemplo n.º 2
0
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

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

                // Load the network folder application
                _folderApp = NetworkFolderAppFactory.Create(device);

                _folderApp.WorkflowLogger = WorkflowLogger;
                _folderApp.Pacekeeper     = new Pacekeeper(_data.AutomationPause);
                if (_folderApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
                else
                {
                    throw new DeviceWorkflowException(result.Message);
                }
            }
            finally
            {
                SetJobEndStatus(result);
                // We got far enough to start the scan job, so submit the log
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
Ejemplo n.º 3
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));
            }

            // Update the destination type
            ScanLog.ScanType = _data.DestinationType;

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

            InitializeAuthenticator(_data.AuthProvider, device, ExecutionData);
            // Load the network folder application
            _folderApp = NetworkFolderAppFactory.Create(device);

            _folderApp.WorkflowLogger = Authenticator.WorkflowLogger = WorkflowLogger;
            _folderApp.Pacekeeper     = Authenticator.Pacekeeper = new Pacekeeper(_data.AutomationPause);
            _folderApp.Launch(Authenticator, !_data.ApplicationAuthentication ? AuthenticationMode.Eager : AuthenticationMode.Lazy);

            // Apply settings from the configuration
            if (_data.UseQuickset)
            {
                _folderApp.SelectQuickset(_data.QuickSetName);
            }
            else
            {
                //Network credential being passed as parameter to access the folder and it is used by jediomninetworkfolderapp now
                _folderApp.AddFolderPath(_data.FolderPath, ExecutionData.Credential, _data.ApplyCredentialsOnVerification);
            }

            // Update the destination count
            ScanLog.DestinationCount = (_data.DestinationCount > 0 ?
                                        (short)_data.DestinationCount :
                                        (short)_folderApp.GetDestinationCount());

            // Enter the file name
            _folderApp.EnterFileName(FilePrefix.ToString().ToLowerInvariant());

            //Sets the scan job options
            SetOptions(_data.ScanOptions, _folderApp.Options.GetType(), _folderApp.GetType(), device);
            ScanLog.Ocr = _data.UseOcr;

            // Set job build
            _folderApp.Options.SetJobBuildState(UseJobBuild);
        }
        /// <summary>
        /// Networks the folder lazy authentication.
        /// </summary>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="device">The device.</param>
        protected void NetworkFolderLazyAuth(IAuthenticator authenticator, IDevice device)
        {
            INetworkFolderApp networkFolderApp = NetworkFolderAppFactory.Create(device);

            networkFolderApp.Launch(authenticator, AuthenticationMode.Lazy);
        }
Ejemplo n.º 5
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);
        }