📄 global.asax
字号:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["OnLine"] = 0;
GetCopyRight();
//GetItems();
CheckPath();
GetLogo();
GetTopBanner();
GetSMTP();
}
/// <summary>
/// 获取数据库中SMTP设置
/// </summary>
void GetSMTP()
{
SystemEntity sys = new SystemEntity();
SystemBussiness sysBuss = new SystemBussiness();
sys.SystemKey = "SMTP";
bool isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["SMTP"]= sys.SystemValue;
}
else
{
Application["SMTP"] = "smtp.163.com";
}
sys.SystemKey = "SMTPAccount";
isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["SMTPAccount"] = sys.SystemValue;
}
else
{
Application["SMTPAccount"] = "wertpoiuy";
}
sys.SystemKey = "SMTPPassword";
isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["SMTPPassword"] = sys.SystemValue;
}
else
{
Application["SMTPPassword"] = "yuioptrew";
}
sys.SystemKey = "SendAS";
isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["SendAS"] = sys.SystemValue;
}
else
{
Application["SendAS"] = "wertpoiuy@163.com";
}
}
/// <summary>
/// 获取数据库中顶部广告的URL
/// </summary>
void GetTopBanner()
{
SystemEntity sys = new SystemEntity();
SystemBussiness sysBuss = new SystemBussiness();
sys.SystemKey = "TopBanner";
bool isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["TopBanner"] = sys.SystemValue;
}
else
{
Application["TopBanner"] = "";
}
sys.SystemKey = "TopBannerAlter";
isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["TopBannerAlter"] = sys.SystemValue;
}
else
{
Application["TopBannerAlter"] = "";
}
sys.SystemKey = "TopBannerNavigateURL";
isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["TopBannerNavigateURL"] = sys.SystemValue;
}
else
{
Application["TopBannerNavigateURL"] = "";
}
}
/// <summary>
/// 获取数据库中Logo的URL
/// </summary>
void GetLogo()
{
SystemEntity sys = new SystemEntity();
SystemBussiness sysBuss = new SystemBussiness();
sys.SystemKey = "Logo";
bool isExist = sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["Logo"] = sys.SystemValue;
}
else
{
Application["Logo"] = "";
}
}
/// <summary>
/// 检查数据库中应用程序的物理路径和实际是否符合
/// </summary>
void CheckPath()
{
SystemBussiness sysBuss = new SystemBussiness();
SystemEntity sys = new SystemEntity();
sys.SystemKey = "PhysicalPath";
sysBuss.GetValueByKey(ref sys);
string strPhsicalPath = sys.SystemValue;
if (strPhsicalPath == null)
{
sys.SystemValue = Server.MapPath("~/");
sysBuss.AddValueByKey(sys);
}
else
{
if (strPhsicalPath != Server.MapPath("~/"))
{
sys.SystemValue = Server.MapPath("~/");
sysBuss.AddValueByKey(sys);
}
}
Application["PhysicalPath"] = Server.MapPath("~/");
}
/// <summary>
/// 获取系统版权信息
/// </summary>
void GetCopyRight()
{
SystemEntity sys = new SystemEntity();
SystemBussiness sysBuss = new SystemBussiness();
sys.SystemKey = "BBSName";
bool isExist= sysBuss.GetValueByKey(ref sys);
if (isExist)
{
Application["BBSName"] = sys.SystemValue;
}
else
{
Application["BBSName"] = "BBS";
}
}
/// <summary>
/// 获取所有栏目
/// </summary>
//void GetItems()
//{
// eNewsItem eni = new eNewsItem();
// Application["Items"] = eni.GetAllItem();
//}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
Application["OnLine"] = (int)Application["OnLine"]+1;
}
void Session_End(object sender, EventArgs e)
{
Application["OnLine"] = (int)Application["OnLine"]-1;
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -