Example #1
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"];
                }
            }
        }
Example #2
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("构架类生成成功"));
        }
Example #3
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("控制器编译成功"));
        }
Example #4
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);
                }
            }
        }
Example #5
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}");
                }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            //using (dpz3.Text.Pinyin py = new dpz3.Text.Pinyin()) {
            //    var words = py.DebugOut();
            //    Console.WriteLine(words.Count);
            //    foreach (var item in words) {
            //        Console.WriteLine($"dicSpecial.Add('{item.Key}', new PinyinInfo(\"{item.Value.Pinyin}\", {item.Value.Tone}));");
            //    }
            //}


            string sz = "进入手机界面后,你会发现页面变得十分简洁,就算没登陆账号也能进行复制,手机网页的格式较为单一,你直接复制到word等其他地方,格式差异不大。";

            Console.WriteLine(sz);
            Console.WriteLine(dpz3.Text.Pinyin.GetPinyinFromString(sz));
            Console.WriteLine(dpz3.Text.Pinyin.GetPinyinToneFromString(sz));
            Console.WriteLine(dpz3.Text.Pinyin.GetInitialLettersFromString(sz));



            var arg = new dpz3.Console.Arguments(args);

            Console.WriteLine("path:" + arg.ContainsKey("t"));
            Console.WriteLine("path:" + arg.ContainsKey("n"));
            Console.WriteLine("path:" + arg.ContainsKey("path"));

            string fldHtmPath  = "X:\\Projects\\beikejie\\dotnet-core-ycp-entity-bkj\\wwwroot\\pages\\Web\\WebAds\\list\\src\\field.Operate.htm";
            string htmlContent = dpz3.File.UTF8File.ReadAllText(fldHtmPath, true);

            using (var doc = new dpz3.Html.HtmlDocument()) {
                var div = doc.CreateElement("div");
                doc.Nodes.Add(div);
                div.InnerHTML = htmlContent;
                Console.WriteLine($"div:\r\n{doc.InnerHTML}");
            }

            string xml = "<div class=\"dig-body\">";

            xml += "<div dpz-id=\"Tool\" class=\"dig-tools\">";
            xml += "<a href=\"javascript:;\" v-on:click=\"onSave\"><img v-bind:src=\"Images.Save\" />保存</a>";
            xml += "<a href=\"javascript:;\" v-on:click=\"onCancel\"><img v-bind:src=\"Images.Cancel\" />取消</a>";
            xml += "</div>";
            xml += "<div dpz-id=\"Form\" class=\"dig-form\">";
            xml += "<div class=\"dig-form-box\">";
            xml += "<xorm src=\"orm.xml\" type=\"form\"></xorm>";
            xml += "</div>";
            xml += "</div>";
            xml += "</div>";

            using (dpz3.Html.HtmlDocument doc = new dpz3.Html.HtmlDocument(xml)) {
                Console.WriteLine($"html:\r\n{doc.InnerHTML}");
            }

            using (dpz3.Xml.XmlDocument doc = new dpz3.Xml.XmlDocument(xml)) {
                Console.WriteLine($"xml:\r\n{doc.InnerXml}");
            }

            string urlCss = "https://v5.lywos.com/css/Shared/Home.css";
            string szCss  = dpz3.Net.HttpClient.Get(urlCss);

            using (dpz3.Html.HtmlCss css = new dpz3.Html.HtmlCss(szCss)) {
                Console.WriteLine($"css:\r\n{css.ToString()}");
            }

            // 测试http方式获取数据
            string http = dpz3.Net.HttpClient.Get("http://v3.lywos.com/");

            Console.WriteLine($"http:{http.Length}");

            // 测试https方式获取数据
            string https = dpz3.Net.HttpClient.Get("https://v5.lywos.com/");

            Console.WriteLine($"https:{https.Length}");

            //int tick = Environment.TickCount;
            //long lastLoad = 0;
            //dpz3.Net.HttpClient.Download("https://jx3wscs-fullupdatehttps.dl.kingsoft.com/jx3v4_launcher/JX3Installer_1.0.0.522_Official.exe", @"X:\temp\JX3Installer_1.0.0.522_Official.exe", (long size, long loaded) => {
            //    int ts = Environment.TickCount - tick;
            //    tick = Environment.TickCount;

            //    float speed = (int)(((loaded - lastLoad) / (float)ts) * 1000 / 10.24) / (float)100;
            //    lastLoad = loaded;

            //    string speedStr = "";

            //    if (speed < 1024) {
            //        speedStr = $"{speed}KB/s";
            //    } else {
            //        float speedMb = (int)(speed / 10.24) / (float)100;
            //        speedStr = $"{speedMb}MB/s";
            //    }

            //    Console.WriteLine($"{loaded}/{size} - {speedStr}");
            //});
        }
