private List <AppReturn> ProcessQParam(dynamic data = null) { // add JArray parameters to AppArgs with key _g.KEY_REQ_ARGS_ARR then process if (data == null) { data = _g.TKVStr(AppArgs, _g.KEY_QPARAM_JSON); } // if not in json array format, ie. JValue if (data.GetType().Name != "JArray") { data = DALGlobals.btoJA(data.ToString()); } //AppArgs.Add(_g.KEY_REQ_ARGS_ARR, DALGlobals.btoJA(data)); AppArgs.Add(_g.KEY_REQ_ARGS_ARR, data); return(ExecuteGetRequest()); }
public List <AppReturn> get(string table, string key = "", string keyField = "", string includedFields = "", string filter = "", string sortFields = "", string pageNumber = "0", string pageSize = "0", string requestConfig = "", string fieldMap = "") //string keyField = "") { //_g.CONFIG_FILE = "ngarbi.settings.json"; // process request where all parameters are embedded in the Base64 querystring parameter "_p" // Add all parameters to the AppArgs object List <AppReturn> retVal = new List <AppReturn> { }; if (isAppDebug) { return new List <AppReturn> { DebugPath } } ; AppReturn appReturn = new AppReturn(); if (table == "@gents") { // Generate client-side typescript files AppDataset.Initialize(); appReturn.props.Add("Tables", AppDataset.AppTables.Count()); appReturn.subsKey = "Hello Test Me!"; appReturn.props.Add("Views", AppDataset.AppViews.Count()); appReturn.props.Add("StoredProcedures", AppDataset.AppProcedures.Count()); foreach (string tblCode in AppDataset.AppTables.Keys) { DALTable tbl = AppDataset.AppTables[tblCode]; appReturn.processLogs.Add(tblCode, tbl.tableName); appReturn.processLogs.Add(tblCode + "_relation", tbl.tableRelations == null ? "0" : tbl.tableRelations.Count.ToString()); foreach (string pv in tbl.tableProcessLogs.Keys) { appReturn.processLogs.Add(tblCode + "_proc_" + pv, tbl.tableProcessLogs[pv]); } } //retVal.Add(appReturn); return retVal; return(new List <AppReturn> { appReturn }); } if (table == "@locs") { Stopwatch st = new Stopwatch(); st.Start(); string[] keyArr = key.Split('`'); string pCode = ""; if (keyArr.Length >= 2) { pCode = keyArr[1]; } DALData.DAL.BuildNodeLocation(Convert.ToInt32(keyArr[0]), pCode); appReturn.returnCode = table; st.Stop(); appReturn.requestDuration = st.ElapsedMilliseconds; return(new List <AppReturn> { appReturn }); } if (table == "@mtbl") { // multi table query, accepts json formatted parameters supplied as // Base64 encoded querystring parameters named ?p= // api call <protocol>://<domain>[/application]/api/app/@mtbl?p=<base64 encoded parameters> return(new List <AppReturn> { appReturn }); } if (isAppDebugPaths) { return new List <AppReturn> { DebugPath } } ; JObject jArgs = new JObject() { }; // split "table" parameter to get the parent table code (first element) and from clause join codes (second element) string[] tableArr = table.Split('|'); jArgs.Add("code", tableArr[0]); if (tableArr.Length > 1) { jArgs.Add("fromClauseExpr", tableArr[1]); } jArgs.Add("key", (key == "-" ? "" : key)); jArgs.Add("keyField", (keyField == "-" ? "" : keyField)); jArgs.Add("includedFields", (includedFields == "-" ? "" : includedFields)); jArgs.Add("filter", (filter == "-" ? "" : filter)); jArgs.Add("fieldMap", (filter == "-" ? "" : fieldMap)); jArgs.Add("sortFields", (sortFields == "-" ? "" : sortFields)); jArgs.Add("pageNumber", (!pageNumber.All(char.IsDigit) ? 0 : Convert.ToInt64(pageNumber))); jArgs.Add("pageSize", (!pageSize.All(char.IsDigit) ? 0 : Convert.ToInt64(pageSize))); jArgs.Add("requestConfig", (requestConfig == "-" ? "" : requestConfig)); jArgs.Add("snapshot", _g.TKVBln(AppArgs, "snapshot")); jArgs.Add("distinct", _g.TKVBln(AppArgs, "distinct")); AppArgs.Add(_g.KEY_REQ_ARGS_ARR, new JArray() { jArgs }); return(ExecuteGetRequest()); } //public ReturnObjectExternal xxxxpostX(string table, [FromBody]JObject values) //{ // ReturnObject retVal = AppDataset.Post(table, values, AppArgs); // return retVal.result; //} /********************************************************************************************************** * Private Methods *********************************************************************************************************/ //private JObject AppArgs() //{ // // Collect query string arguments and some headers ... // JObject ret = new JObject(); // List<KeyValuePair<string, string>> retList = ControllerContext.Request.GetQueryNameValuePairs().ToList(); // // add request data/time stamp // retList.Add(new KeyValuePair<string, string>(AppGlobals.KEY_REQUEST_STAMP, DateTime.Now.ToString())); // //add content type // if (this.Request.Content.Headers.Contains("Content-Type")) // { // ret.Add(new KeyValuePair<string, string>(AppGlobals.KEY_CONTENT_TYPE, this.Request.Content.Headers.ContentType.ToString().ToLower())); // } // foreach (KeyValuePair<string, string> arg in retList) // { // ret.Add(arg.Key, arg.Value); // } // return ret; //} } }
private List <AppReturn> ProcessQParam() { // add JArray parameters to AppArgs with key _g.KEY_REQ_ARGS_ARR then process AppArgs.Add(_g.KEY_REQ_ARGS_ARR, DALGlobals.btoJA(_g.TKVStr(AppArgs, _g.KEY_QPARAM_JSON))); return(ExecuteGetRequest()); }
public List <AppReturn> get(string table, string key = "", string keyField = "", string includedFields = "", string filter = "", string sortFields = "", string pageNumber = "0", string pageSize = "0", string requestConfig = "", string fieldMap = "") //string keyField = "") { //_g.CONFIG_FILE = "ngarbi.settings.json"; // process request where all parameters are embedded in the Base64 querystring parameter "_p" // Add all parameters to the AppArgs object List <AppReturn> retVal = new List <AppReturn> { }; if (isAppDebug) { return new List <AppReturn> { DebugPath } } ; AppReturn appReturn = new AppReturn(); if (table == "@gents") { // Generate client-side typescript files AppDataset.Initialize(); appReturn.props.Add("Tables", AppDataset.AppTables.Count()); appReturn.subsKey = "Hello Test Me!"; appReturn.props.Add("Views", AppDataset.AppViews.Count()); appReturn.props.Add("StoredProcedures", AppDataset.AppProcedures.Count()); foreach (string tblCode in AppDataset.AppTables.Keys) { DALTable tbl = AppDataset.AppTables[tblCode]; appReturn.processLogs.Add(tblCode, tbl.tableName); appReturn.processLogs.Add(tblCode + "_relation", tbl.tableRelations == null ? "0" : tbl.tableRelations.Count.ToString()); foreach (string pv in tbl.tableProcessLogs.Keys) { appReturn.processLogs.Add(tblCode + "_proc_" + pv, tbl.tableProcessLogs[pv]); } } //retVal.Add(appReturn); return retVal; return(new List <AppReturn> { appReturn }); } if (table == "@locs") { Stopwatch st = new Stopwatch(); st.Start(); string[] keyArr = key.Split('`'); string pCode = ""; if (keyArr.Length >= 2) { pCode = keyArr[1]; } DALData.DAL.BuildNodeLocation(Convert.ToInt32(keyArr[0]), pCode); appReturn.returnCode = table; st.Stop(); appReturn.requestDuration = st.ElapsedMilliseconds; return(new List <AppReturn> { appReturn }); } if (table == "@mtbl") { // multi table query, accepts json formatted parameters supplied as // Base64 encoded querystring parameters named ?p= // api call <protocol>://<domain>[/application]/api/app/@mtbl?p=<base64 encoded parameters> return(new List <AppReturn> { appReturn }); } if (isAppDebugPaths) { return new List <AppReturn> { DebugPath } } ; JObject jArgs = new JObject() { }; // split "table" parameter to get the parent table code (first element) and from clause join codes (second element) string[] tableArr = table.Split('|'); jArgs.Add("code", tableArr[0]); if (tableArr.Length > 1) { jArgs.Add("fromClauseExpr", tableArr[1]); } jArgs.Add("key", (key == "-" ? "" : key)); jArgs.Add("keyField", (keyField == "-" ? "" : keyField)); jArgs.Add("includedFields", (includedFields == "-" ? "" : includedFields)); jArgs.Add("filter", (filter == "-" ? "" : filter)); jArgs.Add("fieldMap", (filter == "-" ? "" : fieldMap)); jArgs.Add("sortFields", (sortFields == "-" ? "" : sortFields)); jArgs.Add("pageNumber", (!pageNumber.All(char.IsDigit) ? 0 : Convert.ToInt64(pageNumber))); jArgs.Add("pageSize", (!pageSize.All(char.IsDigit) ? 0 : Convert.ToInt64(pageSize))); jArgs.Add("requestConfig", (requestConfig == "-" ? "" : requestConfig)); jArgs.Add("snapshot", _g.TKVBln(AppArgs, "snapshot")); jArgs.Add("distinct", _g.TKVBln(AppArgs, "distinct")); AppArgs.Add(_g.KEY_REQ_ARGS_ARR, new JArray() { jArgs }); return(ExecuteGetRequest()); }