?? userslogdata.java
字號:
/*
* 創建日期 2005-8-23
*
* TODO 要更改此生成的文件的模板,請轉至
* 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
package org.infosys.util;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import com.infosys.Hibernate.PUserLog;
import com.infosys.Hibernate.SessionFactory;
/**
* @author Administrator
* 取得用戶日志數據
*/
public class UsersLogData {
/**
* 取得用戶日志數據
* @param start 開始序列號
* @param len 長度
* @return List
*/
public List get(int start,int len){
List list=new ArrayList();
Session session;
try {
session = SessionFactory.currentSession();
String sql="from PUserLog a order by a.logdate asc";
Query query=session.createQuery(sql);
//設置翻頁
query.setFirstResult(start);
query.setMaxResults(len);
List logs=query.list();
PUserLog logObj=new PUserLog();
Hashtable tmphash=new Hashtable();
String backcolor="#ffffff";
for(int i=0;i<logs.size();i++){
backcolor=((i % 2)==0)?"#ffffff":"#eaeaea";
logObj=(PUserLog)logs.get(i);
tmphash=new Hashtable();
tmphash.put("backcolor",backcolor);
tmphash.put("userid",logObj.getUserid());
tmphash.put("handleAct",((logObj.getHandleact()==null)?"":logObj.getHandleact()));
tmphash.put("ip",((logObj.getIp()==null)?"":logObj.getIp()));
tmphash.put("logdate",ParamUtil.getDate(logObj.getLogdate(),"yyyy-MM-dd HH:mm:ss"));
list.add(tmphash);
}
logs=null;
tmphash=null;
query=null;
} catch (HibernateException e) {
e.printStackTrace();
} finally {
try {
SessionFactory.closeSession();
} catch (HibernateException e1) {
e1.printStackTrace();
}
}
return list;
}
/**
* 取得用戶日志數據長度
* @return
*/
public int getTotalNum(){
int totalnum=0;
Session session;
try {
session = SessionFactory.currentSession();
Integer total=(Integer)session.createQuery("select count(*) from PUserLog a").uniqueResult();
totalnum=total.intValue();
} catch (HibernateException e) {
e.printStackTrace();
} finally {
try {
SessionFactory.closeSession();
} catch (HibernateException e1) {
e1.printStackTrace();
}
}
return totalnum;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -