日期:2014-03-14 浏览次数:20372 次
==========================================
具体实现如下:
1、 新建一个名为ActiveUser的类,存储单个活动用户数据。
/// <summary>
/// 单个在线用户数据,无法继承此类。
/// </summary>
public sealed class ActiveUser
{
private readonly string _ticket; //票据名称
private readonly string _username; //登陆用户名
private readonly string _truename; //登陆用户名
private readonly string _roleid; //角色
private readonly DateTime _refreshtime; //最新刷新时间
private readonly DateTime _activetime; //最新活动时间
private readonly string _clientip; //登陆IP
public ActiveUser(string Ticket,string UserName,string TrueName,string RoleID,string ClientIP) {
this._ticket=Ticket;
this._username=UserName;
this._truename=TrueName;
this._roleid=RoleID;
this._refreshtime=DateTime.Now;
this._activetime=DateTime.Now;
this._clientip=ClientIP;
}
public ActiveUser(string Ticket,string UserName,string TrueName,string RoleID,DateTime RefreshTime,DateTime ActiveTime,string ClientIP) {
this._ticket=Ticket;
this._username=UserName;
this._truename=TrueName;
this._roleid=RoleID;
this._refreshtime=RefreshTime;
this._activetime=ActiveTime;
this._clientip=ClientIP;
}
public string Ticket { get{return _ticket;} }
public string UserName { get{return _username;} }
public string TrueName { get{return _truename;} }
public string RoleID { get{return _roleid;} }
public DateTime RefreshTime { get{return _refreshtime;} }
public DateTime ActiveTime { get{return _activetime;} }
public string ClientIP { get{return _clientip;} }
}
2、 新建一个名为PassPort的类,存储在线用户列表。
/// <summary>
/// 单个在线用户数据,无法继承此类。
/// </summary>
public sealed class ActiveUser
{
private readonly string _ticket; //票据名称
private readonly string _username; //登陆用户名
private readonly string _truename; //登陆用户名
private readonly string _roleid; //角色
private readonly DateTime _refreshtime; //最新刷新时间
private readonly Date