public override string Execute() { var sid = m_Args.AttrByName(CONFIG_SID_ATTR).ValueAsULong(); var cname = m_Args.AttrByName(CONFIG_NAME_ATTR).Value; var param = m_Args.AttrByName(CONFIG_PARAM_ATTR).Value; var value = m_Args.AttrByName(CONFIG_VALUE_ATTR).Value; var call = m_Args[CONFIG_CALL_ATTR, CONFIG_CALL_LIST_ATTR]; //todo: add accept: header to return json etc... //cman{ sid=123 call-list{} }}; // for Help //cman{ sid=123 call{ directsql{sql="select 2+2 from DUAL"} }}; var sb = new StringBuilder(1024); sb.AppendLine(AppRemoteTerminal.MARKUP_PRAGMA); sb.Append("<push><f color=gray>"); sb.AppendLine("Component Manager"); sb.AppendLine("----------------------"); if (sid == 0 && cname.IsNullOrWhiteSpace()) { listAll(sb); } else { ApplicationComponent cmp = null; if (sid > 0) { cmp = ApplicationComponent.GetAppComponentBySID(App, sid); } if (cmp == null && cname.IsNotNullOrWhiteSpace()) { cmp = ApplicationComponent.GetAppComponentByCommonName(App, cname); } if (cmp != null) { if (call.Exists) { doCall(sb, cmp, call, call.IsSameName(CONFIG_CALL_LIST_ATTR)); } else { details(sb, cmp, param, value); } } else { sb.AppendFormat("<f color=red>Component with the supplied SID and CommonName was not found\n"); } } sb.AppendLine("<pop>"); return(sb.ToString()); }
public object SetComponentParameter(ulong sid, string key, string val) { var cmp = ApplicationComponent.GetAppComponentBySID(sid); if (cmp == null) { return new { OK = false, err = "Component (SID={0}) couldn't be found".Args(sid) } } ; var parameterized = cmp as IExternallyParameterized; if (parameterized == null) { return new { OK = false, err = "Component (SID={0}) doesn't implement IExternallyParameterized".Args(sid) } } ; if (!parameterized.ExternalSetParameter(key, val)) { return new { OK = false, err = "Parameter \"{0}\" of component (SID={1}) couldn't be set to value \"{2}\"".Args(key, sid, val) } } ; object setVal; parameterized.ExternalGetParameter(key, out setVal); var valStr = setVal.AsString(); if (valStr.IsNotNullOrWhiteSpace() && valStr.StartsWith(NFX.CoreConsts.EXT_PARAM_CONTENT_LACONIC)) { valStr = valStr.Substring(NFX.CoreConsts.EXT_PARAM_CONTENT_LACONIC.Length); return(new { OK = true, val = valStr.AsLaconicConfig().ToJSONDataMap() }); } else { return(new { OK = true, val = setVal }); } }
public override string Execute() { var sid = m_Args.AttrByName(CONFIG_SID_ATTR).ValueAsULong(); var cname = m_Args.AttrByName(CONFIG_NAME_ATTR).Value; var param = m_Args.AttrByName(CONFIG_PARAM_ATTR).Value; var value = m_Args.AttrByName(CONFIG_VALUE_ATTR).Value; var sb = new StringBuilder(1024); sb.AppendLine(AppRemoteTerminal.MARKUP_PRAGMA); sb.Append("<push><f color=gray>"); sb.AppendLine("Component Manager"); sb.AppendLine("----------------------"); if (sid == 0 && cname.IsNullOrWhiteSpace()) { listAll(sb); } else { ApplicationComponent cmp = null; if (sid > 0) { cmp = ApplicationComponent.GetAppComponentBySID(App, sid); } if (cmp == null && cname.IsNotNullOrWhiteSpace()) { cmp = ApplicationComponent.GetAppComponentByCommonName(App, cname); } if (cmp != null) { details(sb, cmp, param, value); } else { sb.AppendFormat("<f color=red>Component with the supplied SID and CommonName was not found\n"); } } sb.AppendLine("<pop>"); return(sb.ToString()); }
public static ApplicationComponent GetApplicationComponentBySIDorName(IApplication app, IConfigSectionNode args) { if (args == null || !args.Exists) { return(null); } ApplicationComponent cmp = null; var sid = args.AttrByName(CONFIG_SID_ATTR).ValueAsULong(); var cname = args.AttrByName(CONFIG_NAME_ATTR).Value; if (sid > 0) { cmp = ApplicationComponent.GetAppComponentBySID(app, sid); } if (cmp == null && cname.IsNotNullOrWhiteSpace()) { cmp = ApplicationComponent.GetAppComponentByCommonName(app, cname); } return(cmp); }