Esempio n. 1
0
        public FileResult ExportFile(string tableStr)
        {
            if (string.IsNullOrEmpty(tableStr))
            {
                return(File("text/plain", "dbd.md"));
            }

            var outInfo   = "## 数据库描述导出信息\n";
            var tableList = tableStr.Split(';').ToList();

            foreach (var item in tableList)
            {
                var tableInfo = item.Split('/').Where(g => !string.IsNullOrEmpty(g)).ToList();
                if (tableInfo.Count < 2)
                {
                    outInfo += $"### 导出 `{item}` 表参数不正确\n\n";
                }
                else
                {
                    outInfo += $"### `{item}表信息导出`\n";
                    var desc = DbMapManager.FetchTableDescruption(tableInfo[0], tableInfo[1]);
                    var data = DbMapManager.FetchTableMap(tableInfo[0], tableInfo[1]);
                    desc     = string.IsNullOrWhiteSpace(desc) ? "暂无描述" : desc;
                    outInfo += $"{DbMapManager.ConvertToMdStr(desc, data)}\n";
                }
            }

            var output = new MemoryStream();
            var writer = new StreamWriter(output, System.Text.Encoding.UTF8);

            writer.Write(outInfo);
            writer.Flush();
            output.Position = 0;
            return(File(output, "text/plain", "dbd.md"));
        }
Esempio n. 2
0
        public JsonResult FetchTableDetail(string DbName, string TableName)
        {
            if (string.IsNullOrWhiteSpace(DbName) || string.IsNullOrWhiteSpace(TableName))
            {
                return(Json(new
                {
                    Code = 0,
                    Info = "参数格式不正确"
                }));
            }

            var data = DbMapManager.FetchTableMap(DbName, TableName);

            return(Json(new
            {
                Tablename = TableName,
                Description = DbMapManager.FetchTableDescruption(DbName, TableName),
                Data = data.Select(g => new SimpleDbMapModel
                {
                    FieldName = g.FieldName,
                    FieldType = g.FieldType,
                    ByteCount = g.ByteCount,
                    FieldSize = g.FieldSize,
                    IsNullable = g.IsNullable,
                    Description = g.Description
                })
            }));
        }
Esempio n. 3
0
        public JsonResult FetchTableDescruption(string DbName, string TableName)
        {
            if (string.IsNullOrWhiteSpace(DbName) || string.IsNullOrWhiteSpace(TableName))
            {
                return(Json(new
                {
                    Code = 0,
                    Info = "参数格式不正确"
                }));
            }

            var result = DbMapManager.FetchTableDescruption(DbName, TableName);

            return(Json(new
            {
                Code = result == null ? 0 : 1,
                Info = result
            }));
        }