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

📄 sendtestmmsaction.java

📁 MM7彩信对接网关示例
💻 JAVA
字号:
/*
 * Created on 2005-7-6
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.rainbow.mms.manage;

import java.util.Date;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.rainbow.mms.common.CMCCMM7SubmitMsg;
import com.rainbow.mms.common.MmsContent;
import com.rainbow.util.tools.HibernateUtil;

/**
 * 发送测试使用的彩信。
 * @author Rainbow MMS Group Leader —— TrWorks
 *
 */
public class SendTestMmsAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private Logger log = Logger.getLogger(SendTestMmsAction.class);

	public String execute() throws Exception {
		String gatewayID = ServletActionContext.getRequest().getParameter("gatewayID");
		String srcNum = ServletActionContext.getRequest().getParameter("srcNum");
		String dstNum = ServletActionContext.getRequest().getParameter("dstNum");
		String mtServiceCode = ServletActionContext.getRequest().getParameter("mtServiceCode");

		if (gatewayID == null || srcNum == null || dstNum == null || mtServiceCode == null ||
			gatewayID.equalsIgnoreCase("") || srcNum.equalsIgnoreCase("") || dstNum.equalsIgnoreCase("") ||
			mtServiceCode.equalsIgnoreCase("")){
			log.error("SendTestMmsAction execute function input params error.");
			return ERROR;
		}
		
		MmsContent mms = (MmsContent)ActionContext.getContext().getSession().get("mmsResult");
		CMCCMM7SubmitMsg msg = new CMCCMM7SubmitMsg();
		msg.setContent(mms);
		msg.setContentType(1);
		msg.setCreateTime(new Date());
		msg.setDstNum(dstNum);
		msg.setFeeNum(dstNum);
		msg.setGateWayID(Integer.parseInt(gatewayID));
		msg.setMsgClass(0);
		msg.setMtServiceCode(mtServiceCode);
		msg.setSrcNum(srcNum);
		msg.setWantReport(1);
		msg.setMsgID("-1");
		
		String result = ERROR;
		try{
			Session sess = HibernateUtil.currentSession();
			Transaction tx = sess.beginTransaction();
			sess.save(msg);	
			tx.commit();
			result = SUCCESS;
			
		} catch (HibernateException e) {
			e.printStackTrace();
		}
		finally{
			HibernateUtil.closeSession();
		}
		
		return result;
	}
}

⌨️ 快捷键说明

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