/// <summary> /// 得到列表 /// </summary> public Extends_Vote GetVote() { using (DbOperHandler _doh = new Common().Doh()) { Extends_Vote vote = new Extends_Vote(); _doh.Reset(); _doh.SqlCmd = "SELECT TOP 1 [Id],[Title],[VoteText],[VoteNum],[VoteTotal],[Type] FROM [jcms_extends_vote] WHERE [Lock]=0 ORDER BY Id Desc"; DataTable dtVote = _doh.GetDataTable(); if (dtVote.Rows.Count > 0) { vote.Id = dtVote.Rows[0]["Id"].ToString(); vote.Title = dtVote.Rows[0]["Title"].ToString(); vote.VoteTotal = Str2Int(dtVote.Rows[0]["VoteTotal"].ToString()); string[] itemtext = dtVote.Rows[0]["VoteText"].ToString().Split('|'); string[] itemclicks = dtVote.Rows[0]["VoteNum"].ToString().Split('|'); List<Extends_VoteItem> voteitems = new List<Extends_VoteItem>(); for (int i = 0; i < itemtext.Length; i++) { voteitems.Add(new Extends_VoteItem(itemtext[i], Str2Int(itemclicks[i]))); } vote.Item = voteitems; vote.Type = Str2Int(dtVote.Rows[0]["Type"].ToString()); } else vote.Id = "0"; dtVote.Clear(); dtVote.Dispose(); return vote; } }
/// <summary> /// 得到列表 /// </summary> public List<Extends_QQOnline> QQOnlineList() { using (DbOperHandler _doh = new Common().Doh()) { List<Extends_QQOnline> qqonlines; qqonlines = new List<Extends_QQOnline>(); _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_extends_qqonline] Where State=1 ORDER BY OrderNum Desc,Id Desc"; DataTable dtQQOnline = _doh.GetDataTable(); if (dtQQOnline.Rows.Count > 0) { for (int i = 0; i < dtQQOnline.Rows.Count; i++) { qqonlines.Add(new Extends_QQOnline(dtQQOnline.Rows[i]["Id"].ToString(), dtQQOnline.Rows[i]["QQID"].ToString(), dtQQOnline.Rows[i]["Title"].ToString(), dtQQOnline.Rows[i]["TColor"].ToString(), dtQQOnline.Rows[i]["face"].ToString() )); } } dtQQOnline.Clear(); dtQQOnline.Dispose(); return qqonlines; } }
/// <summary> /// 得到列表 /// </summary> public List<Extends_Placard> PlacardList() { using (DbOperHandler _doh = new Common().Doh()) { List<Extends_Placard> placards; placards = new List<Extends_Placard>(); _doh.Reset(); _doh.SqlCmd = "SELECT TOP 10 [Id],[Title],[AddTime] FROM [jcms_extends_placard] WHERE [State]=1 ORDER BY Id Desc"; DataTable dtPlacard = _doh.GetDataTable(); if (dtPlacard.Rows.Count > 0) { for (int i = 0; i < dtPlacard.Rows.Count; i++) { placards.Add(new Extends_Placard(dtPlacard.Rows[i]["Id"].ToString(), dtPlacard.Rows[i]["Title"].ToString(), "", Convert.ToDateTime(dtPlacard.Rows[i]["AddTime"].ToString()), 1 )); } } dtPlacard.Clear(); dtPlacard.Dispose(); return placards; } }
public override void CreateContent(string _ChannelId, string _ContentId, int _CurrentPage) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT [PhotoUrl],[FirstPage] FROM [jcms_module_photo] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); //图片地址分割处理 string PhotoUrl = dtContent.Rows[0]["PhotoUrl"].ToString().Replace("\r\n", "\r"); string ContentFirstPage = dtContent.Rows[0]["FirstPage"].ToString(); dtContent.Clear(); dtContent.Dispose(); if (PhotoUrl != "") { string[] PhotoUrlArr = PhotoUrl.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries); int pageCount = PhotoUrlArr.Length; if (ContentFirstPage.Length == 0) { _doh.Reset(); _doh.SqlCmd = "UPDATE [jcms_module_photo] SET [FirstPage]='" + Go2View(1, true, _ChannelId, _ContentId, false) + "' WHERE [ChannelId]=" + _ChannelId + " and [IsPass]=1 and [Id]=" + _ContentId; _doh.ExecuteSqlNonQuery(); } for (int j = 1; j < (pageCount + 1); j++) { JumboTCMS.Utils.DirFile.SaveFile(GetContent(_ChannelId, _ContentId, j), Go2View(j, true, _ChannelId, _ContentId, true)); } } } }
public override string GetContent(string _ChannelId, string _ContentId, int _CurrentPage) { using (DbOperHandler _doh = new Common().Doh()) { JumboTCMS.Entity.Normal_Channel _Channel = new JumboTCMS.DAL.Normal_ChannelDAL().GetEntity(_ChannelId); if (_Channel.Enabled == false) { return "频道错误"; } _doh.Reset(); _doh.SqlCmd = "SELECT [ClassId] FROM [jcms_module_photo] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtSearch = _doh.GetDataTable(); if (dtSearch.Rows.Count == 0) { dtSearch.Clear(); dtSearch.Dispose(); return "内容错误"; } string ClassId = dtSearch.Rows[0]["ClassId"].ToString(); dtSearch.Clear(); dtSearch.Dispose(); TemplateEngineDAL te = new TemplateEngineDAL(_ChannelId); _doh.Reset(); _doh.SqlCmd = "SELECT Id FROM [jcms_normal_class] WHERE [IsOut]=0 AND [ChannelId]=" + _ChannelId + " and [Id]=" + ClassId; if (_doh.GetDataTable().Rows.Count == 0) { return "栏目错误"; } string PageStr = string.Empty; _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_module_photo] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); string _FirstPage = dtContent.Rows[0]["FirstPage"].ToString(); System.Collections.ArrayList ContentList = new System.Collections.ArrayList(); p__GetChannel_Photo(te, dtContent, ref PageStr, ref ContentList, 0); te.ReplaceContentTag(ref PageStr, _ContentId); te.ReplaceContentLoopTag(ref PageStr);//主要解决通过tags关联 te.ExcuteLastHTML(ref PageStr); ContentList.Add(PageStr); p__replaceSinglePhoto(dtContent, ref _CurrentPage, ref PageStr, ref ContentList); int _TotalPage = Convert.ToInt16(ContentList[1].ToString());//总页数 dtContent.Clear(); dtContent.Dispose(); string _PrevLink = _CurrentPage == 1 ? "#" : Go2View(_CurrentPage - 1, (_Channel.IsHtml), _ChannelId, _ContentId, false); string _NextLink = _CurrentPage == _TotalPage ? "#" : Go2View(_CurrentPage + 1, (_Channel.IsHtml), _ChannelId, _ContentId, false); string _html = ContentList[0].ToString(); string[] ThisPhotoUrl = ContentList[2].ToString().Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries); string CurrentPhotoUrl = ThisPhotoUrl[ThisPhotoUrl.Length - 1]; string CurrentPhotoTitle = ThisPhotoUrl.Length == 1 ? "" : ThisPhotoUrl[0]; return _html .Replace("{$CurrentPage}", _CurrentPage.ToString()) .Replace("{$TotalPage}", ContentList[1].ToString()) .Replace("{$CurrentPhotoUrl}", CurrentPhotoUrl) .Replace("{$CurrentPhotoTitle}", CurrentPhotoTitle) .Replace("{$SlideJSON}", ContentList[3].ToString()) .Replace("{$PrevLink}", _PrevLink) .Replace("{$NextLink}", _NextLink); } }
/// <summary> /// 绑定数据到实体 /// </summary> /// <param name="_id"></param> public void BindData2Entity(string _id, JumboTCMS.Entity.Normal_Class _class) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_normal_class] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { _class.Id = dt.Rows[0]["Id"].ToString(); _class.ChannelId = Validator.StrToInt(dt.Rows[0]["ChannelId"].ToString(), 0); _class.ParentId = Validator.StrToInt(dt.Rows[0]["ParentId"].ToString(), 0); _class.Title = dt.Rows[0]["Title"].ToString(); _class.Info = dt.Rows[0]["Info"].ToString(); _class.Img = dt.Rows[0]["Img"].ToString(); _class.FilePath = dt.Rows[0]["FilePath"].ToString(); _class.Code = dt.Rows[0]["Code"].ToString(); _class.IsPost = Validator.StrToInt(dt.Rows[0]["IsPost"].ToString(), 0) == 1; _class.IsTop = Validator.StrToInt(dt.Rows[0]["IsTop"].ToString(), 0) == 1; _class.TopicNum = Validator.StrToInt(dt.Rows[0]["TopicNum"].ToString(), 0); _class.TemplateId = Str2Str(dt.Rows[0]["TemplateId"].ToString()); _class.ContentTemp = Str2Str(dt.Rows[0]["ContentTemp"].ToString()); _class.PageSize = Validator.StrToInt(dt.Rows[0]["PageSize"].ToString(), 0); _class.IsOut = Validator.StrToInt(dt.Rows[0]["IsOut"].ToString(), 0) == 1; _class.FirstPage = dt.Rows[0]["FirstPage"].ToString(); _class.ReadGroup = Validator.StrToInt(dt.Rows[0]["ReadGroup"].ToString(), 0); } } }
public virtual void CreateContent(string _ChannelId, string _ContentId, int _CurrentPage) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT [Content],[FirstPage] FROM [jcms_module_article] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); string ArticleContent = dtContent.Rows[0]["Content"].ToString(); string ContentFirstPage = dtContent.Rows[0]["FirstPage"].ToString(); dtContent.Clear(); dtContent.Dispose(); if (ArticleContent != "") { int pageCount = 1; //处理文章内容分页 if (ArticleContent.Contains("[Jumbot_PageBreak]")) { string[] ContentArr = ArticleContent.Split(new string[] { "[Jumbot_PageBreak]" }, StringSplitOptions.RemoveEmptyEntries); pageCount = ContentArr.Length; } if (ContentFirstPage.Length == 0) { _doh.Reset(); _doh.SqlCmd = "UPDATE [jcms_module_article] SET [FirstPage]='" + Go2View(1, true, _ChannelId, _ContentId, false) + "' WHERE [ChannelId]=" + _ChannelId + " and [IsPass]=1 and [Id]=" + _ContentId; _doh.ExecuteSqlNonQuery(); } for (int j = 1; j < (pageCount + 1); j++) { JumboTCMS.Utils.DirFile.SaveFile(GetContent(_ChannelId, _ContentId, j), Go2View(j, true, _ChannelId, _ContentId, true)); } } } }
/// <summary> /// 得到列表 /// </summary> public List<Normal_Link> LinkList() { using (DbOperHandler _doh = new Common().Doh()) { List<Normal_Link> links; links = new List<Normal_Link>(); _doh.Reset(); _doh.SqlCmd = "SELECT [Id],[Title],[Url],[ImgPath],[Info],[Style] FROM [jcms_normal_link] WHERE [State]=1 ORDER BY Style Desc,OrderNum Desc,Id Desc"; DataTable dtLink = _doh.GetDataTable(); if (dtLink.Rows.Count > 0) { for (int i = 0; i < dtLink.Rows.Count; i++) { links.Add(new Normal_Link(dtLink.Rows[i]["Id"].ToString(), dtLink.Rows[i]["Title"].ToString(), dtLink.Rows[i]["Url"].ToString(), dtLink.Rows[i]["ImgPath"].ToString(), dtLink.Rows[i]["Info"].ToString(), Str2Int(dtLink.Rows[i]["Style"].ToString()) )); } } dtLink.Clear(); dtLink.Dispose(); return links; } }
/// <summary> /// 得到评论列表 /// </summary> /// <param name="_thispage">当前页码</param> /// <param name="_pagesize">每页记录条数</param> /// <param name="_channelid">频道ID</param> /// <param name="_contentid">内容ID</param> public string GetTopList(int _thispage, int _pagesize, string _channelid, string _contentid) { using (DbOperHandler _doh = new Common().Doh()) { string sqlStr = ""; int countNum = 0; string whereStr = "[IsPass]=1 AND [ParentId]=0"; if (_channelid != "0") whereStr += " AND [ChannelId]=" + _channelid; if (_contentid != "0") whereStr += " AND [ContentId]=" + _contentid; _doh.Reset(); _doh.ConditionExpress = whereStr; countNum = _doh.Count("jcms_normal_review"); sqlStr = JumboTCMS.Utils.SqlHelp.GetSql("Id,ChannelId,ContentId,IP,UserName,AddDate,Content", "jcms_normal_review", "id", _pagesize, _thispage, "desc", whereStr); _doh.Reset(); _doh.SqlCmd = sqlStr; DataTable dt = _doh.GetDataTable(); string ResponseStr = ""; for (int j = 0; j < dt.Rows.Count; j++) { ResponseStr += "<li><a href=\"" + site.Dir + "review/default.aspx?ccid=" + dt.Rows[j]["ChannelId"].ToString() + "&id=" + dt.Rows[j]["ContentId"].ToString() + "#c" + dt.Rows[j]["Id"].ToString() + "\" target=\"_blank\">" + dt.Rows[j]["Content"].ToString() + "</a></li>"; } dt.Clear(); dt.Dispose(); return ResponseStr; } }
public override string GetContent(string _ChannelId, string _ContentId, int _CurrentPage) { using (DbOperHandler _doh = new Common().Doh()) { JumboTCMS.Entity.Normal_Channel _Channel = new JumboTCMS.DAL.Normal_ChannelDAL().GetEntity(_ChannelId); if (_Channel.Enabled == false) { return "频道错误"; } _doh.Reset(); _doh.SqlCmd = "SELECT [ClassId] FROM [jcms_module_soft] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtSearch = _doh.GetDataTable(); if (dtSearch.Rows.Count == 0) { dtSearch.Clear(); dtSearch.Dispose(); return "内容错误"; } string ClassId = dtSearch.Rows[0]["ClassId"].ToString(); dtSearch.Clear(); dtSearch.Dispose(); TemplateEngineDAL te = new TemplateEngineDAL(_ChannelId); _doh.Reset(); _doh.SqlCmd = "SELECT Id FROM [jcms_normal_class] WHERE [IsOut]=0 AND [ChannelId]=" + _ChannelId + " and [Id]=" + ClassId; if (_doh.GetDataTable().Rows.Count == 0) { return "栏目错误"; } string PageStr = string.Empty; _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_module_soft] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); System.Collections.ArrayList ContentList = new System.Collections.ArrayList(); p__GetChannel_Soft(te, dtContent, ref PageStr, ref ContentList, 0); te.ReplaceContentTag(ref PageStr, _ContentId); te.ReplaceContentLoopTag(ref PageStr);//主要解决通过tags关联 te.ExcuteLastHTML(ref PageStr); ContentList.Add(PageStr); p__replaceSingleSoft(dtContent, ref PageStr, ref ContentList); dtContent.Clear(); dtContent.Dispose(); return ContentList[0].ToString().Replace("{$DownUrl}", ContentList[1].ToString()); } }
/// <summary> /// 得到数据表 /// </summary> /// <param name="_channelid"></param> /// <returns></returns> public DataTable GetDataTable(string _channelid) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); if (_channelid == "0") _doh.SqlCmd = "SELECT ID,Title,iWidth,iHeight FROM [jcms_normal_thumbs] ORDER BY ChannelID,ID"; else _doh.SqlCmd = "SELECT ID,Title,iWidth,iHeight FROM [jcms_normal_thumbs] WHERE [ChannelId]=" + _channelid + " OR [ChannelId]=0 ORDER BY ChannelID,ID"; DataTable dt = _doh.GetDataTable(); return dt; } }
/// <summary> /// 批量操作插件 /// </summary> /// <param name="_act">行为</param> /// <param name="_ids">id,以,隔开</param> public bool BatchOper(string _act, string _ids) { using (DbOperHandler _doh = new Common().Doh()) { string[] idValue; idValue = _ids.Split(','); if (_act == "pass") { for (int i = 0; i < idValue.Length; i++) { _doh.Reset(); _doh.ConditionExpress = "id=@id"; _doh.AddConditionParameter("@id", idValue[i]); _doh.AddFieldItem("Enabled", 1); _doh.Update("jcms_normal_extends"); } } else if (_act == "nopass") { for (int i = 0; i < idValue.Length; i++) { _doh.Reset(); _doh.ConditionExpress = "id=@id"; _doh.AddConditionParameter("@id", idValue[i]); _doh.AddFieldItem("Enabled", 0); _doh.Update("jcms_normal_extends"); } } string TempStr = ""; _doh.Reset(); _doh.SqlCmd = JumboTCMS.Utils.SqlHelp.GetSql("[Title],[Name],[Type],[Enabled]", "jcms_normal_extends", "pId", 100, 1, "desc", ""); DataTable dt = _doh.GetDataTable(); for (int i = 0; i < dt.Rows.Count; i++) { if(dt.Rows[i]["Enabled"].ToString() =="1") TempStr += "\r\nvar Plugin" + dt.Rows[i]["Name"].ToString() + " = true;//" + dt.Rows[i]["Title"].ToString() + "插件"; else TempStr += "\r\nvar Plugin" + dt.Rows[i]["Name"].ToString() + " = false;//" + dt.Rows[i]["Title"].ToString() + "插件"; } string _globalJS = JumboTCMS.Utils.DirFile.ReadFile("~/_data/jcmsV5.js"); string _strBegin = "//<!--插件开关begin"; string _strEnd = "//-->插件开关end"; System.Collections.ArrayList TagArray = JumboTCMS.Utils.Strings.GetHtmls(_globalJS, _strBegin, _strEnd, true, true); if (TagArray.Count > 0)//标签存在 { _globalJS = _globalJS.Replace(TagArray[0].ToString(), _strBegin + "\r\n\r\n" + TempStr + "\r\n\r\n" + _strEnd); } JumboTCMS.Utils.DirFile.SaveFile(_globalJS, "~/_data/jcmsV5.js"); } return true; }
public override void CreateContent(string _ChannelId, string _ContentId, int _CurrentPage) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT [FirstPage] FROM [jcms_module_soft] WHERE [ChannelId]=" + _ChannelId + " and [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); string ContentFirstPage = dtContent.Rows[0]["FirstPage"].ToString(); dtContent.Clear(); dtContent.Dispose(); if (ContentFirstPage.Length == 0) { _doh.Reset(); _doh.SqlCmd = "UPDATE [jcms_module_soft] SET [FirstPage]='" + Go2View(1, true, _ChannelId, _ContentId, false) + "' WHERE [ChannelId]=" + _ChannelId + " and [IsPass]=1 and [Id]=" + _ContentId; _doh.ExecuteSqlNonQuery(); } JumboTCMS.Utils.DirFile.SaveFile(GetContent(_ChannelId, _ContentId, 1), Go2View(1, true, _ChannelId, _ContentId, true)); } }
/// <summary> /// 得到列表JSON数据 /// </summary> /// <param name="_thispage">当前页码</param> /// <param name="_pagesize">每页记录条数</param> /// <param name="_joinstr">关联条件</param> /// <param name="_wherestr1">外围条件(带A.)</param> /// <param name="_wherestr2">分页条件(不带A.)</param> /// <param name="_jsonstr">返回值</param> public void GetListJSON(int _thispage, int _pagesize, string _joinstr, string _wherestr1, string _wherestr2, ref string _jsonstr) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.ConditionExpress = _wherestr2; string sqlStr = ""; int _countnum = _doh.Count("jcms_normal_adminlogs"); sqlStr = JumboTCMS.Utils.SqlHelp.GetSql("A.id as id,A.AdminId as AdminId,B.[AdminName] as AdminName,A.OperInfo as OperInfo,A.OperTime as OperTime,A.OperIP as OperIP", "jcms_normal_adminlogs", "jcms_normal_user", "Id", _pagesize, _thispage, "desc", _joinstr, _wherestr1, _wherestr2); _doh.Reset(); _doh.SqlCmd = sqlStr; DataTable dt = _doh.GetDataTable(); _jsonstr = "{result :\"1\"," + "returnval :\"操作成功\"," + "pagerbar :\"" + JumboTCMS.Utils.HtmlPager.GetPageBar(3, "js", 2, _countnum, _pagesize, _thispage, "javascript:ajaxList(<#page#>);") + "\"," + JumboTCMS.Utils.dtHelp.DT2JSON(dt, (_pagesize * (_thispage - 1))) + "}"; dt.Clear(); dt.Dispose(); } }
public string GetAdvBody(string _id) { using (DbOperHandler _doh = new Common().Doh()) { string _body = ""; _doh.Reset(); _doh.SqlCmd = "select * from [jcms_normal_adv] where id=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count == 0) { return null; } string _advname = dt.Rows[0]["Title"].ToString(); string _type = dt.Rows[0]["AdvType"].ToString().ToLower(); string _width = dt.Rows[0]["width"].ToString(); string _height = dt.Rows[0]["height"].ToString(); string _content = dt.Rows[0]["Content"].ToString(); string _url = dt.Rows[0]["Url"].ToString(); string _picurl = dt.Rows[0]["Picurl"].ToString(); switch (_type) { case "img": if (_url.Length > 10) _body = string.Format("<!--" + _advname + "开始--><a href='{3}' target='_blank'><img src='{0}' width='{1}' height='{2}' border='0' /></a><!--" + _advname + "结束-->", _picurl, _width, _height, _url); else _body = string.Format("<!--" + _advname + "开始--><img src='{0}' width='{1}' height='{2}' border='0' /><!--" + _advname + "结束-->", _picurl, _width, _height); break; case "flash": _body = "<!--" + _advname + "开始--><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + _width + "' height='" + _height + "' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='" + _picurl + "' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='" + _picurl + "' quality='high' bgcolor='#ffffff' width='" + _width + "' height='" + _height + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object><!--" + _advname + "结束-->"; break; case "iframe": _body = "<!--" + _advname + "开始--><iframe src='" + _content + "' width='" + _width + "' height='" + _height + "' scrolling='auto' frameborder='0' marginheight='0' marginwidth='0'></iframe><!--" + _advname + "结束-->"; break; default: _body = "<!--" + _advname + "开始-->" + _content + "<!--" + _advname + "结束-->"; break; } return _body; } }
/// <summary> /// 获得指定栏目内容页数 /// </summary> /// <param name="_channelid">频道ID</param> /// <param name="_classid">栏目ID</param> /// <param name="_includechild">是否包含子类内容</param> /// <returns></returns> public int GetContetPageCount(string _channelid, string _classid, bool _includechild) { using (DbOperHandler _doh = new Common().Doh()) { string _channeltype = new Normal_ChannelDAL().GetChannelType(_channelid); if (_channeltype.Length == 0) return 0; _doh.Reset(); _doh.SqlCmd = "SELECT [PageSize],[Code] FROM [jcms_normal_class] WHERE [ChannelId]=" + _channelid + " AND [Id]=" + _classid; int _pagesize = JumboTCMS.Utils.Validator.StrToInt(_doh.GetDataTable().Rows[0]["PageSize"].ToString(), 0); string _classcode = _doh.GetDataTable().Rows[0]["Code"].ToString(); if (_pagesize == 0) _pagesize = 20; string _pstr = string.Empty; if (!_includechild) _pstr = " [ClassID]=" + _classid + " AND [IsPass]=1 AND [ChannelId]=" + _channelid; else _pstr = " [ClassID] in (Select id FROM [jcms_normal_class] WHERE [Code] LIKE '" + _classcode + "%') AND [IsPass]=1 AND [ChannelId]=" + _channelid; _doh.Reset(); _doh.ConditionExpress = _pstr; int _totalcount = _doh.Count("jcms_module_" + _channeltype); return JumboTCMS.Utils.Int.PageCount(_totalcount, _pagesize); } }
/// <summary> /// 获得单页内容的单条记录实体 /// </summary> /// <param name="_id"></param> public JumboTCMS.Entity.Normal_SpecialContent GetEntity(string _id) { JumboTCMS.Entity.Normal_SpecialContent specialcontent = new JumboTCMS.Entity.Normal_SpecialContent(); using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_normal_specialcontent] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { specialcontent.Id = dt.Rows[0]["Id"].ToString(); specialcontent.Title = dt.Rows[0]["Title"].ToString(); specialcontent.ChannelId = Validator.StrToInt(dt.Rows[0]["ChannelId"].ToString(), 0); specialcontent.ContentId = Validator.StrToInt(dt.Rows[0]["ContentId"].ToString(), 0); specialcontent.sId = Validator.StrToInt(dt.Rows[0]["sId"].ToString(), 0); } return specialcontent; } }
/// <summary> /// 替换频道栏目循环标签(不支持跨频道) /// </summary> /// <param name="_pagestr"></param> private void replaceTag_ChannelClassLoop(ref string _pagestr) { using (DbOperHandler _doh = new Common().Doh()) { string RegexString = "<jcms:classloop (?<tagcontent>.*?)>(?<tempstr>.*?)</jcms:classloop>"; string[] _tagcontent = JumboTCMS.Utils.Strings.GetRegValue(_pagestr, RegexString, "tagcontent", false); string[] _tempstr = JumboTCMS.Utils.Strings.GetRegValue(_pagestr, RegexString, "tempstr", false); if (_tagcontent.Length > 0)//标签存在 { string _loopbody = string.Empty; string _replacestr = string.Empty; string _viewstr = string.Empty; string _tagrepeatnum, _tagselectids, _tagdepth, _tagparentid, _tagwherestr, _tagorderfield, _tagordertype, _hascontent = string.Empty; for (int i = 0; i < _tagcontent.Length; i++) { _loopbody = "<jcms:classloop " + _tagcontent[i] + ">" + _tempstr[i] + "</jcms:classloop>"; string _tagchannelid = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "channelid"); _tagrepeatnum = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "repeatnum"); _tagselectids = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "selectids"); _tagdepth = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "depth"); _tagparentid = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "parentid"); _tagwherestr = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "wherestr"); _tagorderfield = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "orderfield"); if (_tagorderfield == "") _tagorderfield = "code"; _tagordertype = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "ordertype"); if (_tagordertype == "") _tagordertype = "asc"; if (_tagrepeatnum == "") _tagrepeatnum = "0"; _hascontent = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "hascontent"); if (_hascontent == "") _hascontent = "0"; if (_tagdepth == "") _tagdepth = "0"; string pStr = " [Id],[Title],[Info],[TopicNum],[Code],[ChannelId] FROM [jcms_normal_class] WHERE [IsOut]=0 AND [ChannelId]=" + _tagchannelid; string oStr = " ORDER BY code asc"; if (_tagorderfield.ToLower() != "code") oStr = " ORDER BY " + _tagorderfield + " " + _tagordertype + ",code asc"; else oStr = " ORDER BY " + _tagorderfield + " " + _tagordertype; _doh.Reset(); if (_tagdepth != "-1" && _tagdepth != "0") pStr += " AND Len(Code)=" + (Str2Int(_tagdepth, 0) * 4); if (_tagrepeatnum != "0") pStr = " top " + _tagrepeatnum + pStr; if (_tagparentid != "" && _tagparentid != "0") pStr += " AND [ParentId]=" + _tagparentid; if (_hascontent == "1") pStr += " AND [TopicNum]>0"; if (_tagwherestr != "") pStr += " AND " + _tagwherestr.Replace("小于", "<").Replace("大于", ">").Replace("不等于", "<>"); if (_tagselectids != "") pStr += " AND [id] IN (" + _tagselectids.Replace("|", ",") + ")"; _doh.SqlCmd = "select" + pStr + oStr; DataTable _dt = _doh.GetDataTable(); StringBuilder sb = new StringBuilder(); for (int j = 0; j < _dt.Rows.Count; j++) { if (_tagdepth == "-1") { _doh.Reset(); _doh.ConditionExpress = "[IsOut]=0 AND [ChannelId]=" + _tagchannelid + " AND [ParentId]=" + _dt.Rows[j]["Id"].ToString(); int countNum = _doh.Count("jcms_normal_class"); if (countNum > 1)//表示非末级栏目,直接跳过 continue; } _viewstr = _tempstr[i]; _viewstr = _viewstr.Replace("{$ClassNO}", (j + 1).ToString()); executeTag_Class(ref _viewstr, _dt.Rows[j]["Id"].ToString()); sb.Append(_viewstr); } _pagestr = _pagestr.Replace(_loopbody, sb.ToString()); _dt.Clear(); _dt.Dispose(); } } } }
private string p__getNeightor(bool isHtml, string channelType, string channelId, string classId, string contentId) { using (DbOperHandler _doh = new Common().Doh()) { StringBuilder sb = new StringBuilder(); _doh.Reset(); _doh.SqlCmd = "SELECT TOP 1 [Id],[Title],[FirstPage] FROM [jcms_module_" + channelType + "] WHERE [ChannelId] = " + channelId + " And [IsPass]=1 AND [Id]<" + contentId + " order By [Id] DESC"; DataTable dtContent = _doh.GetDataTable(); if (dtContent.Rows.Count > 0) sb.Append("<div class=\"l\"><span title=\"往前\">«</span> <a title=\"" + dtContent.Rows[0]["Title"].ToString() + "\" href=\"" + dtContent.Rows[0]["FirstPage"].ToString() + "\">" + dtContent.Rows[0]["Title"].ToString() + "</a></div>\r\n"); else sb.Append("<div class=\"l\"><span title=\"返回列表\">«</span> <a title=\"返回列表\" href=\"" + Go2Class(1, isHtml, channelId, classId, false) + "\">返回列表</a></div>\r\n"); _doh.Reset(); _doh.SqlCmd = "SELECT TOP 1 [Id],[Title],[FirstPage] FROM [jcms_module_" + channelType + "] WHERE [ChannelId] = " + channelId + " AND [IsPass]=1 AND [Id]>" + contentId + " order By [Id] ASC"; dtContent = _doh.GetDataTable(); if (dtContent.Rows.Count > 0) sb.Append("<div class=\"r\"><span title=\"往后\">»</span> <a title=\"" + dtContent.Rows[0]["Title"].ToString() + "\" href=\"" + dtContent.Rows[0]["FirstPage"].ToString() + "\">" + dtContent.Rows[0]["Title"].ToString() + "</a></div>\r\n"); else sb.Append("<div class=\"r\"><span title=\"返回列表\">»</span> <a title=\"返回列表\" href=\"" + Go2Class(1, isHtml, channelId, classId, false) + "\">返回列表</a></div>\r\n"); dtContent.Clear(); dtContent.Dispose(); return sb.ToString(); } }
/// <summary> /// 提取列表供列表标签使用 /// </summary> /// <param name="Parameter"></param> /// <returns></returns> private string getContentList_RL(string _tagcontent, string _tempstr) { using (DbOperHandler _doh = new Common().Doh()) { string _viewstr = string.Empty; string _tagrepeatnum = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "repeatnum"); if (_tagrepeatnum == "") _tagrepeatnum = "10"; string _tagchannelid = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "channelid"); if (_tagchannelid == "") _tagchannelid = "0"; string _tagchanneltype = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "channeltype"); if (_tagchanneltype == "") _tagchanneltype = "article"; string _tagclassid = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "classid"); if (_tagclassid == "") _tagclassid = "0"; string _tagfields = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "fields"); string _tagorderfield = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "orderfield"); if (_tagorderfield == "") _tagorderfield = "adddate"; string _tagordertype = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "ordertype"); if (_tagordertype == "") _tagordertype = "desc"; string _tagistop = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "istop"); if (_tagistop == "") _tagistop = "0"; string _tagisfocus = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "isfocus"); if (_tagisfocus == "") _tagisfocus = "0"; string _tagisimg = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "isimg"); if (_tagisimg == "") _tagisimg = "0"; string _tagtimerange = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "timerange"); string _tagexceptids = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "exceptids"); string _tagwherestr = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "wherestr"); string _tagislike = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "islike"); string _tagkeywords = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent, "keywords"); string _ccType = string.Empty; if (_tagchannelid != "0") { _doh.Reset(); _doh.SqlCmd = "SELECT [Id],[Type] FROM [jcms_normal_channel] WHERE [Id]=" + _tagchannelid + " AND [Enabled]=1"; DataTable dtChannel = _doh.GetDataTable(); if (dtChannel.Rows.Count > 0) { _ccType = dtChannel.Rows[0]["Type"].ToString(); } else { return " 频道参数错误"; } dtChannel.Clear(); dtChannel.Dispose(); } else { _ccType = _tagchanneltype; } JumboTCMS.DAL.Normal_ChannelDAL dal = new JumboTCMS.DAL.Normal_ChannelDAL(); dal.ExecuteTags(ref _tempstr, _tagchannelid); if (_tagclassid != "0") executeTag_Class(ref _tempstr, _tagclassid); string sql = "SELECT TOP " + _tagrepeatnum + " [Id],[ChannelId],(select ishtml from [jcms_normal_channel] where id=[jcms_module_" + _ccType + "].channelid) as channelishtml,[ClassId],[FirstPage]," + _tagfields + " FROM [jcms_module_" + _ccType + "] WHERE ([IsPass]=1"; if (_tagchannelid != "0") { string isChannel = " AND [ChannelId]=" + _tagchannelid; sql += isChannel; if (_tagclassid != "0") sql += " And [ClassId] in (SELECT ID FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Code] Like (SELECT Code FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Id]=" + _tagclassid + isChannel + ")+'%')" + isChannel; } else { if (_tagclassid != "0") sql += " And [ClassId] in (SELECT ID FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Code] Like (SELECT Code FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Id]=" + _tagclassid + ")+'%')"; else sql += " And [ChannelId] in (SELECT ID FROM [jcms_normal_channel] WHERE [Type]='" + _ccType + "' AND [Enabled]=1)"; } if (_tagistop == "1") sql += " And [IsTop]=1"; else if (_tagistop == "-1") sql += " And [IsTop]=0"; if (_tagisfocus == "1") sql += " And [IsFocus]=1"; if (DBType == "0") { switch (_tagtimerange) { case "1d": sql += " AND datediff('d',AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1w": sql += " AND datediff('ww',AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1m": sql += " AND datediff('m',AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1y": sql += " AND AddDate>=#" + (DateTime.Now.Year + "-1-1") + "#"; break; } } else { switch (_tagtimerange) { case "1d": sql += " AND datediff(d,AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1w": sql += " AND datediff(ww,AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1m": sql += " AND datediff(m,AddDate,'" + DateTime.Now.ToShortDateString() + "')=0"; break; case "1y": sql += " AND AddDate>='" + (DateTime.Now.Year + "-1-1") + "'"; break; } } if (_tagisimg == "1") sql += " And [IsImg]=1 And (right(Img,4)='.jpg' Or right(Img,4)='.gif')"; if (_tagwherestr != "") sql += " AND " + _tagwherestr.Replace("小于", "<").Replace("大于", ">").Replace("不等于", "<>"); if (_tagexceptids != "") sql += " AND id not in(" + _tagexceptids + ")"; if (_tagislike == "1") { if (_tagkeywords == "") _tagkeywords = "将博"; _tagkeywords = _tagkeywords.Replace(",", " ").Replace("、", " "); string[] key = _tagkeywords.Split(new string[] { " " }, StringSplitOptions.None); string _joinstr = " AND ("; for (int i = 0; i < key.Length; i++) { if (key[i].Length > 1) { if (i == 0) _joinstr += "[Tags] LIKE '%" + key[i].Trim() + "%'"; else _joinstr += " OR [Tags] LIKE '%" + key[i].Trim() + "%'"; } } _joinstr += ")"; sql += _joinstr; } if (_tagorderfield.ToLower() != "rnd") { if (_tagorderfield.ToLower() != "adddate") sql += ") ORDER BY " + _tagorderfield + " " + _tagordertype + ",adddate Desc,id Desc"; else sql += ") ORDER BY " + _tagorderfield + " " + _tagordertype + ",id Desc"; ; } else { sql += ")" + ORDER_BY_RND(); } _doh.Reset(); _doh.SqlCmd = sql; DataTable dt = _doh.GetDataTable(); string ReplaceStr = operateContentTag(_ccType, dt, _tempstr); ReplaceStr = ReplaceStr.Replace("{$ContentCount}", dt.Rows.Count.ToString()); dt.Clear(); dt.Dispose(); return ReplaceStr; } }
/// <summary> /// 内容加入专题 /// </summary> /// <param name="_specialid">专题ID</param> /// <param name="_channelid">频道ID</param> /// <param name="_channeltype">频道类型,也就是内容的模型</param> /// <param name="_contentids">内容ID,以,隔开</param> public bool Move2Special(int _specialid, string _channelid, string _channeltype, string _contentids) { using (DbOperHandler _doh = new Common().Doh()) { string _contentid = string.Empty; string _title = string.Empty; _doh.Reset(); _doh.SqlCmd = "SELECT [Id],[Title] FROM [jcms_module_" + _channeltype + "] WHERE [ChannelId]=" + _channelid + " AND [Id] In (" + _contentids + ")"; DataTable dt = _doh.GetDataTable(); for (int i = 0; i < dt.Rows.Count; i++) { _contentid = dt.Rows[i]["Id"].ToString(); _title = dt.Rows[i]["Title"].ToString(); _doh.Reset(); _doh.ConditionExpress = "sid=@sid and contentid=@contentid and channelid=@channelid"; _doh.AddConditionParameter("@sid", _specialid); _doh.AddConditionParameter("@contentid", _contentid); _doh.AddConditionParameter("@channelid", _channelid); if (!_doh.Exist("jcms_normal_specialcontent")) { _doh.Reset(); _doh.AddFieldItem("Title", _title); _doh.AddFieldItem("sId", _specialid); _doh.AddFieldItem("ChannelId", _channelid); _doh.AddFieldItem("ContentId", _contentid); _doh.Insert("jcms_normal_specialcontent"); } } } return true; }
/// <summary> /// 获得标签的单条记录实体 /// </summary> /// <param name="_id"></param> public JumboTCMS.Entity.Normal_Tag GetEntity(string _id) { JumboTCMS.Entity.Normal_Tag tag = new JumboTCMS.Entity.Normal_Tag(); using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_normal_tag] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { tag.Id = dt.Rows[0]["Id"].ToString(); tag.Title = dt.Rows[0]["Title"].ToString(); tag.ClickTimes = Validator.StrToInt(dt.Rows[0]["ClickTimes"].ToString(), 0); tag.ChannelId = Validator.StrToInt(dt.Rows[0]["ChannelId"].ToString(), 0); } return tag; } }
/// <summary> /// 解析栏目标签 /// </summary> /// <param name="_pagestr"></param> /// <param name="_classid"></param> /// <returns></returns> private void executeTag_Class(ref string _pagestr, string _classid) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT [Id],[Title],[Info],[Img],[TopicNum],[Code],len(code) as len,[ChannelId],[ParentId] FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Id]=" + _classid; DataTable _dt = _doh.GetDataTable(); if (_dt.Rows.Count > 0) { string _channelid = _dt.Rows[0]["ChannelId"].ToString(); string _parentid = _dt.Rows[0]["ParentId"].ToString(); if (_channelid == this.MainChannel.Id)//说明是当前 this.ThisChannel = this.MainChannel; else this.ThisChannel = new JumboTCMS.DAL.Normal_ChannelDAL().GetEntity(_channelid); _pagestr = _pagestr.Replace("{$ClassId}", _dt.Rows[0]["Id"].ToString()); _pagestr = _pagestr.Replace("{$ClassName}", _dt.Rows[0]["Title"].ToString()); _pagestr = _pagestr.Replace("{$ClassInfo}", _dt.Rows[0]["Info"].ToString()); _pagestr = _pagestr.Replace("{$ClassImg}", _dt.Rows[0]["Img"].ToString()); _pagestr = _pagestr.Replace("{$ClassTopicNum}", _dt.Rows[0]["TopicNum"].ToString()); _pagestr = _pagestr.Replace("{$ClassLink}", Go2Class(1, this.ThisChannel.IsHtml, _channelid, _classid, false)); _pagestr = _pagestr.Replace("{$ClassCode}", _dt.Rows[0]["Code"].ToString()); _pagestr = _pagestr.Replace("{$ClassDepth}", (Str2Int(_dt.Rows[0]["Len"].ToString()) / 4).ToString()); _pagestr = _pagestr.Replace("{$ClassParentId}", _dt.Rows[0]["ParentId"].ToString()); if (_dt.Rows[0]["ParentId"].ToString() != "0") { JumboTCMS.Entity.Normal_Class _parentclass = new JumboTCMS.DAL.Normal_ClassDAL().GetEntity(_parentid); _pagestr = _pagestr.Replace("{$ClassParentName}", _parentclass.Title); _pagestr = _pagestr.Replace("{$ClassParentLink}", Go2Class(1, this.ThisChannel.IsHtml, _channelid, _parentid, false)); _pagestr = _pagestr.Replace("{$ClassParentCode}", _parentclass.Code); } else { _pagestr = _pagestr.Replace("{$ClassParentName}", this.ThisChannel.Title); _pagestr = _pagestr.Replace("{$ClassParentLink}", Go2Channel(this.ThisChannel.IsHtml, _channelid, false)); _pagestr = _pagestr.Replace("{$ClassParentCode}", ""); } } _dt.Clear(); _dt.Dispose(); } }
/// <summary> /// 替换循环频道标签(将频道信息赋值给循环体)(解析次序:5) /// </summary> /// <param name="_pagestr"></param> private void replaceTag_ChannelLoop(ref string _pagestr) { using (DbOperHandler _doh = new Common().Doh()) { string RegexString = "<jcms:channelloop (?<tagcontent>.*?)>(?<tempstr>.*?)</jcms:channelloop>"; string[] _tagcontent = JumboTCMS.Utils.Strings.GetRegValue(_pagestr, RegexString, "tagcontent", false); string[] _tempstr = JumboTCMS.Utils.Strings.GetRegValue(_pagestr, RegexString, "tempstr", false); if (_tagcontent.Length > 0)//标签存在 { string _loopbody = string.Empty; string _replacestr = string.Empty; string _viewstr = string.Empty; string _tagrepeatnum, _tagisnav, _tagselectids, _tagorderfield, _tagordertype, _tagwherestr = string.Empty; for (int i = 0; i < _tagcontent.Length; i++) { _loopbody = "<jcms:channelloop " + _tagcontent[i] + ">" + _tempstr[i] + "</jcms:channelloop>"; _tagisnav = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "isnav"); if (_tagisnav == "") _tagisnav = "0"; _tagrepeatnum = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "repeatnum"); _tagselectids = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "selectids"); _tagorderfield = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "orderfield"); if (_tagorderfield == "") _tagorderfield = "pid"; _tagordertype = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "ordertype"); if (_tagordertype == "") _tagordertype = "asc"; _tagwherestr = JumboTCMS.Utils.Strings.AttributeValue(_tagcontent[i], "wherestr"); _doh.Reset(); string _sql = "select top " + _tagrepeatnum + " * FROM [jcms_normal_channel] WHERE [Enabled]=1"; if (_tagisnav == "1") _sql += " AND [IsNav]=1"; if (_tagselectids != "") _sql += " AND id in (" + _tagselectids.Replace("|", ",") + ")"; if (_tagwherestr != "") _sql += " and " + _tagwherestr; _sql += " ORDER BY " + _tagorderfield + " " + _tagordertype; _doh.SqlCmd = _sql; DataTable _dt = _doh.GetDataTable(); StringBuilder sb = new StringBuilder(); for (int j = 0; j < _dt.Rows.Count; j++) { _viewstr = _tempstr[i]; DataRow dr = _dt.Rows[j]; JumboTCMS.Entity.Normal_Channel _Channel = new JumboTCMS.DAL.Normal_ChannelDAL().GetEntity(dr); new JumboTCMS.DAL.Normal_ChannelDAL().ExecuteTags(ref _viewstr, _Channel); //_viewstr = _viewstr.Replace("{$ChannelId}", _dt.Rows[j]["Id"].ToString()); //_viewstr = _viewstr.Replace("{$ChannelName}", _dt.Rows[j]["Title"].ToString()); sb.Append(_viewstr); } _pagestr = _pagestr.Replace(_loopbody, sb.ToString()); _dt.Clear(); _dt.Dispose(); } } } }
/// <summary> /// 解析栏目标签 /// </summary> /// <param name="_pagestr"></param> /// <param name="_classid"></param> /// <returns></returns> private void executeTag_Class2(ref string _pagestr, string _classid) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT [Id],[Title],[Info],[Img],[TopicNum],[Code],len(code) as len,[ChannelId],[ParentId] FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Id]=" + _classid; DataTable _dt = _doh.GetDataTable(); if (_dt.Rows.Count > 0) { _pagestr = _pagestr.Replace("{$Class2Id}", _dt.Rows[0]["Id"].ToString()); _pagestr = _pagestr.Replace("{$Class2Name}", _dt.Rows[0]["Title"].ToString()); _pagestr = _pagestr.Replace("{$Class2Info}", _dt.Rows[0]["Info"].ToString()); _pagestr = _pagestr.Replace("{$Class2Img}", _dt.Rows[0]["Img"].ToString()); _pagestr = _pagestr.Replace("{$Class2TopicNum}", _dt.Rows[0]["TopicNum"].ToString()); _pagestr = _pagestr.Replace("{$Class2Link}", Go2Class(1, this.MainChannel.IsHtml, _dt.Rows[0]["ChannelId"].ToString(), _dt.Rows[0]["Id"].ToString(), false)); _pagestr = _pagestr.Replace("{$Class2Code}", _dt.Rows[0]["Code"].ToString()); _pagestr = _pagestr.Replace("{$Class2Depth}", (Str2Int(_dt.Rows[0]["Len"].ToString()) / 4).ToString()); } _dt.Clear(); _dt.Dispose(); } }
/// <summary> /// 获得单页内容的单条记录实体 /// </summary> /// <param name="_id"></param> public JumboTCMS.Entity.Normal_Page GetEntity(string _id) { JumboTCMS.Entity.Normal_Page page = new JumboTCMS.Entity.Normal_Page(); using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_normal_page] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { page.Id = dt.Rows[0]["Id"].ToString(); page.Title = dt.Rows[0]["Title"].ToString(); page.Source = dt.Rows[0]["Source"].ToString(); page.OutUrl = dt.Rows[0]["OutUrl"].ToString(); } return page; } }
/// <summary> /// 得到所有好友列表 /// </summary> /// <param name="_userid"></param> /// <returns></returns> public DataTable GetTable(string _userid) { DataTable dt = null; using (DbOperHandler _doh = new Common().Doh()) { string sqlStr = ""; sqlStr = JumboTCMS.Utils.SqlHelp.GetSql("A.FriendId as FriendUserId,B.UserName as FriendUserName,B.NickName as FriendNickName,B.Sex as FriendSex,B.Birthday as FriendBirthday,B.ProvinceCity as FriendProvinceCity,B.HomePage as FriendHomePage,B.Signature as FriendSignature", "jcms_normal_user_friends", "jcms_normal_user", "Id", 200, 1, "desc", "A.FriendId=B.Id", "A.UserId=" + _userid, "UserId=" + _userid); _doh.Reset(); _doh.SqlCmd = sqlStr; dt = _doh.GetDataTable(); } return dt; }
/// <summary> /// 解析单条内容标签 /// </summary> /// <param name="_pagestr"></param> /// <param name="_contentid"></param> /// <returns></returns> private void executeTag_Content(ref string _pagestr, string _contentid) { using (DbOperHandler _doh = new Common().Doh()) { string _randomstr = "1" + RandomStr(4); string _tempstr = string.Empty; _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_module_" + this.MainChannel.Type + "] WHERE [Id]=" + _contentid; DataTable dtContent = _doh.GetDataTable(); if (dtContent.Rows.Count > 0) { _tempstr = p__getNeightor(this.MainChannel.IsHtml, this.MainChannel.Type, dtContent.Rows[0]["ChannelId"].ToString(), dtContent.Rows[0]["ClassId"].ToString(), _contentid); _pagestr = _pagestr.Replace("{$_getNeightor()}", _tempstr); for (int i = 0; i < dtContent.Columns.Count; i++) { if (dtContent.Rows[0]["IsImg"].ToString() == "0" || dtContent.Rows[0]["Img"].ToString().Length == 0) _pagestr = _pagestr.Replace("{$_img}", site.Dir + "style/common/nophoto.jpg"); else _pagestr = _pagestr.Replace("{$_img}", dtContent.Rows[0]["Img"].ToString()); switch (dtContent.Columns[i].ColumnName.ToLower()) { case "adddate": _pagestr = _pagestr.Replace("{$_adddate}", Convert.ToDateTime(dtContent.Rows[0]["AddDate"]).ToString("yyyy-MM-dd")); break; case "viewnum": _pagestr = _pagestr.Replace("{$_viewnum}", "<script src=\"" + site.Dir + "plus/viewcount.aspx?ccid=" + this.MainChannel.Id + "&cType=" + this.MainChannel.Type + "&id=" + _contentid + "&addit=1\"></script>"); break; case "downnum": _pagestr = _pagestr.Replace("{$_downnum}", "<script src=\"" + site.Dir + "plus/downcount.aspx?ccid=" + this.MainChannel.Id + "&cType=" + this.MainChannel.Type + "&id=" + _contentid + "\"></script>"); break; default: _pagestr = _pagestr.Replace("{$_" + dtContent.Columns[i].ColumnName.ToLower() + "}", dtContent.Rows[0][i].ToString()); break; } } } dtContent.Clear(); dtContent.Dispose(); } }
/// <summary> /// 得到列表JSON数据 /// </summary> /// <param name="_thispage">当前页码</param> /// <param name="_pagesize">每页记录条数</param> /// <param name="_wherestr">搜索条件</param> /// <param name="_jsonstr">返回值</param> public void GetListJSON(int _thispage, int _pagesize, string _wherestr, ref string _jsonstr) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.ConditionExpress = _wherestr; string sqlStr = ""; int _countnum = _doh.Count("jcms_normal_page"); sqlStr = JumboTCMS.Utils.SqlHelp.GetSql("*", "jcms_normal_page", "Id", _pagesize, _thispage, "desc", _wherestr); _doh.Reset(); _doh.SqlCmd = sqlStr; DataTable dt = _doh.GetDataTable(); _jsonstr = "{result :\"1\"," + "returnval :\"操作成功\"," + "pagerbar :\"" + JumboTCMS.Utils.HtmlPager.GetPageBar(3, "js", 2, _countnum, _pagesize, _thispage, "javascript:ajaxList(<#page#>);") + "\"," + JumboTCMS.Utils.dtHelp.DT2JSON(dt) + "}"; dt.Clear(); dt.Dispose(); } }
private void getClassSinglePageListBody(Normal_Class _class, ref System.Collections.ArrayList ContentList, int _pagecount, int _page) { using (DbOperHandler _doh = new Common().Doh()) { string whereStr = string.Empty; string _pagestr = ContentList[0].ToString(); whereStr = " [ClassId] in (SELECT ID FROM [jcms_normal_class] WHERE [IsOut]=0 AND [Code] LIKE '" + _class.Code + "%')"; whereStr += " AND [IsPass]=1 AND [ChannelId]=" + this.MainChannel.Id; int _pagesize = (_class.PageSize < 1) ? 20 : _class.PageSize; System.Collections.ArrayList TagArray = JumboTCMS.Utils.Strings.GetHtmls(_pagestr, "{$jcms:class(", "{$/jcms:class}", false, false); if (TagArray.Count > 0)//标签存在 { string LoopBody = string.Empty; string TempStr = string.Empty; string FiledsStr = string.Empty; int StartTag, EndTag; StartTag = TagArray[0].ToString().IndexOf(")}", 0); FiledsStr = TagArray[0].ToString().Substring(0, StartTag).ToLower(); if (!("," + FiledsStr + ",").Contains(",adddate,")) FiledsStr += ",adddate"; EndTag = TagArray[0].ToString().Length; LoopBody = "{$jcms:class(" + TagArray[0].ToString() + "{$/jcms:class}"; TempStr = TagArray[0].ToString().Substring(StartTag + 2, EndTag - StartTag - 2).Replace("<#foreach content>", "<#foreach collection=\"${contents}\" var=\"field\" index=\"i\">");//需要循环的部分 ContentList.Add(LoopBody); if (_pagecount > 0) { if (_page == 0) { for (int i = 1; i < _pagecount + 1; i++) { NameValueCollection orders = new NameValueCollection(); orders.Add("AddDate", "desc"); orders.Add("Id", "desc"); string wStr = JumboTCMS.Utils.SqlHelp.GetMultiOrderPagerSQL("Id,ChannelId,ClassId,[IsPass],[FirstPage]," + FiledsStr, "jcms_module_" + this.MainChannel.Type, _pagesize, i, orders, whereStr); _doh.Reset(); _doh.SqlCmd = wStr; DataTable dtContent = _doh.GetDataTable(); ContentList.Add(operateContentTag(this.MainChannel.Type, dtContent, TempStr)); dtContent.Clear(); dtContent.Dispose(); } } else { _page = _page == 0 ? 1 : _page; NameValueCollection orders = new NameValueCollection(); orders.Add("AddDate", "desc"); orders.Add("Id", "desc"); string wStr = JumboTCMS.Utils.SqlHelp.GetMultiOrderPagerSQL("Id,ChannelId,ClassId,[IsPass],[FirstPage]," + FiledsStr, "jcms_module_" + this.MainChannel.Type, _pagesize, _page, orders, whereStr); _doh.Reset(); _doh.SqlCmd = wStr; DataTable dtContent = _doh.GetDataTable(); ContentList.Add(operateContentTag(this.MainChannel.Type, dtContent, TempStr)); dtContent.Clear(); dtContent.Dispose(); } } else ContentList.Add(" "); } } }