Example #1
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" /> to use for execution.</param>
        /// <returns>
        /// A <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionResult" /> indicating the outcome of the execution.
        /// </returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            BlueprintActivityData data = executionData.GetMetadata <BlueprintActivityData>();

            if (_documentCollectionIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentCollectionIterator = new DocumentCollectionIterator(mode);
            }

            BlueprintPullPrintManager manager = new BlueprintPullPrintManager(executionData, data);

            manager.StatusUpdate           += UpdateStatus;
            manager.DeviceSelected         += UpdateDevice;
            manager.DocumentActionSelected += UpdateDocumentAction;
            manager.TimeStatusUpdate       += PullPrintManager_TimeStatusUpdate;
            manager.SessionIdUpdate        += UpdateSessionId;

            if (executionData.PrintQueues.Any() && executionData.Documents.Any())
            {
                try
                {
                    manager.ExecutePrintJob(_documentCollectionIterator, data.UsePrintServerNotification, data.DelayAfterPrint);
                }
                catch (PrintQueueNotAvailableException ex)
                {
                    //This exception has already been logged in the call to manager.ExecutePrintJob
                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Print Failure."));
                }
            }
            return(manager.ExecutePullPrintOperation());
        }
Example #2
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)
        {
            SafeQPullPrintingActivityData data    = executionData.GetMetadata <SafeQPullPrintingActivityData>();
            SafeQPullPrintManager         manager = new SafeQPullPrintManager(executionData, data);

            if (_documentCollectionIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentCollectionIterator = new DocumentCollectionIterator(mode);
            }

            manager.StatusUpdate           += UpdateStatus;
            manager.DeviceSelected         += UpdateDevice;
            manager.DocumentActionSelected += UpdateDocumentAction;
            manager.TimeStatusUpdate       += PullPrintManager_TimeStatusUpdate;
            manager.SessionIdUpdate        += UpdateSessionId;

            if (executionData.PrintQueues.Any() && executionData.Documents.Any())
            {
                try
                {
                    manager.ExecutePrintJob(_documentCollectionIterator, data.UsePrintServerNotification, data.DelayAfterPrint);
                }
                catch (AggregateException ex)
                {
                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Print Process Aborted."));
                }
            }
            return(manager.ExecutePullPrintOperation());
        }
        /// <summary>
        /// Executes the print job. Sends the selected document(s) to the solution's print server.
        /// </summary>
        /// <param name="documentCollectionIterator">The document collection iterator.</param>
        /// <param name="usePrintServerNotification">if set to <c>true</c> [use print server notification].</param>
        /// <param name="delayAfterPrint">The delay after print.</param>
        public void ExecutePrintJob(DocumentCollectionIterator documentCollectionIterator, bool usePrintServerNotification, int delayAfterPrint)
        {
            OnStatusUpdate("Print queues and documents specified, sending document(s) to the print server...");

            PrintManager printManager = new PrintManager(ExecutionData, documentCollectionIterator);

            try
            {
                printManager.Execute();

                if (!usePrintServerNotification)
                {
                    TimeSpan delay = TimeSpan.FromSeconds(delayAfterPrint);
                    OnStatusUpdate("Print completed. Delaying pull printing by " + delayAfterPrint.ToString() + " seconds.");
                    Thread.Sleep(delay);
                }
                else
                {
                    printManager.WaitOnPrintServerNotification();
                }
            }
            catch (PrintQueueNotAvailableException ex)
            {
                GatherTriageData(ex.ToString());
                throw;
            }
        }
        /// <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)
        {
            GeniusBytesPullPrintingActivityData data = executionData.GetMetadata <GeniusBytesPullPrintingActivityData>();

            GeniusBytesPullPrintManager manager = new GeniusBytesPullPrintManager(executionData, data, executionData.Environment);

            if (_documentCollectionIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentCollectionIterator = new DocumentCollectionIterator(mode);
            }
            manager.StatusUpdate           += UpdateStatus;
            manager.DeviceSelected         += UpdateDevice;
            manager.DocumentActionSelected += UpdateDocumentAction;
            manager.TimeStatusUpdate       += PullPrintManager_TimeStatusUpdate;
            manager.SessionIdUpdate        += UpdateSessionId;

            if (executionData.PrintQueues.Any() && executionData.Documents.Any())
            {
                try
                {
                    // Thread the print task so that any issues don't crash the user main thread.
                    Task printTask = Task.Factory.StartNew(() => manager.ExecutePrintJob(_documentCollectionIterator, data.UsePrintServerNotification, data.DelayAfterPrint));
                    printTask.Wait();
                }
                catch (AggregateException ex)
                {
                    ExecutionServices.SystemTrace.LogError(ex);
                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Print Process Aborted."));
                }
            }
            return(manager.ExecutePullPrintOperation());
        }
        /// <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);
            }
        }
