private PluginExecutionResult ExecuteHpcrComAction(PrintDeviceInfo asset, HpcrActivityData data, string serverAddress) { _device = DeviceConstructor.Create(asset); try { switch (data.HpcrAction) { case HpcrAction.Install: Install(serverAddress, data.DeviceGroup, _device.Address, _device.AdminPassword); break; case HpcrAction.Uninstall: Uninstall(serverAddress, data.DeviceGroup, _device.Address, _device.AdminPassword); break; } } catch (WebException wex) { ExecutionServices.SystemTrace.LogError($"Hpcr Action {data.HpcrAction} failed on device:{_device.Address}", wex); UpdateStatus($"{asset.AssetId}: Failed with exception: {wex.Message}"); return(new PluginExecutionResult(PluginResult.Failed, wex.Message)); } _device.Dispose(); UpdateStatus($"{asset.AssetId}-{data.HpcrAction}: Passed"); return(new PluginExecutionResult(PluginResult.Passed)); }
public JetAdvantageManager(PluginExecutionData executionData, DeviceWorkflowLogger workflowLogger, IDevice device, PrintDeviceInfo printDeviceInfo) { _pluginExecutionData = executionData; _activityData = executionData.GetMetadata <JetAdvantageActivityData>(); _device = device; _printDeviceInfo = printDeviceInfo; WorkflowLogger = workflowLogger; }
/// <summary> /// Executes this plug-in'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) { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Skipped); _data = executionData.GetMetadata <PaperCutInstallerActivityData>(); _serverInfo = executionData.Servers.FirstOrDefault(); _printDeviceInfo = executionData.Assets.OfType <PrintDeviceInfo>().FirstOrDefault(); _device = DeviceConstructor.Create(_printDeviceInfo); var bundleInstaller = new BundleInstaller(_device as JediOmniDevice); try { _signedSessionId = bundleInstaller.SignIn(string.Empty); switch (_data.Action) { case PaperCutInstallerAction.Install: { result = bundleInstaller.InstallSolution(_signedSessionId, _data.BundleFile); } break; case PaperCutInstallerAction.Register: { result = RegisterDevice(); } break; case PaperCutInstallerAction.ConfigureCredentials: case PaperCutInstallerAction.ConfigureSettings: { result = ConfigureDevice(); } break; } } catch (WebException wex) { _device.Dispose(); ExecutionServices.SystemTrace.LogError( $"PaperCut Installer Action {_data.Action} failed on device:{_device.Address}", wex); UpdateStatus($"{_printDeviceInfo.AssetId}: Failed with exception: {wex.Message}"); return(new PluginExecutionResult(PluginResult.Failed, wex.Message)); } catch (Exception ex) { _device.Dispose(); ExecutionServices.SystemTrace.LogError( $"PaperCut Installer Action {_data.Action} failed on device:{_device.Address}", ex); UpdateStatus($"{_printDeviceInfo.AssetId}: Failed with exception: {ex.Message}"); return(new PluginExecutionResult(PluginResult.Failed, ex.Message)); } _device.Dispose(); UpdateStatus($"{_printDeviceInfo.AssetId}: {result.Result}"); return(result); }
public PluginExecutionResult Execute(PluginExecutionData executionData) { var result = new PluginExecutionResult(PluginResult.Passed); IAssetInfo printAsset = (IAssetInfo)executionData.Assets.First();; DeviceWorkflowLogger workflowLogger = new DeviceWorkflowLogger(executionData); PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First(); var activityData = executionData.GetMetadata <JetAdvantageActivityData>(); try { using (_device = GetDevice(printDeviceInfo)) { FillFormWithActivityData(activityData); workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin); UpdateStatus("Starting JetAdvantage Pull Printing Application"); _manager = new JetAdvantageManager(executionData, workflowLogger, _device, printDeviceInfo); _manager.StatusUpdate += _manager_StatusUpdate; var token = new AssetLockToken(printAsset, TimeSpan.FromHours(1), TimeSpan.FromHours(1)); ExecutionServices.CriticalSection.Run(token, () => { var retryManager = new PluginRetryManager(executionData, UpdateStatus); result = retryManager.Run(() => _manager.RunJetAdvantage()); }); } 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 (ScalableTest.Framework.Synchronization.AcquireLockTimeoutException) { return(new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable.")); } catch (ScalableTest.Framework.Synchronization.HoldLockTimeoutException) { return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {TimeSpan.FromHours(1)}.", "Automation timeout exceeded.")); } finally { UpdateStatus($"Finished JetAdvantage Printing activity"); } return(result); }
public PluginExecutionResult Execute(PluginExecutionData executionData) { _activityData = executionData.GetMetadata <WirelessAssociationActivityData>(); PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First(); _device = DeviceConstructor.Create(printDeviceInfo); _httpClientHandler = new HttpClientHandler { AllowAutoRedirect = true, UseCookies = false, MaxAutomaticRedirections = 2 }; ServicePointManager.Expect100Continue = false; ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; try { _ssid = WirelessAssociationActivityData.StringToHexConversion(_activityData.Ssid); _passPhrase = WirelessAssociationActivityData.StringToHexConversion(_activityData.Passphrase); switch (_activityData.AuthenticationType) { case AuthenticationMode.WPAAES: { _jediProfileString = string.Format(Properties.Resources.VEPWPA2AESProfilesValue, _activityData.Ssid, _activityData.Passphrase); } break; case AuthenticationMode.WPAHex: { _jediProfileString = string.Format(Properties.Resources.VEPWPA2HexProfilesValue, _activityData.Ssid, _passPhrase); } break; case AuthenticationMode.WPAAuto: { _jediProfileString = string.Format(Properties.Resources.VEPWPA2AutoProfilesValue, _activityData.Ssid, _activityData.Passphrase); } break; case AuthenticationMode.AutoAES: { _siriusTriptaneProfileString = string.Format(Properties.Resources.TriptaneAutoAESProfilesValue, _ssid, _passPhrase); _jediProfileString = string.Format(Properties.Resources.VEPAutoAESProfilesValue, _activityData.Ssid, _activityData.Passphrase); } break; } PersonalWirelessSetting(); } catch (Exception exception) { return(new PluginExecutionResult(PluginResult.Failed, $"Failed for {_device.Address} with exception:{exception.Message}")); } return(new PluginExecutionResult(PluginResult.Passed)); }
private void ConfigureDevice(PrintDeviceInfo printDeviceInfo, List <HpacConfiguration> configuration) { _hpacController.ConfigureDevice(printDeviceInfo, configuration); UpdateStatus("Configured the device on HPAC server."); //check if the device has rebooted and wait if it is so UpdateStatus("Checking if the device has rebooted due to deployment."); CheckAndWaitForDeviceReboot(printDeviceInfo); UpdateStatus("Checking the server for deployment status."); _hpacController.CheckForDeployment(printDeviceInfo); UpdateStatus("Deployment completed."); }
private string CreateDeviceList(PrintDeviceInfo deviceInfo) { string activityUrn = "urn:hp:imaging:con:service:systemconfiguration:SystemConfigurationService"; string endpoint = "systemconfiguration"; string deviceListFileName = string.Empty; var jediDevice = new JediDevice(deviceInfo.Address, deviceInfo.AdminPassword); var systemConfigurationTicket = jediDevice.WebServices.GetDeviceTicket(endpoint, activityUrn); var deviceListDoc = XDocument.Parse(Properties.Resources.DeviceList); deviceListDoc.Element("DeviceList")?.Element("Name")?.SetValue($"DL#{DateTime.Now:HHmmdd}"); var deviceGuid = Guid.NewGuid(); var deviceElement = deviceListDoc.Element("DeviceList")?.Element("Devices")?.Elements("Device") .FirstOrDefault(); if (deviceElement != null) { deviceElement.Attribute("guid")?.SetValue(deviceGuid); deviceElement.Attribute("deviceId")? .SetValue( $"{systemConfigurationTicket.FindElement("MakeAndModel").Value}#{systemConfigurationTicket.FindElement("SerialNumber").Value}"); deviceElement.Attribute("ipAddress")?.SetValue(deviceInfo.Address); //we need to enter hashed password here, so let's do that later string hashedPassword = EncryptStringByAes(deviceInfo.AdminPassword, SaltString, BoundaryAeshk); deviceElement.Element("Password")?.SetValue($"{hashedPassword}"); deviceElement.Element("Model")?.SetValue(systemConfigurationTicket.FindElement("MakeAndModel").Value); deviceElement.Element("Hostname")?.SetValue(HostName(jediDevice)); deviceElement.Element("FactoryDefaultHostname")?.SetValue(HostName(jediDevice)); deviceElement.Element("MacAddress")?.SetValue(MacId(jediDevice)); deviceElement.Element("FwVersion")?.SetValue(jediDevice.GetDeviceInfo().FirmwareRevision); var fwDateTimeString = jediDevice.GetDeviceInfo().FirmwareDateCode; string format = "yyyyMMdd"; DateTime fwDateTime = DateTime.ParseExact(fwDateTimeString, format, CultureInfo.InvariantCulture); deviceElement.Element("FwDate")?.SetValue(fwDateTime.ToString("s")); deviceElement.Element("Ram")?.SetValue(systemConfigurationTicket.FindElement("MemoryInstalled").Value); deviceElement.Element("SerialNumber")?.SetValue(systemConfigurationTicket.FindElement("SerialNumber").Value); } string scheduledTaskFolder = $@"\\{_serverInfo.Address}\c$\Program Files (x86)\HP\Embedded Capture Installer\scheduledTaskFiles"; scheduledTaskFolder = Path.Combine(scheduledTaskFolder, _sessionId); UserImpersonator.Execute(() => deviceListFileName = CreateRemoteXmlFile(scheduledTaskFolder, "deviceList.xml", deviceListDoc), new NetworkCredential(_credential.UserName, _credential.Password, _credential.Domain)); return(deviceListFileName); }
static void Main(string[] args) { var simulator = new PluginFrameworkSimulator(); // Uncomment the following lines to run the plugin general example simulator.ConfigurationControlType = typeof(SdkGeneralExampleConfigControl); simulator.ExecutionEngineType = typeof(SdkGeneralExampleExecutionControl); // Uncomment the following lines to run the pull print plugin example //simulator.ConfigurationControlType = typeof(SdkPullPrintExampleConfigurationControl); //simulator.ExecutionEngineType = typeof(SdkPullPrintExampleExecutionControl); // Add mock credentials simulator.SessionId = "TEST"; simulator.UserName = "******"; simulator.UserPassword = "******"; simulator.UserDomain = null; simulator.UserDnsDomain = null; // Add mock plugin settings simulator.PluginSettings["sampleKey"] = "sampleValue"; // Add sample printer to asset inventory mock // change ip address, admin password, etc. as necessary var printer = new PrintDeviceInfo("samplePrinter", (AssetAttributes.ControlPanel | AssetAttributes.Printer), "MFP", "192.168.1.1", "someAdminPassword", "productName", 9100, true); simulator.AssetInventory.AddAsset(printer); // Add sample documents to test document library mock DocumentBuilder documentBuilder = new DocumentBuilder(); documentBuilder.Group = "All Documents"; simulator.DocumentLibrary.AddDocuments(documentBuilder.BuildDocuments("foo.doc", 10)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new PluginFrameworkSimulatorForm(simulator) { Size = new System.Drawing.Size(1024, 800) }); }
/// <summary> /// Setting Custom Security Settings /// </summary> /// <param name="printer">printer Info</param> /// <param name="securityType"> Security Configuration Type</param> private void CustomSecurityConfiguration(PrintDeviceInfo printer, SecurityConfigurationType securityType) { _cookies = new CookieCollection(); Uri baseUri = new Uri($"https://{printer.Address}"); if (!string.IsNullOrEmpty(printer.AdminPassword)) { _authorizationRequired = true; Uri url = new Uri(baseUri, "hp/device/SignIn/Index"); _webRequest = HttpWebRequestValidate(url); _webRequest.CookieContainer = new CookieContainer(); _webRequest.CookieContainer.Add(_cookies); _webRequest.Headers.Add(HttpRequestHeader.Authorization, "Basic " + _strAuthorization); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SignInIndexConfig"), UserName)); } else { _configUrl = new Uri(baseUri, "welcome.html"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Get(_webRequest); if (_result.StatusCode == 0) { _authorizationRequired = true; _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Get(_webRequest); } } _cookies = _result.Cookies; _configUrl = new Uri(baseUri, "welcome.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, GetKey("WelcomeConfig")); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); int startindex = _result.Response.IndexOf("Hide\" VALUE=\"", StringComparison.OrdinalIgnoreCase) + 13; string truncatedResponse = _result.Response.Substring(startindex); int endIndex = truncatedResponse.IndexOf("\">", StringComparison.OrdinalIgnoreCase); string hideValue = truncatedResponse.Substring(0, endIndex); _configUrl = new Uri(baseUri, "level.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("LevelConfig"), securityType, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "password.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("PasswordConfig"), printer.AdminPassword, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "websecurity/http_mgmt.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("WebSecurityConfig"), _activityData.EncryptionStrength.ToLower(CultureInfo.InvariantCulture), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "mgmt_protocols.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("MgmtConfig"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "snmp.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SNMPCustomConfig"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "snmpv1v2_creds.html/config"); _webRequest = (HttpWebRequest)WebRequest.Create(_configUrl); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SNMPV1V2Config"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "acl.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("ACLConfig"), _activityData.AccessControlIpv4, _activityData.Mask, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "protocols.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("ProtocolConfig"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); int startIndex = _result.Response.IndexOf("SuserID\">", StringComparison.OrdinalIgnoreCase) + 9; string tempResponse = _result.Response.Substring(startIndex); endIndex = tempResponse.IndexOf(" / ", StringComparison.OrdinalIgnoreCase); tempResponse = tempResponse.Substring(0, endIndex); _configUrl = new Uri(baseUri, "dot1x_config.htm/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("Dot1xConfig"), tempResponse, _activityData.AuthenticationPassword, _activityData.AuthenticationPassword, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "review.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("ReviewConfig"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); PowerCyclePrinter(printer.Address); ValidateEncryption(baseUri, securityType); }
/// <summary> /// Setting Basic/Enhanced Security Settings /// </summary> /// <param name="printer">printer Info</param> /// <param name="securityType"> Security Configuration Type</param> private void BasicEnhancedSecurityConfig(PrintDeviceInfo printer, SecurityConfigurationType securityType) { _cookies = new CookieCollection(); Uri baseUri = new Uri($"https://{printer.Address}"); if (!string.IsNullOrEmpty(printer.AdminPassword)) { _authorizationRequired = true; Uri url = new Uri(baseUri, "hp/device/SignIn/Index"); _webRequest = HttpWebRequestValidate(url); _webRequest.CookieContainer = new CookieContainer(); _webRequest.CookieContainer.Add(_cookies); _webRequest.Headers.Add(HttpRequestHeader.Authorization, "Basic " + _strAuthorization); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SignInIndexConfig"), UserName)); } else { _configUrl = new Uri(baseUri, "welcome.html"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Get(_webRequest); if (_result.StatusCode == 0) { _authorizationRequired = true; _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Get(_webRequest); } } _cookies = _result.Cookies; _configUrl = new Uri(baseUri, "welcome.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, GetKey("WelcomeConfig")); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); int startindex = _result.Response.IndexOf("Hide\" VALUE=\"", StringComparison.OrdinalIgnoreCase) + 13; string truncatedResponse = _result.Response.Substring(startindex); int endIndex = truncatedResponse.IndexOf("\">", StringComparison.OrdinalIgnoreCase); string hideValue = truncatedResponse.Substring(0, endIndex); _configUrl = new Uri(baseUri, "level.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("LevelConfig"), securityType, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); _configUrl = new Uri(baseUri, "password.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("PasswordConfig"), printer.AdminPassword, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); if (securityType == SecurityConfigurationType.Enhanced) { _configUrl = new Uri(baseUri, "snmp.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SNMPConfig"), _activityData.SnmpV3Enhanced, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{ (object)_configUrl.AbsoluteUri} Status:{ (object)_result.StatusCode}"); _configUrl = new Uri(baseUri, "snmpv3_creds.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SNMPV3Config"), _activityData.Snmpv3UserName, _activityData.AuthenticationPassphraseProtocol, _activityData.PrivacyPassphraseProtocol, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{ (object)_configUrl.AbsoluteUri} Status:{ (object)_result.StatusCode}"); _configUrl = new Uri(baseUri, "snmp_legacy.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("SNMPLegacy"), _activityData.Snmpv1v2ReadOnlyAccess, hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); } _configUrl = new Uri(baseUri, "review.html/config"); _webRequest = PrepareHttpWebRequest(_configUrl); _result = HttpWebEngine.Post(_webRequest, string.Format(GetKey("ReviewConfig"), hideValue)); ExecutionServices.SystemTrace.LogDebug($"Navigating to Url:{_configUrl.AbsoluteUri} Status:{_result.StatusCode}"); PowerCyclePrinter(printer.Address); ValidateEncryption(baseUri, securityType); }
/// <summary> /// Sets up the scan job. /// </summary> /// <param name="device">The device.</param> public PluginExecutionResult Execute(PluginExecutionData executionData) { bool activityFailed = false; StringBuilder failedMessages = new StringBuilder(); _activityData = executionData.GetMetadata <ePrintAdminActivityData>(); _credential = executionData.Credential; PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First(); _device = DeviceConstructor.Create(printDeviceInfo); _userDnsName = executionData.Environment.UserDnsDomain; _ePrintServerIp = executionData.Servers.First().Address; CookieCollection loginCookie = new CookieCollection(); if (Login(loginCookie).Result == PluginResult.Failed) { return(new PluginExecutionResult(PluginResult.Failed, "Unable to login to eprint server")); } foreach (var eprintTask in _activityData.ePrintAdminTasks) { activityStatus_dataGridView.DataSource = null; try { switch (eprintTask.Operation) { case EprintAdminToolOperation.AddPrinteripv4: case EprintAdminToolOperation.AddPrinterHpac: case EprintAdminToolOperation.AddPrinterPJL: { ePrintAddPrinter(eprintTask, loginCookie); } break; case EprintAdminToolOperation.DeletePrinter: { ePrintDeletePrinter(eprintTask, loginCookie); } break; case EprintAdminToolOperation.ImportPrinter: { ePrintImportPrinter(eprintTask, loginCookie); } break; case EprintAdminToolOperation.RegularUser: case EprintAdminToolOperation.GuestUser: { AddUser(eprintTask, loginCookie); } break; case EprintAdminToolOperation.SendPrintJob: { ePrintSendPrintJob(eprintTask, loginCookie); } break; } activityStatus_dataGridView.Visible = false; activityStatus_dataGridView.DataSource = _activityData.ePrintAdminTasks; activityStatus_dataGridView.Visible = true; } catch (Exception ex) { failedMessages.AppendLine($"Failed for ActivityTask:{eprintTask.Operation} with Exception: {ex.Message}"); activityFailed = true; } } return(activityFailed ? new PluginExecutionResult(PluginResult.Failed, string.Join(",", failedMessages)) : new PluginExecutionResult(PluginResult.Passed, "All test cases passed")); }
private void UpdateAuthenticators(PrintDeviceInfo printDeviceInfo, List <HpacAuthenticators> authenticators) { _hpacController.UpdateAuthenticators(printDeviceInfo, authenticators); }
private IDevice GetDevice(PrintDeviceInfo printDeviceInfo) => DeviceConstructor.Create(printDeviceInfo);
public PluginExecutionResult Execute(PluginExecutionData executionData) { _activityData = executionData.GetMetadata <CertificateInstallerActivityData>(); PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First(); _device = DeviceConstructor.Create(printDeviceInfo); try { string authorization = string.Empty; _userAgent = GetUserAgent(_activityData.BrowserType); // Installs certificate on Client VM if (_activityData.ClientVMCA) { ExecutionServices.SystemTrace.LogDebug($"Certificate Path { (object)_activityData.CACertificate}"); InstallVMCertificate(_activityData.CACertificate); } // Check for the printer availability if (!PingUntilTimeout(IPAddress.Parse(_device.Address), TimeSpan.FromMinutes(1))) { string errorMessage = $"Ping failed with IP Address:{ (object)_device.Address}"; ExecutionServices.SystemTrace.LogDebug(errorMessage); _device.Dispose(); return(new PluginExecutionResult(PluginResult.Failed, errorMessage)); } if (!string.IsNullOrEmpty(_device.AdminPassword)) { string credentials = $"admin:{_device.AdminPassword}"; byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(credentials); authorization = "Basic " + Convert.ToBase64String(plainTextBytes); } // Enterprise Lock on device so that only one dispatcher can reserve at a time. // Action action = new Action(() => { //Installs CA certificate on the printer if (_activityData.InstallPrinterCA) { ExecutionServices.CriticalSection.Run(new AssetLockToken(executionData.Assets.First(), new LockTimeoutData(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))), () => InstallCertificate(authorization)); } //Deletes CA certificate from the printer if (_activityData.DeletePrinterCA) { ExecutionServices.CriticalSection.Run(new AssetLockToken(executionData.Assets.First(), new LockTimeoutData(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))), () => DeleteCertificate(authorization, _device.Address)); } } } catch (Exception exception) { var failureMessage = $"Activity failed on device {_device.Address} with exception {exception.Message}"; _device.Dispose(); return(new PluginExecutionResult(PluginResult.Failed, failureMessage)); } _device.Dispose(); return(new PluginExecutionResult(PluginResult.Passed)); }