📄 threadlist.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 ThreadList : UserControl
{
protected Repeater list;
protected Pager pager;
protected CurrentPage currentPage;
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack && !AjaxManager.IsCallBack)
{
BindData();
}
AjaxManager.Register(this, "AjaxMethod");
}
private void BindData()
{
if (list == null)
{
return;
}
WebContext context = WebContext.Current;
EntityList threads = BusinessManager.GetThreadList(RequestBuilder.BuildThreadListRequest(context.SectionId, pager.PageIndex, pager.PageSize));
list.DataSource = threads;
list.DataBind();
if (pager != null && currentPage != null)
{
pager.TotalPages = pager.CalculateTotalPages(threads.TotalCount);
currentPage.TotalRecords = threads.TotalCount;
currentPage.TotalPages = pager.TotalPages;
currentPage.PageIndex = pager.PageIndex;
}
}
#region Ajax Method
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeleteThread(int threadId)
{
Thread thread = BusinessManager.GetThread(RequestBuilder.BuildThreadRequest(threadId)) as Thread;
BusinessManager.DeleteThread(threadId);
//更新版块回复总数
Section section = BusinessManager.GetSection(thread.SectionId);
if (section != null)
{
section.TotalThreads--;
BusinessManager.UpdateSection(section);
}
}
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeleteThreads(string articleIds)
{
if (string.IsNullOrEmpty(articleIds))
{
return;
}
string[] articleIdArray = articleIds.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
int articleId = 0;
foreach (string stringArticleId in articleIdArray)
{
try
{
articleId = Int32.Parse(stringArticleId);
}
catch
{
continue;
}
if (articleId > 0)
{
DeleteThread(articleId);
}
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -