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

📄 conferenceactionajax.java

📁 sso呵呵
💻 JAVA
字号:
package com.mdcl.mocha.jlcmcc.conferenceManager.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.mdcl.mocha.bpm.sdk.ServiceManager;
import com.mdcl.mocha.bpm.sdk.license.LicenseException;
import com.mdcl.mocha.bpm.sdk.osm.IAccountsMgmtService;
import com.mdcl.mocha.bpm.sdk.osm.entity.AccountsBean;
import com.mdcl.mocha.bpm.sdk.osm.entity.EmpInstBean;
import com.mdcl.mocha.bpm.webcommons.action.BPMBaseAction;
import com.mdcl.mocha.bpm.webcommons.constant.ISessionAttributeConstant;
import com.mdcl.mocha.jlcmcc.conferenceManager.bean.BaseActionForm;
import com.mdcl.mocha.jlcmcc.conferenceManager.bean.MeetingInfo;
import com.mdcl.mocha.jlcmcc.conferenceManager.dao.IConferenceManage;
import com.mdcl.mocha.jlcmcc.conferenceManager.dao.daoImpl.ConferenceManageImpl;

/**
 * <strong>Title : ConferenceActionAjax<br>
 * </strong> <strong>Description : </strong><br>
 * <strong>Create on : 2007-10-14<br>
 * </strong>
 * <p>
 * <strong>Copyright (C) Mocha Software Co.,Ltd.<br>
 * </strong>writenum.chaxunlishikongxianhao
 * <p>
 *
 * @author linda linda@mochasoft.com.cn<br>
 * @version <strong>吉林移动BPM一期</strong><br>
 *          <br>
 *          <strong>修改历史:</strong><br>
 *          修改人 修改日期 修改描述<br>
 *          -------------------------------------------<br>
 *          <br>
 *          <br>
 */
public class ConferenceActionAjax extends BPMBaseAction {

	/**
	 * <code>S_LOGGER</code>-注释
	 */
	private static final Logger S_LOGGER = Logger
			.getLogger(ConferenceActionAjax.class);

