?? usersession.java
字號:
package cn.com.syntc.webapp.session;
/*
*********************************************************************
* 文件 : UserSession:$
* 項目 : 考試系統
* 公司 : 沈陽NTC計算機工程公司
* 日期 : $Date$
* 說明 :
**********************************************************************
* 版本歷史:
* $Log: $
*********************************************************************
*/
import java.io.*;
import java.util.*;
import java.text.*;
import cn.com.syntc.webapp.define.Constant;
/**
* <p>
*
* Description:登錄用戶信息接口</p> <p>
*
* Copyright: Copyright (c) 2003</p> <p>
*
* Company: SYNTC </p>
*
*@author wangy Mail : wangy@syntc.com.cn
*@created 2003年12月9日
*@version 1.0
*/
public class UserSession
{
/**
* 用戶ID
*/
public String UserID = "";
/**
* 用戶名
*/
public String UserName = "";
/**
* 用戶別名
*/
public String NiceName = "";
/**
* 用戶密碼(加密后存儲于session中)
*/
public String Password = "";
/**
* 用戶性別
*/
public String Sex = "";
/**
* 出生年月
*/
public String Birthday = "";
/**
* 用戶郵件
*/
public String Mail = "";
/**
* 用戶QQ
*/
public String Oicq = "";
/**
* 來自哪兒
*/
public String ComeFrom = "";
/**
* 個人主頁
*/
public String HomePage = "";
/**
* 個人介紹
*/
public String Introduction = "";
/**
* 所屬單位名稱
*/
public String OrgName = "";
/**
* 所屬部門名稱
*/
public String UnitName = "";
/**
* 登錄時間
*/
public String LoginTime = "";
/**
* 登錄IP
*/
public String LogonIP = "";
/**
* 角色ID
*/
public int RoleID = Constant.GUEST;
/**
* 角色名
*/
public String RoleName = "";
/**
* 構造對象 UserSession
*/
public UserSession() { }
/**
* 取得用戶ID
*
*@return 用戶ID
*/
public String getUserID()
{
return this.UserID;
}
/**
* 取得用戶名
*
*@return 用戶名
*/
public String getUserName()
{
return this.UserName;
}
/**
* 取得用戶別名
*
*@return 用戶別名
*/
public String getNiceName()
{
return this.NiceName;
}
/**
* 取得用戶密碼(加密后存儲于session中)
*
*@return 用戶密碼
*/
public String getPassword()
{
return this.Password;
}
/**
* 取得用戶郵件
*
*@return 用戶郵件
*/
public String getMail()
{
return this.Mail;
}
/**
* 取得用戶性別
*/
public String getSex()
{
return this.Sex;
}
/**
* 取得出生年月
*/
public String getBirthday()
{
return this.Birthday;
}
/**
* 取得所屬單位名稱
*
*@return 所屬單位名稱
*/
public String getOrgName()
{
return this.OrgName;
}
/**
* 取得所屬部門名稱
*
*@return 所屬部門名稱
*/
public String getUnitName()
{
return this.UnitName;
}
/**
* 用戶QQ
*/
public String getOicq()
{
return this.Oicq;
}
/**
* 來自哪兒
*/
public String getComeFrom()
{
return this.ComeFrom;
}
/**
* 個人主頁
*/
public String getHomePage()
{
return this.HomePage;
}
/**
* 個人介紹
*/
public String getIntroduction()
{
return this.Introduction;
}
/**
* 取得登錄時間
*
*@return 登錄時間
*/
public String getLoginTime()
{
return this.LoginTime;
}
/**
* 取得登錄IP
*
*@return 登錄IP
*/
public String getLogonIP()
{
return this.LogonIP;
}
/**
* 取得用戶角色ID
*
*@return 用戶角色ID
*/
public int getRoleID()
{
return this.RoleID;
}
/**
* 取得用戶角色名
*
*@return 用戶角色名
*/
public String getRoleName()
{
return this.RoleName;
}
/**
* 取得用戶停留時間
*
*@return 用戶停留時間
*/
public String getStayTime()
{
// 2003-11-30 00:00:00
String StayTime = "";
try
{
Calendar loginCalendar = Calendar.getInstance();
Calendar nowCalendar = Calendar.getInstance();
DateFormat df = DateFormat.getDateTimeInstance();
// 取得登錄的時間
Date LoginDate = df.parse(this.LoginTime);
loginCalendar.setTime(LoginDate);
// 取得當前的時間
nowCalendar.setTime(new Date());
// 計算停留時間(微秒)
long lStayTime = nowCalendar.getTimeInMillis() - loginCalendar.getTimeInMillis();
StayTime = lStayTime / (60 * 60 * 1000) + "小時"
+ lStayTime % 60 / (60 * 1000) + "分鐘"
+ lStayTime % (60 * 1000) / 1000 + "秒";
}
catch(Exception ex)
{
System.out.println("取得用戶停留時間錯誤:"+ex.getMessage());
}
return StayTime;
}
/**
* 設置用戶ID
*
*@param UserId 用戶ID
*/
public void setUserID(String UserID)
{
if(UserID==null)
this.UserID = "";
else
this.UserID = UserID;
}
/**
* 設置用戶名
*
*@param UserName 設置用戶名
*/
public void setUserName(String UserName)
{
if(UserName==null)
this.UserName = "";
else
this.UserName = UserName;
}
/**
* 設置用戶別名
*
*@param NiceName 用戶別名
*/
public void setNiceName(String NiceName)
{
if(NiceName==null)
this.NiceName = "";
else
this.NiceName = NiceName;
}
/**
* 設置用戶密碼(加密后存儲于session中)
*
*@param Password 用戶密碼
*/
public void setPassword(String Password)
{
if(Password==null)
this.Password = "";
else
this.Password = Password;
}
/**
* 設置用戶郵件
*
*@param Mail 用戶郵件
*/
public void setMail(String Mail)
{
if(Mail==null)
this.Mail = "";
else
this.Mail = Mail;
}
/**
* 設置所屬單位名稱
*
*@param OrgName 所屬單位名稱
*/
public void setOrgName(String OrgName)
{
if(OrgName==null)
this.OrgName = "";
else
this.OrgName = OrgName;
}
/**
* 設置所屬部門名稱
*
*@param UnitName 所屬部門名稱
*/
public void setUnitName(String UnitName)
{
if(UnitName==null)
this.UnitName = "";
else
this.UnitName = UnitName;
}
/**
* 設置用戶性別
*
*@param Sex 用戶性別
*/
public void setSex(String Sex)
{
if(Sex==null)
this.Sex = "";
else
this.Sex = Sex;
}
/**
* 設置出生年月
*
*@param Birthday 出生年月
*/
public void setBirthday(String Birthday)
{
if(Birthday==null)
this.Birthday = "";
else
this.Birthday = Birthday;
}
/**
* 設置用戶QQ
*
*@param Oicq 用戶QQ
*/
public void setOicq(String Oicq)
{
if(Oicq==null)
this.Oicq = "";
else
this.Oicq = Oicq;
}
/**
* 設置來自哪兒
*
*@param ComeFrom 來自哪兒
*/
public void setComeFrom(String ComeFrom)
{
if(ComeFrom==null)
this.ComeFrom = "";
else
this.ComeFrom = ComeFrom;
}
/**
* 設置個人主頁
*
*@param HomePage 個人主頁
*/
public void setHomePage(String HomePage)
{
if(HomePage==null)
this.HomePage = "";
else
this.HomePage = HomePage;
}
/**
* 設置個人介紹
*
*@param Introduction 個人介紹
*/
public void setIntroduction(String Introduction)
{
if(Introduction==null)
this.Introduction = "";
else
this.Introduction = Introduction;
}
/**
* 設置登錄時間
*
*@param LoginTime 登錄時間
*/
public void setLoginTime(String LoginTime)
{
if(LoginTime==null)
this.LoginTime = "";
else
this.LoginTime = LoginTime;
}
/**
* 設置登錄IP
*
*@param LogonIP 登錄IP
*/
public void setLogonIP(String LogonIP)
{
if(LogonIP==null)
this.LogonIP = "";
else
this.LogonIP = LogonIP;
}
/**
* 設置用戶角色
*
*@param RoleID 用戶角色
*/
public void setRoleID(int RoleID)
{
if(RoleID<0)
this.RoleID = Constant.GUEST;
else
this.RoleID = RoleID;
}
/**
* 設置用戶角色名
*
*@param RoleName 用戶角色名
*/
public void setRoleName(String RoleName)
{
if(RoleName==null)
this.RoleName = "";
else
this.RoleName = RoleName;
}
/**
* 是否是系統管理員
*
*@return 判斷結果 true 是系統管理員
*/
public boolean isAdmin()
{
if(this.RoleID == Constant.ADMIN)
return true;
else
return false;
}
/**
* 是否是教師
*
*@return 判斷結果 true 是教師
*/
public boolean isTeacher()
{
if(this.RoleID == Constant.TEACHER)
return true;
else
return false;
}
/**
* 是否是學生
*
*@return 判斷結果 true 是學生
*/
public boolean isStudent()
{
if(this.RoleID == Constant.STUDENT)
return true;
else
return false;
}
/**
* 是否是游客
*
*@return 判斷結果 true 是游客
*/
public boolean isGuest()
{
if(this.RoleID == Constant.GUEST)
return true;
else
return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -