📄 logmgr.java
字号:
package com.nari.pmos.log.log;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import pbos.dao.DB.ConnectParameters;
import pbos.dao.helper.DAOFactory;
import pbos.dao.helper.DAOParameter;
import pbos.dao.services.PbosDAO;
import com.nari.pmos.log.table_log.Rt_Log;
public class LogMgr {
private PbosDAO dao = null;
private static String dsName = "jdbc/pmosDB";
public LogMgr() {
if (dao == null) {
ConnectParameters.DataSource = dsName;
this.dao = DAOFactory.getPbosDAO();
}
}
public boolean recorde(String log_Type, String user_Account,
String message, String log_Flag) {
boolean flag = false;
try {
flag = false;
Rt_Log log = new Rt_Log();
log.setLog_Type(log_Type);
log.setUser_Account(user_Account);
log.setEjb("#");
log.setMethod("#");
log.setMessage(message);
log.setLog_Flag(log_Flag);
log.setLog_Date(new Date());
flag = dao.insertData(log);
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return flag;
}
public boolean recorde(String log_Type, String user_Account, String ejb,
String method, String message, String log_Flag) {
boolean flag = false;
try {
Rt_Log log = new Rt_Log();
log.setLog_Type(log_Type);
log.setUser_Account(user_Account);
log.setEjb(ejb);
log.setMethod(method);
log.setMethod(message);
log.setLog_Flag(log_Flag);
log.setLog_Date(new Date());
flag = dao.insertData(log);
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return flag;
}
public Collection find_LogInfo_By_User_Account(String user_Account) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param.setFilter("USER_ACCOUNT == :m_user_Account");
m_param.setParameter("m_user_Account", user_Account);
col = (Collection) dao.findData(m_param);
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public Collection find_LogInfo_By_Log_Type(String log_Type) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param.setFilter("LOG_TYPE == :m_log_Type");
m_param.setParameter("m_log_Type", log_Type);
col = (Collection) dao.findData(m_param);
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public Collection find_LogInfo_By_Log_Flag(String log_Flag) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param.setFilter("LOG_FLAG == :m_log_Flag");
m_param.setParameter("m_log_Flag", log_Flag);
col = (Collection) dao.findData(m_param);
if (col != null) {
Iterator it = col.iterator();
while (it.hasNext()) {
Rt_Log log = (Rt_Log) it.next();
System.out.println(log.getLog_Flag());
}
}
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public Collection find_LogInfo_By_Log_Date_Befor(Date log_Date_Befor) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param.setFilter("LOG_DATE <= :m_log_Date_Befor");
m_param.setParameter("m_log_Date_Befor", log_Date_Befor);
col = (Collection) dao.findData(m_param);
if (col != null) {
Iterator it = col.iterator();
while (it.hasNext()) {
Rt_Log log = (Rt_Log) it.next();
System.out.println(log.getLog_Date());
}
}
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public Collection find_LogInfo_By_Log_Date_After(Date log_Date_After) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param.setFilter("LOG_DATE >= :m_log_Date_After");
m_param.setParameter("m_log_Date_After", log_Date_After);
col = (Collection) dao.findData(m_param);
if (col != null) {
Iterator it = col.iterator();
while (it.hasNext()) {
Rt_Log log = (Rt_Log) it.next();
System.out.println(log.getLog_Date());
}
}
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public Collection find_LogInfo_By_Log_Date_Between(Date log_Date_After,
Date log_Date_Befor) {
Collection col = null;
try {
DAOParameter m_param = DAOFactory.getDAOParameter();
m_param.setCandiateClass(com.nari.pmos.log.table_log.Rt_Log.class);
m_param
.setFilter("Log_Date >= :LOG_DATE_AFTER AND Log_Date <= :LOG_DATE_BEFOR");
m_param.setParameter("LOG_DATE_AFTER", log_Date_After);
m_param.setParameter("LOG_DATE_BEFOR", log_Date_Befor);
col = (Collection) dao.findData(m_param);
if (col != null) {
Iterator it = col.iterator();
while (it.hasNext()) {
Rt_Log log = (Rt_Log) it.next();
System.out.println(log.getLog_Date());
}
}
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
return col;
}
public static void main(String[] args) {
ConnectParameters.IP = "192.168.202.128";
ConnectParameters.Port = 1521;
ConnectParameters.ServerName = "demo";
ConnectParameters.UserName = "hbcc";
ConnectParameters.Password = "pmos2000";
PbosDAO m_dao = DAOFactory.getPbosDAO();
System.out.println(new LogMgr().recorde("info", "jm", "aa", "client"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -