container.cs
来自「基于Asp.net、MS sql sever 2000、C# 论坛系统源码」· CS 代码 · 共 164 行
CS
164 行
using System;
using System.Web;
using System.Web.UI;
using Stella.Web.ProcessFlow;
using Stella.Model;
using Stella.BusinessLogic;
using Stella.Utility;
namespace Stella.Web.Pages
{
/// <summary>
/// 一切页的容器页
/// </summary>
public class Container : System.Web.UI.Page
{
#region IsRefresh
private bool refreshState;
private bool isRefresh;
protected bool IsRefresh
{
get{ return this.isRefresh; }
}
protected override void LoadViewState(object savedState)
{
object[] states=(object[])savedState;
base.LoadViewState(states[0]);
this.refreshState=(bool)states[1];
this.isRefresh=(this.refreshState==(bool)Context.Session["isRefresh"]);
}
protected override object SaveViewState()
{
Session["isRefresh"]=this.refreshState;
object[] states=new object[]{base.SaveViewState(),!this.refreshState};
return states;
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
if(Context.Session["isRefresh"]==null)
Context.Session["isRefresh"]=false;
}
#endregion
//只在调试时这样做
protected override void OnError(EventArgs e)
{
System.Exception ex=Server.GetLastError();
DebugHelper.CatchException(ex);
}
protected override void OnLoad(EventArgs e)
{
Control form=Page.Controls[1];
Control header=Page.LoadControl(@"../Controls/Header.ascx");
Control footer=Page.LoadControl(@"../Controls/Footer.ascx");
form.Controls.AddAt(0,header);
form.Controls.AddAt(form.Controls.Count,footer);
base.OnLoad (e);
}
/// <summary>
/// 指示是否是斑竹
/// </summary>
/// <param name="themeId">版块编号</param>
/// <returns></returns>
protected bool isManager(int themeId)
{
if(this.Request.IsAuthenticated)
{
if(this.User.IsInRole("manager"))
{
if(Session["user"]!=null)
{
Model.Member member=(Model.Member)Session["user"];
if(member.Manage==themeId)
return true;
}
}
}
return false;
}
/// <summary>
/// 指示用户是否登陆
/// </summary>
protected bool isLogin
{
get{return this.Request.IsAuthenticated;}
}
private CacheController cc;
/// <summary>
/// 缓存控制器
/// </summary>
protected CacheController cC
{
get
{
if(cc==null)
cc=new CacheController();
return cc;
}
}
private Stella.BusinessLogic.ArtLogic al;
/// <summary>
/// 帖子操作
/// </summary>
protected Stella.BusinessLogic.ArtLogic artLogic
{
get
{
if(al==null)
al=new ArtLogic(new TopicChangedEventHandler(topicChange));
return al;
}
}
private void topicChange(Art art)
{
HttpContext.Current.Cache.Remove(CType.Topics(art.ThemeId));
HttpContext.Current.Cache.Remove(CType.NewTopics);
}
private Stella.BusinessLogic.UserLogic ul;
/// <summary>
/// 用户操作
/// </summary>
protected Stella.BusinessLogic.UserLogic userLogic
{
get
{
if(ul==null)
ul=new UserLogic();
return ul;
}
}
/// <summary>
/// 版块资料统计
/// </summary>
protected ThemeInfoSum themeCounter
{
get{ return ThemeInfoSum.GetInstance(); }
}
/// <summary>
/// 论坛资料统计
/// </summary>
protected ForumInfoSum forumCounter
{
get{return ForumInfoSum.GetInstance();}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?