You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.5 KiB
C#

11 months ago
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
namespace DSWeb
{
public class OpenPageBase : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
if (HttpContext.Current.Session["USERID"] == null)
{
if (Request.Cookies["DSUSERID"] != null)
{
string cookieUserID = Request.Cookies["DSUSERID"].Value;
UserLoginStatusDA userLoginStatusDA = new UserLoginStatusDA();
UserLoginStatusEntity userLoginStatusEntity = new UserLoginStatusEntity();
//查看是否当前登录用户是否是时效内重新登录的用户
userLoginStatusEntity = userLoginStatusDA.GetLoginStatusByUserID(cookieUserID);
if (userLoginStatusEntity.GID != null)
{
DateTime signDateTime = userLoginStatusEntity.SignInTime;
DateTime serverDateTime = userLoginStatusEntity.ServerDateTime;
double expiresMinutes = double.Parse(userLoginStatusEntity.ExpiresMinutes.ToString());
if (signDateTime.AddMinutes(expiresMinutes).CompareTo(serverDateTime) >= 0)
{
userLoginStatusDA.DeleteUserLoginStatus(userLoginStatusEntity.GID);
}
else
{
userLoginStatusDA.UpdateLoginStatusForReSign(userLoginStatusEntity);
UserEntity userEntity = new UserDA().GetUserSignByID(cookieUserID);
Session["USERID"] = userEntity.Gid;
Session["CODENAME"] = userEntity.CodeName;
Session["SHOWNAME"] = userEntity.ShowName;
Session["PASSWORD"] = userEntity.PassWord;
}
}
else
{
throw new Exception();
}
}
else
{
Response.Redirect("login.aspx");
Response.End();
}
}
base.OnLoad(e);
}
}
}