Пример #1
0
        public IResult BuildController()
        {
            dpz3.db.Connection dbc = Host.Connection;
            // 生成程序相关路径
            string hostWorkFolder = Host.WorkFolder.Replace("\\", "/");

            if (!hostWorkFolder.EndsWith("/"))
            {
                hostWorkFolder += "/";
            }
            // 获取参数
            string groupName      = Request.Str["Group"];
            string itemName       = Request.Str["Item"];
            string name           = Request.Str["Name"];
            string pathXml        = $"{hostWorkFolder}conf/projects.xml";
            string folderTemplete = $"{hostWorkFolder}template/{groupName}";
            // 读取项目配置
            string szXml = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            if (item == null)
            {
                return(Fail("未发现项目信息"));
            }
            // 获取路径信息
            string workFolder = item.Attr["path"];

            // 将路径进行处理
            if (!workFolder.EndsWith("/"))
            {
                workFolder += "/";
            }
            string pathCfg = $"{workFolder}modular.json";

            if (!System.IO.File.Exists(pathCfg))
            {
                return(Fail("未找到配置文件"));
            }
            // 读取包配置文件
            string szJson = dpz3.File.UTF8File.ReadAllText(pathCfg);

            using (var json = dpz3.Json.Parser.ParseJson(szJson)) {
                // 生成文件控制器
                try {
                    PageBuilder.BuildClass(json, folderTemplete, workFolder, name);
                    PageBuilder.BuildControllerClass(json, folderTemplete, workFolder, name);
                } catch (Exception ex) {
                    return(Error(ex.Message, 0, ex.ToString()));
                }
            }
            return(Success("构架类生成成功"));
        }
Пример #2
0
        // 加载mime集合
        private void LoadMimes()
        {
            string path = $"{it.Config.WorkFolder}mime.xml";

            if (!System.IO.File.Exists(path))
            {
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var mime = xml.AddNode("mime");
                    mime.Attr["extension"] = ".html";
                    mime.Attr["value"]     = "text/html";
                    dpz3.File.UTF8File.WriteAllText(path, doc.InnerXml);
                }
            }
            string content = dpz3.File.UTF8File.ReadAllText(path);

            using (var doc = new dpz3.Xml.XmlDocument(content)) {
                var xml   = doc["xml"];
                var mimes = xml.GetNodesByTagName("mime", false);
                foreach (var mime in mimes)
                {
                    _mimes[mime.Attr["extension"].ToLower()] = mime.Attr["value"];
                }
            }
        }
Пример #3
0
 /// <summary>
 /// 填充数据
 /// </summary>
 /// <param name="node"></param>
 public void FillData(dpz3.Xml.XmlNode node)
 {
     this.Name        = node.Attr["name"];
     this.Title       = node.Attr["title"];
     this.Inherit     = node.Attr["inherit"];
     this.Description = node.Attr["description"];
 }
Пример #4
0
 /// <summary>
 /// 填充数据
 /// </summary>
 /// <param name="node"></param>
 public void FillData(dpz3.Xml.XmlNode node)
 {
     this.Name    = node.Attr["name"];
     this.Title   = node.Attr["title"];
     this.Version = node.Attr["version"];
     this.Path    = node.Attr["path"];
     this.MD5     = node.Attr["md5"];
 }
Пример #5
0
        // 安装所有的包
        private void InstallPacks()
        {
            Program.Println("[*] 初始化包管理 ...");

            string folderRoot    = $"{it.ExecPath}wwwroot";
            string folderDown    = $"{it.ExecPath}downloads";
            string folderPackage = $"{it.ExecPath}packages";

            if (!System.IO.Directory.Exists(folderRoot))
            {
                System.IO.Directory.CreateDirectory(folderRoot);
            }
            if (!System.IO.Directory.Exists(folderDown))
            {
                System.IO.Directory.CreateDirectory(folderDown);
            }
            if (!System.IO.Directory.Exists(folderPackage))
            {
                System.IO.Directory.CreateDirectory(folderPackage);
            }

            // 判断并创建配置文件
            string fileXml = $"{folderPackage}{it.SplitChar}packages.xml";

            if (!System.IO.File.Exists(fileXml))
            {
                Program.Println("[*] 正在创建包管理文件 ...");
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var packages = xml.AddNode("packages");
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }

            // 读取配置文件
            string szXml    = dpz3.File.UTF8File.ReadAllText(fileXml);
            bool   isUpdate = false;

            using (var doc = dpz3.Xml.Parser.GetDocument(szXml)) {
                var xml      = doc["xml"];
                var packages = xml["packages"];
                foreach (var package in packages.GetNodesByTagName("package", false))
                {
                    string packageName    = package.Attr["name"];
                    string packageInstall = package.Attr["version"];
                    // 添加一个包信息
                    _packages.Add(new ModularPackage(_mimes, folderPackage, packageName, packageInstall));
                }
                // 保存配置
                if (isUpdate)
                {
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }
        }
Пример #6
0
        public IResult BuildController()
        {
            dpz3.db.Connection dbc  = Host.Connection;
            string             path = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = Request.Str["Group"];
            string itemName  = Request.Str["Item"];

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            string pathXml = $"{path}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            if (item == null)
            {
                return(Fail("未发现项目信息"));
            }
            // 获取路径信息
            string workFolder = item.Attr["path"];
            // 生成文件控制器
            string pathController = $"{workFolder}/controller/bin/Debug/netcoreapp3.1/controller.dll";

            if (System.IO.File.Exists(pathController))
            {
                try {
                    System.IO.File.Delete(pathController);
                } catch (Exception ex) {
                    return(Error(ex.Message, 0, ex.ToString()));
                }
            }
            // 存储登录信息
            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
            info.WorkingDirectory = $"{workFolder}/controller";
            info.FileName         = "dotnet";
            info.Arguments        = "build /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary";
            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo = info;
            pro.Start();
            pro.WaitForExit();
            if (!System.IO.File.Exists(pathController))
            {
                return(Fail("编译失败"));
            }
            return(Success("控制器编译成功"));
        }
Пример #7
0
        /// <summary>
        /// 填充数据
        /// </summary>
        /// <param name="node"></param>
        public void FillData(dpz3.Xml.XmlNode node)
        {
            this.Name  = node.Attr["name"];
            this.Title = node.Attr["title"];
            // 获取字段定义
            var fieldData = node["data"];

            this.DataType  = fieldData.Attr["type"];
            this.DataSize  = fieldData.Attr["size"].ToInteger();
            this.DataFloat = fieldData.Attr["float"].ToInteger();
        }
Пример #8
0
        // 卸载包
        private static void ListPacks(string path)
        {
            Console.WriteLine("[*] 初始化包管理 ...");

            string folderRoot    = $"{path}wwwroot";
            string folderPackage = $"{path}packages";

            if (!System.IO.Directory.Exists(folderRoot))
            {
                System.IO.Directory.CreateDirectory(folderRoot);
            }
            if (!System.IO.Directory.Exists(folderPackage))
            {
                System.IO.Directory.CreateDirectory(folderPackage);
            }

            // 判断并创建配置文件
            string fileXml = $"{folderPackage}{it.SplitChar}packages.xml";

            if (!System.IO.File.Exists(fileXml))
            {
                Console.WriteLine("[*] 正在创建包管理文件 ...");
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var packages = xml.AddNode("packages");
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }

            // 读取配置文件
            string szXml = dpz3.File.UTF8File.ReadAllText(fileXml);

            Console.WriteLine($"[*] 读取包信息 ...");
            using (var doc = dpz3.Xml.Parser.GetDocument(szXml)) {
                var xml      = doc["xml"];
                var packages = xml["packages"];
                foreach (var package in packages.GetNodesByTagName("package", false))
                {
                    string packageName    = package.Attr["name"];
                    string packageInstall = package.Attr["version"];
                    Console.WriteLine($"[*] 包 {packageName} 安装版本:{packageInstall}");
                }
            }
        }
Пример #9
0
 /// <summary>
 /// 填充数据
 /// </summary>
 /// <param name="node"></param>
 public void FillData(dpz3.Xml.XmlNode node)
 {
     this.Version = node.Attr["version"];
 }
Пример #10
0
        public IResult index()
        {
            StringBuilder sb = new StringBuilder();

            dpz3.db.Connection dbc = Host.Connection;
            var    session         = Host.Session;
            var    request         = Host.Context.Request;
            var    response        = Host.Context.Response;
            string path            = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = $"{request.Query["group"]}";
            string itemName  = $"{request.Query["item"]}";

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            string pathXml = $"{path}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            sb.Append("<!DOCTYPE html>\n");
            sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
            sb.Append("<head>\n");
            sb.Append("<meta charset=\"utf-8\" />\n");
            sb.Append("<title>模块化网站项目管理器</title>\n");
            sb.Append("<link rel=\"icon\" href=\"/modular-project-common/manager.ico\" type=\"image/x-icon\" />\n");
            sb.Append("<script src=\"/modular-project-common/js/jquery-3.4.1.min.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/vue.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/dpz2.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/host.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/jttp.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-manage/index/page.js\"></script>\n");
            sb.Append("<link rel=\"stylesheet\" href=\"/modular-project-manage/index/page.css\" />\n");
            sb.Append("</head>\n");
            sb.Append("<body>\n");
            sb.Append("<div class=\"info\" style=\"display: none;\">正在处理,请稍等...</div>\n");
            if (item != null)
            {
                string workFolder        = item.Attr["path"];
                string workFolderXorm    = $"{workFolder}/xorm";
                string workFolderModular = $"{workFolder}/modular.json";
                // 读取包信息
                string content = dpz3.File.UTF8File.ReadAllText(workFolderModular);
                var    package = dpz3.Json.Parser.ParseJson(content);
                // 读取所有的配置文件
                string[] files = null;
                if (System.IO.Directory.Exists(workFolderXorm))
                {
                    files = System.IO.Directory.GetFiles(workFolderXorm, "*.xml");
                }
                else
                {
                    files = new string[0];
                }
                sb.Append("<div class=\"list\">\n");
                sb.Append("<dl>\n");
                sb.Append("<dt>包信息</dt>\n");
                sb.Append("<dd>名称:");
                sb.Append(package.Str["name"]);
                sb.Append("</dd>\n");
                sb.Append("<dd>版本:");
                sb.Append(package.Str["version"]);
                sb.Append("</dd>\n");
                sb.Append("<dd>描述:");
                sb.Append(package.Str["description"]);
                sb.Append("</dd>\n");
                sb.Append("<dt>快捷操作</dt>\n");
                sb.Append("<dd>\n");
                if (System.IO.File.Exists($"{workFolder}/pages/pages.sln"))
                {
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildPages('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("');\">生成页面控制器</a></s>&nbsp;\n");
                }
                if (System.IO.File.Exists($"{workFolder}/controller/controller.sln"))
                {
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildController('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("');\">编译控制器</a></s>&nbsp;\n");
                }
                sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildPackage('");
                sb.Append(groupName);
                sb.Append("','");
                sb.Append(itemName);
                sb.Append("');\">生成MP包</a></s>&nbsp;\n");
                sb.Append("</dd>\n");
                sb.Append("<dd>\n");
                if (System.IO.File.Exists($"{workFolder}/pages/pages.sln"))
                {
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.openPages('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("');\">使用VS编辑Pages</a></s>&nbsp;\n");
                }
                if (System.IO.File.Exists($"{workFolder}/controller/controller.sln"))
                {
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.openController('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("');\">使用VS编辑Controller</a></s>&nbsp;\n");
                }
                sb.Append("<s><a href=\"/modular-project-manage/dir?group=");
                sb.Append(groupName);
                sb.Append("&item=");
                sb.Append(itemName);
                sb.Append("&path=/\">浏览文件</a></s>&nbsp;\n");
                sb.Append("</dd>\n");
                sb.Append("<dt>对象映射信息</dt>\n");
                if (files.Length > 0)
                {
                    foreach (var file in files)
                    {
                        string fileContent = dpz3.File.UTF8File.ReadAllText(file);
                        using (var fileDoc = dpz3.Xml.Parser.GetDocument(fileContent)) {
                            var table = fileDoc["table"];
                            if (table != null)
                            {
                                sb.Append("<dd><i><a href=\"/modular-project-manage/Xorm?group=");
                                sb.Append(groupName);
                                sb.Append("&item=");
                                sb.Append(itemName);
                                sb.Append("&name=");
                                sb.Append(table.Attr["name"]);
                                sb.Append("\">");
                                sb.Append(table.Attr["title"]);
                                sb.Append("&nbsp;[");
                                sb.Append(table.Attr["name"]);
                                sb.Append(":");
                                sb.Append(table.Attr["version"]);
                                sb.Append("]</a></i></dd>\n");
                            }
                            else
                            {
                                sb.Append("<dd>文件");
                                sb.Append(file);
                                sb.Append("读取错误</dd>\n");
                            }
                        }
                    }
                }
                else
                {
                    sb.Append("<dd>未发现对象映射信息</dd>\n");
                }
                sb.Append("</dl>\n");
                sb.Append("</div>\n");
            }
            else
            {
                sb.Append("<div>未发现项目信息</div>\n");
            }
            sb.Append("</body>\n");
            sb.Append("</html>\n");
            return(Html(sb.ToString()));
        }
