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"));
        }