Beispiel #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)
        {
            HpacActivityData data = executionData.GetMetadata <HpacActivityData>(ConverterProvider.GetMetadataConverters());

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

            HpacPullPrintManager manager = new HpacPullPrintManager(executionData, data);

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

            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());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HpacPullPrintManager"/> class.
 /// </summary>
 /// <param name="pluginExecutionData">The plugin execution data.</param>
 /// <param name="activityData">The activity data.</param>
 public HpacPullPrintManager(PluginExecutionData pluginExecutionData, HpacActivityData activityData) : base(pluginExecutionData)
 {
     _activityData     = activityData;
     PullPrintSolution = "HP AC Pull Printing";
     this.LockTimeouts = _activityData.LockTimeouts;
     this.AuthProvider = _activityData.AuthProvider;
 }
 public void Initialize(PluginEnvironment environment)
 {
     _activityData = new HpacActivityData();
     assetSelectionControl.Initialize(_deviceAttributes);
     printingTaskConfigurationControl.Initialize();
     lockTimeoutControl.Initialize(_activityData.LockTimeouts);
 }
Beispiel #4
0
        private void SetAction(PullPrintDocumentProcessActions oldAction, HpacActivityData newActivityData)
        {
            switch (oldAction)
            {
            case PullPrintDocumentProcessActions.PrintSingleDocument:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.PrintDelete;
                break;

            case PullPrintDocumentProcessActions.PrintAllDocuments:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.PrintAll;
                break;

            case PullPrintDocumentProcessActions.PrintKeepSingleDocument:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.PrintKeep;
                break;

            case PullPrintDocumentProcessActions.PrintKeepAllDocuments:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.PrintKeep;
                newActivityData.SelectAll             = true;
                break;

            case PullPrintDocumentProcessActions.DeleteSingleDocument:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.Delete;
                break;

            case PullPrintDocumentProcessActions.DeleteAllDocuments:
                newActivityData.DocumentProcessAction = HpacPullPrintAction.Delete;
                newActivityData.SelectAll             = true;
                break;
            }
        }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData            = configuration.GetMetadata <HpacActivityData>(ConverterProvider.GetMetadataConverters());
            _pluginConfigurationData = configuration;

            assetSelectionControl.Initialize(_pluginConfigurationData.Assets, _deviceAttributes);
            printingTaskConfigurationControl.Initialize(_pluginConfigurationData.Documents, _pluginConfigurationData.PrintQueues, _activityData.DelayAfterPrint, _activityData.ShuffleDocuments, _activityData.UsePrintServerNotification);
            lockTimeoutControl.Initialize(_activityData.LockTimeouts);
            SetConfiguration();
        }
Beispiel #6
0
        /// <summary>
        /// Validates the given metadata against the HPAC Activity data.
        /// </summary>
        /// <param name="configurationData">The configuration data.</param>
        /// <returns>true if valid</returns>
        public bool ValidateMetadata(ref PluginConfigurationData configurationData)
        {
            bool             validData    = true;
            HpacActivityData activityData = null;

            try
            {
                activityData = configurationData.GetMetadata <HpacActivityData>(ConverterProvider.GetMetadataConverters());
            }
            catch
            {
                activityData = new HpacActivityData();
                validData    = false;
            }

            configurationData = new PluginConfigurationData(activityData, HpacPullPrintingConfigurationControl.Version);

            return(validData);
        }
        /// <summary>
        /// Grab values out of PrintingTaskData without the need for the class to serialize/de-serialize.
        /// </summary>
        /// <param name="rootNS"></param>
        /// <param name="xml"></param>
        /// <param name="newActivityData"></param>
        private void ConvertPrintingTask(XNamespace rootNS, XElement xml, HpacActivityData newActivityData)
        {
            XElement   prinTaskElement = xml.Element(rootNS + "PrintingTaskData");
            XNamespace prinTaskNS      = GetNamespace(prinTaskElement);

            try
            {
                // Set native properties
                newActivityData.ShuffleDocuments = GetBool(prinTaskElement, "ShuffleDocuments");

                // Only set if a real value is there.
                int delayVal = GetInt(prinTaskElement, "DelayAfterPrint");
                if (delayVal > 0)
                {
                    newActivityData.DelayAfterPrint = delayVal;
                }
            }
            catch (ArgumentNullException)
            { }
        }
        /// <summary>
        /// Converts the specified XML metadata to the new version.
        /// </summary>
        /// <param name="xml">The XML metadata.</param>
        /// <returns>System.Xml.Linq.XElement.</returns>
        public XElement Convert(XElement xml)
        {
            // Create Proxy object, serialize what we can
            HpacActivityData1_1 proxyData = Serializer.Deserialize <HpacActivityData1_1>(xml, Maps);

            // Get XML root namespace for manual conversion
            XNamespace rootNS = xml.GetDefaultNamespace();

            // Create the latest ActivityData
            HpacActivityData resultData = new HpacActivityData()
            {
                AuthProvider               = AuthenticationProvider.HpacIrm,
                DocumentProcessAction      = proxyData.DocumentProcessAction,
                LockTimeouts               = proxyData.LockTimeouts,
                DeviceMemoryProfilerConfig = proxyData.DeviceMemoryProfilerConfig,
                HpacAuthentication         = proxyData.HpacAuthentication,
                SelectAll = proxyData.SelectAll
            };

            ConvertPrintingTask(rootNS, xml, resultData);

            return(Serializer.Serialize(resultData));
        }
Beispiel #9
0
        /// <summary>
        /// Converts the specified XML metadata to the new version.
        /// </summary>
        /// <param name="xml">The XML metadata.</param>
        /// <returns>System.Xml.Linq.XElement.</returns>
        public XElement Convert(XElement xml)
        {
            // Create Proxy object, deserialize what we can.
            HpacActivityData1_0 proxyData = Serializer.Deserialize <HpacActivityData1_0>(xml, Maps);

            // Get XML root namespace for manual conversion
            XNamespace rootNS = xml.GetDefaultNamespace();

            // Create a new ActivityData
            HpacActivityData resultData = new HpacActivityData()
            {
                AuthProvider = AuthenticationProvider.HpacIrm,
                LockTimeouts = proxyData.LockTimeouts,
                DeviceMemoryProfilerConfig = proxyData.DeviceMemoryProfilerConfig,
                HpacAuthentication         = UseSolutionAuth(rootNS, xml)
            };

            // Set the DocumentProcessAction property
            SetAction(proxyData.DocumentProcessAction, resultData);
            ConvertPrintingTask(rootNS, xml, resultData);

            return(Serializer.Serialize(resultData));
        }