Пример #11
0
        public IResult BuildPackage()
        {
            dpz3.db.Connection dbc        = Host.Connection;
            string             workFolder = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = Request.Str["Group"];
            string itemName  = Request.Str["Item"];

            if (!workFolder.EndsWith("/"))
            {
                workFolder += "/";
            }
            string pathXml = $"{workFolder}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            if (item == null)
            {
                return(Fail("未发现项目信息"));
            }
            // 获取路径信息
            // string workFolder = item.Attr["path"];
            string path = item.Attr["path"].Replace("\\", "/");

            // 判断路径是否指定
            if (path.IsNoneOrNull())
            {
                // Console.WriteLine($"[!] 未指定路径");
                return(Fail("未指定路径"));
            }
            // 将路径进行处理
            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            string pathCfg = $"{path}modular.json";

            if (!System.IO.File.Exists(pathCfg))
            {
                //Console.WriteLine($"[!] 未找到配置文件");
                return(Fail("未找到配置文件"));
            }
            // 读取配置文件
            // Console.WriteLine($"[*] 读取配置文件 {pathCfg} ...");
            string szJson = dpz3.File.UTF8File.ReadAllText(pathCfg);
            string name;
            string version;

            using (var json = dpz3.Json.Parser.ParseJson(szJson)) {
                name    = json.Str["name"];
                version = json.Str["version"];
                // Console.WriteLine($"[*] 当前版本 {version}");
                var ver = new dpz3.TimeVersion(version);
                version = ver.GetNextVersion().ToString();
                // Console.WriteLine($"[*] 新版本 {version}");
                json.Str["version"] = version;
                dpz3.File.UTF8File.WriteAllText(pathCfg, json.ToJsonString());
            }
            // 创建临时输出目录
            string pathOutput = $"{path}output";

            if (!System.IO.Directory.Exists(pathOutput))
            {
                // Console.WriteLine($"[+] 创建目录 {pathOutput} ...");
                System.IO.Directory.CreateDirectory(pathOutput);
            }
            // 复制配置文件
            string pathOutputCfg = $"{pathOutput}/modular.json";

            Console.WriteLine($"[+] 增加拷贝文件 {pathOutputCfg} ...");
            System.IO.File.Copy(pathCfg, pathOutputCfg, true);
            // 复制静态页面
            string pathRoot = $"{path}wwwroot";

            if (System.IO.Directory.Exists(pathRoot))
            {
                string pathOutputRoot = $"{pathOutput}/wwwroot";
                if (!System.IO.Directory.Exists(pathOutputRoot))
                {
                    //Console.WriteLine($"[+] 创建目录 {pathOutputRoot} ...");
                    System.IO.Directory.CreateDirectory(pathOutputRoot);
                }
                // 复制需要打包的文件到临时文件夹中
                CopyFolder(pathRoot, pathOutputRoot);
            }
            // 复制数据库定义文件夹
            string pathXorm = $"{path}xorm";

            if (System.IO.Directory.Exists(pathXorm))
            {
                string pathOutputXorm = $"{pathOutput}/xorm";
                if (!System.IO.Directory.Exists(pathOutputXorm))
                {
                    Console.WriteLine($"[+] 创建目录 {pathOutputXorm} ...");
                    System.IO.Directory.CreateDirectory(pathOutputXorm);
                }
                // 复制需要打包的文件到临时文件夹中
                CopyFolder(pathXorm, pathOutputXorm);
            }
            // 复制控制器
            string pathController = $"{path}controller/bin/Debug/netcoreapp3.1";

            if (System.IO.Directory.Exists(pathController))
            {
                // 复制需要打包的文件到临时文件夹中
                CopyFolder(pathController, pathOutput);
            }
            // 建立包文件夹
            string pathPackage = $"{path}package";

            if (!System.IO.Directory.Exists(pathPackage))
            {
                //Console.WriteLine($"[+] 创建目录 {pathPackage} ...");
                System.IO.Directory.CreateDirectory(pathPackage);
            }
            // 打包文件
            string pathPackageFile = $"{pathPackage}/{name}-{version}.zip";

            //Console.WriteLine($"[+] 输出包文件 {pathPackageFile} ...");
            ZipFile.CreateFromDirectory(pathOutput, pathPackageFile);
            // 清理临时目录
            if (System.IO.Directory.Exists(pathOutput))
            {
                //Console.WriteLine($"[-] 清理目录 {pathOutput} ...");
                System.IO.Directory.Delete(pathOutput, true);
            }
            // 生成脚本文件
            string pathBatFile = $"{pathPackage}/{name}.bat";
            string cmd         = $"@echo off\r\n" +
                                 $"cd ..\r\n" +
                                 $".\\pm /name {name} /version {version}\r\n" +
                                 $"cd downloads\r\n" +
                                 $"del {name}.bat\r\n" +
                                 $"pause";

            dpz3.File.TextFile.WriteAllBytes(pathBatFile, System.Text.Encoding.ASCII.GetBytes(cmd));
            return(Success("生成MP包成功"));
        }
