📄 loginsrv.java
字号:
/**
* @作者: 胡俊
* @创建时间: 2008-03-05
* @更新时间: 2008-03-05
* @描述:
*
*/
package com.nari.pmos.proxy.server;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Collection;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pbos.dao.helper.DAOFactory;
import pbos.dao.services.PbosDAO;
import com.nari.pmos.amm.amm.CheckIn;
/**
* @author hujun
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class LoginSrv {
// private PbosDAO m_dao = DAOFactory.getPbosDAO();
private String cmd = null;
/**
*
*/
public LoginSrv() {
super();
// TODO Auto-generated constructor stub
}
/**
* @return Returns the cmd.
*/
public String getCmd() {
return cmd;
}
/**
* @param cmd
* The cmd to set.
*/
public void setCmd(String cmd) {
this.cmd = cmd;
}
public void doLogin(HttpServletRequest req, HttpServletResponse res)
throws IOException {
String uAccount = "-";
String uPwd = "-";
String sessionId = "---***---";
Integer N = null;
int isChkOk = -1;
if (cmd.equals("logon")) {
CheckIn checkIn = null;
// 读取数据
ObjectInputStream in = new ObjectInputStream(req.getInputStream());
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
try {
N = (Integer) in.readObject();
uAccount = (String) in.readObject();
uPwd = (String) in.readObject();
} catch (Exception e) {
e.printStackTrace();
}
PbosDAO dao = null;
Collection col = null;
try {
dao = DAOFactory.getPbosDAO();
//checkIn = new CheckIn(dao);
checkIn = new CheckIn(); //2008-04-12
isChkOk = checkIn.IsRegUser(uAccount, uPwd);
if (isChkOk > 0) {// register user active
col = checkIn.RetrieveViews(uAccount, uPwd);
if (col != null) {
out.writeObject(sessionId);
N = new Integer(col.size());
out.writeObject(N);
Iterator it = col.iterator();
while (it.hasNext()) {
Object obj = it.next();
out.writeObject(obj);
}
} else {// no objects
out.writeObject(sessionId);
out.writeObject(new Integer(0));
}
} else {
out.writeObject(sessionId);
out.writeObject(new Integer(-1));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dao.closeDAO();
}
// Flush 数据缓冲区
out.flush();
byte buf[] = byteOut.toByteArray();
// 设置属性
res.setContentType("application/octet-stream");
res.setHeader("Cache-Control", "no-cache");
res.setContentLength(buf.length);
// 发送数据
DataOutputStream dataOut = new DataOutputStream(res
.getOutputStream());
dataOut.write(buf);
dataOut.flush();
dataOut.close();
} else if (cmd.equals("logout")) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -