public override ExecuteResult Execute(HandlerStartInfo startInfo) { ExecuteResult result = new ExecuteResult(); result.Status = StatusType.Success; if (startInfo.Parameters != null) { parameters = this.DeserializeOrDefault <HandlerParameters>(startInfo.Parameters); } OnLogMessage("ConfigValues", "================================"); OnLogMessage("ConfigValues", "ConfigValue1 = " + config.ConfigValue1); OnLogMessage("ConfigValues", "ConfigValue2 = " + config.ConfigValue2); foreach (String value in config.ConfigValues3) { OnLogMessage("ConfigValues", "ConfigValue3 = " + value); } OnLogMessage("ParamValues", "================================"); OnLogMessage("ParamValues", "ParamValue1 = " + parameters.ParamValue1); OnLogMessage("ParamValues", "ParamValue2 = " + parameters.ParamValue2); foreach (String param in parameters.ParamValues3) { OnLogMessage("ParamValues", "ParamValue3 = " + param); } return(result); }
/// <summary> /// GetCpuUsage /// </summary> /// <param name="sender">Websocket object</param> public void GetRamUsage(object sender) { HandlerParameters parameter = (HandlerParameters)sender; try { //LogMessage("StartMonitoring Method Started.", ((NativeWebSocket)parameter.Sender)); statusEx.setValues(); //double data = Convert.ToDouble(MEMORYSTATUSEX.graphMemory); Hashtable ramUsage = new Hashtable(); ramUsage.Add("ramUsage", statusEx); Dictionary <string, Hashtable> response = new Dictionary <string, Hashtable>(); response.Add("GetRamUsage", ramUsage); bool successMessage = false; if (ramUsage.Count > 0) { successMessage = true; } Response res = parameter.Args.RequestInfo.GenerateResponse(successMessage, response); ((NativeWebSocket)parameter.Sender).SendResponse(res); } catch (Exception ex) { //LogMessage(ex.Message + " Exception in ILETSNetLib.validateQuality() " + ex.StackTrace, ((NativeWebSocket)parameter.Sender)); } }
/// <summary> /// GetCpuUsage /// </summary> /// <param name="sender">Websocket object</param> public void GetCpuUsage(object sender) { HandlerParameters parameter = (HandlerParameters)sender; try { //LogMessage("StartMonitoring Method Started.", ((NativeWebSocket)parameter.Sender)); int data = parameter.Instance.GetCpuUsage(); Hashtable cpuUsage = new Hashtable(); cpuUsage.Add("cpuUsage", data); Dictionary <string, Hashtable> response = new Dictionary <string, Hashtable>(); response.Add("GetCpuUsage", cpuUsage); bool successMessage = false; if (cpuUsage.Count > 0) { successMessage = true; } Response res = parameter.Args.RequestInfo.GenerateResponse(successMessage, response); ((NativeWebSocket)parameter.Sender).SendResponse(res); } catch (Exception ex) { //LogMessage(ex.Message + " Exception in ILETSNetLib.validateQuality() " + ex.StackTrace, ((NativeWebSocket)parameter.Sender)); } }
/// <summary> /// GetDiskUsage /// </summary> /// <param name="sender">Websocket object</param> public void GetCpuAlerts(object sender) { HandlerParameters parameter = (HandlerParameters)sender; try { //LogMessage("StartMonitoring Method Started.", ((NativeWebSocket)parameter.Sender)); DB_Access sqldb = new DB_Access(); DataSet alerts = sqldb.getCPUAlerts(parameter.Args.RequestInfo.Parameters["from"], parameter.Args.RequestInfo.Parameters["to"]); Hashtable cpuAlerts = new Hashtable(); cpuAlerts.Add("cpuAlerts", alerts); Dictionary <string, Hashtable> response = new Dictionary <string, Hashtable>(); response.Add("GetCpuAlerts", cpuAlerts); bool successMessage = false; if (cpuAlerts.Count > 0) { successMessage = true; } Response res = parameter.Args.RequestInfo.GenerateResponse(successMessage, response); ((NativeWebSocket)parameter.Sender).SendResponse(res); } catch (Exception ex) { //LogMessage(ex.Message + " Exception in ILETSNetLib.validateQuality() " + ex.StackTrace, ((NativeWebSocket)parameter.Sender)); } }
static void Main(string[] args) { HandlerKind operation; SequenceHandler fibHandler = new FibonacciSequenceHandler(); SequenceHandler squaresHandler = new SquaresLessThanNSequenceHandler(); fibHandler.SetNextHandler(squaresHandler); StartLogging(); do { ulong[] arguments; UI.PrintMenu(); operation = UI.GetOperation(); if (operation != HandlerKind.Empty) { UI.PrintParamHelper(operation); UI.GetArgs(out arguments); HandlerParameters parameters = new HandlerParameters(operation, arguments); UI.PrintSequence(fibHandler.Handle(parameters)); } } while (UI.IsProgramContinued()); FinishLogging(); }
static void nws_GetDiskUsageMethodReceived(object sender, MethodReceivedEventArgs args) { try { HandlerParameters parameter = new HandlerParameters(sender, Instance, args); Thread thread = new Thread(new ParameterizedThreadStart(responseHandler.GetDiskUsage)); thread.Start(parameter); } catch (Exception ex) { //SendError(ex.Message + " Exception in ILETSNetLib.checkSystem() " + ex.StackTrace); } }
public override object GetParametersInstance() { HandlerParameters parms = new HandlerParameters(); parms.Text = @"SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG = ?"; parms.IsQuery = true; parms.Parameters = new List <ParameterType>(); ParameterType p = new ParameterType(); p.Name = @"NotReallyUsedInOdbc"; p.Value = @"SANDBOX"; parms.Parameters.Add(p); return(parms); }
/// <summary> /// Method used to call if an undefined method name is sent in the request name /// </summary> /// <param name="sender">Websocket object</param> public void UndefinedMethodRecievedHandler(object sender) { HandlerParameters parameter = (HandlerParameters)sender; try { //LogMessage("UndefinedMethod Method Started.", ((NativeWebSocket)parameter.Sender)); Response res = parameter.Args.RequestInfo.GenerateResponse(false); ((NativeWebSocket)parameter.Sender).SendResponse(res); } catch (Exception ex) { //LogMessage(ex.Message + " Exception in UndefinedMethodRecieved() " + ex.StackTrace, ((NativeWebSocket)parameter.Sender)); } }
public override object GetParametersInstance() { HandlerParameters parms = new HandlerParameters(); parms.Text = @"SELECT * FROM PRESIDENTS WHERE AGE > :AGE"; parms.IsQuery = true; parms.Parameters = new List <ParameterType>(); ParameterType p = new ParameterType(); p.Name = @"AGE"; p.Value = @"70"; parms.Parameters.Add(p); return(parms); }
public override ExecuteResult Execute(HandlerStartInfo startInfo) { ExecuteResult result = new ExecuteResult(); result.Status = StatusType.Success; // TODO : Implement DryRun Functionality if (startInfo.IsDryRun) { throw new NotImplementedException("Dry Run Functionality Has Not Yet Been Implemented."); } if (startInfo.Parameters != null) { parameters = this.DeserializeOrDefault <HandlerParameters>(startInfo.Parameters); } OdbcDatabaseEngine db = new OdbcDatabaseEngine(config, parameters, Logger); result.ExitData = db.ExecuteCommand(startInfo.IsDryRun); return(result); }
protected override void ProcessRecord() { using (var vlt = Util.VaultHelper.GetVault(VaultProfile)) { vlt.OpenStorage(); var v = vlt.LoadVault(); if (v.ProviderProfiles == null) { WriteVerbose("Initializing Provider Profile collection"); v.ProviderProfiles = new Vault.Util.EntityDictionary <Vault.Model.ProviderProfileInfo>(); } WriteVerbose($"Searching for existing Provider Profile for reference [{ProfileName}]"); var ppi = v.ProviderProfiles.GetByRef(ProfileName, throwOnMissing: false); if (ppi == null) { WriteVerbose("No existing Profile found"); } else { WriteVerbose($"Existing Profile found [{ppi.Id}][{ppi.Alias}]"); } if (!string.IsNullOrEmpty(Rename)) { if (ppi == null) { throw new KeyNotFoundException("no existing profile found that can be renamed"); } v.ProviderProfiles.Rename(ProfileName, Rename); ppi.Alias = Rename; } else if (Remove) { WriteVerbose($"Removing named Provider Profile for name [{ProfileName}]"); if (ppi == null) { WriteVerbose("No Provider Profile found for given name"); return; } else { v.ProviderProfiles.Remove(ppi.Id); WriteVerbose("Provider Profile removed"); } } else { if (ppi != null) { if (!Force) { throw new InvalidOperationException("existing profile found;" + " specify -Force to overwrite"); } WriteVerbose("Removing existing Profile"); v.ProviderProfiles.Remove(ppi.Id); } if (ChallengeHandlerExtManager.GetProviderInfo(Handler) == null) { throw new ArgumentException("Unknown or invalid Handler provider name") .With(nameof(Handler), Handler); } WriteVerbose("Adding new Provider Profile Info"); ppi = new Vault.Model.ProviderProfileInfo { Id = Guid.NewGuid(), Alias = ProfileName, Label = Label, Memo = Memo, }; var pp = new ProviderProfile { ProfileParameters = new Dictionary <string, object> { [nameof(ChallengeType)] = ChallengeType, }, ProviderType = ProviderType.CHALLENGE_HANDLER, ProviderName = Handler, InstanceParameters = (IReadOnlyDictionary <string, object> )HandlerParameters.Convert <string, object>(), }; var asset = vlt.CreateAsset(Vault.VaultAssetType.ProviderConfigInfo, ppi.Id.ToString()); using (var s = vlt.SaveAsset(asset)) { JsonHelper.Save(s, pp); } v.ProviderProfiles.Add(ppi); } vlt.SaveVault(v); } }