Пример #12
0
        public IResult BuildPages()
        {
            dpz3.db.Connection dbc        = Host.Connection;
            string             workFolder = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = Request.Str["Group"];
            string itemName  = Request.Str["Item"];

            if (!workFolder.EndsWith("/"))
            {
                workFolder += "/";
            }
            string pathXml = $"{workFolder}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            if (item == null)
            {
                return(Fail("未发现项目信息"));
            }
            // 获取路径信息
            // string workFolder = item.Attr["path"];
            string path = item.Attr["path"].Replace("\\", "/");

            // 判断路径是否指定
            if (path.IsNoneOrNull())
            {
                //Console.WriteLine($"[!] 未指定路径");
                return(Fail("未指定路径"));
            }
            // 将路径进行处理
            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            // 判断页面文件夹
            string pathPages = $"{path}pages";

            if (!System.IO.Directory.Exists(pathPages))
            {
                //Console.WriteLine($"[!] 未找到pages文件夹");
                return(Fail("未找到pages文件夹"));
            }
            // 判断并创建控制器工程文件夹
            string pathController = $"{path}controller/pages";

            if (!System.IO.Directory.Exists(pathController))
            {
                Console.WriteLine($"[+] 创建文件夹 {pathController} ...");
                System.IO.Directory.CreateDirectory(pathController);
                return(Fail("未找到pages文件夹"));
            }
            MakerController(pathPages, pathController, "pages", "");
            return(Success("控制器页面代码生成成功"));
        }
Пример #13
0
        public IResult Dir()
        {
            StringBuilder sb = new StringBuilder();

            dpz3.db.Connection dbc = Host.Connection;
            var    session         = Host.Session;
            var    request         = Host.Context.Request;
            var    response        = Host.Context.Response;
            string hostWorkFolder  = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = $"{request.Query["group"]}";
            string itemName  = $"{request.Query["item"]}";
            string path      = $"{request.Query["path"]}";

            path = path.Replace("//", "/");
            if (!hostWorkFolder.EndsWith("/"))
            {
                hostWorkFolder += "/";
            }
            string pathXml = $"{hostWorkFolder}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            sb.Append("<!DOCTYPE html>\n");
            sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
            sb.Append("<head>\n");
            sb.Append("<meta charset=\"utf-8\" />\n");
            sb.Append("<title>模块化网站项目管理器</title>\n");
            sb.Append("<link rel=\"icon\" href=\"/modular-project-common/manager.ico\" type=\"image/x-icon\" />\n");
            sb.Append("<script src=\"/modular-project-common/js/jquery-3.4.1.min.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/vue.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/dpz2.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/host.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/jttp.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-manage/dir/page.js\"></script>\n");
            sb.Append("<link rel=\"stylesheet\" href=\"/modular-project-manage/dir/page.css\" />\n");
            sb.Append("</head>\n");
            sb.Append("<body>\n");
            sb.Append("<div class=\"info\" style=\"display: none;\">正在处理,请稍等...</div>\n");
            if (item != null)
            {
                // 获取路径段
                string[] paths = path.Split('/');
                // 获取工作目录
                string workFolder        = item.Attr["path"];
                string workFolderXorm    = $"{workFolder}/xorm";
                string workFolderModular = $"{workFolder}/modular.json";
                sb.Append("<div class=\"list\">\n");
                sb.Append("<dl>\n");
                sb.Append("<dd>\n");
                sb.Append("<s><a href=\"/modular-project-manage/index?group=");
                sb.Append(groupName);
                sb.Append("&item=");
                sb.Append(itemName);
                sb.Append("\">返回</a></s>&nbsp;\n");
                sb.Append("<i><a href=\"/modular-project-manage/dir?group=");
                sb.Append(groupName);
                sb.Append("&item=");
                sb.Append(itemName);
                sb.Append("&path=/\">根目录</a></i>\n");
                string pathPart = "";
                for (int i = 1; i < paths.Length; i++)
                {
                    pathPart += $"/{paths[i]}";
                    sb.Append("<i>/</i>\n");
                    sb.Append("<i><a href=\"/modular-project-manage/dir?group=");
                    sb.Append(groupName);
                    sb.Append("&item=");
                    sb.Append(itemName);
                    sb.Append("&path=");
                    sb.Append(pathPart);
                    sb.Append("\">");
                    sb.Append(paths[i]);
                    sb.Append("</a></i>\n");
                }
                sb.Append("</dd>\n");
                // 获取所有文件夹
                string[] dirs = System.IO.Directory.GetDirectories($"{workFolder}{path}");
                for (int i = 0; i < dirs.Length; i++)
                {
                    string fileName = System.IO.Path.GetFileName(dirs[i]);
                    sb.Append("<dd>\n");
                    sb.Append("<img src=\"/modular-project-manage/dir/image/folder.png\" /><i><a href=\"/modular-project-manage/dir?group=");
                    sb.Append(groupName);
                    sb.Append("&item=");
                    sb.Append(itemName);
                    sb.Append("&path=");
                    sb.Append(path);
                    sb.Append("/");
                    sb.Append(fileName);
                    sb.Append("\">");
                    sb.Append(fileName);
                    sb.Append("</a></i></dd>\n");
                }
                // 获取所有文件
                string[] files = System.IO.Directory.GetFiles($"{workFolder}{path}");
                for (int i = 0; i < files.Length; i++)
                {
                    string fileName = System.IO.Path.GetFileName(files[i]);
                    if (fileName == "config.json")
                    {
                        sb.Append("<dd>\n");
                        sb.Append("<img src=\"/modular-project-manage/dir/image/file.png\" /><i>");
                        sb.Append(fileName);
                        sb.Append("</i>&nbsp;|&nbsp;<i><a href=\"javascript:;\" onclick=\"pg.buildMainPage('");
                        sb.Append(groupName);
                        sb.Append("','");
                        sb.Append(itemName);
                        sb.Append("','");
                        sb.Append(path);
                        sb.Append("');\">构建页面</a></i></dd>\n");
                    }
                    else
                    {
                        sb.Append("<dd>\n");
                        sb.Append("<img src=\"/modular-project-manage/dir/image/file.png\" /><i>");
                        sb.Append(fileName);
                        sb.Append("</i></dd>\n");
                    }
                }
                sb.Append("</dl>\n");
                sb.Append("</div>\n");
            }
            else
            {
                sb.Append("<div>未发现项目信息</div>\n");
            }
            sb.Append("</body>\n");
            sb.Append("</html>\n");
            return(Html(sb.ToString()));
        }
