/// <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) { _executionData = executionData; _performanceLogger = new DeviceWorkflowLogger(_executionData); _activityData = executionData.GetMetadata <EWSFirmwarePerformanceActivityData>(); TimeSpan lockTimeout = TimeSpan.FromMinutes(10); TimeSpan holdTimeout = TimeSpan.FromMinutes(60); PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Failed to Start Upgrade"); ///Dictionary<string, PluginExecutionResult> results = new Dictionary<string, PluginExecutionResult>(); if (_executionData.Assets.OfType <IDeviceInfo>().Count() == 0) { return(new PluginExecutionResult(PluginResult.Failed, $"There were no assets retrieved. If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error")); } try { var assetTokens = _executionData.Assets.OfType <IDeviceInfo>().Select(n => new AssetLockToken(n, lockTimeout, holdTimeout)); _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin); ExecutionServices.CriticalSection.Run(assetTokens, selectedToken => { _performanceLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin); IDeviceInfo asset = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo; ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(_executionData, asset)); ExecutionServices.SystemTrace.LogDebug("Validating Firmware bundle for the selected asset"); result = ValidateFirmwareBundles(asset.AssetId, asset.AdminPassword, asset.Address); if (result.Result == PluginResult.Failed) { throw new DeviceWorkflowException($"Failed to validate FW bundle for device {asset.AssetId}. Error: {result.Message}"); } if (result.Result != PluginResult.Skipped) { ExecutionServices.SystemTrace.LogDebug($"Performing update on device {asset.AssetId} at address {asset.Address}"); result = UpgradeFirmware(asset); } }); } catch (Exception e) { ExecutionServices.SystemTrace.LogDebug(e); UpdateStatus(e.Message); result = new PluginExecutionResult(PluginResult.Failed, e.Message); } _performanceLogger.RecordEvent(DeviceWorkflowMarker.ActivityEnd); _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd); return(result); }
/// <summary> /// Initializes this configuration control with the specified <see cref="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) { _data = configuration.GetMetadata <EWSFirmwarePerformanceActivityData>(); assetSelectionControl.Initialize(configuration.Assets, AssetAttributes.None); if (!Directory.Exists(_data.FimBundlesLocation)) { MessageBox.Show(@"The firmware location is no longer available . Please add the firmware directory detail again.", @"Firmware File Missing", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { textBoxFirmwareFolder.Text = _data.FimBundlesLocation; checkBoxAutoBackup.Checked = _data.AutoBackup; checkBoxValidate.Checked = _data.ValidateFlash; validatetimeSpanControl.Value = _data.ValidateTimeOut == TimeSpan.FromMinutes(0) ? TimeSpan.FromMinutes(1) : _data.ValidateTimeOut; validateFW_Checkbox.Checked = _data.ValidateFWBundles; } }
/// <summary> /// Initializes this configuration control to default values. /// </summary> /// <param name="environment">Information about the plugin environment.</param> public void Initialize(PluginEnvironment environment) { _data = new EWSFirmwarePerformanceActivityData(); validatetimeSpanControl.Value = TimeSpan.FromMinutes(30.0); }