/*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/).
*/
package ch06.module;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
import java.text.*;
import javax.servlet.http.HttpSession;
import ch06.*;
/**
* 针对简历登入页面的后台处理
* 注意:可以同时为Guest登录和管理员登录服务
* @author ShenYK
* @version 1.0
*/
public class MResume extends MCommon
{
//guest登录简历的情况
public boolean registerGuestResume ( HttpSession mySession,
ResumeContent resumeObj )
{
//设置用户信息
Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_GUEST_REGISTER);
//登录简历
ResumeContent resumeFinish = register( mySession, resumeObj);
//如果登录成功
if ( resumeFinish.getResumeId() != null && resumeFinish.getResumeId().length() > 0 )
{
myValues.put( "resume", resumeFinish );
return true;
}
else
{
myValues.put( "resume", resumeObj);
return false;
}
}
//管理员登录简历的情况
public boolean registerAdminResume ( HttpSession mySession,
ResumeContent resumeObj )
{
//设置用户信息
Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_REGISTER_DETAIL);
//登录简历
ResumeContent resumeFinish = register( mySession, resumeObj);
//如果登录成功
if ( resumeFinish.getResumeId() != null && resumeFinish.getResumeId().length() > 0 )
{
myValues.put( "resume", resumeFinish );
return true;
}
else
{
myValues.put( "resume", resumeObj);
return false;
}
}
//登录简历
private synchronized ResumeContent register( HttpSession mySession, ResumeContent resumeObj)
{
//获得数据库连接
Connection conn = this.getDBConnection( mySession );
if ( conn == null )
{
return resumeObj;
}
Statement stmt = null;
ResultSet rs = null;
try
{
//得到当前系统时间
String sDate = (new SimpleDateFormat("yyyy/MM/dd")).format(new Date(System.currentTimeMillis()));
//获得数据库中简历的最大id
String sResumeId = "";
stmt = conn.createStatement();
//执行SQL语句
String sQuery = "select max(resume_id) from resume";
rs = stmt.executeQuery( sQuery );
rs.next();
String sCurrentMaxId = rs.getString(1);
//当前是第一次登录
if ( sCurrentMaxId == null )
{
sResumeId = "00000001";
}
else
{
int iMaxCd = Integer.parseInt(sCurrentMaxId);
sResumeId = String.valueOf(iMaxCd+1);
int iLength = sResumeId.length();
for(int i=8; i>iLength; i--)
{
sResumeId = "0" + sResumeId;
}
}
//尝试插入数据库
StringBuffer sInsertSQL = new StringBuffer();
sInsertSQL.append( "insert into resume set ");
sInsertSQL.append( "resume_id = '" + sResumeId + "', ");
sInsertSQL.append( "realname = '" + resumeObj.getRealname() + "', " );
sInsertSQL.append( "sex = '" + resumeObj.getSex() + "', " );
sInsertSQL.append( "born_date = '" + resumeObj.getBornDate() + "', " );
sInsertSQL.append( "max_education = '" + resumeObj.getMaxEducation() + "', " );
sInsertSQL.append( "major = '" + resumeObj.getMajor() + "', " );
sInsertSQL.append( "email = '" + resumeObj.getEmail() + "', " );
sInsertSQL.append( "contact_phone = '" + resumeObj.getContactPhone() + "', " );
sInsertSQL.append( "mobile = '" + resumeObj.getMobile() + "', " );
sInsertSQL.append( "current_job_type = '" + resumeObj.getCurrentJobType() + "', " );
sInsertSQL.append( "expect_job_type = '" + resumeObj.getExpectJobType() + "', " );
sInsertSQL.append( "current_position = '" + resumeObj.getCurrentPosition() + "', " );
sInsertSQL.append( "expect_position = '" + resumeObj.getExpectPosition() + "', " );
sInsertSQL.append( "current_city = '" + resumeObj.getCurrentCity() + "', " );
sInsertSQL.append( "expect_city = '" + resumeObj.getExpectCity() + "', " );
sInsertSQL.append( "expect_salary = '" + resumeObj.getExpectSalary() + "', " );
sInsertSQL.append( "resume_content = '" + resumeObj.getResumeContent() + "', " );
sInsertSQL.append( "expire_time = '" + resumeObj.getExpireTime() + "', " );
sInsertSQL.append( "add_time = '" + sDate + "'" );
stmt.executeUpdate( sInsertSQL.toString() );
resumeObj.setResumeId(sResumeId);
return resumeObj;
}
catch(Exception e)
{
e.printStackTrace();
mySession.setAttribute("errMsg","往数据库中添加新简历的时候出现错误,请联系技术人员!");
return resumeObj;
}
finally
{
try
{
rs.close();
stmt.close();
conn.close();
}catch(Exception ex)
{
}
}
}
//得到所有未处理的简历一览
public boolean getAllProcessResume( HttpSession mySession )
{
//设置用户信息
Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_PROCESS_LIST);
//获得数据库连接
Connection conn = this.getDBConnection( mySession );
if ( conn == null )
{
return false;
}
Statement stmt = null;
ResultSet rs = null;
try
{
stmt = conn.createStatement();
//执行SQL语句
String sQuery = "select * from resume where expire_time='' order by resume_id desc";
rs = stmt.executeQuery( sQuery );
Vector processResumes = new Vector();
//循环取得所有未整理的简历
while ( rs.next() )
{
ResumeContent resumeObj = new ResumeContent();
resumeObj.setResumeId( rs.getString("resume_id") );
resumeObj.setRealname( rs.getString("realname") );
resumeObj.setSex( rs.getString("sex") );
resumeObj.setBornDate( rs.getString("born_date") );
resumeObj.setMaxEducation( rs.getString("max_education") );
resumeObj.setMajor( rs.getString("major") );
resumeObj.setEmail( rs.getString("email") );
resumeObj.setContactPhone( rs.getString("contact_phone") );
resumeObj.setMobile( rs.getString("mobile") );
resumeObj.setCurrentJobType( rs.getString("current_job_type") );
resumeObj.setExpectJobType( rs.getString("expect_job_type") );
resumeObj.setCurrentPosition( rs.getString("current_position") );
resumeObj.setExpectPosition( rs.getString("expect_position") );
resumeObj.setCurrentCity( rs.getString("current_city") );
resumeObj.setExpectCity( rs.getString("expect_city") );
resumeObj.setExpectSalary( rs.ge