⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 .#executefunction.java.1.4

📁 银行项目为后台socket通信写的程序
💻 4
字号:
/****************************************************************************
 * Package		: com.ecSolutions.ecAppServer.business
 * File			: ExecuteFunction.java
 * Create Date  : 2007-7-21
 * Author		: Steven Chen
 * 
 * Copyright(C) 2006 ecSolutions(shanghai) Co.,Limited.All Rights Reserved.
 *			
 ***************************************************************************/
package com.ecSolutions.ecAppServer.business;

import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

import org.apache.log4j.Logger;

import com.ecSolutions.ecAppServer.appSession.AppServerSessionMgr;
import com.ecSolutions.ecAppServer.appSession.ExecFunctionFailException;
import com.ecSolutions.ecAppServer.appSession.ExecRequest;
import com.ecSolutions.ecAppServer.appSession.User;
import com.ecSolutions.ecAppServer.appSession.UserLoginFailException;
import com.ecSolutions.ecAppServer.util.DbUtil;
import com.ecSolutions.ecAppServer.util.RunCommand;

public class ExecuteFunction {
	private String request;

	private String sessionID;

	private String userID;

	private AppServerSessionMgr sessionMgr;

	private static Logger log = Logger.getLogger("ExecuteFunction");

	public ExecuteFunction(String req) {
		this.request = req;
	}

	public void execFunc() throws ExecFunctionFailException {
		// check user has login
		ExecRequest execReq = new ExecRequest(request);
		sessionMgr = AppServerSessionMgr.getInstance();
		sessionID = execReq.getSessionID();
		userID = execReq.getUserId();
		if (sessionMgr.hasSession(sessionID)) {
			String command = execReq.getTransactionName();
			User user = sessionMgr.getSession(sessionID);
			String menuId = user.getUsermenu();
			if (checkFuctionId(menuId, execReq.getTransactionName())) {
				throw new ExecFunctionFailException("USERNOAUTH");
			}
			RunCommand.exec(sessionID, userID, command);
		} else {
			throw new ExecFunctionFailException("USERNOTLOGIN");
		}
	}

	/**
	 * checkFuctionId
	 * 
	 * @param menuId
	 * @param functionId
	 * @return
	 * @throws ExecFunctionFailException
	 */
	private boolean checkFuctionId(String menuId, String functionId)
			throws ExecFunctionFailException {
		boolean noAuth = true;
		String sql = "select FUNCTIONID from TXXM0XXX where MENUID = ?";
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		Connection connection = null;
		try {
			connection = DbUtil.getConnection();
			pstmt = connection.prepareStatement(sql);
			pstmt.setString(1, menuId);
			rs = pstmt.executeQuery();
			String funcId = "";
			while (rs.next()) {
				funcId = rs.getString("FUNCTIONID");
				if (functionId.equals(funcId)) {
					noAuth = false;
				}
			}
		} catch (SQLException e) {
			log.error("user login query exception:" + e.toString());
			throw new ExecFunctionFailException("USERAUTHCHECKEXCEPTION");
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
				}
				rs = null;
			}
			if (pstmt != null) {
				try {
					pstmt.close();
				} catch (SQLException e) {
				}
				pstmt = null;
			}
			if (connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
				}
				connection = null;
			}
		}
		return noAuth;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -