📄 threadrequest.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetFocus.Web.Core;
namespace NetFocus.Web.Applications.Forum
{
public class ThreadRequest : EntityRequest
{
public int SectionId = 0;
public int AuthorId = 0;
public int ReplierId = 0;
public string Tags = string.Empty;
public string Subject = string.Empty;
public int ThreadType = 0;
public bool HasSectionId
{
get
{
return SectionId > 0;
}
}
public bool HasAuthorId
{
get
{
return AuthorId > 0;
}
}
public bool HasReplierId
{
get
{
return ReplierId > 0;
}
}
public bool HasTags
{
get
{
return !string.IsNullOrEmpty(Tags);
}
}
public override string GetPopulateSql()
{
StringBuilder sb = new StringBuilder();
if (!HasReplierId)
{
sb.AppendFormat("Select top {0} {2} From tb_Entities E where E.EntityType = {1}", (PageIndex + 1) * PageSize, (int)NetFocus.Web.Applications.Forum.EntityType.ForumThread, GetInternalSelectSql());
}
else
{
sb.AppendFormat("Select top {0} {2} From tb_Entities E where E.EntityType = {1} and E.EntityId in (Select E.ParentId From tb_Entities E where E.EntityType = {3} and E.IntField3 = {4})", (PageIndex + 1) * PageSize, (int)NetFocus.Web.Applications.Forum.EntityType.ForumThread, GetInternalSelectSql(), (int)NetFocus.Web.Applications.Forum.EntityType.Post, ReplierId);
}
//对于模糊查询,目前暂时采用Like,以后采用全文检索。 TODO
if (HasTags)
sb.AppendFormat(" and E.VarChar2 Like '%{0}%'", Tags.Replace("'", "''"));
if (HasSectionId)
sb.AppendFormat(" and E.IntField1 = {0}", SectionId);
if (HasAuthorId)
sb.AppendFormat(" and E.IntField5 = {0}", AuthorId);
if (ThreadType == 1 || ThreadType == 3)
sb.AppendFormat(" and E.IntField4 = {0}", ThreadType);
sb.Append(base.GetOrderSql());
return sb.ToString();
}
public override string GetFullPopulateSql()
{
StringBuilder sb = new StringBuilder();
if (!HasReplierId)
{
sb.AppendFormat("Select E.EntityId From tb_Entities E where E.EntityType = {0}", (int)NetFocus.Web.Applications.Forum.EntityType.ForumThread);
}
else
{
sb.AppendFormat("Select E.EntityId From tb_Entities E where E.EntityType = {0} and E.EntityID in (Select E.ParentID From tb_Entities E where E.EntityType = {1} and E.IntField3 = {2})", (int)NetFocus.Web.Applications.Forum.EntityType.ForumThread, (int)NetFocus.Web.Applications.Forum.EntityType.Post, ReplierId);
}
//对于模糊查询,目前暂时采用Like,以后采用全文检索。 TODO
if (HasTags)
sb.AppendFormat(" and E.VarChar2 Like '%{0}%'", Tags.Replace("'", "''"));
if (HasSectionId)
sb.AppendFormat(" and E.IntField1 = {0}", SectionId);
if (HasAuthorId)
sb.AppendFormat(" and E.IntField5 = {0}", AuthorId);
if (ThreadType == 1 || ThreadType == 3)
sb.AppendFormat(" and E.IntField4 = {0}", ThreadType);
return sb.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -