Ejemplo n.º 1
0
        public void BuildHtml(string content, string path, HtmlBuildItem item, NewsTemplate template)
        {
            //文件内容和脚本内容
            StringBuilder str = new StringBuilder();
            StringBuilder script = new StringBuilder();
            //单个标签内容和单个脚本内容
            string label = "";
            string tempScript = "";
            //第一个标签开始和结束
            int left = content.IndexOf("┣");
            int right = content.IndexOf("┫");
            //当标签存在,生成标签内容
            while (left >= 0 && right >= 0)
            {
                //标签前面内容直接输出
                str.Append(content.Substring(0, left));
                //得到标签名称
                label = content.Substring(left + 1, right - left - 1);
                //获取标签真实内容,和所需要脚本
                str.Append(GetModuleByLabel2(item, label, out tempScript));//lvcunku修改,原来是用GetModuleByLabel
                //暂存所有需要脚本
                script.Append(tempScript + "\r\n");
                //模板中已生成的内容截取掉
                content = content.Substring(right + 1);
                //重新设置第一个标签的开始和结束0
                left = content.IndexOf("┣");
                right = content.IndexOf("┫");
            }
            //找到body前的最后位置,安置脚本
            left = content.IndexOf("</body>");
            content = str.ToString() + content;

            str.AppendFormat("<!--LastCreateTime:{0}-->", DateTime.Now);

            UpdateStaticHtml(path, content, template);
        }
Ejemplo n.º 2
0
 private void UpdateStaticHtml(string path, string content, NewsTemplate template)
 {
     string sql = "update X5_wsStaticHtml set sContent=@content where sUrl='" + path + "'";
     System.Data.SqlClient.SqlParameter  par= new System.Data.SqlClient.SqlParameter("@content", content);
     int effect= dbContext.ExecuteCommand(sql, CommandType.Text, par);
     if (effect == 0) {
         sql = "insert into X5_wsStaticHtml(sUrl,sContent,lTemplateCode) values('"+path+"',@content,"+template.AutoCode+")";
         dbContext.ExecuteCommand(sql, CommandType.Text, par);
     }
 }