Exemplo n.º 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());
        }
Exemplo n.º 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 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>
        /// 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);
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentCollectionIterator" /> class.
 /// </summary>
 /// <param name="selectorMode">The selection mode.</param>
 public DocumentCollectionIterator(CollectionSelectorMode selectorMode)
 {
     _selectorMode = selectorMode;
 }