Esempio n. 1
0
        /// <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 "&nbsp;频道参数错误";
                    }
                    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;

            }
        }