三层架构分为:表现层(UI)、业务逻辑层(BLL)、数据访问层(DAL)再加上实体类库(Model)
、、、
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;
using Entities;
using BasicItem;
using MenuUtility;
using System.IO;
namespace THMS
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!VerifySign())
{
Response.Redirect("License.aspx");
}
if (Request.Cookies["THMS_UserName"] != null && Request.Cookies["THMS_Password"] != null)
{
User_InfoBLL UserInfoBLL = new User_InfoBLL();
//读取出cookies中的值
string strUserName = Request.Cookies["THMS_UserName"].Value;
string strPassword = Request.Cookies["THMS_Password"].Value;
//获取用户信息
DataTable dt = UserInfoBLL.GetUserInfo(strUserName, strPassword);
if (dt != null && dt.Rows.Count > 0)
{
User_Info model = new User_Info();
model.User_ID = CommonHelper.GetLong(dt.Rows[0]["User_ID"].ToString(), 0);
model.User_No = dt.Rows[0]["User_No"].ToString();
model.User_Name = dt.Rows[0]["User_Name"].ToString();
model.Company_ID = CommonHelper.GetLong(dt.Rows[0]["Company_ID"].ToString(), 0);
model.User_Phone = dt.Rows[0]["User_Phone"].ToString();
model.User_Mail = dt.Rows[0]["User_Mail"].ToString();
model.User_Sex = dt.Rows[0]["User_Sex"].ToString();
LoginHandler.CurrentUser = model;
Log_InfoBLL.AddSysLog("用户" + model.User_No + "登陆成功", this.Title);
Response.Redirect("Page/MyDefault.aspx");
}
else
{
Response.Redirect("page/homeLogin.aspx");
}
}
else
{
Response.Redirect("page/homeLogin.aspx");
}
}
private bool VerifySign()
{
if (File.Exists(Server.MapPath("/code.lic")))
{
//读取文件asp.net
StreamReader sr = new StreamReader(Server.MapPath(@"\code.lic"), System.Text.Encoding.Default);
try
{
string input = sr.ReadToEnd();
sr.Close();
//解密时间
//string str=CommonHelper.DesEncrypt(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
string strDes = CommonHelper.DesDecrypt(input);
string[] ArDes = strDes.Split(',');
if (ArDes.Length > 1)
{
string strType = ArDes[1].ToUpper();
if (strType == "PERMANENT")
{
return true;
}
else if (strType == "LIMITED")
{
string strDateTime = ArDes[0];
if (strDateTime != "")
{
//比较时间
DateTime dtRead = DateTime.Parse(strDateTime);
if (dtRead > DateTime.Now)
return true;
else
return false;
}
return false;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch
{
return false;
}
}
else
{
return false;
}
}
}
}
、、、