?? rsmailinfoutil.java.svn-base
字號:
package com.nsi.scheduling;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.nsi.control.exceptions.NsiEventException;
import com.nsi.persistence.DataSrcUtil;
import com.nsi.persistence.IsqlDataSource;
import com.nsi.util.ValHelper;
/**
* @author Chris Ye, created on Oct 10, 2008
*
* RsMailInfoUtil
*/
public final class RsMailInfoUtil
{
private static Log log = LogFactory.getLog(RsMailInfoUtil.class);
/**
* private constructor of RsMailInfoUtil, prevent instantiation
*/
private RsMailInfoUtil()
{
}
private static class RsMailInfoUtilHolder
{
static final RsMailInfoUtil rsMailInfoUtil = new RsMailInfoUtil();
}
/**
* @return an instance of RsMailInfoUtil
*/
public static RsMailInfoUtil getInstance()
{
return RsMailInfoUtilHolder.rsMailInfoUtil;
}
public List<RsEmailInfo> getEmaillist() throws NsiEventException
{
List<RsEmailInfo> emaillist = new ArrayList<RsEmailInfo>();
List<Map<String,String>> result = new ArrayList<Map<String,String>>();
String sSql = "select a.firstname, a.lastname, a.middlename, a.email " +
"from t_resource a, t_res_position b " +
"where a.resourceid = b.resourceid " +
"and b.departmentid in(2,8) " +
"and a.bactive = 'T' " +
"order by a.firstname desc, a.lastname desc";
IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
Connection conn = null;
try
{
conn = src.getConnection();
result = src.executeRetrieve(conn, sSql);
}
catch(SQLException se)
{
log.error("getEmaillist() -- caught SQLException: ", se);
throw new NsiEventException( "getEmaillist() -- caught SQLException: ", se );
}
catch(Exception ex)
{
log.error("getEmaillist() -- caught Exception: ", ex);
throw new NsiEventException( "getEmaillist() -- caught Exception: ", ex );
}
finally
{
src.closeConn(conn);
}
if( !result.isEmpty())
{
int size = result.size();
for ( int i=0; i<size;i++)
{
Map<String,String> resultmap = result.get(i);
RsEmailInfo info = new RsEmailInfo();
String email = ValHelper.getInstance().getValue(resultmap, "email");
if( ValHelper.getInstance().isNotNullAndEmpty(email))
{
info.setFirstname(ValHelper.getInstance().getValue(resultmap, "firstname"));
info.setLastname(ValHelper.getInstance().getValue(resultmap, "lastname"));
info.setMiddlename(ValHelper.getInstance().getValue(resultmap, "middlename"));
info.setEmail(email);
emaillist.add(info);
}
}
}
return emaillist;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -