예제 #1
0
        /// <summary>
        /// 加载数据库表 返回JSon
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTableNameTreeJson()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            if (Config.GetValue("CodeMaticMode") == "PowerDesigner")
            {
                XmlNodeList myXmlNodeList = _codematicbll.GetTableName();
                foreach (XmlNode myXmlNode in myXmlNodeList)
                {
                    sb.Append("{");
                    sb.Append("\"id\":\"" + myXmlNode.ChildNodes[2].InnerText + "\",");
                    sb.Append("\"text\":\"" + myXmlNode.ChildNodes[1].InnerText + "\",");
                    sb.Append("\"value\":\"" + myXmlNode.ChildNodes[2].InnerText + "\",");
                    sb.Append("\"title\":\"" + myXmlNode.ChildNodes[2].InnerText + "\",");
                    sb.Append("\"img\":\"/Content/Images/Icon16/dataBase_table.png\",");
                    sb.Append("\"isexpand\":true,");
                    sb.Append("\"hasChildren\":false,");
                    sb.Append("\"ChildNodes\":[]");
                    sb.Append("},");
                }
            }
            else if (Config.GetValue("CodeMaticMode") == "DataBase")
            {
                DataTable dt = _basedatabasebll.GetList();
                if (DataHelper.IsExistRows(dt))
                {
                    foreach (DataRow itemRow in dt.Rows)
                    {
                        sb.Append("{");
                        sb.Append("\"id\":\"" + itemRow["name"] + "\",");
                        sb.Append("\"text\":\"" + itemRow["tdescription"] + "\",");
                        sb.Append("\"value\":\"" + itemRow["name"] + "\",");
                        sb.Append("\"title\":\"" + itemRow["name"] + "\",");
                        sb.Append("\"img\":\"/Content/Images/Icon16/dataBase_table.png\",");
                        sb.Append("\"isexpand\":true,");
                        sb.Append("\"hasChildren\":false,");
                        sb.Append("\"ChildNodes\":[]");
                        sb.Append("},");
                    }
                }
            }
            sb = sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            return(Content(sb.ToString()));
        }
예제 #2
0
 /// <summary>
 /// 【数据库管理】返回列表JONS
 /// </summary>
 /// <returns></returns>
 public ActionResult GridListJson(string tableName)
 {
     try
     {
         Stopwatch watch    = CommonHelper.TimerStart();
         DataTable listData = _baseDatabasebll.GetList(tableName);
         var       jsonData = new
         {
             records  = listData.Rows.Count,
             costtime = CommonHelper.TimerEnd(watch),
             rows     = listData,
         };
         string str = Util.Json.ToJson(jsonData);
         return(Content(Util.Json.ToJson(jsonData)));
     }
     catch (Exception ex)
     {
         BaseSysLogBll.Instance.WriteLog("", OperationType.Query, "-1", "异常错误:" + ex.Message);
         return(null);
     }
 }