// 跳转页面地址 public string GetUrl() { string itemid = Eval("ID").ToString(); if (!string.IsNullOrEmpty(Eval("PageUrl").ToString()))//如为子站数据,则直接返回链接 { return(Eval("PageUrl").ToString()); } else if (!string.IsNullOrEmpty(Eval("HtmlLink").ToString()))//有静态链接 { return(SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + Eval("HtmlLink")); } else { string url = string.Empty; string tbname = Eval("TableName").ToString(); if (tbname.Contains("ZL_C_")) { url = "/Item/" + itemid + ".aspx"; } else if (tbname.Contains("ZL_P_")) { DataTable protable = pll.SelectProByCmdID(DataConverter.CLng(itemid)); if (protable != null && protable.Rows.Count > 0)//当内容表与商品表同步时,取商品地址 { url = "/Shop/" + protable.Rows[0]["ID"] + ".aspx"; } else//否则取内容地址 { url = "/Item/" + itemid + ".aspx"; } } return(url); } }
public void StoreContent() { if (ItemID < 1) { ErrToClient("[产生错误的可能原因:您访问的商品信息不存在!"); } M_Product ItemInfo = proBll.GetproductByid(ItemID); if (ItemInfo == null) { ErrToClient("[产生错误的可能原因:您访问的商品信息不存在!]"); return; } M_Node nodeinfo = nodeBll.GetNodeXML(ItemInfo.Nodeid); if (nodeinfo.PurviewType) { if (!buser.CheckLogin()) { function.WriteErrMsg("该信息所属栏目需登录验证,请先登录再进行此操作!", "/User/login"); return; } else { //此处以后可以加上用户组权限检测 } } string TemplateDir = ""; //ItemID 商品ID if (proBll.SelectProByCmdID(ItemID).Rows.Count < 1) { function.WriteErrMsg("该商品不存在!"); return; } int UserID = DataConverter.CLng(proBll.SelectProByCmdID(ItemID).Rows[0]["UserID"]); string username = buser.GetUserByUserID(UserID).UserName; DataTable mosinfo = mfbll.SelectTableName("ZL_CommonModel", "TableName like 'ZL_Store_%' and Inputer='" + username + "'"); int GeneralID = DataConverter.CLng(mosinfo.Rows[0]["GeneralID"]); DataTable infos = conBll.GetContent(GeneralID); int StoreStyleID = DataConverter.CLng(infos.Rows[0]["StoreStyleID"]); M_StoreStyleTable stinfo = sstbll.GetStyleByID(DataConverter.CLng(StoreStyleID)); string ContentStyle = stinfo.ContentStyle; M_ModelInfo modelinfo = modBll.GetModelById(ItemInfo.ModelID); string TempNode = nodeBll.GetModelTemplate(ItemInfo.Nodeid, ItemInfo.ModelID); if (!string.IsNullOrEmpty(TempNode)) { TemplateDir = TempNode; } if (!string.IsNullOrEmpty(ContentStyle)) { TemplateDir = ContentStyle; } if (string.IsNullOrEmpty(TemplateDir)) { Response.Write("[产生错误的可能原因:该商品所属模型未指定模板!]"); } else { TemplateDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + "/" + TemplateDir; TemplateDir = TemplateDir.Replace("/", @"\"); string ContentHtml = FileSystemObject.ReadFile(TemplateDir); ContentHtml = this.createBll.CreateHtml(ContentHtml, 0, ItemID, "0"); if (!string.IsNullOrEmpty(ContentHtml)) { /* --------------------判断是否分页 并做处理------------------------------------------------*/ string infoContent = ""; //进行处理的商品字段 string pagelabel = ""; string infotmp = ""; string pattern = @"{\#Content}([\s\S])*?{\/\#Content}"; //查找要分页的商品 if (Regex.IsMatch(ContentHtml, pattern, RegexOptions.IgnoreCase)) { infoContent = Regex.Match(ContentHtml, pattern, RegexOptions.IgnoreCase).Value; infotmp = infoContent; infoContent = infoContent.Replace("{#Content}", "").Replace("{/#Content}", ""); } //查找分页标签 bool isPage = false; string pattern1 = @"{ZL\.Page([\s\S])*?\/}"; if (Regex.IsMatch(ContentHtml, pattern1, RegexOptions.IgnoreCase)) { pagelabel = Regex.Match(ContentHtml, pattern1, RegexOptions.IgnoreCase).Value; isPage = true; } if (isPage) { if (string.IsNullOrEmpty(infoContent)) //没有设定要分页的字段商品 { ContentHtml = ContentHtml.Replace(pagelabel, ""); } else //进行商品分页处理 { //文件名 string file1 = "StoreContent.aspx?ItemID=" + ItemID.ToString(); //取分页标签处理结果 返回字符串数组 根据数组元素个数生成几页 string ilbl = pagelabel.Replace("{ZL.Page ", "").Replace("/}", "").Replace(" ", ","); string lblContent = ""; int NumPerPage = 500; IList <string> ContentArr = new List <string>(); if (string.IsNullOrEmpty(ilbl)) { lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航 ContentArr = this.createBll.GetContentPage(infoContent, NumPerPage); } else { string[] paArr = ilbl.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (paArr.Length == 0) { lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航 ContentArr = this.createBll.GetContentPage(infoContent, NumPerPage); } else { string lblname = paArr[0].Split(new char[] { '=' })[1].Replace("\"", ""); if (paArr.Length > 1) { NumPerPage = DataConverter.CLng(paArr[1].Split(new char[] { '=' })[1].Replace("\"", "")); } B_Label blbl = new B_Label(); lblContent = blbl.GetLabelXML(lblname).Content; if (string.IsNullOrEmpty(lblContent)) { lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航 } ContentArr = this.createBll.GetContentPage(infoContent, NumPerPage); } } //Response.Write(NumPerPage.ToString()); //Response.End(); if (ContentArr.Count > 0) //存在分页数据 { ContentHtml = ContentHtml.Replace(infotmp, ContentArr[Cpage - 1]); ContentHtml = ContentHtml.Replace(pagelabel, this.createBll.GetPage(lblContent, ItemID, Cpage, ContentArr.Count, NumPerPage)); } else { ContentHtml = ContentHtml.Replace(infotmp, infoContent); ContentHtml = ContentHtml.Replace(pagelabel, ""); } } } else //没有分页标签 { //如果设定了分页商品字段 将该字段商品的分页标志清除 if (!string.IsNullOrEmpty(infoContent)) { ContentHtml = ContentHtml.Replace(infotmp, infoContent); } } } /*--------------------- 分页商品处理结束-------------------------------------------------------------------------*/ Response.Write(ContentHtml); } }