Example #6
0
        private void LoadAdf(string address, int pageCount)
        {
            if (!ExecutionData.Documents.Any())
            {
                throw new ArgumentException("Document selection data resulted in 0 documents.");
            }

            // Clear the ADF before we do anything else
            AdfSimulator.Clear(address);

            // Iterate over the documents until we reach the desired page count
            DocumentCollectionIterator iterator = new DocumentCollectionIterator(CollectionSelectorMode.RoundRobin);

            for (int i = 0; i < pageCount; i++)
            {
                // Select and log document(s)
                Document document = iterator.GetNext(ExecutionData.Documents);
                ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(ExecutionData, document);
                ExecutionServices.DataLogger.Submit(documentLog);

                // Convert relative paths to absolute network paths
                string sharePath = ExecutionServices.FileRepository.AsInternal().GetDocumentSharePath(document);

                // Load it into the ADF
                AdfSimulator.LoadPage(address, sharePath);
            }
        }
        /// <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)
        {
            _activityData  = executionData.GetMetadata <HpRoamActivityData>();
            _executionData = executionData;

            PluginExecutionResult finalResult = null;

            if (_documentIterator == null)
            {
                CollectionSelectorMode mode = _activityData.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentIterator = new DocumentCollectionIterator(mode);
            }

            try
            {
                activeSession_Label.InvokeIfRequired(n => n.Text = _executionData.SessionId);

                // Execute Print Operation (Push job to Roam)
                switch (_activityData.RoamDocumentSendAction)
                {
                case DocumentSendAction.Android:
                    PrintToRoamCloudViaPhone();
                    break;

                case DocumentSendAction.Windows:
                    if (executionData.PrintQueues.Any() && executionData.Documents.Any())
                    {
                        PrintToRoamCloudViaDriver(0);
                    }
                    break;

                default:     //DocumentSend.WebClient not implemented at this time
                    break;
                }

                // Execute Pull Print Operation (Pull job from Roam to device)
                if (_activityData.PhoneDocumentPush)
                {
                    finalResult = PrintFromRoamToDeviceViaPhone();
                }
                else
                {
                    finalResult = PrintFromRoamToDevice();
                }
            }
            catch (Exception ex)
            {
                //If there were errors during the printing operation, we could end up here.
                finalResult = new PluginExecutionResult(PluginResult.Error, ex);
            }

            return(finalResult);
        }
Example #8
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            iSecStarActivityData     data    = executionData.GetMetadata <iSecStarActivityData>();
            iSecStarPullPrintManager manager = new iSecStarPullPrintManager(executionData, data);

            if (_documentCollectionIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentCollectionIterator = new DocumentCollectionIterator(mode);
            }

            manager.StatusUpdate           += UpdateStatus;
            manager.DeviceSelected         += UpdateDevice;
            manager.DocumentActionSelected += UpdateDocumentAction;
            manager.SessionIdUpdate        += UpdateSessionId;
            manager.TimeStatusUpdate       += PullPrintManager_TimeStatusUpdate;

            if (executionData.PrintQueues.Any() && executionData.Documents.Any())
            {
                try
                {
                    CloseOrphanedClientPopup();

                    manager.ExecutePrintJob(_documentCollectionIterator, data.UsePrintServerNotification, data.DelayAfterPrint);

                    if (CheckForErrorPrompt())
                    {
                        Thread.Sleep(humanTimeSpan);
                        PerformPrintTask(executionData);
                    }
                }
                catch (PrintQueueNotAvailableException ex)
                {
                    //This exception has already been logged in the call to manager.ExecutePrintJob
                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Print Failure."));
                }
            }
            return(manager.ExecutePullPrintOperation());
        }
        /// <summary>
        /// Sets the HpcrActivityData runtime information.
        /// </summary>
        private void SetRuntimeData()
        {
            // Massage originator email with runtime information (if necessary)
            _runtimeOriginator = ReplaceCurrentUser(_runtimeOriginator);

            // Massage recipient with runtime information (if necessary)
            if (_runtimeRecipients.Any(x => x.Equals(Constants.RANDOM_DISTRIBUTION)))
            {
                var distributionNames = ProxyClient.GetDistributions(_pluginExecutionData.Servers.First().Address, _runtimeOriginator).Select(x => x.Title);
                var revisedRecipients = new Collection <string>();
                foreach (var recipient in _runtimeRecipients)
                {
                    revisedRecipients.Add(ReplaceRandomDistribution(recipient, distributionNames));
                }
                _runtimeRecipients = revisedRecipients;
            }

            UpdateStatus("Fetching documents...");

            //Cap at 2 documents max (chosen at random if more than 2 exist).
            if (_pluginExecutionData.Documents.Count > 2)
            {
                DocumentCollectionIterator iterator = new DocumentCollectionIterator(CollectionSelectorMode.ShuffledRoundRobin);

                string path1 = ExecutionServices.FileRepository.AsInternal().GetDocumentSharePath(iterator.GetNext(_pluginExecutionData.Documents));
                string path2 = ExecutionServices.FileRepository.AsInternal().GetDocumentSharePath(iterator.GetNext(_pluginExecutionData.Documents));

                _runtimeDocumentPaths.Add(path1);
                _runtimeDocumentPaths.Add(path2);
            }
            else
            {
                string path = ExecutionServices.FileRepository.AsInternal().GetDocumentSharePath(_pluginExecutionData.Documents.First());
                _runtimeDocumentPaths = new Collection <string>();
                _runtimeDocumentPaths.Add(path);
            }
        }
Example #10
0
        /// <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)
        {
            _executionData     = executionData;
            _performanceLogger = new DeviceWorkflowLogger(_executionData);
            _activityData      = _executionData.GetMetadata <DriverlessPrintingActivityData>();
            var printer = executionData.Assets.OfType <PrintDeviceInfo>().FirstOrDefault();

            if (printer == null)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "No assets available for execution."));
            }
            if (!printer.Attributes.HasFlag(AssetAttributes.Printer))
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "The device has no print capability."));
            }
            var address = printer.Address;

            var iteratorMode = _activityData.ShuffleDocuments
                ? CollectionSelectorMode.ShuffledRoundRobin
                : CollectionSelectorMode.Random;
            var      documentIterator = new DocumentCollectionIterator(iteratorMode);
            var      document         = documentIterator.GetNext(executionData.Documents);
            FileInfo localFile        = ExecutionServices.FileRepository.GetFile(document);

            if (_activityData.PinProtected)
            {
                AddPinProtection(localFile, _activityData.Pin);
            }

            if (_activityData.PrintMethod == PrintMethod.Random)
            {
                Random newRandom = new Random(4);
                var    randomInt = newRandom.Next(0, 999) % 4;
                _activityData.PrintMethod = (PrintMethod)randomInt;
            }

            _performanceLogger.RecordEvent(DeviceWorkflowMarker.PrintJobBegin);
            UpdateStatus($"Printing {document.FileName} via {_activityData.PrintMethod}.");
            switch (_activityData.PrintMethod)
            {
            default:
                Print9100(address, localFile);
                break;

            case PrintMethod.Ftp:
                PrintFtp(address, "admin", printer.AdminPassword, localFile, true);
                break;

            case PrintMethod.Ipp:
                PrintIpp(address, localFile);
                break;

            case PrintMethod.Ews:
                PrintEws(address, printer.AdminPassword, localFile);
                break;
            }
            _performanceLogger.RecordEvent(DeviceWorkflowMarker.PrintJobEnd);
            _performanceLogger.RecordExecutionDetail(DeviceWorkflowMarker.PrintJobEnd, _activityData.PrintMethod.ToString());
            ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(executionData, document);

            ExecutionServices.DataLogger.Submit(documentLog);

            if (_activityData.PrintJobSeparator)
            {
                UpdateStatus("Printing Job Separator.");
                PrintJobSeparator(address);
            }
            localFile.Delete();
            return(_result);
        }