	/**
	 * 方法描述
	 *
	 * 利用Ajax请求,处理数据查询请求,以XML格式输出数据
	 *
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward queryInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.queryInfo()>>>");
		}

		try {
			request.setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}

		// 设置返回内容的类型
		response.setContentType("text/xml;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");

		// 设置文件头
		String xml_head = "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		String xml = "<infos>\n";
		xml += "\t<content_type>Options</content_type>\n";

		// 调用接口获取数据
		IConferenceManage confManage = new ConferenceManageImpl();
		List list = confManage.queryMeetingInfo();
		if (list != null && !list.isEmpty()) {
			for (int i = 0; i < list.size(); i++) {
				MeetingInfo roomBean = (MeetingInfo) list.get(i);
				xml += "\t<info>\n";
				xml += "\t\t<roomId>" + roomBean.getId() + "</roomId>\n";
				xml += "\t\t<roomName>" + roomBean.getName() + "</roomName>\n";
				xml += "\t\t<capacity>" + roomBean.getHold_peoples()
						+ "</capacity>\n";
				xml += "\t\t<multiMedia>" + roomBean.getIs_medium()
						+ "</multiMedia>\n";
				xml += "\t</info>\n";
			}
		}

		xml = xml_head + xml + "</infos>\n";

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug(xml);
		}
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}
		out.write(xml);
		out.flush();
		out.close();

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.queryInfo()<<<");
		}
		return null;
	}

	/**
	 * 方法描述
	 *
	 * 通过Ajax请求,获取流程数据,进行保存
	 *
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward saveInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.saveInfo()>>>");
		}

		try {
			request.setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}

		String valuesStr = request.getParameter("values");
		try {
			valuesStr = java.net.URLDecoder.decode(valuesStr, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}

		if (valuesStr == null)
			return null;
		String[] values = valuesStr.split("##");

		try {
			// 获得帐号管理服务类接口
			IAccountsMgmtService accountsMng = (IAccountsMgmtService) ServiceManager
					.getInstance().getService(IAccountsMgmtService.class);
			// 通过帐号ID获得帐号实体Bean
			AccountsBean account = accountsMng.getAccountsById(values[0]);
			List list = account.getEilist();
			EmpInstBean empInst = (EmpInstBean) list.get(0);

			// 保存数据
			BaseActionForm baseForm = new BaseActionForm();
			baseForm.setId("");
			baseForm.setUser_id(values[0]);
			baseForm.setUser_name(values[1]);
			baseForm.setDept_id(empInst.getOrgid());
			baseForm.setDept_name(values[2]);
			baseForm.setDraft_time(values[3]);
			baseForm.setExigency(values[4]);
			baseForm.setFlow_id(values[5]);
			baseForm.setContact_phone(values[6]);
			baseForm.setStart_time(values[7]);
			baseForm.setEnd_time(values[8]);
			baseForm.setPresent_num(values[9]);
			baseForm.setMetting_id(values[10]);
			baseForm.setName(values[11]);
			baseForm.setHold_peoples(values[12]);
			baseForm.setIs_medium(values[13]);
			baseForm.setEquipment(values[14]);
			baseForm.setMetting_note(values[15]);

			IConferenceManage confManage = new ConferenceManageImpl();
			confManage.createNewMeetingUseInfo(baseForm);

		} catch (LicenseException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
			request.getSession().setAttribute(
					ISessionAttributeConstant.LICENSE_EXCEPTION_KEY, e);
			request.setAttribute("message", "操作失败!");
			return mapping.findForward("Message");
		} catch (Exception e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
			request.getSession().setAttribute(
					ISessionAttributeConstant.ERR_EXCEPTION_KEY, e);
			request.setAttribute("message", "操作失败!");
			return mapping.findForward("Message");
		}
		// 设置返回内容的类型
		response.setContentType("text/xml;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		// 设置文件头
		String xml_head = "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		String xml = "<infos>\n";
		xml += "\t<content_type>SaveInfo</content_type>\n";
		xml = xml_head + xml + "</infos>\n";

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug(xml);
		}
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}
		out.write(xml);
		out.flush();
		out.close();

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.saveInfo()<<<");
		}
		return null;
	}

	/**
	 * 方法描述
	 *
	 * 利用Ajax请求,处理数据验证请求
	 *
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward checkInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.checkInfo()>>>");
		}

		try {
			request.setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}
		String valuesStr = request.getParameter("values");


		boolean result = false;
		if (valuesStr != null) {
			try {
				valuesStr = java.net.URLDecoder.decode(valuesStr, "UTF-8");
			} catch (UnsupportedEncodingException e) {
				S_LOGGER.error("ConferenceActionAjax.error", e);
			}
			String[] values = valuesStr.split("##");

			// 保存数据
			BaseActionForm baseForm = new BaseActionForm();
			baseForm.setId(values[0]);
			baseForm.setStart_time(values[1]);
			baseForm.setEnd_time(values[2]);

			// 调用接口获取数据
			IConferenceManage confManage = new ConferenceManageImpl();
			result = confManage.isExistMeetingUseInfo(baseForm);
		}

		// 设置返回内容的类型
		response.setContentType("text/xml;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		// 设置文件头
		String xml_head = "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		String xml = "<infos>\n";
		xml += "\t<content_type>CheckResult</content_type>\n";
		xml += "\t<info>" + result + "</info>\n";
		xml = xml_head + xml + "</infos>\n";
		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug(xml);
		}
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			S_LOGGER.error("ConferenceActionAjax.error", e);
		}
		out.write(xml);
		out.flush();
		out.close();

		if (S_LOGGER.isDebugEnabled()) {
			S_LOGGER.debug("ConferenceActionAjax.checkInfo()<<<");
		}
		return null;
	}
}

⌨️ 快捷键说明

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