/// <summary> /// Initializes this configuration control with the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginConfigurationData" />. /// </summary> /// <param name="configuration">The configuration data.</param> /// <param name="environment">Information about the plugin environment.</param> public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment) { assetSelectionControl.Initialize(configuration.Assets, _deviceAttributes); _activityData = configuration.GetMetadata <AuthenticationData>(ConverterProvider.GetMetadataConverters()); BindControls(); }
/// <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) { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed); _executionData = executionData; _deviceAssets = executionData.Assets.OfType <IDeviceInfo>().ToList(); ExecutionServices.SystemTrace.LogDebug($"# of assets in ExecutionData: {executionData.Assets.Count}"); try { UpdateStatus("Starting activity..."); _activityData = executionData.GetMetadata <AuthenticationData>(ConverterProvider.GetMetadataConverters()); _workflowLogger = new DeviceWorkflowLogger(executionData); TimeSpan acquireTimeout = _activityData.LockTimeouts.AcquireTimeout; TimeSpan holdTimeout = _activityData.LockTimeouts.HoldTimeout; string msg = string.Empty; List <AssetLockToken> tokens = _deviceAssets.Select(n => new AssetLockToken(n, acquireTimeout, holdTimeout)).ToList(); _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin); ExecutionServices.CriticalSection.Run(tokens, selectedToken => { IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo; LogDevice(deviceInfo); using (IDevice device = SetDevice(deviceInfo)) { var retryManager = new PluginRetryManager(executionData, UpdateStatus); result = retryManager.Run(() => LaunchApp(device, deviceInfo)); } }); _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 (AcquireLockTimeoutException) { return(new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified devices(s).", "Device unavailable.")); } catch (HoldLockTimeoutException) { return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_activityData.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded.")); } finally { UpdateStatus("Finished activity"); } return(result); }
/// <summary> /// Initializes this configuration control to default values. /// </summary> /// <param name="environment">Information about the plugin environment.</param> public void Initialize(PluginEnvironment environment) { assetSelectionControl.Initialize(_deviceAttributes); _activityData = new AuthenticationData(); BindControls(); }