/// <summary> /// XML help? /// </summary> public string GetUrl(string Id) { string Url = null; ROYcms.Sys.BLL.ROYcms_class ___ROYcms_class = new ROYcms.Sys.BLL.ROYcms_class(); ROYcms.Sys.BLL.ROYcms_news ___ROYcms_news = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms.Sys.BLL.ROYcms_Url ___ROYcms_Url = new ROYcms.Sys.BLL.ROYcms_Url(); int ClassId = Convert.ToInt32(___ROYcms_news.GetField(Convert.ToInt32(Id), "classname")); string ShowRules = ___ROYcms_class.GetClassField(ClassId, "ShowRules"); string jumpurl = ___ROYcms_news.GetField(Convert.ToInt32(Id), "jumpurl").Trim(); ShowRules = ShowRules.Replace("{id}", Id).Replace("{yyyy}/{MM}/{dd}/", "show_"); if (jumpurl.Length > 2) { Url = jumpurl; } else { if (___ROYcms_Url.Exists_bh(Convert.ToInt32(Id))) { Url = ___ROYcms_Url.GetUrl(Convert.ToInt32(Id)); } else { Url = (___ROYcms_class.GetClassField(ClassId, "FilePath").Replace("{cmspath}/", "/")) + ShowRules; } } return(Url); }
/// <summary> /// Dels the HTML. /// </summary> /// <param name="Model">The model.</param> /// <returns></returns> public void DelHtml(int id) { try { ROYcms.Sys.BLL.ROYcms_news BLL = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms.Sys.BLL.ROYcms_class ClassBLL = new ROYcms.Sys.BLL.ROYcms_class(); ROYcms.Sys.Model.ROYcms_class Model = ClassBLL.GetModel(ClassBLL.GetClassId(Convert.ToInt32(BLL.GetClassName(id)))); ROYcms.Sys.Model.ROYcms_news NewModel = BLL.GetModel(id); string Path = null; Model.FilePath = Model.FilePath.Replace("{cmspath}", "~"); Path = (Model.ShowRules.Contains("~/") ? Model.ShowRules : (Model.FilePath + Model.ShowRules)); //文件生成地址 Path = Path.Replace("{yyyy}", Convert.ToDateTime(NewModel.time).ToString("yyyy")); Path = Path.Replace("{MM}", Convert.ToDateTime(NewModel.time).ToString("MM")); Path = Path.Replace("{dd}", Convert.ToDateTime(NewModel.time).ToString("dd")); Path = Path.Replace("{id}", id.ToString()); using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")))) { // File.Delete(HttpContext.Current.Server.MapPath(Path)); sw.WriteLine("文件已经删除!<a href='/inde.aspx'>到首页</a>"); sw.Flush(); } } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } }
/// <summary> /// 输出 /// </summary> /// <param name="output">The output.</param> protected override void Render(HtmlTextWriter output) { if (this.Rid != null) { ROYcms.Sys.BLL.ROYcms_news ___ROYcms_news = new ROYcms.Sys.BLL.ROYcms_news(); try { ___ROYcms_news.Hits_news(Convert.ToInt32(this.Rid)); output.Write("<!--浏览一次!-->"); } catch { output.Write("<!--无分页数据!-->"); } } }
/// <summary> /// 删除一个菜单项 /// </summary> /// <param name="ClassId"></param> /// <returns></returns> public bool DelByClassId(string ClassId) { //级联删除分类关联 ROYcms.Sys.BLL.ROYcms_Class_News ROYcms_Class_News_bll = new ROYcms.Sys.BLL.ROYcms_Class_News(); //删除 ROYcms_Class_News_bll.Delete(" class_id='" + ClassId + "'"); //级联删除新闻 ROYcms.Sys.BLL.ROYcms_news ROYcms_news_bll = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms_news_bll.Delete(" classname=" + GetIdForClassId(ClassId)); //级联删除智能表单模型关联 ROYcms.Sys.BLL.ROYcms_Class_Model ROYcms_Class_Model_bll = new ROYcms.Sys.BLL.ROYcms_Class_Model(); ROYcms_Class_Model_bll.CidDelete(GetIdForClassId(ClassId)); bool err = dal.DelByClassId(ClassId); return(err); }
/// <summary> /// 输出 /// </summary> /// <param name="output">The output.</param> protected override void Render(HtmlTextWriter output) { try { string XMLCon = null; if (this.Root == null) { ROYcms.Sys.BLL.ROYcms_news ___ROYcms_news = new ROYcms.Sys.BLL.ROYcms_news(); XMLCon = GetValue(Convert.ToInt32(Rid), ___ROYcms_news.GetClassKind(Convert.ToInt32(Rid)), this.Name); } else { XMLCon = GetXmlValue(this.Rid, this.Root, this.Name); } output.Write(XMLCon == "" ? "<!--无数据!-->" : XMLCon); } catch { output.Write("<!--输出错误!-->"); } }
/// <summary> /// 文章详细页面重写 /// </summary> /// <param name="URL"></param> /// <returns></returns> public static string IsShowUrl(string URL) { ROYcms.Sys.BLL.ROYcms_news NewBll = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms.Sys.BLL.ROYcms_class ClassBll = new ROYcms.Sys.BLL.ROYcms_class(); string NewUrlModel = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("new_url_model"); if (NewUrlModel == "" || NewUrlModel == null) { NewUrlModel = "show"; } if (URL.Contains("/" + NewUrlModel + "_")) { string[] Parameters = URL.Substring(URL.LastIndexOf("/" + NewUrlModel + "_") + 6, URL.LastIndexOf(".") - (URL.LastIndexOf("/" + NewUrlModel + "_") + 6)).Split('_'); string ClassId = Convert.ToString(NewBll.GetClassName(Convert.ToInt32(Parameters[0]))); string NewPath = ClassBll.GetClassField(Convert.ToInt32(ClassId), "TemplateShow");; if (NewPath != "") { if (Parameters.Length > 1) { NewPath = NewPath + String.Format("?id={0}&class={1}&page={2}", Parameters[0], ClassId, Parameters[1]); } else { NewPath = NewPath + String.Format("?id={0}&class={1}", Parameters[0], ClassId); } return(NewPath); } else { return(null); } } else { return(URL); } }
/// <summary> /// 输出 /// </summary> /// <param name="output">The output.</param> protected override void Render(HtmlTextWriter output) { if (this.Rid != null) { ROYcms.Sys.BLL.ROYcms_news ___ROYcms_news = new ROYcms.Sys.BLL.ROYcms_news(); try { if (ROYcms.Common.cooks.GetCookie(this.Rid) == null) { ___ROYcms_news.Hits_news(Convert.ToInt32(this.Rid)); ROYcms.Common.cooks.SaveCookie(this.Rid, this.Rid, 30); output.Write("<!--浏览一次!-->"); } else { output.Write("<!--重复的信息浏览!-->"); } } catch { output.Write("<!--浏览信息记入数据库出错!-->"); } } }
/// <summary> /// 输出 /// </summary> /// <param name="output">The output.</param> protected override void Render(HtmlTextWriter output) { ROYcms.Sys.BLL.ROYcms_news ___ROYcms_news = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms.Sys.BLL.ROYcms_Custom ROYcms_CustomBLL = new ROYcms.Sys.BLL.ROYcms_Custom(); string MainField = null; try { if (Array.IndexOf(ROYcms.Common.Zn_En.MainField(), Name) != -1) //是默认字段 { MainField = ___ROYcms_news.GetField(Convert.ToInt32(Rid), ROYcms.Common.Zn_En.Fy(Name)); } else { int Class = Convert.ToInt32(___ROYcms_news.GetClassName(Convert.ToInt32(Rid))); //获取Class MainField = ROYcms_CustomBLL.GetVal(Convert.ToInt32(Rid), Class, Name); //获取自定义字段的名字 } output.Write(MainField); } catch { output.Write("<!--输出错误!-->"); } }
/// <summary> /// 静态生成频道下所有文章 /// </summary> /// <param name="Class">频道ID</param> /// <returns></returns> public static string StaticChannelArticle(int Class) { int s = 0; //成功生成个数 int e = 0; //失败生成个数 DataSet ds = new ROYcms.Sys.BLL.ROYcms_news().GetList("classname='" + Class + "'"); if (ds == null) { return("频道下无文章"); } foreach (DataRow dr in ds.Tables[0].Rows) { if (StaticHtmlDate.StaticArticle(Convert.ToInt32(dr["bh"]))) { s++; } else { e++; } } return(" 成功生成频道下所有文章[" + s.ToString() + "]个失败[" + e.ToString() + "]个! "); }
/// <summary> /// 静态生成所有文章 /// </summary> /// <returns></returns> public static string StaticAllArticle() { int s = 0; //成功生成个数 int e = 0; //失败生成个数 DataSet ds = new ROYcms.Sys.BLL.ROYcms_news().GetAllList(); if (ds == null) { return("无文章内容"); } foreach (DataRow dr in ds.Tables[0].Rows) { if (StaticHtmlDate.StaticArticle(Convert.ToInt32(dr["bh"]))) { s++; } else { e++; } } return(" 成功生成所有文章[" + s.ToString() + "]个失败[" + e.ToString() + "]个! "); }
protected override void OnDataBinding(EventArgs e) { string Strs = null; DataSet DS = null; //Tag标签 if (this.Tag != null) { Strs += "tag like '%" + this.Tag + "%' and "; } //审核状态 if (this.Switchs != null) { Strs += "Switchs = " + this.Switchs + " and "; } //置顶状态 if (this.Ding != null) { Strs += "Ding = " + this.Ding + " and "; } //推荐状态 if (this.Tuijian != null) { Strs += "Tuijian = " + this.Tuijian + " and "; } //Class分类ID标识 if (this.Class != null) { //是否包含子类内容 if (this.Son != null) { Strs += " classname in (" + ClassWheres() + ") and "; } else { Strs += "classname='" + this.Class + "' and "; } } //ClassKind标识 if (this.ClassKind != null) { Strs += "type='" + this.ClassKind + "' and "; } if (Strs.EndsWith("and ")) { Strs = Strs.Remove(Strs.LastIndexOf("and"), 4); } //自定义SQL查询条件 if (this.StrWhere != null) { Strs = this.StrWhere; } //自定义SQL语句 if (this.SQL != null) { Strs = this.SQL; } DS = new ROYcms.Sys.BLL.ROYcms_news().GetList(Top, Strs, this.FiledOrder); dataSource = (IList)(new DataView(((DataSet)(DS)).Tables[0])); base.DataSource = dataSource; intItemCount = dataSource.Count; base.OnDataBinding(e); }
/// <summary> /// 输出智能表单 返回一个字段的HTML的描述 方法 /// </summary> /// <param name="Name">字段名称 字段名称</param> /// <param name="Lable">字段的Lable 字段的Lable</param> /// <param name="Len">字段的长度 字段的长度</param> /// <param name="FieldType">字段的类型 字段的类型</param> /// <param name="IsNull">是否为空 是否为空</param> /// <param name="DefaultVal">默认值 默认值</param> /// <param name="Display">显示可见状态 显示可见状态</param> /// <param name="InputType"> input输入框的类型</param> /// <param name="InputLen">Input的显示长度</param> /// <returns>返回一个字段的HTML的描述</returns> public static string FormPut(string Id, string Class, string Name, string Lable, string Len, string FieldType, string IsNull, string DefaultVal, string Display, string InputType, string InputLen) { ROYcms.Sys.BLL.ROYcms_Custom CustomBLL = new ROYcms.Sys.BLL.ROYcms_Custom(); ROYcms.Sys.BLL.ROYcms_news ROYcms_newsBLL = new ROYcms.Sys.BLL.ROYcms_news(); string FieldVal = null; if (Id != null && Class != null) //如果是编辑 { if (!Name.Contains("_R")) { FieldVal = CustomBLL.GetVal(Convert.ToInt32(Id), Convert.ToInt32(Class), Name); } else { if (Name == "_RTitle") { FieldVal = ROYcms_newsBLL.GetField(Convert.ToInt32(Id), "title"); } else if (Name == "_RContent") { FieldVal = ROYcms_newsBLL.GetField(Convert.ToInt32(Id), "contents"); } } } DefaultVal = FieldVal; string Html = null; string input = "<input id='ROYcms_[Name]' name='ROYcms_[Name]' type='[InputType]' value='[DefaultVal]' maxlength='[Len]' style='width:[InputLen]px;' class='txtInput' />"; string textarea = "<textarea id='ROYcms_[Name]' name='ROYcms_[Name]'>[DefaultVal]</textarea>"; string Editor = @"<script> var editor; KindEditor.ready(function(K) { editor = K.create('#ROYcms_[Name]',{ cssPath : '/Administrator/Editor/plugins/code/prettify.css', uploadJson : '/Administrator/Editor/C/upload_json.ashx?root=News,Content', fileManagerJson : '/Administrator/Editor/C/file_manager_json.ashx?root=News,Content', autoHeightMode : true, allowFileManager : true }); }); </script> <textarea class='REditor' id='ROYcms_[Name]' name='ROYcms_[Name]' style='width:100%;height:360px;'>[DefaultVal]</textarea>"; string EditorBasic = @"<script> var Editor[Name]; KindEditor.ready(function(K) { Editor[Name] = K.create('#ROYcms_[Name]', { resizeType : 1, allowPreviewEmoticons : false, allowImageUpload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); }); </script> <textarea class='REditor' id='ROYcms_[Name]' name='ROYcms_[Name]' style='width:[InputLen]px;height:200px;'>[DefaultVal]</textarea>"; string UFile = @" <script> KindEditor.ready(function(K) { var editor = K.editor({ cssPath : '/Administrator/Editor/plugins/code/prettify.css', uploadJson : '/Administrator/Editor/C/upload_json.ashx?root=News,Content', fileManagerJson : '/Administrator/Editor/C/file_manager_json.ashx?root=News,Content', allowFileManager : true }); K('#fileDialog[Name]').click(function() { editor.loadPlugin('insertfile', function() { editor.plugin.fileDialog({ fileUrl : K('#ROYcms_[Name]').val(), clickFn : function(url, title) { K('#ROYcms_[Name]').val(url); editor.hideDialog(); } }); }); }); }); </script> <input type='text' id='ROYcms_[Name]' name='ROYcms_[Name]' value='[DefaultVal]' class='txtInput' /> <input type='button' id='fileDialog[Name]' value='选择文件' /> "; string UImg = @" <script> KindEditor.ready(function(K) { var editor = K.editor({ cssPath : '/Administrator/Editor/plugins/code/prettify.css', uploadJson : '/Administrator/Editor/C/upload_json.ashx?root=News,Content', fileManagerJson : '/Administrator/Editor/C/file_manager_json.ashx?root=News,Content', allowFileManager : true }); K('#imageDialog[Name]').click(function() { editor.loadPlugin('image', function() { editor.plugin.imageDialog({ imageUrl : K('#ROYcms_[Name]').val(), clickFn : function(url, title, width, height, border, align) { K('#ROYcms_[Name]').val(url); editor.hideDialog(); } }); }); }); }); </script> <input type='text' id='ROYcms_[Name]' name='ROYcms_[Name]' value='[DefaultVal]' class='txtInput' /> <input type='button' id='imageDialog[Name]' value='选择图片' /> "; if (InputType == "1") //文本框 { Html = input; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "2") //多行输入 { Html = textarea; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "3") //单选按钮 { Html = input; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "4") //复选框 { Html = input; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "5") //下拉列表 { Html = input; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "6" && Name.Contains("_RContent")) //编辑器 复杂 { Html = Editor; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "6" && !Name.Contains("_RContent")) //编辑器 简单 { Html = EditorBasic; Html = Html.Replace("[Name]", Name.Trim()); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "7") //上传图片 { Html = UImg; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } else if (InputType == "8") //上传文件 { Html = UFile; Html = Html.Replace("[Name]", Name); Html = Html.Replace("[InputType]", "text"); Html = Html.Replace("[InputLen]", InputLen); Html = Html.Replace("[DefaultVal]", DefaultVal); Html = Html.Replace("[Len]", (Convert.ToInt32(Len) / 2).ToString()); } return(Html); }
/// <summary> /// show页面标签 替换 /// </summary> /// <param name="template">模板内容</param> /// <returns></returns> public string ShowTag(string template) { if (this.bh != null) { ROYcms.Sys.BLL.ROYcms_news bll = new ROYcms.Sys.BLL.ROYcms_news(); DataSet dt = bll.GetList("bh = '" + this.bh + "'"); DataSet pg_Dn = bll.GetList("bh > '" + this.bh + "'"); DataSet pg_Up = bll.GetList("bh < '" + this.bh + "' order by bh DESC"); if (pg_Dn.Tables[0].Rows.Count > 0) { template = Replace(template, @"\[SG:pg_Dn\]", pg_Dn.Tables[0].Rows[0]["title"].ToString()); template = Replace(template, @"\[SG:pg_Dn_Link\]", pg_Dn.Tables[0].Rows[0]["jumpurl"].ToString() == "" ? (config.web_host + TemplateZone.Zpath(this.pageHost) + "show" + this.templet + "-" + pg_Dn.Tables[0].Rows[0]["bh"].ToString() + "-" + Convert.ToDateTime(pg_Dn.Tables[0].Rows[0]["time"]).ToString("yyyyMM") + config.web_forge) : pg_Dn.Tables[0].Rows[0]["jumpurl"].ToString()); } else { template = Replace(template, @"\[SG:pg_Dn\]", "无数据"); template = Replace(template, @"\[SG:pg_Dn_Link\]", "#"); } if (pg_Up.Tables[0].Rows.Count > 0) { template = Replace(template, @"\[SG:pg_Up\]", pg_Up.Tables[0].Rows[0]["title"].ToString()); template = Replace(template, @"\[SG:pg_Up_Link\]", pg_Up.Tables[0].Rows[0]["jumpurl"].ToString() == "" ? (config.web_host + TemplateZone.Zpath(this.pageHost) + "show" + this.templet + "-" + pg_Up.Tables[0].Rows[0]["bh"].ToString() + "-" + Convert.ToDateTime(pg_Up.Tables[0].Rows[0]["time"]).ToString("yyyyMM") + config.web_forge) : pg_Up.Tables[0].Rows[0]["jumpurl"].ToString()); } else { template = Replace(template, @"\[SG:pg_Up\]", "无数据"); template = Replace(template, @"\[SG:pg_Up_Link\]", "#"); } template = Replace(template, @"\[SG:UrlPath\]", config.web_host); Regex r = new Regex(@"(\[SG:Field\s+name=" + "\"" + @"(?<name>[^" + "\"" + "]*)" + "\"" + @"\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); if (dt.Tables[0].Rows.Count > 0) { foreach (Match m in r.Matches(template)) { string name = m.Groups["name"].ToString().ToLowerInvariant(); if (name == "year") { template = template.Replace(m.Groups[0].Value.ToString(), Convert.ToDateTime(dt.Tables[0].Rows[0]["time"]).Date.Year.ToString()); } else if (name == "month") { template = template.Replace(m.Groups[0].Value.ToString(), Convert.ToDateTime(dt.Tables[0].Rows[0]["time"]).Date.Month.ToString()); } else if (name == "day") { template = template.Replace(m.Groups[0].Value.ToString(), Convert.ToDateTime(dt.Tables[0].Rows[0]["time"]).Date.Day.ToString()); } else { try { template = template.Replace(m.Groups[0].Value.ToString(), dt.Tables[0].Rows[0][name].ToString()); } catch { return("标签定义出错"); } } } } } else { return(template); } return(template); }
/// <summary> /// 文章列表 频道 生成方法 循环标签的匹配替换 News the HTML. /// </summary> /// <param name="Model">The model.ROYcms_class 表对象</param> /// <returns></returns> public bool NewHtml(ROYcms.Sys.Model.ROYcms_class Model) { //定义参数 //StreamWriter sw = null; Model.FilePath = Model.FilePath.Replace("{cmspath}", "~"); string Path = ""; string ShowPath = ""; string templatepath = null; //模版地址 string HTML = ""; //模版内容 //最终列表栏目模式 if (Model.ColumnsType == 0) { templatepath = Model.TemplateList;//模版地址 // 生成默认页面开始 string TemplateIndexHTML = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))); string TemplateIndexPath = (Model.FilePath + Model.DefaultFile); //文件生成地址 NewMain(TemplateIndexPath, TemplateIndexHTML); //生成默认页面结束 int onepage = (this.onepage == null ? 10 : Convert.ToInt32(this.onepage)); int Count = new ROYcms.Sys.BLL.ROYcms_news().GetCount((this.classname == null ? "" : " classname=" + this.classname)); int allpages = Count / onepage; string Text = ""; string AllText = ""; string content = ""; Regex r = new Regex(@"(\[SG:loop\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:loop\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); for (int i = 0; i < (allpages < 1 ? 1 : allpages); i++) { HTML = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))); Path = (Model.ListeRules.Contains("~/") ? Model.ListeRules : (Model.FilePath + Model.ListeRules));//文件生成地址 Path = Path.Replace("{page}", i.ToString()); ShowPath = Model.ShowRules; string tempath = Path.Substring(0, Path.LastIndexOf("/") + 1); if (!Directory.Exists(HttpContext.Current.Server.MapPath(tempath))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(tempath)); } int start = i * onepage; int nextpage = i + 1; int perpage = i - 1; if (nextpage == allpages) { nextpage = i; } if (perpage == -1) { perpage = 0; } string SQL = "SELECT TOP " + onepage + " * FROM [ROYcms_news] WHERE (bh NOT IN (SELECT TOP " + start + " bh FROM [ROYcms_news] " + (this.classname == null ? "" : " where classname=" + this.classname) + " ORDER BY bh desc ))" + (this.classname == null ? "" : " and classname=" + this.classname) + " ORDER BY bh desc "; DataSet ds = BLL.GetDataSet(SQL); DataTable dt = ds.Tables[0]; using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")))) { #region 对循环的内容进行替换 foreach (Match m in r.Matches(HTML)) { Text = m.Groups["text"].ToString(); //循环的内容不包含SG:Loop AllText = m.Groups[0].Value.ToString(); //整个匹配的内容包含SG:Loop foreach (DataRow dr in dt.Rows) { string str = Text; string T_ShowPath = ShowPath; str = Template.Replace(str, @"\[SG:Id\]", dr["bh"].ToString()); str = Template.Replace(str, @"\[SG:Title\]", dr["title"].ToString()); str = Template.Replace(str, @"\[SG:zhaiyao\]", dr["zhaiyao"].ToString()); str = Template.Replace(str, @"\[SG:pic\]", dr["pic"].ToString()); str = Template.Replace(str, @"\[SG:classname\]", dr["classname"].ToString()); str = Template.Replace(str, @"\[SG:author\]", dr["author"].ToString()); str = Template.Replace(str, @"\[SG:time\]", dr["time"].ToString()); str = Template.Replace(str, @"\[SG:Year\]", Convert.ToDateTime(dr["time"]).ToString("yyyy")); str = Template.Replace(str, @"\[SG:Month\]", Convert.ToDateTime(dr["time"]).ToString("MM")); str = Template.Replace(str, @"\[SG:Day\]", Convert.ToDateTime(dr["time"]).ToString("dd")); T_ShowPath = T_ShowPath.Replace("{yyyy}", Convert.ToDateTime(dr["time"]).ToString("yyyy")); T_ShowPath = T_ShowPath.Replace("{MM}", Convert.ToDateTime(dr["time"]).ToString("MM")); T_ShowPath = T_ShowPath.Replace("{dd}", Convert.ToDateTime(dr["time"]).ToString("dd")); T_ShowPath = T_ShowPath.Replace("{id}", dr["bh"].ToString()); str = Template.Replace(str, @"\[SG:Link\]", T_ShowPath); content += AllText.Replace(AllText, str); } HTML = HTML.Replace(AllText, content); HTML = HTML.Replace(@"[SG:PageUp]", Model.ListeRules.Replace("{page}", perpage.ToString())); HTML = HTML.Replace(@"[SG:PageDow]", Model.ListeRules.Replace("{page}", nextpage.ToString())); content = ""; } #endregion //创建文件 try { sw.WriteLine(HTML); sw.Flush(); err = true; } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); HttpContext.Current.Response.End(); err = false; } finally { sw.Close(); } } } } //封面频道方式 if (Model.ColumnsType == 1) { templatepath = Model.TemplateIndex; //模版地址 HTML = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))); Path = (Model.FilePath + Model.DefaultFile); //文件生成地址 NewMain(Path, HTML); err = true; } return(err); }
protected override void OnDataBinding(EventArgs e) { string Strs = null; // int Count; DataSet DS = null; //Tag标签 if (this.Tag != null) { Strs += "tag like '%" + this.Tag + "%' and "; } //审核状态 if (this.Switchs != null) { Strs += "Switchs = " + this.Switchs + " and "; } //置顶状态 if (this.Ding != null) { Strs += "Ding = " + this.Ding + " and "; } //推荐状态 if (this.Tuijian != null) { Strs += "Tuijian = " + this.Tuijian + " and "; } //Class分类ID标识 if (this.Type != null) { //是否包含子类内容 if (this.Son != null) { Strs += " classname in (" + ClassWheres() + ") and "; } else { Strs += "classname='" + this.Type + "' and "; } } //ClassKind标识 if (this.ClassKind != null) { Strs += "type='" + this.ClassKind + "' and "; } if (Strs.EndsWith("and ")) { Strs = Strs.Remove(Strs.LastIndexOf("and"), 4); } //自定义SQL查询条件 if (this.StrWhere != null) { Strs = this.StrWhere; } //自定义SQL语句 if (this.SQL != null) { Strs = this.SQL; } DS = new ROYcms.Sys.BLL.ROYcms_news().GetList(this.PageSize, Convert.ToInt32(this.CurrentPageIndex), Strs, 1, "TIME"); //增加几列 文章链接、栏目名称、栏目链接 if (DS.Tables[0].Rows.Count > 0) { DS.Tables[0].Columns.Add("ShowLink", typeof(System.String)); //添加一列数据 文章链接 DS.Tables[0].Columns.Add("ChannelName", typeof(System.String)); //添加一列数据 栏目名称 DS.Tables[0].Columns.Add("ChannelLink", typeof(System.String)); //添加一列数据 栏目链接 DS.Tables[0].Columns.Add("ChannelListLink", typeof(System.String)); //添加一列数据 栏目链接2 foreach (DataRow Dr in DS.Tables[0].Rows) { Dr["ShowLink"] = new ROYcms.Templet.GetMyUrl().GetArticle(Convert.ToInt32(Dr["bh"])); Dr["ChannelName"] = this.ClassBll.GetClassField(Convert.ToInt32(Dr["classname"]), "ClassName"); Dr["ChannelLink"] = new ROYcms.Templet.GetMyUrl().GetChannel(Convert.ToInt32(Dr["classname"]), 0); Dr["ChannelListLink"] = new ROYcms.Templet.GetMyUrl().GetChannel(Convert.ToInt32(Dr["classname"]), 1); } } DataView dv = new DataView(); dv.Table = DS.Tables[0]; dv.Sort = this.FiledOrder; dataSource = (IList)dv; intItemCount = new ROYcms.Sys.BLL.ROYcms_news().GetCount(Strs); if (CurrentPageIndex != "1") { this.RealSource = true; } if (this.RealSource) //数据源已分页 { base.DataSource = dataSource; } else//数据源未分页 { int start = (Convert.ToInt32(intCurrentPage) - 1) * intPageSize; int size = Math.Min(intPageSize, intItemCount - start); IList list = new ArrayList(); for (int i = 0; i < size; i++) { list.Add(dataSource[start + i]); } base.DataSource = list; } base.OnDataBinding(e); }
protected override void OnDataBinding(EventArgs e) { string Strs = null; // int Count; DataSet DS = null; //Tag标签 if (this.Tag != null) { Strs += "tag like '%" + this.Tag + "%' and "; } //审核状态 if (this.Switchs != null) { Strs += "Switchs = " + this.Switchs + " and "; } //置顶状态 if (this.Ding != null) { Strs += "Ding = " + this.Ding + " and "; } //推荐状态 if (this.Tuijian != null) { Strs += "Tuijian = " + this.Tuijian + " and "; } //Class分类ID标识 if (this.Class != null) { //是否包含子类内容 if (this.Son != null) { Strs += " classname in (" + ClassWheres() + ") and "; } else { Strs += "classname='" + this.Class + "' and "; } } //ClassKind标识 if (this.ClassKind != null) { Strs += "type='" + this.ClassKind + "' and "; } if (Strs.EndsWith("and ")) { Strs = Strs.Remove(Strs.LastIndexOf("and"), 4); } //自定义SQL查询条件 if (this.StrWhere != null) { Strs = this.StrWhere; } //自定义SQL语句 if (this.SQL != null) { Strs = this.SQL; } DS = new ROYcms.Sys.BLL.ROYcms_news().GetList(this.PageSize, Convert.ToInt32(this.CurrentPageIndex), Strs, 0); DataView dv = new DataView(); dv.Table = DS.Tables[0]; dv.Sort = this.FiledOrder; dataSource = (IList)dv; // dataSource = (IList)(new DataView(((DataSet)(DS)).Tables[0])); //intItemCount = ((IList)(new DataView(((DataSet)(DS1)).Tables[0]))).Count; intItemCount = new ROYcms.Sys.BLL.ROYcms_news().GetCount(Strs); if (CurrentPageIndex != "1") { this.RealSource = true; } if (this.RealSource) //数据源已分页 { base.DataSource = dataSource; } else//数据源未分页 { int start = (Convert.ToInt32(intCurrentPage) - 1) * intPageSize; int size = Math.Min(intPageSize, intItemCount - start); IList list = new ArrayList(); for (int i = 0; i < size; i++) { list.Add(dataSource[start + i]); } base.DataSource = list; } base.OnDataBinding(e); }