Пример #14
0
        /// <summary>
        /// 从字符串模板定义中加载模板结果
        /// </summary>
        /// <param name="str"></param>
        /// <param name="field"></param>
        /// <returns></returns>
        public static string FromPartString(string str, dpz3.Json.JsonUnit package, dpz3.Xml.XmlNode table, dpz3.Xml.XmlNode field)
        {
            // 字符串创建器
            StringBuilder sb = new StringBuilder();

            // 命令解析器
            ParseType     pt    = ParseType.Normal;
            StringBuilder sbCmd = new StringBuilder();

            for (int i = 0; i < str.Length; i++)
            {
                char chr = str[i];

                switch (chr)
                {
                case '$':
                    if (pt == ParseType.Define)
                    {
                        sb.Append(chr);
                        pt = ParseType.Normal;
                    }
                    else
                    {
                        pt = ParseType.Define;
                    }
                    break;

                case '{':
                    if (pt == ParseType.Define)
                    {
                        if (sbCmd.Length > 0)
                        {
                            throw new Exception("语法错误");
                        }
                        sbCmd.Append(chr);
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;

                case '}':
                    if (pt == ParseType.Define)
                    {
                        if (sbCmd.Length <= 0)
                        {
                            throw new Exception("语法错误");
                        }
                        if (sbCmd[0] != '{')
                        {
                            throw new Exception("语法错误");
                        }

                        // 获取定义内容
                        sbCmd.Remove(0, 1);
                        string cmdStr = sbCmd.ToString();
                        sbCmd.Clear();

                        string[] cmds = cmdStr.Split('.');
                        if (cmds.Length != 2)
                        {
                            throw new Exception($"不支持的对象\"{cmdStr}\"");
                        }

                        // 判断命令类型
                        switch (cmds[0])
                        {
                        case "package":
                            sb.Append(package.Str[cmds[1]]);
                            break;

                        case "table":
                            sb.Append(table.Attr[cmds[1]]);
                            break;

                        case "field":
                            if (cmds[1] == "data")
                            {
                                sb.Append(field["data"].Attr[cmds[2]]);
                            }
                            else
                            {
                                sb.Append(field.Attr[cmds[1]]);
                            }
                            //sb.Append(field.GetType().GetProperty(cmds[1]).GetValue(field));
                            break;

                        default: throw new Exception($"不支持的对象\"{cmdStr}\"");
                        }

                        // 重置解析模式
                        pt = ParseType.Normal;
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;

                default:
                    if (pt == ParseType.Define)
                    {
                        sbCmd.Append(chr);
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;
                }
            }

            return(sb.ToString());
        }
Пример #15
0
        // 重建数据库
        private static void BuildDatabase(string path)
        {
            Console.WriteLine("[*] 初始化包管理 ...");

            string folderRoot    = $"{path}wwwroot";
            string folderPackage = $"{path}packages";

            if (!System.IO.Directory.Exists(folderRoot))
            {
                System.IO.Directory.CreateDirectory(folderRoot);
            }
            if (!System.IO.Directory.Exists(folderPackage))
            {
                System.IO.Directory.CreateDirectory(folderPackage);
            }

            // 判断并创建配置文件
            string fileXml = $"{folderPackage}{it.SplitChar}packages.xml";

            if (!System.IO.File.Exists(fileXml))
            {
                Console.WriteLine("[*] 正在创建包管理文件 ...");
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var packages = xml.AddNode("packages");
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }

            // 读取配置文件
            string szXml = dpz3.File.UTF8File.ReadAllText(fileXml);

            Console.WriteLine($"[*] 读取包信息 ...");
            using (var doc = dpz3.Xml.Parser.GetDocument(szXml)) {
                var xml      = doc["xml"];
                var packages = xml["packages"];
                foreach (var package in packages.GetNodesByTagName("package", false))
                {
                    string packageName    = package.Attr["name"];
                    string packageVersion = package.Attr["version"];
                    string folderInstall  = $"{folderPackage}{it.SplitChar}{packageName}{it.SplitChar}{packageVersion}";
                    // 进行Xorm数据库安装更新
                    string folderInstallXorm = $"{folderInstall}{it.SplitChar}xorm";
                    if (System.IO.Directory.Exists(folderInstallXorm))
                    {
                        // 进行包内静态文件的复制
                        Console.WriteLine("[*] 正在进行数据库升级 ...");
                        string folderConf = $"{path}conf";
                        using (var db = dpz3.db.Database.LoadFromConf($"{folderConf}{it.SplitChar}db.cfg", "entity")) {
                            using (var dbc = new dpz3.db.Connection(db)) {
                                string[] fileXmls = System.IO.Directory.GetFiles(folderInstallXorm, "*.xml");
                                foreach (var file in fileXmls)
                                {
                                    Console.WriteLine($"[*] 正在检测数据库配置文件 {file} ...");
                                    string txtXml = dpz3.File.UTF8File.ReadAllText(file, false);
                                    using (var table = new dpz3.XOrm.StandaloneTable(txtXml)) {
                                        UpdateDatabase(dbc, table);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        // 卸载包
        private static void UninstallPack(string path, string name)
        {
            // 检测参数完整性
            if (name.IsNoneOrNull())
            {
                Console.WriteLine("[!] 缺少包名称");
                return;
            }

            Console.WriteLine("[*] 初始化包管理 ...");

            string folderRoot    = $"{path}wwwroot";
            string folderPackage = $"{path}packages";

            if (!System.IO.Directory.Exists(folderRoot))
            {
                System.IO.Directory.CreateDirectory(folderRoot);
            }
            if (!System.IO.Directory.Exists(folderPackage))
            {
                System.IO.Directory.CreateDirectory(folderPackage);
            }

            // 判断并创建配置文件
            string fileXml = $"{folderPackage}{it.SplitChar}packages.xml";

            if (!System.IO.File.Exists(fileXml))
            {
                Console.WriteLine("[*] 正在创建包管理文件 ...");
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var packages = xml.AddNode("packages");
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }

            // 读取配置文件
            string szXml    = dpz3.File.UTF8File.ReadAllText(fileXml);
            bool   isUpdate = false;

            using (var doc = dpz3.Xml.Parser.GetDocument(szXml)) {
                var xml      = doc["xml"];
                var packages = xml["packages"];
                foreach (var package in packages.GetNodesByTagName("package", false))
                {
                    string packageName = package.Attr["name"];
                    if (packageName == name)
                    {
                        string packageInstall = package.Attr["version"];
                        string folderInstall  = $"{folderPackage}{it.SplitChar}{packageName}{it.SplitChar}{packageInstall}";
                        Console.WriteLine($"[*] 读取包版本 {packageName} 安装版本:{packageInstall}");
                        // 进行包的解压
                        Console.WriteLine($"[-] 包信息删除 {packageName} ...");
                        package.Parent.Nodes.Remove(package);
                        try {
                            // 判断安装目录是否存在
                            if (System.IO.Directory.Exists(folderInstall))
                            {
                                // 删除已安装目录
                                Console.WriteLine($"[-] 清理已安装目录 {folderInstall} ...");
                                System.IO.Directory.Delete(folderInstall, true);
                            }
                        } catch (Exception ex) {
                            Console.WriteLine($"[!] 清理发生异常 {ex.Message}");
                        }
                        isUpdate = true;
                        break;
                    }
                }
                // 保存配置
                if (isUpdate)
                {
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }
        }
Пример #17
0
        // 安装包
        private static void InstallPack(string path, string name, string version, string url = null)
        {
            // 检测参数完整性
            if (name.IsNoneOrNull())
            {
                Console.WriteLine("[!] 缺少包名称");
                return;
            }
            if (version.IsNoneOrNull())
            {
                Console.WriteLine("[!] 缺少包版本");
                return;
            }

            Console.WriteLine("[*] 初始化包管理 ...");

            string folderRoot    = $"{path}wwwroot";
            string folderDown    = $"{path}downloads";
            string folderPackage = $"{path}packages";

            if (!System.IO.Directory.Exists(folderRoot))
            {
                System.IO.Directory.CreateDirectory(folderRoot);
            }
            if (!System.IO.Directory.Exists(folderDown))
            {
                System.IO.Directory.CreateDirectory(folderDown);
            }
            if (!System.IO.Directory.Exists(folderPackage))
            {
                System.IO.Directory.CreateDirectory(folderPackage);
            }

            // 判断并创建配置文件
            string fileXml = $"{folderPackage}{it.SplitChar}packages.xml";

            if (!System.IO.File.Exists(fileXml))
            {
                Console.WriteLine("[*] 正在创建包管理文件 ...");
                using (var doc = new dpz3.Xml.XmlDocument()) {
                    var xml = new dpz3.Xml.XmlNode("xml");
                    doc.Nodes.Add(xml);
                    var packages = xml.AddNode("packages");
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }

            // 读取配置文件
            string szXml    = dpz3.File.UTF8File.ReadAllText(fileXml);
            bool   isNew    = true;
            bool   isUpdate = false;

            using (var doc = dpz3.Xml.Parser.GetDocument(szXml)) {
                var xml      = doc["xml"];
                var packages = xml["packages"];
                foreach (var package in packages.GetNodesByTagName("package", false))
                {
                    string packageName = package.Attr["name"];
                    if (packageName == name)
                    {
                        isNew = false;
                        //string packageDownload = package.Attr["download"];
                        string packageInstall = package.Attr["version"];
                        string folderInstall  = $"{folderPackage}{it.SplitChar}{packageName}{it.SplitChar}{packageInstall}";
                        Console.WriteLine($"[*] 读取包版本 {packageName} 待安装版本:{version} 安装版本:{packageInstall}");
                        if (packageInstall != name)
                        {
                            // 进行包的解压
                            Console.WriteLine($"[+] 包安装 {packageName} 版本:{version} ...");
                            string fileDown            = $"{folderDown}{it.SplitChar}{packageName}-{version}.zip";
                            string folderInstallBefore = folderInstall;
                            folderInstall = $"{folderPackage}{it.SplitChar}{packageName}{it.SplitChar}{version}";
                            if (!System.IO.Directory.Exists(folderDown))
                            {
                                System.IO.Directory.CreateDirectory(folderDown);
                            }
                            ZipFile.ExtractToDirectory(fileDown, folderInstall, true);
                            //// 进行包的安装
                            //string folderInstallRoot = $"{folderInstall}{it.SplitChar}wwwroot";
                            //if (System.IO.Directory.Exists(folderInstallRoot)) {
                            //    // 进行包内静态文件的复制
                            //    Console.WriteLine("[*] 正在复制 wwwroot 文件夹 ...");
                            //    CopyFolder(folderInstallRoot, folderRoot);
                            //}
                            // 进行Xorm数据库安装更新
                            string folderInstallXorm = $"{folderInstall}{it.SplitChar}xorm";
                            if (System.IO.Directory.Exists(folderInstallXorm))
                            {
                                // 进行包内静态文件的复制
                                Console.WriteLine("[*] 正在进行数据库升级 ...");
                                string folderConf = $"{path}conf";
                                using (var db = dpz3.db.Database.LoadFromConf($"{folderConf}{it.SplitChar}db.cfg", "entity")) {
                                    using (var dbc = new dpz3.db.Connection(db)) {
                                        string[] fileXmls = System.IO.Directory.GetFiles(folderInstallXorm, "*.xml");
                                        foreach (var file in fileXmls)
                                        {
                                            Console.WriteLine($"[*] 正在检测数据库配置文件 {file} ...");
                                            string txtXml = dpz3.File.UTF8File.ReadAllText(file, false);
                                            using (var table = new dpz3.XOrm.StandaloneTable(txtXml)) {
                                                UpdateDatabase(dbc, table);
                                            }
                                        }
                                    }
                                }
                            }
                            try {
                                // 判断是否为重新安装
                                if (folderInstall != folderInstallBefore)
                                {
                                    // 判断之前安装目录是否存在
                                    if (System.IO.Directory.Exists(folderInstallBefore))
                                    {
                                        // 删除已安装目录
                                        Console.WriteLine($"[-] 清理已安装目录 {folderInstallBefore} ...");
                                        System.IO.Directory.Delete(folderInstallBefore, true);
                                    }
                                }
                            } catch (Exception ex) {
                                Console.WriteLine($"[!] 清理发生异常 {ex.Message}");
                            }
                            try {
                                // 判断安装文件是否存在
                                if (System.IO.File.Exists(fileDown))
                                {
                                    // 删除安装文件
                                    Console.WriteLine($"[-] 清理安装文件 {fileDown} ...");
                                    System.IO.File.Delete(fileDown);
                                }
                            } catch (Exception ex) {
                                Console.WriteLine($"[!] 清理发生异常 {ex.Message}");
                            }
                            // 更新版本号
                            package.Attr["version"] = version;
                            isUpdate = true;
                        }
                    }
                }
                // 当包信息不存在时,新增包信息
                if (isNew)
                {
                    // 建立新的节点
                    var package = packages.AddNode("package");
                    package.Attr["name"]    = name;
                    package.Attr["version"] = version;
                    string folderInstall = $"{folderPackage}{it.SplitChar}{name}{it.SplitChar}{version}";
                    // 进行包的解压
                    Console.WriteLine($"[+] 包安装 {name} 版本:{version} ...");
                    string fileDown = $"{folderDown}{it.SplitChar}{name}-{version}.zip";
                    folderInstall = $"{folderPackage}{it.SplitChar}{name}{it.SplitChar}{version}";
                    if (!System.IO.Directory.Exists(folderDown))
                    {
                        System.IO.Directory.CreateDirectory(folderDown);
                    }
                    // 加压到指定文件夹
                    ZipFile.ExtractToDirectory(fileDown, folderInstall, true);
                    // 进行包的安装
                    // string folderInstallRoot = $"{folderInstall}{it.SplitChar}wwwroot";
                    //if (System.IO.Directory.Exists(folderInstallRoot)) {
                    //    // 进行包内静态文件的复制
                    //    // CopyFolder(folderInstallRoot, folderRoot);
                    //}
                    // 进行Xorm数据库安装更新
                    string folderInstallXorm = $"{folderInstall}{it.SplitChar}xorm";
                    if (System.IO.Directory.Exists(folderInstallXorm))
                    {
                        // 进行包内静态文件的复制
                        Console.WriteLine("[*] 正在进行数据库升级 ...");
                        string folderConf = $"{path}conf";
                        using (var db = dpz3.db.Database.LoadFromConf($"{folderConf}{it.SplitChar}db.cfg", "entity")) {
                            using (var dbc = new dpz3.db.Connection(db)) {
                                string[] fileXmls = System.IO.Directory.GetFiles(folderInstallXorm, "*.xml");
                                foreach (var file in fileXmls)
                                {
                                    Console.WriteLine($"[*] 正在检测数据库配置文件 {file} ...");
                                    string txtXml = dpz3.File.UTF8File.ReadAllText(file, false);
                                    using (var table = new dpz3.XOrm.StandaloneTable(txtXml)) {
                                        UpdateDatabase(dbc, table);
                                    }
                                }
                            }
                        }
                    }
                    try {
                        // 判断安装文件是否存在
                        if (System.IO.File.Exists(fileDown))
                        {
                            // 删除安装文件
                            Console.WriteLine($"[-] 清理安装文件 {fileDown} ...");
                            System.IO.File.Delete(fileDown);
                        }
                    } catch (Exception ex) {
                        Console.WriteLine($"[!] 清理发生异常 {ex.Message}");
                    }
                    isUpdate = true;
                }
                // 保存配置
                if (isUpdate)
                {
                    dpz3.File.UTF8File.WriteAllText(fileXml, doc.InnerXml);
                }
            }
        }
Пример #18
0
        public IResult OpenPages()
        {
            dpz3.db.Connection dbc  = Host.Connection;
            string             path = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = Request.Str["Group"];
            string itemName  = Request.Str["Item"];

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            string pathXml = $"{path}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            if (item == null)
            {
                return(Fail("未发现项目信息"));
            }
            // 获取路径信息
            string workFolder = item.Attr["path"];
            string slnPath    = $"{workFolder}/pages/pages.sln";

            // 读取工具配置
            pathXml = $"{path}conf/tools.xml";
            szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);
            dpz3.Xml.XmlDocument docTools = dpz3.Xml.Parser.GetDocument(szXml);
            var tools = docTools["tools"];

            if (tools == null)
            {
                return(Fail("未发现visualstudio配置信息"));
            }
            var tool = tools.GetNodeByAttr("name", "visualstudio", false);

            if (tool == null)
            {
                return(Fail("未发现visualstudio配置信息"));
            }
            string toolPath = tool.Attr["path"];

            if (toolPath.IsNoneOrNull())
            {
                return(Fail("未发现visualstudio配置信息"));
            }
            // 存储登录信息
            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
            info.FileName  = toolPath;
            info.Arguments = slnPath;
            System.Diagnostics.Process.Start(info);
            return(Success());
        }
Пример #19
0
 /// <summary>
 /// 填充数据
 /// </summary>
 /// <param name="node"></param>
 public void FillData(dpz3.Xml.XmlNode node)
 {
     this.Name  = node.Attr["name"];
     this.Title = node.Attr["title"];
 }
Пример #20
0
        /// <summary>
        /// 从字符串模板定义中加载模板结果
        /// </summary>
        /// <param name="str"></param>
        /// <param name="table"></param>
        /// <returns></returns>
        public static string FromString(string str, dpz3.Json.JsonUnit package, dpz3.Xml.XmlNode table)
        {
            // 字符串创建器
            StringBuilder sb = new StringBuilder();

            // 命令解析器
            ParseType     pt     = ParseType.Normal;
            StringBuilder sbCmd  = new StringBuilder();
            StringBuilder sbPart = new StringBuilder();

            for (int i = 0; i < str.Length; i++)
            {
                char chr = str[i];

                switch (chr)
                {
                case '$':
                    if (pt == ParseType.Define)
                    {
                        sb.Append(chr);
                        pt = ParseType.Normal;
                    }
                    else if (pt == ParseType.PartCommand)
                    {
                        throw new Exception("语法错误");
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        sbPart.Append(chr);
                    }
                    else
                    {
                        pt = ParseType.Define;
                    }
                    break;

                case '@':
                    #region [=====解析段定义=====]
                    if (pt == ParseType.PartCommand)
                    {
                        if (sbCmd.Length <= 0)
                        {
                            // @符号转义
                            sb.Append(chr);
                            pt = ParseType.Normal;
                        }
                        else
                        {
                            throw new Exception("语法错误");
                        }
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        sbPart.Append(chr);
                    }
                    else if (pt == ParseType.Define)
                    {
                        throw new Exception("语法错误");
                    }
                    else
                    {
                        pt = ParseType.PartCommand;
                    }
                    break;

                    #endregion
                case ';':
                    #region [=====解析段定义=====]
                    if (pt == ParseType.PartCommand)
                    {
                        throw new Exception("语法错误");
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        if (sbPart.Length <= 0)
                        {
                            throw new Exception("语法错误");
                        }

                        // 判断是否为端结束
                        if (sbPart[sbPart.Length - 1] == '}')
                        {
                            // 段定义结束
                            sbPart.Remove(sbPart.Length - 1, 1);
                            string part = sbPart.ToString();
                            sbPart.Clear();

                            // 获取脚本内容
                            string cmdStr = sbCmd.ToString();
                            sbCmd.Clear();

                            #region [=====代码段执行=====]
                            // 命令模式
                            if (cmdStr.StartsWith("(") && cmdStr.EndsWith(")"))
                            {
                                // 命令采用都号隔开
                                string[] cmds = cmdStr.Split(',');
                                // 解析命令
                                switch (cmds[0].Trim())
                                {
                                case "list":
                                    // 列表模式
                                    if (cmds.Length != 2)
                                    {
                                        throw new Exception("语法错误");
                                    }
                                    string[] varParts = cmds[1].Trim().Split('.');
                                    if (varParts.Length != 2)
                                    {
                                        throw new Exception("语法错误");
                                    }
                                    switch (varParts[0])
                                    {
                                    case "table":
                                        if (varParts[1] == "Fields")
                                        {
                                            foreach (var field in table.GetNodesByTagName("field", false))
                                            {
                                                sb.Append(FromPartString(part, package, table, field));
                                            }
                                        }
                                        else
                                        {
                                            throw new Exception($"不支持的对象\"{cmds[1].Trim()}\"");
                                        }
                                        break;

                                    default: throw new Exception($"不支持的对象\"{cmds[1].Trim()}\"");
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                // 直接定义内容则为默认的list段
                                string[] varParts = cmdStr.Trim().Split('.');
                                if (varParts.Length != 2)
                                {
                                    throw new Exception("语法错误");
                                }
                                switch (varParts[0])
                                {
                                case "table":
                                    if (varParts[1] == "Fields")
                                    {
                                        foreach (var field in table.GetNodesByTagName("field", false))
                                        {
                                            sb.Append(FromPartString(part, package, table, field));
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception($"不支持的对象\"{cmdStr.Trim()}\"");
                                    }
                                    break;

                                default: throw new Exception($"不支持的对象\"{cmdStr.Trim()}\"");
                                }
                            }
                            #endregion

                            // 重新设置解析模式
                            pt = ParseType.Normal;
                        }
                        else if (sbPart[sbPart.Length - 1] == '$')
                        {
                            // 转义模式
                            sbPart[sbPart.Length - 1] = chr;
                        }
                        else
                        {
                            sbPart.Append(chr);
                        }
                    }
                    else if (pt == ParseType.Define)
                    {
                        throw new Exception("语法错误");
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;

                    #endregion
                case '{':
                    if (pt == ParseType.Define)
                    {
                        if (sbCmd.Length > 0)
                        {
                            throw new Exception("语法错误");
                        }
                        sbCmd.Append(chr);
                    }
                    else if (pt == ParseType.PartCommand)
                    {
                        pt = ParseType.PartContent;
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        sbPart.Append(chr);
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;

                case '}':
                    if (pt == ParseType.Define)
                    {
                        if (sbCmd.Length <= 0)
                        {
                            throw new Exception("语法错误");
                        }
                        if (sbCmd[0] != '{')
                        {
                            throw new Exception("语法错误");
                        }

                        // 获取定义内容
                        sbCmd.Remove(0, 1);
                        string cmdStr = sbCmd.ToString();
                        sbCmd.Clear();

                        string[] cmds = cmdStr.Split('.');
                        if (cmds.Length != 2)
                        {
                            throw new Exception($"不支持的对象\"{cmdStr}\"");
                        }

                        // 判断命令类型
                        switch (cmds[0])
                        {
                        case "package":
                            sb.Append(package.Str[cmds[1]]);
                            break;

                        case "table":
                            sb.Append(table.Attr[cmds[1]]);
                            break;

                        default: throw new Exception($"不支持的对象\"{cmdStr}\"");
                        }

                        // 设置解析模式
                        pt = ParseType.Normal;
                    }
                    else if (pt == ParseType.PartCommand)
                    {
                        throw new Exception("语法错误");
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        sbPart.Append(chr);
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;

                default:
                    if (pt == ParseType.Define || pt == ParseType.PartCommand)
                    {
                        sbCmd.Append(chr);
                    }
                    else if (pt == ParseType.PartContent)
                    {
                        sbPart.Append(chr);
                    }
                    else
                    {
                        sb.Append(chr);
                    }
                    break;
                }
            }

            return(sb.ToString());
        }
Пример #21
0
        // 构建表格页
        private void BuildViewPage()
        {
            if (node == null)
            {
                return;
            }

            // 关闭状态栏
            this.toolStripButtonBuildTable.Enabled = false;

            // 获取表定义
            //var platform = setting[node.Parent.Name];
            string workFolderXorm  = workPath + "\\xorm";
            string tableName       = node.Name;
            string workFolderTable = $"{workFolderXorm}\\{tableName}.xml";

            dpz3.Xml.XmlNode table;
            // 读取文件内容
            string content = dpz3.File.UTF8File.ReadAllText(workFolderTable);

            using (var docTable = dpz3.Xml.Parser.GetDocument(content)) {
                table = docTable["table"];

                // 拼接输出路径
                var workBuildGroup = workCfg["Build"];
                var rootFolder     = $"{workPath}{workBuildGroup["PagePath"]}";
                var mainFolder     = $"{rootFolder}\\wwwroot\\{tableName}\\view";
                var srcFolder      = $"{mainFolder}\\src";
                var pageFile       = $"{mainFolder}\\page.html";
                var cssFile        = $"{mainFolder}\\page.css";
                var jsFile         = $"{mainFolder}\\page.js";
                var configFile     = $"{mainFolder}\\config.json";
                var mainFile       = $"{srcFolder}\\main.htm";
                var ormFile        = $"{srcFolder}\\orm.xml";

                // 自动建立模板路径
                var templateFolder = $"{localTemplateFolder}\\View";
                if (!System.IO.Directory.Exists(templateFolder))
                {
                    System.IO.Directory.CreateDirectory(templateFolder);
                }

                // 自动建立路径
                if (!System.IO.Directory.Exists(srcFolder))
                {
                    System.IO.Directory.CreateDirectory(srcFolder);
                }

                // 判断是否存在配置文件,不存在则创建
                if (!System.IO.File.Exists(configFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\config.json", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(configFile, Template.FromString(configTemplate, table));
                }

                // 判断主文件是否存在,不存在则创建
                if (!System.IO.File.Exists(mainFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\main.htm", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(mainFile, Template.FromString(configTemplate, table));
                }

                // 判断样式文件是否存在,不存在则创建
                if (!System.IO.File.Exists(cssFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\page.css", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(cssFile, Template.FromString(configTemplate, table));
                }

                // 判断脚本文件是否存在,不存在则创建
                if (!System.IO.File.Exists(jsFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\page.js", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(jsFile, Template.FromString(configTemplate, table));
                }

                // 从输出路径加载xml设定,达到兼容目的
                Say("正在加载现有ORM文件...");
                string xml = dpz3.File.UTF8File.ReadAllText(ormFile);
                using (dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(xml)) {
                    // 判断代表是否存在
                    var xmlTable = doc["table"];
                    if (xmlTable == null)
                    {
                        xmlTable             = new dpz3.Xml.XmlNode("table");
                        xmlTable.Attr["md5"] = "";
                        doc.Nodes.Add(xmlTable);
                    }

                    // 校验文件缓存文件是否存在变更
                    var tabMD5 = xmlTable.Attr["md5"];
                    var md5    = dpz3.File.BinaryFile.GetMD5(workFolderTable);

                    if (tabMD5 != md5)
                    {
                        // 生成页面文件
                        xmlTable.Attr["name"]  = table.Attr["name"];
                        xmlTable.Attr["title"] = table.Attr["title"];
                        xmlTable.Attr["md5"]   = md5;

                        // 界面定义节点
                        var xmlInterface = xmlTable["interface"];
                        if (xmlInterface == null)
                        {
                            xmlInterface = xmlTable.AddNode("interface");
                        }

                        // 定义line呈现
                        var xmlInterfaceLine = xmlInterface["line"];
                        if (xmlInterfaceLine == null)
                        {
                            xmlInterfaceLine                  = xmlInterface.AddNode("line");
                            xmlInterfaceLine.IsSingle         = true;
                            xmlInterfaceLine.Attr["tag-name"] = "div";
                        }

                        // 定义title呈现
                        var xmlInterfaceTitle = xmlInterface["title"];
                        if (xmlInterfaceTitle == null)
                        {
                            xmlInterfaceTitle                  = xmlInterface.AddNode("title");
                            xmlInterfaceTitle.IsSingle         = true;
                            xmlInterfaceTitle.Attr["tag-name"] = "i";
                        }

                        // 定义content呈现
                        var xmlInterfaceContent = xmlInterface["content"];
                        if (xmlInterfaceContent == null)
                        {
                            xmlInterfaceContent                  = xmlInterface.AddNode("content");
                            xmlInterfaceContent.IsSingle         = true;
                            xmlInterfaceContent.Attr["tag-name"] = "s";
                        }

                        // 字段定义节点
                        var xmlFields = xmlTable["fields"];
                        if (xmlFields == null)
                        {
                            xmlFields = xmlTable.AddNode("fields");
                        }

                        foreach (var fld in table.GetNodesByTagName("field", false))
                        {
                            // 判断标题中是否存在字段定义,不存在则创建
                            string fldName = fld.Attr["name"];
                            if (xmlFields.GetNodeByAttr("name", fldName) == null)
                            {
                                var xmlField = xmlFields.AddNode("field");
                                xmlField.IsSingle      = true;
                                xmlField.Attr["name"]  = fldName;
                                xmlField.Attr["title"] = fld.Attr["title"];
                                xmlField.Attr["type"]  = "text";
                                xmlField.InnerXml      = fld.Attr["title"];
                            }
                        }
                        // 保存
                        Say("正在保存文件...");
                        dpz3.File.UTF8File.WriteAllText(ormFile, doc.InnerXml);
                    }
                }

                // 构建页面
                //BuildPage(rootFolder, srcFolder, mainFile, pageFile);

                // 重新开启工具
                this.toolStripButtonBuildTable.Enabled = true;
                Say("完成");
            }
        }
Пример #22
0
        // 构建表格页
        private void BuildListPage(string ListType)
        {
            if (node == null)
            {
                return;
            }

            // 关闭状态栏
            this.toolStripButtonBuildTable.Enabled = false;

            // 获取表定义
            //var platform = setting[node.Parent.Name];
            string workFolderXorm  = workPath + "\\xorm";
            string tableName       = node.Name;
            string workFolderTable = $"{workFolderXorm}\\{tableName}.xml";

            dpz3.Xml.XmlNode table;
            // 读取文件内容
            string content = dpz3.File.UTF8File.ReadAllText(workFolderTable);

            using (var docTable = dpz3.Xml.Parser.GetDocument(content)) {
                table = docTable["table"];

                // 拼接输出路径
                var rootFolder = $"{workPath}\\wwwroot";
                var mainFolder = $"{rootFolder}\\{tableName.ToLower()}\\{ListType.ToLower()}";
                var srcFolder  = $"{mainFolder}\\src";
                var pageFile   = $"{mainFolder}\\page.html";
                var cssFile    = $"{mainFolder}\\page.css";
                var jsFile     = $"{mainFolder}\\page.js";
                var configFile = $"{mainFolder}\\config.json";
                var mainFile   = $"{srcFolder}\\main.htm";
                var ormFile    = $"{srcFolder}\\orm.xml";

                // 自动建立模板路径
                var templateFolder = $"{localTemplateFolder}\\{ListType}";
                if (!System.IO.Directory.Exists(templateFolder))
                {
                    System.IO.Directory.CreateDirectory(templateFolder);
                }

                // 自动建立路径
                if (!System.IO.Directory.Exists(srcFolder))
                {
                    System.IO.Directory.CreateDirectory(srcFolder);
                }

                // 判断是否存在配置文件,不存在则创建
                if (!System.IO.File.Exists(configFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\config.json", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(configFile, Template.FromString(configTemplate, table));
                }

                // 判断主文件是否存在,不存在则创建
                if (!System.IO.File.Exists(mainFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\main.htm", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(mainFile, Template.FromString(configTemplate, table));
                }

                // 判断样式文件是否存在,不存在则创建
                if (!System.IO.File.Exists(cssFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\page.css", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(cssFile, Template.FromString(configTemplate, table));
                }

                // 判断脚本文件是否存在,不存在则创建
                if (!System.IO.File.Exists(jsFile))
                {
                    // 加载模板文件
                    string configTemplate = dpz3.File.UTF8File.ReadAllText($"{templateFolder}\\page.js", true);

                    // 输出处理后的模板内容
                    dpz3.File.UTF8File.WriteAllText(jsFile, Template.FromString(configTemplate, table));
                }

                // 从输出路径加载xml设定,达到兼容目的
                Say("正在加载现有ORM文件...");
                string xml = dpz3.File.UTF8File.ReadAllText(ormFile);
                using (dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(xml)) {
                    // 判断代表是否存在
                    var xmlTable = doc["table"];
                    if (xmlTable == null)
                    {
                        xmlTable             = new dpz3.Xml.XmlNode("table");
                        xmlTable.Attr["md5"] = "";
                        doc.Nodes.Add(xmlTable);
                    }

                    // 校验文件缓存文件是否存在变更
                    var tabMD5 = xmlTable.Attr["md5"];
                    var md5    = dpz3.File.BinaryFile.GetMD5(workFolderTable);

                    if (tabMD5 != md5)
                    {
                        // 生成页面文件
                        xmlTable.Attr["name"]  = table.Attr["name"];
                        xmlTable.Attr["title"] = table.Attr["title"];
                        xmlTable.Attr["md5"]   = md5;

                        // 界面定义节点
                        var xmlInterface = xmlTable["interface"];
                        if (xmlInterface == null)
                        {
                            xmlInterface = xmlTable.AddNode("interface");
                        }

                        // 定义vue绑定
                        var xmlInterfaceVue = xmlInterface["vue"];
                        if (xmlInterfaceVue == null)
                        {
                            xmlInterfaceVue = xmlInterface.AddNode("vue");

                            // list配置
                            var xmlInterfaceVueList = xmlInterfaceVue.AddNode("list");
                            xmlInterfaceVueList.IsSingle     = true;
                            xmlInterfaceVueList.Attr["for"]  = "(row,index) in list";
                            xmlInterfaceVueList.Attr["item"] = "row";
                            xmlInterfaceVueList.Attr["key"]  = "row.ID";

                            // order配置
                            var xmlInterfaceVueOrder = xmlInterfaceVue.AddNode("order");
                            xmlInterfaceVueOrder.IsSingle      = true;
                            xmlInterfaceVueOrder.Attr["field"] = "orderField";
                            xmlInterfaceVueOrder.Attr["sort"]  = "orderSort";
                            xmlInterfaceVueOrder.Attr["click"] = "onOrder";
                        }

                        // 定义行操作
                        var xmlInterfaceRow = xmlInterface["row"];
                        if (xmlInterfaceRow == null)
                        {
                            xmlInterfaceRow          = xmlInterface.AddNode("row");
                            xmlInterfaceRow.IsSingle = true;
                        }

                        // 定义行操作
                        var xmlInterfaceCell = xmlInterface["cell"];
                        if (xmlInterfaceCell == null)
                        {
                            xmlInterfaceCell          = xmlInterface.AddNode("cell");
                            xmlInterfaceCell.IsSingle = true;
                        }

                        // 定义图像控件操作
                        var xmlInterfaceImg = xmlInterface["img"];
                        if (xmlInterfaceImg == null)
                        {
                            xmlInterfaceImg = xmlInterface.AddNode("img");
                        }

                        // 定义图像控件容器
                        var xmlInterfaceImgBox = xmlInterfaceImg["box"];
                        if (xmlInterfaceImgBox == null)
                        {
                            xmlInterfaceImgBox                  = xmlInterfaceImg.AddNode("box");
                            xmlInterfaceImgBox.IsSingle         = true;
                            xmlInterfaceImgBox.Attr["tag-name"] = "s";
                        }

                        // 定义勾选框控件操作
                        var xmlInterfaceCheck = xmlInterface["check"];
                        if (xmlInterfaceCheck == null)
                        {
                            xmlInterfaceCheck                  = xmlInterface.AddNode("check");
                            xmlInterfaceCheck.IsSingle         = true;
                            xmlInterfaceCheck.Attr["tag-name"] = "div";
                            xmlInterfaceCheck.Attr["class"]    = "x-check";
                        }

                        // 定义排序控件操作
                        var xmlInterfaceOrder = xmlInterface["order"];
                        if (xmlInterfaceOrder == null)
                        {
                            xmlInterfaceOrder = xmlInterface.AddNode("order");
                            xmlInterfaceOrder.Attr["tag-name"] = "div";
                            xmlInterfaceOrder.Attr["class"]    = "x-order";

                            var xmlInterfaceOrderAsc = xmlInterfaceOrder.AddNode("asc");
                            xmlInterfaceOrderAsc.IsSingle         = true;
                            xmlInterfaceOrderAsc.Attr["tag-name"] = "div";
                            xmlInterfaceOrderAsc.Attr["class"]    = "x-order-asc";

                            var xmlInterfaceOrderAscAct = xmlInterfaceOrder.AddNode("asc-act");
                            xmlInterfaceOrderAscAct.IsSingle         = true;
                            xmlInterfaceOrderAscAct.Attr["tag-name"] = "div";
                            xmlInterfaceOrderAscAct.Attr["class"]    = "x-order-asc-act";

                            var xmlInterfaceOrderDesc = xmlInterfaceOrder.AddNode("desc");
                            xmlInterfaceOrderDesc.IsSingle         = true;
                            xmlInterfaceOrderDesc.Attr["tag-name"] = "div";
                            xmlInterfaceOrderDesc.Attr["class"]    = "x-order-desc";

                            var xmlInterfaceOrderDescAct = xmlInterfaceOrder.AddNode("desc-act");
                            xmlInterfaceOrderDescAct.IsSingle         = true;
                            xmlInterfaceOrderDescAct.Attr["tag-name"] = "div";
                            xmlInterfaceOrderDescAct.Attr["class"]    = "x-order-desc-act";
                        }

                        // 字段定义节点
                        var xmlFields = xmlTable["fields"];
                        if (xmlFields == null)
                        {
                            xmlFields = xmlTable.AddNode("fields");
                        }

                        foreach (var fld in table.GetNodesByTagName("field", false))
                        {
                            // 判断标题中是否存在字段定义,不存在则创建
                            string fldName = fld.Attr["name"];
                            if (xmlFields.GetNodeByAttr("name", fldName) == null)
                            {
                                var xmlField = xmlFields.AddNode("field");
                                xmlField.IsSingle      = true;
                                xmlField.Attr["name"]  = fldName;
                                xmlField.Attr["title"] = fld.Attr["title"];
                                string fldDataType = fld["data"].Attr["type"].ToLower();
                                switch (fldDataType)
                                {
                                case "text":
                                    // 文本类型的大块内容 默认不显示
                                    xmlField.Attr["type"] = "none";
                                    break;

                                case "numeric":
                                case "int":
                                    xmlField.Attr["type"]  = "text";
                                    xmlField.Attr["width"] = "60px";
                                    xmlField.Attr["order"] = "false";
                                    break;

                                default:
                                    xmlField.Attr["type"]  = "text";
                                    xmlField.Attr["width"] = "100px";
                                    xmlField.Attr["order"] = "false";
                                    break;
                                }
                                xmlField.InnerXml = fld.Attr["title"];
                            }
                        }
                        // 保存
                        Say("正在保存文件...");
                        dpz3.File.UTF8File.WriteAllText(ormFile, doc.InnerXml);
                    }
                }

                // 构建页面
                //BuildPage(rootFolder, srcFolder, mainFile, pageFile);

                // 重新开启工具
                this.toolStripButtonBuildTable.Enabled = true;
                Say("完成");
            }
        }
Пример #23
0
        public IResult Xorm()
        {
            StringBuilder sb = new StringBuilder();

            dpz3.db.Connection dbc = Host.Connection;
            var    session         = Host.Session;
            var    request         = Host.Context.Request;
            var    response        = Host.Context.Response;
            string hostWorkFolder  = Host.WorkFolder.Replace("\\", "/");
            // 获取参数
            string groupName = $"{request.Query["group"]}";
            string itemName  = $"{request.Query["item"]}";
            string name      = $"{request.Query["name"]}";

            if (!hostWorkFolder.EndsWith("/"))
            {
                hostWorkFolder += "/";
            }
            string pathXml = $"{hostWorkFolder}conf/projects.xml";
            string szXml   = dpz3.File.UTF8File.ReadAllText(pathXml);

            dpz3.Xml.XmlDocument doc = dpz3.Xml.Parser.GetDocument(szXml);
            var xml = doc["xml"];

            dpz3.Xml.XmlNode group = xml.GetNodeByAttr("name", groupName, false);
            dpz3.Xml.XmlNode item  = null;
            if (group != null)
            {
                item = group.GetNodeByAttr("name", itemName, false);
            }
            sb.Append("<!DOCTYPE html>\n");
            sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
            sb.Append("<head>\n");
            sb.Append("<meta charset=\"utf-8\" />\n");
            sb.Append("<title>模块化网站项目管理器</title>\n");
            sb.Append("<link rel=\"icon\" href=\"/modular-project-common/manager.ico\" type=\"image/x-icon\" />\n");
            sb.Append("<script src=\"/modular-project-common/js/jquery-3.4.1.min.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/vue.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/dpz2.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/host.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-common/js/jttp.js\"></script>\n");
            sb.Append("<script src=\"/modular-project-manage/xorm/page.js\"></script>\n");
            sb.Append("<link rel=\"stylesheet\" href=\"/modular-project-manage/xorm/page.css\" />\n");
            sb.Append("</head>\n");
            sb.Append("<body>\n");
            sb.Append("<div class=\"info\" style=\"display: none;\">正在处理,请稍等...</div>\n");
            if (item != null)
            {
                // 获取工作目录
                string workFolder     = item.Attr["path"];
                string workFolderXorm = $"{workFolder}/xorm";
                string pathXorm       = $"{workFolderXorm}/{name}.xml";
                string folderTemplete = $"{hostWorkFolder}template/{groupName}";
                if (!System.IO.Directory.Exists(folderTemplete))
                {
                    System.IO.Directory.CreateDirectory(folderTemplete);
                }
                string fileContent = dpz3.File.UTF8File.ReadAllText(pathXorm);
                using (var fileDoc = dpz3.Xml.Parser.GetDocument(fileContent)) {
                    var table  = fileDoc["table"];
                    var fields = table.GetNodesByTagName("field", false);
                    sb.Append("<div class=\"list\">\n");
                    sb.Append("<dl>\n");
                    sb.Append("<dt>相关信息</dt>\n");
                    sb.Append("<dd>名称:");
                    sb.Append(table.Attr["name"]);
                    sb.Append("</dd>\n");
                    sb.Append("<dd>标题:");
                    sb.Append(table.Attr["title"]);
                    sb.Append("</dd>\n");
                    sb.Append("<dd>版本:");
                    sb.Append(table.Attr["version"]);
                    sb.Append("</dd>\n");
                    sb.Append("<dt>快捷操作</dt>\n");
                    sb.Append("<dd>\n");
                    sb.Append("<s><a href=\"/modular-project-manage/index?group=");
                    sb.Append(groupName);
                    sb.Append("&item=");
                    sb.Append(itemName);
                    sb.Append("\">返回主界面</a></s>&nbsp;\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildController('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建类构造代码</a></s>&nbsp;\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildList('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建列表代码</a></s>&nbsp;\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildSelector('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建选择器代码</a></s>&nbsp;\n");
                    sb.Append("</dd>\n");
                    sb.Append("<dd>\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildAddForm('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建添加对话框代码</a></s>&nbsp;\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildEditForm('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建编辑对话框代码</a></s>&nbsp;\n");
                    sb.Append("<s><a href=\"javascript:;\" onclick=\"pg.buildViewForm('");
                    sb.Append(groupName);
                    sb.Append("','");
                    sb.Append(itemName);
                    sb.Append("','");
                    sb.Append(name);
                    sb.Append("');\">创建视图对话框代码</a></s>&nbsp;\n");
                    sb.Append("</dd>\n");
                    sb.Append("<dt>字段一览</dt>\n");
                    foreach (var field in fields)
                    {
                        var data = field["data"];
                        sb.Append("<dd>");
                        sb.Append(field.Attr["title"]);
                        sb.Append("(");
                        sb.Append(field.Attr["name"]);
                        sb.Append(") - ");
                        sb.Append(data.Attr["type"]);
                        sb.Append("(");
                        sb.Append(data.Attr["size"]);
                        sb.Append(",");
                        sb.Append(data.Attr["float"]);
                        sb.Append(")</dd>\n");
                    }
                    sb.Append("</dl>\n");
                    sb.Append("</div>\n");
                }
            }
            else
            {
                sb.Append("<div>未发现项目信息</div>\n");
            }
            sb.Append("</body>\n");
            sb.Append("</html>\n");
            return(Html(sb.ToString()));
        }