Example #11
0
        /// <summary>
        /// Start the activity.
        /// </summary>
        /// <param name="executionData">Serialized activity data.</param>
        public PluginExecutionResult ProcessActivity(PluginExecutionData executionData)
        {
            PrintingActivityData     data        = executionData.GetMetadata <PrintingActivityData>();
            PrintQueueInfoCollection printQueues = executionData.PrintQueues;

            // Initialize the document iterator, if it is not already created
            if (_documentIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentIterator = new DocumentCollectionIterator(mode);
            }

            // Check to make sure we have something in the pool...
            if (printQueues.Count == 0)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "None of the selected print queues are available.", "No available print queues."));
            }

            // Select a print queue and log the device/server if applicable
            PrintQueueInfo printQueueInfo = printQueues.GetRandom();

            LogDevice(executionData, printQueueInfo);
            LogServer(executionData, printQueueInfo);

            // Get the corresponding system print queue
            LogDebug(string.Format("Retrieving print queue for {0}", printQueueInfo.QueueName));
            PrintQueue printQueue;

            if (ExecutionServices.SessionRuntime.AsInternal().IsCitrixEnvironment())
            {
                printQueue = GetCitrixPrintQueue(printQueueInfo);
            }
            else
            {
                printQueue = PrintQueueController.Connect(printQueueInfo);
            }

            LogDebug(string.Format("Found queue: {0}", printQueue.FullName));

            if (data.JobThrottling)
            {
                // Make sure that there is enough room in the print queue for this job.
                if (!CheckJobCountInQueue(printQueue, data.MaxJobsInQueue))
                {
                    // Skip the activity.
                    return(new PluginExecutionResult(PluginResult.Skipped, "Print Queue cannot accept any more jobs.", "Print queue throttling."));
                }
            }

            LogDebug("Executing print controller");
            if (data.PrintJobSeparator)
            {
                PrintTag(printQueue, executionData);
            }

            // Select a document to print
            Document document = _documentIterator.GetNext(executionData.Documents);
            ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(executionData, document);

            ExecutionServices.DataLogger.Submit(documentLog);

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

            // Print the job
            var engine = new Print.PrintingEngine();

            engine.StatusChanged += (s, e) => StatusChanged?.Invoke(s, e);
            var result = engine.Print(localFile, printQueue, jobId);

            // Log the ending information
            LogPrintJobEnd(log, result);
            LogDebug("Controller execution completed");
            return(new PluginExecutionResult(PluginResult.Passed));
        }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrintManager"/> class.
 /// </summary>
 /// <param name="pluginExecData">The plugin execute data.</param>
 /// <param name="documentIterator">The document iterator.</param>
 public PrintManager(PluginExecutionData pluginExecData, DocumentCollectionIterator documentIterator)
 {
     _pluginData       = pluginExecData;
     _printQueues      = _pluginData.PrintQueues;
     _documentIterator = documentIterator;
 }