/// <summary> /// Validates the given metadata against the DeviceConfiguration Activity data. /// </summary> /// <param name="configurationData">The configuration data.</param> /// <returns>true if valid</returns> public bool ValidateMetadata(ref PluginConfigurationData configurationData) { bool validData = true; DeviceConfigurationActivityData activityData = null; try { activityData = configurationData.GetMetadata <DeviceConfigurationActivityData>(); } catch { activityData = new DeviceConfigurationActivityData(); validData = false; } configurationData = new PluginConfigurationData(activityData, DeviceConfigurationConfigurationControl.Version); return(validData); }
/// <summary> /// Initializes the configuration control with the specified settings. /// </summary> /// <param name="configuration"></param> /// <param name="environment"></param> public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment) { _data = configuration.GetMetadata <DeviceConfigurationActivityData>(); assetSelectionControl.Initialize(configuration.Assets, Framework.Assets.AssetAttributes.None); //DefaultSetupData enablePassword_CheckBox.Checked = _data.EnableDefaultPW; //maxPasswordLength_Textbox.Text = _data.MaxPWLength.ToString() == "-1" ? "" : _data.MaxPWLength.ToString(); //winDomains_TextBox.Text = _data.WindowsDomains.Count > 1 ? string.Join(";", _data.WindowsDomains) : _data.WindowsDomains.Count == 1 ? _data.WindowsDomains[0] : ""; //defaultDomain_TextBox.Text = _data.DefaultDomain; //passwordComplexity_CheckBox.Checked = _data.EnablePasswordComplexity; //windowsAuth_CheckBox.Checked = _data.EnableWindowsAuthentication; //GeneralSettingsData var gendata = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(GeneralSettingsData)); if (gendata != null) { generalSettingsControl.SetControl(_data.ComponentData); //Alternatively just sending gendata } var emailData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(EmailSettingsData)); if (emailData != null) { emailSettingsControl.SetControl(_data.ComponentData); } var passWinData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(PasswordWindowsData)); if (passWinData != null) { passwordWindowsControl.SetControl(_data.ComponentData); } var quickSetData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(QuickSetSettingsData)); if (quickSetData != null) { quickSetControl.SetControl(_data.ComponentData); } var copyData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(CopySettingsData)); if (copyData != null) { copyDefaultControl.SetControl(_data.ComponentData); } var printData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(PrintSettingsData)); if (printData != null) { printDefaultControl.SetControl(_data.ComponentData); } var folderData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(FolderSettingsData)); if (folderData != null) { folderDefaultControl.SetControl(_data.ComponentData); } var scanUsbData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(ScanUsbSettingData)); if (scanUsbData != null) { scanToUsbDefaultControl.SetControl(_data.ComponentData); } var jobData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(JobSettingsData)); if (jobData != null) { jobStorageDefaultControl.SetControl(_data.ComponentData); } var webTroubleData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(WebTroubleShootingData)); if (webTroubleData != null) { webTroubleShootingControl.SetControl(_data.ComponentData); } var speedDialData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(SpeedDialData)); if (speedDialData != null) { speedDailControl.SetControl(_data.ComponentData); } var faxData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(FaxSettingsData)); if (faxData != null) { faxDefaultControl.SetControl(_data.ComponentData); } var manageTraySettingsData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(ManageTraysSettingData)); if (manageTraySettingsData != null) { manageTraysControl.SetControl(_data.ComponentData); } var hpkInstallData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(HPKInstallData)); if (hpkInstallData != null) { hpkInstallControl.SetControl(_data.ComponentData); } var protocolData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(ProtocolSettingsData)); if (protocolData != null) { protocolDefaultControl.SetControl(_data.ComponentData); } }
/// <summary> /// Execute the task of the DeviceConfiguration activity. /// </summary> /// <param name="executionData"></param> /// <returns></returns> public PluginExecutionResult Execute(PluginExecutionData executionData) { //bool result = false; _executionData = executionData; _activityData = executionData.GetMetadata <DeviceConfigurationActivityData>(); TimeSpan lockTimeout = TimeSpan.FromMinutes(10); TimeSpan holdTimeout = TimeSpan.FromMinutes(20); ConcurrentDictionary <string, DataPair <string> > results = new ConcurrentDictionary <string, DataPair <string> >(); if (!_executionData.Assets.OfType <IDeviceInfo>().Any()) { 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")); } ExecutionServices.SystemTrace.LogDebug("Beginning Update"); try { //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(), asset => foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>()) { JediDevice device = null; try { //DeviceConfigResultLog log = new DeviceConfigResultLog(_executionData, asset.AssetId); SetDefaultPassword(asset.Address, asset.AdminPassword); try { device = DeviceConstructor.Create(asset) as JediDevice; } catch { device = DeviceFactory.Create(asset.Address) as JediDevice; } // Make sure the device is in a good state var devicePrepManager = DevicePreparationManagerFactory.Create(device); try { devicePrepManager.InitializeDevice(true); } catch (WebInspectorException webInspectorException) { //let's ignore initialise device errors, this might be due to inspection page in use, //since we are not doing any control panel action, this should be ok ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message); } //devicePrepManager.PerformanceLogger = PerformanceLogger; ExecutionServices.SystemTrace.LogDebug( $"Processing {asset.AssetId} on thread {Thread.CurrentThread}"); AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout); ExecutionServices.CriticalSection.Run(assetToken, () => { ExecutionServices.SystemTrace.LogDebug( $"Performing update on device {asset.AssetId} at address {asset.Address}"); var result = UpdateDevice(device, (AssetInfo)asset, _executionData); results.AddOrUpdate(asset.AssetId, result, (key, oldValue) => UpdateDevice(device, (AssetInfo)asset, _executionData)); device?.Dispose(); }); } catch (DeviceCommunicationException deviceCommunicationException) { ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}"); results.AddOrUpdate(asset.AssetId, new DataPair <string> { Key = "Device Communication", Value = false }, (s, pair) => new DataPair <string>() { Key = "Device Communication", Value = false }); device?.Dispose(); } catch (Exception e) { ExecutionServices.SystemTrace.LogDebug(e); results.AddOrUpdate(asset.AssetId, new DataPair <string> { Key = "Failed Settings", Value = false }, (s, pair) => new DataPair <string> { Key = "Failed Settings", Value = false }); //[Veda]:we had few in use inspection pages error in subsequent plugin/activities, which was as a result of this plugin failing //eg: invalid xml content. disposing the device to avoid those problems device?.Dispose(); } }//); } catch { return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup")); } foreach (var item in results) { UpdateStatus($"Device {item.Key}: Result: {item.Value.Value}, {item.Value.Key}"); } if (results.Any(x => x.Value.Value == false)) { return(new PluginExecutionResult(PluginResult.Failed)); } return(new PluginExecutionResult(PluginResult.Passed)); }
/// <summary> /// Initializes the configuration control with default settings. /// </summary> /// <param name="environment"></param> public void Initialize(PluginEnvironment environment) { _data = new DeviceConfigurationActivityData(); assetSelectionControl.Initialize(Framework.Assets.AssetAttributes.None); }