/// <summary>
        /// Demonstrate document library usage.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>PluginExecutionResult.</returns>
        private PluginExecutionResult DemonstrateDocumentUsage(PluginExecutionData executionData)
        {
            PluginExecutionResult result = null;

            // Return "skipped" if no documents found
            if (executionData.Documents.Count == 0)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, "No documents specified", "No documents");
            }
            else
            {
                // List all available documents in the selection
                UpdateStatus("List all documents in the selection...");
                var enumerator = executionData.Documents.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var doc = enumerator.Current;
                    UpdateStatus($"Document {doc.FileName}, Pages={doc.Pages}, ColorMode={doc.ColorMode}");
                }
                enumerator.Reset();

                // Get a document at random from available
                UpdateStatus("Retrieving a document at random...");
                Document document = executionData.Documents.GetRandom();
                if (document != null)
                {
                    // Use the FileRepository execution service to retrieve the file from the document library and put a copy locally
                    FileInfo fileInfo = ExecutionServices.FileRepository.GetFile(document);
                    UpdateStatus($"Retrieved document at random: {fileInfo.FullName}, length={fileInfo.Length}");
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            _pacekeeper.Pause(); // Sync for Limo
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            try
            {
                if (_data.FaxOperation == FaxTask.SendFax)
                {
                    if (SendFaxFinishJob(device))
                    {
                        result = new PluginExecutionResult(PluginResult.Passed);
                    }
                }
                else if (_data.FaxOperation == FaxTask.ReceiveFax)
                {
                    if (ReceiveFaxFinishJob(device))
                    {
                        result = new PluginExecutionResult(PluginResult.Passed);
                    }
                    else
                    {
                        result = new PluginExecutionResult(PluginResult.Failed, "Fax Receive Result Failed ", "Fax Receive Error");
                    }
                }
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                SetJobEndStatus(result);
                ExecutionServices.DataLogger.Submit(ScanLog);
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Exexutes the Print Job
        /// </summary>
        /// <returns></returns>
        private PluginExecutionResult ExecutePrintJob()
        {
            PluginExecutionResult printResult = new PluginExecutionResult(PluginResult.Passed);

            try
            {
                PrintQueue     defaultPrintQueue;
                PrintQueueInfo printQueueInfo = ExecutionData.PrintQueues.GetRandom();
                UpdateStatus("Print Activity: Retrieving print queue for " + printQueueInfo.QueueName);
                defaultPrintQueue = PrintQueueController.Connect(printQueueInfo);
                PrintingEngine engine = new PrintingEngine();

                // Select a documents to print
                DocumentCollectionIterator documentIterator = new DocumentCollectionIterator(CollectionSelectorMode.ShuffledRoundRobin);
                Document document = documentIterator.GetNext(ExecutionData.Documents);

                // Download the document and log the starting information for the print job
                Guid     jobId     = SequentialGuid.NewGuid();
                FileInfo localFile = ExecutionServices.FileRepository.GetFile(document);

                UpdateStatus($"Print Activity: Printing {localFile.Name} to {defaultPrintQueue.FullName}");
                var result = engine.Print(localFile, defaultPrintQueue);
                UpdateStatus($"Print Activity: Finished printing {localFile.Name}");

                return(printResult);
            }
            catch (Exception genericException)
            {
                printResult = new PluginExecutionResult(PluginResult.Failed, genericException.ToString());
                ExecutionServices.SystemTrace.LogError(genericException.ToString());
                return(printResult);
            }
        }
        /// <summary>
        /// Deliver to distribution.
        /// </summary>
        private PluginExecutionResult DeliverToDistribution()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            UpdateStatus("Deliver to Distribution");

            _runtimeOriginator = _activityData.SendToDistribution.Originator;
            _runtimeRecipients = new Collection <string>()
            {
                _activityData.SendToDistribution.DistributionTitle
            };

            SetRuntimeData();
            PopulateExecutionControls();

            foreach (var doc in _runtimeDocumentPaths)
            {
                foreach (var recipient in _runtimeRecipients)
                {
                    // Lock the document pool so that we don't get conflicts with other users.
                    ExecutionServices.CriticalSection.Run(new LocalLockToken("LocalDocument", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), () =>
                    {
                        ProxyClient.DeliverToDistribution(_pluginExecutionData.Servers.First().Address, doc, _runtimeOriginator, recipient);
                    });
                }
            }


            return(result);
        }
        /// <summary>
        /// Processes the activity given to the plugin.
        /// </summary>
        /// <param name="executionData"></param>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            _activityData = _pluginExecutionData.GetMetadata <JetAdvantageScanActivityData>();
            _device       = (IDeviceInfo)executionData.Assets.First();
            UpdateStatus("Starting JetAdvantage " + "Scan to Cloud Repository");
            SetDataLogger(_device);

            if (CheckJetAdvantageAvailability())
            {
                ScanOptions scanOptions = new ScanOptions()
                {
                    LockTimeouts = _activityData.LockTimeouts,
                    PageCount    = _activityData.PageCount,
                    UseAdf       = _activityData.UseAdf,
                };
                _controller = new JetAdvantageScanAutoController(executionData, scanOptions);
                _controller.ActivityStatusChanged += UpdateStatus;
                _controller.DeviceSelected        += UpdateDevice;
                UpdateDataLogger(result);
                return(_controller.RunScanActivity());
            }

            else
            {
                result = new PluginExecutionResult(PluginResult.Failed);
                UpdateDataLogger(result);
                return(result);
            }
        }
        /// <summary>
        /// Launches the Pull print solution and pulls the desired number of documents.
        /// </summary>
        /// <returns></returns>
        protected override PluginExecutionResult LaunchAndPull()
        {
            OnDocumentProcessSelected(_activityData.DocumentProcessAction.GetDescription());
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            try
            {
                _iSecStarApp = iSecStarAppFactory.Create(Device);
                _iSecStarApp.WorkflowLogger = WorkflowLogger;

                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                if (!_activityData.ReleaseOnSignIn)
                {
                    Launch();
                    ExecutePullPrintAction();
                    ExecutionServices.SystemTrace.LogDebug($"Available jobs (Initial)={InitialJobCount}");
                    ExecutionServices.SystemTrace.LogDebug($"Available jobs (Final)={FinalJobCount}");
                }
                else
                {
                    result = SignInAndRelease();
                }
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error.");
                GatherTriageData(ex.ToString());
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error.");
                GatherTriageData(ex.ToString());
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                GatherTriageData(ex.ToString());
            }
            catch (NoJobsFoundException)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, "No jobs found to pull", "Pull print queue empty.");
            }
            catch (Exception ex)
            {
                GatherTriageData(ex.ToString());
                throw;
            }
            finally
            {
                SignOut(_iSecStarApp);

                SubmitLog(result.Result.ToString());
                CollectMemoryData(_activityData.DeviceMemoryProfilerConfig, "HpacPullPrint");
                RecordEvent(DeviceWorkflowMarker.ActivityEnd);

                //Release any connections to the device.  This is critical for Omni operations.
                Dispose();
            }
            return(result);
        }
Ejemplo n.º 7
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.º 8
0
        /// <summary>
        /// Finish up the copy job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            PluginExecutionResult 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;
                }

                _jobStorageScanApp.Pacekeeper = new Pacekeeper(_data.AutomationPause);
                if (_jobStorageScanApp.ExecuteScanJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Finishes the setup portion of the job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            UpdateStatus(string.Format("Pressing HPCR workflow button {0}.", _activityData.HpcrScanButton));
            try
            {
                ScanExecutionOptions options = new ScanExecutionOptions()
                {
                    JobBuildSegments = _activityData.PageCount
                };

                if (_hpcrScanApplication.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                ScanLog.JobEndStatus = _hpcrScanApplication.HpcrFinalStatus;

                _hpcrScanApplication.JobFinished();
            }
            catch (System.ServiceModel.FaultException e)
            {
                ExecutionServices.SystemTrace.LogError(e);
                result = new PluginExecutionResult(PluginResult.Error, e);
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                SetJobEndStatus(result);
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            AutoStoreActivityData data = executionData.GetMetadata <AutoStoreActivityData>();

            ScanOptions scanOptions = new ScanOptions()
            {
                LockTimeouts = data.ScanOptions.LockTimeouts,
                PageCount    = data.ScanOptions.PageCount,
                FileType     = data.ScanOptions.FileType,
            };

            var manager = new AutoStoreScanManager(executionData);

            UpdateStatus("Starting activity.");

            manager.ActivityStatusChanged += UpdateStatus;
            manager.DeviceSelected        += UpdateDevice;

            PluginExecutionResult executionResult = manager.RunScanActivity();

            UpdateStatus("Finished activity.");
            UpdateStatus($"Result = {executionResult.Result}");

            return(executionResult);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Finishes the scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <returns>
        /// The result of the scan.
        /// </returns>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            UpdateStatus(string.Format("Pressing AutoStore workflow button {0}.", _activityData.AutoStoreScanButton));
            try
            {
                AutoStoreExecutionOptions options = new AutoStoreExecutionOptions()
                {
                    JobBuildSegments = _activityData.ScanOptions.PageCount,
                    ImagePreview     = _activityData.ImagePreview
                };
                options.SetAutoStoreWorkflow(_activityData.AutoStoreScanButton, _activityData.UseOcr);

                if (_autoStoreApplication.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                    ScanLog.JobEndStatus = "Success";
                }

                // Method used to clean up AutoStore settings after a run. If  options have been turned on they
                // must be turned off. Options are NOT auto reset after logout. So any option that is set by the
                // plugin must be reset back to default at end of run.

                _autoStoreApplication.JobFinished(options);
            }
            finally
            {
                _collectMemoryManager.CollectDeviceMemoryProfile(_activityData.DeviceMemoryProfilerConfig, "AutoStore");
                // We got far enough to start the scan job, so submit the log
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
        /// <summary>
        /// Deliver to email.
        /// </summary>
        private PluginExecutionResult DeliverToEmail()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            ClearForm();
            UpdateStatus("Deliver to Email");

            int count  = _activityData.SendToEmail.NumberOfRandomRecipients;
            var toList = ExecutionServices.SessionRuntime.AsInternal().GetOfficeWorkerEmailAddresses(count);

            _runtimeRecipients = new Collection <string>(toList.Select(n => n.Address).ToList());
            _runtimeOriginator = _activityData.SendToEmail.Originator;

            SetRuntimeData();
            PopulateExecutionControls();

            // Deliver to HPCR Proxy
            foreach (var doc in _runtimeDocumentPaths)
            {
                foreach (var recipient in _runtimeRecipients)
                {
                    // Lock the document pool so that we don't get conflicts with other users.
                    ExecutionServices.CriticalSection.Run(new LocalLockToken("LocalDocument", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), () =>
                    {
                        ProxyClient.DeliverToEmailByDocument(_pluginExecutionData.Servers.First().Address, doc, _runtimeOriginator, recipient);
                    });
                }
            }

            return(result);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Runs an activity in contention with the Control Panel activity
        /// </summary>
        /// <returns></returns>
        private PluginExecutionResult RunContentionActivity()
        {
            UpdateStatus("Running Contention Activity...");
            var contentionActivityResult = new PluginExecutionResult(PluginResult.Failed);

            object contentionActivityData = null;
            //Selecting a random contention activity.
            Type ContentionActivityToRun = SelectRandomActivity(_data.SelectedContentionActivities);

            Attribute[] attributes = Attribute.GetCustomAttributes(ContentionActivityToRun);
            foreach (Attribute attr in attributes)
            {
                if (attr is ContentionActivity)
                {
                    ContentionActivity contentionAttribute = (ContentionActivity)attr;
                    switch (contentionAttribute.ActivityName)
                    {
                    case "Print":
                        //Print activity is selected
                        UpdateStatus("Selected Contention Activity: Print");
                        contentionActivityData   = _data.SelectedContentionActivities.OfType <PrintActivityData>().Single();
                        contentionActivityResult = ExecutePrintJob();
                        break;
                    }
                }
            }

            return(contentionActivityResult);
        }
Ejemplo n.º 15
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 (this.UseJobBuild)
                {
                    options.JobBuildSegments = _data.PageCount;
                }

                if (_workflowApp.ExecuteJob(options))
                {
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
            }
            finally
            {
                // We got far enough to start the scan job, so submit the log
                SetJobEndStatus(result);
                ExecutionServices.DataLogger.Submit(ScanLog);
            }
            return(result);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Prints document through FTP using webclient
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="localFileDocument"></param>
        /// <param name="isPassiveMode"></param>
        private void PrintFtp(string ipAddress, string userName, string password, FileInfo localFileDocument, bool isPassiveMode = false)
        {
            // Enclose address with square brackets if IPv6 address
            if (ipAddress.Contains(":"))
            {
                ipAddress = $"[{ipAddress}]";
            }

            var ftpWebRequest = (FtpWebRequest)WebRequest.Create($"ftp://{ipAddress}/{localFileDocument.Name}");

            ftpWebRequest.Credentials = new NetworkCredential(userName, password);
            ftpWebRequest.UseBinary   = true;
            ftpWebRequest.UsePassive  = isPassiveMode;
            ftpWebRequest.KeepAlive   = true;
            ftpWebRequest.Method      = WebRequestMethods.Ftp.UploadFile;
            ftpWebRequest.Timeout     = (int)TimeSpan.FromSeconds(10).TotalMilliseconds;
            using (var ftpStream = ftpWebRequest.GetRequestStream())
            {
                using (Stream stream = new FileStream(localFileDocument.FullName, FileMode.Open, FileAccess.Read))
                {
                    stream.CopyTo(ftpStream);
                }
            }

            FtpWebResponse response = (FtpWebResponse)ftpWebRequest.GetResponse();

            _result = response.StatusCode == FtpStatusCode.ClosingData ? new PluginExecutionResult(PluginResult.Passed) : new PluginExecutionResult(PluginResult.Failed, "FTP Printing failed");
            response.Close();
            ftpWebRequest.Abort();
        }
Ejemplo n.º 17
0
        private PluginExecutionResult RunTwain(IDevice device, PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            _activityData = _executionData.GetMetadata <TwainDriverActivityData>();
            var preparationManager = DevicePreparationManagerFactory.Create(device);

            preparationManager.InitializeDevice(true);
            TopCatUIAutomation.Initialize();

            if (_activityData.TwainOperation == TwainOperation.Install)
            {
                InstallTwainDriver(device);
            }
            else if (_activityData.TwainOperation == TwainOperation.DeviceAddition)
            {
                DeviceAddition(device);
            }
            else
            {
                ConfigureSettings(device, executionData.SessionId, executionData.Credential.UserName);
            }

            preparationManager.Reset();
            return(result);
        }
        /// <summary>
        /// Defines and executes the LocalPullPrintExample workflow.
        /// </summary>
        /// <param name="executionData">Information used in the execution of this workflow.</param>
        /// <returns>The result of executing the workflow.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            var result = new PluginExecutionResult(PluginResult.Error, "Unknown");

            _data = executionData.GetMetadata <SdkPullPrintExampleActivityData>();

            UpdateStatus("Starting execution");

            // Get a random device from the selected assets and log it
            var device = executionData.Assets.GetRandom() as HP.ScalableTest.Framework.Assets.IDeviceInfo;

            UpdateStatus($"Selecting and connecting to device {device.AssetId} ({device.Address})...");
            IDeviceProxy proxy = DeviceProxyFactory.Create(device.Address, device.AdminPassword);

            // Define the parameters for a device lock token
            var token = new AssetLockToken(device, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));

            // Acquire a lock on the device to prevent other STB activities that require exclusive access
            // Perform the action and capture the result
            ExecutionServices.CriticalSection.Run(token, () =>
            {
                result = PerformPullPrint(executionData, result, device, proxy);
            }
                                                  );

            return(result);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Performs the Control Panel activity if lock is acquired on the device, otherwise performs the Contention Activity.
        /// </summary>
        /// <returns></returns>
        public PluginExecutionResult RunContentionJob()
        {
            var result = new PluginExecutionResult(PluginResult.Failed);

            try
            {
                IEnumerable <IDeviceInfo>    devices     = ExecutionData.Assets.OfType <IDeviceInfo>();
                IEnumerable <AssetLockToken> assetTokens = devices.Select(n => new AssetLockToken(n, _data.LockTimeouts));

                RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    using (IDevice device = DeviceConstructor.Create(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(ExecutionData, UpdateStatus);
                        result           = retryManager.Run(() => RunControlPanelActivity(device));
                    }
                }
                                                      );
                RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (AcquireLockTimeoutException)
            {
                //If the user is unable to acquire the lock on device, run the contention activity.
                result = RunContentionActivity();
            }
            catch (HoldLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_data.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded.");
            }
            return(result);
        }
        /// <summary>
        /// Performs the pull print.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <param name="result">The result.</param>
        /// <param name="device">The device.</param>
        /// <param name="proxy">The proxy.</param>
        /// <returns>HP.ScalableTest.Framework.Plugin.PluginExecutionResult.</returns>
        private PluginExecutionResult PerformPullPrint(PluginExecutionData executionData, PluginExecutionResult result, HP.ScalableTest.Framework.Assets.IDeviceInfo device, IDeviceProxy proxy)
        {
            try
            {
                // Log the device being used
                ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(executionData, device));
                UpdateStatus($"Executing as user [{executionData?.Credential?.UserName}]");

                // Reset and make sure we're on home screen
                proxy.DeviceUI.PressKey(KeyCode.ResetKey);
                proxy.DeviceUI.WaitForHomeScreen(TimeSpan.FromSeconds(15));

                // Press the PullPrint example solution button
                var solutionButton = _data.TopLevelButtonName;
                UpdateStatus($"Pressing button [{solutionButton}]");
                proxy.DeviceUI.NavigateToSolution(solutionButton);
                proxy.BrowserUI.WaitForIdle(TimeSpan.FromSeconds(15));

                // Get the list of documents available to print
                UpdateStatus("Checking for available documents");
                Dictionary <string, string>[] checkboxes = proxy.BrowserUI.GetElements("span[class='checkbox']");
                UpdateStatus($"{checkboxes.Length} documents found");

                // Set result to skip if no documents found
                if (checkboxes.Length <= 0)
                {
                    result = new PluginExecutionResult(PluginResult.Skipped, "No documents found to print");
                }
                else
                {
                    UpdateStatus("Checking the the first checkbox");
                    // click the first item in the list to check the checkbox
                    proxy.BrowserUI.ClickElement(checkboxes[0]["id"]);

                    // press the print button
                    UpdateStatus("Clicking the print button");
                    proxy.BrowserUI.ClickElement("printButton");

                    // wait for idle for the job to finish
                    proxy.DeviceProperties.WaitForIdle(TimeSpan.FromSeconds(30));
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
            }
            finally
            {
                try
                {
                    // Navigate through device sign out procedure (if applicable) and return to home screen
                    proxy.DeviceUI.NavigateSignOut();
                    proxy.DeviceUI.WaitForHomeScreen(TimeSpan.FromSeconds(10));
                }
                catch { }

                UpdateStatus("Execution complete");
                UpdateStatus("Result = " + result.Result.ToString());
            }

            return(result);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Finish up the Vertical Connector print job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            _imanage.ExecutionPrintJob();
            result = new PluginExecutionResult(PluginResult.Passed);
            return(result);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Finish up the Vertical Connector scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            _imanage.ExecutionScanJob(_data.PageCount, _data.ScanOptions.OriginalSides, _data.ScanOptions.UseOriginalSides);
            result = new PluginExecutionResult(PluginResult.Passed);
            return(result);
        }
Ejemplo n.º 23
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            var                  result          = new PluginExecutionResult(PluginResult.Passed);
            IAssetInfo           printAsset      = (IAssetInfo)executionData.Assets.First();;
            DeviceWorkflowLogger workflowLogger  = new DeviceWorkflowLogger(executionData);
            PrintDeviceInfo      printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First();

            var activityData = executionData.GetMetadata <JetAdvantageActivityData>();

            try
            {
                using (_device = GetDevice(printDeviceInfo))
                {
                    FillFormWithActivityData(activityData);
                    workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                    UpdateStatus("Starting JetAdvantage Pull Printing Application");

                    _manager = new JetAdvantageManager(executionData, workflowLogger, _device, printDeviceInfo);
                    _manager.StatusUpdate += _manager_StatusUpdate;

                    var token = new AssetLockToken(printAsset, TimeSpan.FromHours(1), TimeSpan.FromHours(1));

                    ExecutionServices.CriticalSection.Run(token, () =>
                    {
                        var retryManager = new PluginRetryManager(executionData, UpdateStatus);
                        result           = retryManager.Run(() => _manager.RunJetAdvantage());
                    });
                }
                workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (DeviceCommunicationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
            }
            catch (ScalableTest.Framework.Synchronization.AcquireLockTimeoutException)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable."));
            }
            catch (ScalableTest.Framework.Synchronization.HoldLockTimeoutException)
            {
                return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {TimeSpan.FromHours(1)}.", "Automation timeout exceeded."));
            }
            finally
            {
                UpdateStatus($"Finished JetAdvantage Printing activity");
            }


            return(result);
        }
        /// <summary>
        /// Executes this plug-in's workflow using the specified <see cref="PluginExecutionData"/>.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult"/> indicating the outcome of the
        /// execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Skipped);

            _data       = executionData.GetMetadata <PaperCutInstallerActivityData>();
            _serverInfo = executionData.Servers.FirstOrDefault();

            _printDeviceInfo = executionData.Assets.OfType <PrintDeviceInfo>().FirstOrDefault();
            _device          = DeviceConstructor.Create(_printDeviceInfo);

            var bundleInstaller = new BundleInstaller(_device as JediOmniDevice);

            try
            {
                _signedSessionId = bundleInstaller.SignIn(string.Empty);

                switch (_data.Action)
                {
                case PaperCutInstallerAction.Install:
                {
                    result = bundleInstaller.InstallSolution(_signedSessionId, _data.BundleFile);
                }
                break;

                case PaperCutInstallerAction.Register:
                {
                    result = RegisterDevice();
                }
                break;

                case PaperCutInstallerAction.ConfigureCredentials:
                case PaperCutInstallerAction.ConfigureSettings:
                {
                    result = ConfigureDevice();
                }
                break;
                }
            }
            catch (WebException wex)
            {
                _device.Dispose();
                ExecutionServices.SystemTrace.LogError(
                    $"PaperCut Installer Action {_data.Action} failed on device:{_device.Address}", wex);
                UpdateStatus($"{_printDeviceInfo.AssetId}: Failed with exception: {wex.Message}");
                return(new PluginExecutionResult(PluginResult.Failed, wex.Message));
            }
            catch (Exception ex)
            {
                _device.Dispose();
                ExecutionServices.SystemTrace.LogError(
                    $"PaperCut Installer Action {_data.Action} failed on device:{_device.Address}", ex);
                UpdateStatus($"{_printDeviceInfo.AssetId}: Failed with exception: {ex.Message}");
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message));
            }
            _device.Dispose();
            UpdateStatus($"{_printDeviceInfo.AssetId}: {result.Result}");
            return(result);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Launch the SafeQ solution.
        /// </summary>
        protected void ScanJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred while ScanJob.");

            UpdateStatus("Start FileType Selection");
            _SafeQApp.SelectJob(_activityData.WorkFlowDescription, _activityData.ScanCount);
            _SafeQApp.Scan(_activityData.ScanCount);
            UpdateStatus("Completed to select FileType");
        }
        /// <summary>
        /// Finish up the Cloud Connector scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            UpdateStatus($"Starting Execution Scan Job :: {EnumUtil.GetDescription(_data.ScanDestination)}");
            _linkScanApp.ExecutionScanJob(_data.PageCount, _data.ScanOptions.OriginalSides, _data.ScanOptions.UseOriginalSides);
            result = new PluginExecutionResult(PluginResult.Passed);
            return(result);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _data = executionData.GetMetadata <LinkScanAppsActivityData>();

            UpdateStatus("Starting activity.");

            PluginExecutionResult executionResult = new PluginExecutionResult(PluginResult.Passed);

            return(ExecuteScan(executionData));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Sets the job end status.
 /// </summary>
 /// <param name="result">The result.</param>
 protected void SetJobEndStatus(PluginExecutionResult result)
 {
     if (result.Result.Equals(PluginResult.Passed))
     {
         ScanLog.JobEndStatus = "Success";
     }
     else if (result.Result.Equals(PluginResult.Skipped))
     {
         ScanLog.JobEndStatus = "Skipped";
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Finish up the Cloud Connector print job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            UpdateStatus($"Starting Execution Copy Job :: Kiosk");
            _kioskApp.ExecutionJob(_data.CopyOptions);

            result = new PluginExecutionResult(PluginResult.Passed, $"Job is completed with successful condition :: {_data.JobType}");

            return(result);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Finish up the RegusKiosk print job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override PluginExecutionResult FinishJob(IDevice device)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Error occurred After Login and Job Configuration.", "Device automation error.");

            UpdateStatus($"Starting Execution Print Job on {_data.PrintOptions.PrintSource} :: RegusKiosk");
            _regusKioskApp.ExecutionJob(_data.JobType);

            result = new PluginExecutionResult(PluginResult.Passed);

            return(result);
        }