Ejemplo n.º 1
0
        private string GetSearchWhere(int?cType, int classId = 0, int updateStatus = 0, int feeType = 0, string keyword = "", Constants.Novel.ShowLocation showLocation = Constants.Novel.ShowLocation.booklist)
        {
            StringBuilder where = new StringBuilder(" and n.Status = 1 ");

            where.Append(EnvSettings.Novel.Filter(showLocation, prefix: "n."));

            if (cType.HasValue)
            {
                where.Append(" and isnull(n.ContentType,0) =@cType ");
            }

            #region 过滤CP

            where.Append(EnvSettings.Novel.Filter(SiteSection.Filter.BookCPID, "n."));

            #endregion 过滤CP

            #region 构建搜索条件

            if (classId > 0)
            {
                where.Append(" and n.ClassId = @classId");
            }
            if (updateStatus > 0)
            {
                where.Append(" and n.UpdateStatus = @updateStatus");
            }
            if (feeType > 0)
            {
                if (feeType == (int)Constants.Novel.FeeTypeFilter.free)
                {
                    where.Append(" and n.FeeType = 0 ");
                }
                else
                {
                    where.Append(" and n.FeeType <> 0 ");
                }
            }
            if (!keyword.IsClearBlankNullOrEmpty(out keyword))
            {
                where.Append(" and (charindex(@keyword,n.Title)>0 or charindex(@keyword,n.Author)>0 or charindex(@keyword,n.Tags)>0 ");

                if (keyword.ToInt() > 0)
                {
                    where.Append(" or n.Id =@keyword ");
                }

                where.Append(" ) ");
            }

            #endregion 构建搜索条件

            return(where.ToString());
        }
Ejemplo n.º 2
0
 public static string Filter(Constants.Novel.ShowLocation showLocation, Constants.Novel.ShowSourceType showSourceType = Constants.Novel.ShowSourceType.wap, string prefix = "")
 {
     return(string.Format(" and (({0}ShowSourceType & {1}) = {1} and ({0}ShowLocation & {2}) = {2}) ", prefix, (int)showSourceType, (int)showLocation));
 }