Example #7
0
        public IResult index()
        {
            StringBuilder sb = new StringBuilder();

            dpz3.db.Connection dbc = Host.Connection;
            var    session         = Host.Session;
            var    response        = Host.Context.Response;
            string path            = Host.WorkFolder.Replace("\\", "/");

            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"];

            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-main/index/page.js\"></script>\n");
            sb.Append("<link rel=\"stylesheet\" href=\"/modular-project-main/index/page.css\" />\n");
            sb.Append("</head>\n");
            sb.Append("<body>\n");
            sb.Append("<div class=\"left\">\n");
            sb.Append("<div class=\"menu\">\n");
            var groups = xml.GetNodesByTagName("group", false);

            foreach (var group in groups)
            {
                sb.Append("<dl id=\"dl_");
                sb.Append(group.Attr["name"]);
                sb.Append("_close\" style=\"display: none;\">\n");
                sb.Append("<dt onclick=\"pg.open('");
                sb.Append(group.Attr["name"]);
                sb.Append("');\">\n");
                sb.Append("<s>\n");
                sb.Append("<img src=\"/modular-project-main/index/image/config.png\" /></s>\n");
                sb.Append("<s>");
                sb.Append(group.Attr["title"]);
                sb.Append("</s>\n");
                sb.Append("<s>\n");
                sb.Append("<img src=\"/modular-project-main/index/image/down2.png\" /></s>\n");
                sb.Append("</dt>\n");
                sb.Append("</dl>\n");
                sb.Append("<dl id=\"dl_");
                sb.Append(group.Attr["name"]);
                sb.Append("_open\">\n");
                sb.Append("<dt onclick=\"pg.close('");
                sb.Append(group.Attr["name"]);
                sb.Append("');\">\n");
                sb.Append("<s>\n");
                sb.Append("<img src=\"/modular-project-main/index/image/config.png\" /></s>\n");
                sb.Append("<s>");
                sb.Append(group.Attr["title"]);
                sb.Append("</s>\n");
                sb.Append("<s>\n");
                sb.Append("<img src=\"/modular-project-main/index/image/down.png\" /></s>\n");
                sb.Append("</dt>\n");
                var items = group.GetNodesByTagName("item", false);
                foreach (var item in items)
                {
                    sb.Append("<dd id=\"dd_");
                    sb.Append(group.Attr["name"]);
                    sb.Append("_");
                    sb.Append(item.Attr["name"]);
                    sb.Append("\" onclick=\"pg.navTo('");
                    sb.Append(group.Attr["name"]);
                    sb.Append("_");
                    sb.Append(item.Attr["name"]);
                    sb.Append("','/modular-project-manage/index?group=");
                    sb.Append(group.Attr["name"]);
                    sb.Append("&item=");
                    sb.Append(item.Attr["name"]);
                    sb.Append("');\">");
                    sb.Append(item.Attr["title"]);
                    sb.Append("(");
                    sb.Append(item.Attr["name"]);
                    sb.Append(")</dd>\n");
                }
                sb.Append("</dl>\n");
            }
            sb.Append("</div>\n");
            sb.Append("</div>\n");
            sb.Append("<div class=\"right\">\n");
            sb.Append("<div class=\"header\">\n");
            sb.Append("<div id=\"switch_hide\" class=\"switch\">\n");
            sb.Append("<a id=\"lnk_menu_hide\" href=\"javascript:;\">\n");
            sb.Append("<div class=\"switch_icon\">\n");
            sb.Append("<img id=\"img_menu_hide\" src=\"/modular-project-main/index/image/left.png\" style=\"display: none;\" />\n");
            sb.Append("<img id=\"img_menu_hide2\" src=\"/modular-project-main/index/image/left_b.png\" />\n");
            sb.Append("</div>\n");
            sb.Append("<div class=\"switch_title\">收起菜单栏</div>\n");
            sb.Append("<div class=\"clear\"></div>\n");
            sb.Append("</a>\n");
            sb.Append("</div>\n");
            sb.Append("<div id=\"switch_show\" class=\"switch\" style=\"display: none;\">\n");
            sb.Append("<a id=\"lnk_menu_show\" href=\"javascript:;\">\n");
            sb.Append("<div class=\"switch_icon\">\n");
            sb.Append("<img id=\"img_menu_show\" src=\"/modular-project-main/index/image/right.png\" style=\"display: none;\" />\n");
            sb.Append("<img id=\"img_menu_show2\" src=\"/modular-project-main/index/image/right_b.png\" />\n");
            sb.Append("</div>\n");
            sb.Append("<div class=\"switch_title\">显示菜单栏</div>\n");
            sb.Append("<div class=\"clear\"></div>\n");
            sb.Append("</a>\n");
            sb.Append("</div>\n");
            sb.Append("<div class=\"exit\"></div>\n");
            sb.Append("<div class=\"user\"></div>\n");
            sb.Append("</div>\n");
            sb.Append("<div class=\"frame\">\n");
            sb.Append("<iframe id=\"frm_main\" src=\"about:blank\"></iframe>\n");
            sb.Append("</div>\n");
            sb.Append("</div>\n");
            sb.Append("<script type=\"text/javascript\">\n");
            sb.Append("$(function () {\n");
            sb.Append("});\n");
            sb.Append("</script>\n");
            sb.Append("</body>\n");
            sb.Append("</html>\n");
            return(Html(sb.ToString()));
        }
Example #8
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("控制器页面代码生成成功"));
        }
Example #9
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包成功"));
        }
Example #10
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("完成");
            }
        }
Example #11
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()));
        }
Example #12
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #13
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("完成");
            }
        }
Example #14
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()));
        }
Example #15
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);
                }
            }
        }
Example #16
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);
                }
            }
        }
Example #17
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());
        }
Example #18
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()));
        }