/// <summary> /// 生成配置数据 /// </summary> /// <param name="code"></param> /// <param name="sqlStr"></param> /// <returns></returns> public async Task <ResultObj <string> > MakeQueryCfg(string code) { ResultObj <String> reObj = new ResultObj <String>(); QuerySearchDto inEnt = new QuerySearchDto() { code = code }; JObject reEnt = new JObject(); SysQueryEntity query = await dal.Single(i => i.code == inEnt.code); if (query == null) { return(reObj); } IList <QueryCfg> cfg = new List <QueryCfg>(); if (!string.IsNullOrEmpty(query.queryCfgJson)) { cfg = TypeChange.ToJsonObject <List <QueryCfg> >(query.queryCfgJson); } string whereStr = ""; string AllSql = MakeSql(inEnt, query.queryConf, ref whereStr); reObj.msg = MakePageSql(AllSql); try { DataTable dt = dal.GetDataTable(reObj.msg); for (int i = 0; i < dt.Columns.Count; i++) { var t = dt.Columns[i]; var tmp = t.DataType.FullName.ToLower().Substring(t.DataType.FullName.IndexOf(".") + 1); IList <string> numberList = new[] { "int", "decimal", "double", "int64", "int16" }; if (numberList.Contains(tmp)) { tmp = "int"; } string searchType = ""; switch (tmp) { case "int": searchType = "numberbox"; break; case "datetime": searchType = "datetimebox"; break; default: searchType = "text"; break; } JObject itemObj = new JObject(); itemObj["title"] = t.ColumnName; itemObj["type"] = searchType; itemObj["editable"] = true; reEnt[t.ColumnName] = itemObj; } reObj.data = reEnt.ToString(); return(reObj); } catch { return(reObj); } }