Esempio n. 1
0
        /// <summary>
        /// Defines and executes the PluginCollectDeviceSystemInfo 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)
        {
            _data = executionData.GetMetadata <CollectDeviceSystemInfoActivityData>(ConverterProvider.GetMetadataConverters());
            _collectDeviceInfoEngine = new CollectDeviceSystemInfoEngine(executionData);

            UpdateStatus("Starting execution");

            // iterate through each applicable asset, acquire the lock and take the memory snapshot, then proceed to next
            var devices = executionData.Assets.OfType <IDeviceInfo>();

            Parallel.ForEach(devices, device =>
            {
                UpdateStatus("Collecting Memory on Asset ID '" + device.AssetId + "'.");
                _collectDeviceInfoEngine.ProcessMemCollectionByDevice(device);
                if (_collectDeviceInfoEngine.IsError)
                {
                    UpdateStatus(_collectDeviceInfoEngine.ErrorMessage);
                    _collectDeviceInfoEngine.ErrorMessage = string.Empty;
                }
            });


            PluginExecutionResult result;

            if (_collectDeviceInfoEngine.ProblemDevices.Any())
            {
                var msg = $"Failed to collect on {string.Join(",", _collectDeviceInfoEngine.ProblemDevices.ToArray())}";
                result = new PluginExecutionResult(PluginResult.Failed, msg, "Memory collection error.");
                UpdateStatus(msg);
            }
            else
            {
                result = new PluginExecutionResult(PluginResult.Passed);
            }

            UpdateStatus("Completing execution");
            UpdateStatus($"Result = {result.Result}");
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Validates the given metadata against the CollectDeviceSystemInfo Activity data.
        /// </summary>
        /// <param name="configurationData">The configuration data.</param>
        /// <returns>true if valid</returns>
        public bool ValidateMetadata(ref PluginConfigurationData configurationData)
        {
            bool validData = true;
            CollectDeviceSystemInfoActivityData activityData = null;

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

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

            return(validData);
        }
 /// <summary>
 /// Initializes the configuration control with the supplied configuration settings.
 /// </summary>
 /// <param name="configuration">Pre-configured plugin settings.</param>
 /// <param name="environment">Domain and plugin specific environment data.</param>
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     // Deserialize the plugin specific configuration settings.
     _data = configuration.GetMetadata <CollectDeviceSystemInfoActivityData>(ConverterProvider.GetMetadataConverters());
     assetSelectionControl.Initialize(configuration.Assets, HP.ScalableTest.Framework.Assets.AssetAttributes.None);
 }