📄 sendtestmmsaction.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.queryservice;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
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");
String mmID = ServletActionContext.getRequest().getParameter("mmsID");
String returnResult = "";
MmsContent mms = null;
if (mmID==null || gatewayID == null || srcNum == null || dstNum == null || mtServiceCode == null ||
gatewayID.equalsIgnoreCase("") || srcNum.equalsIgnoreCase("") || dstNum.equalsIgnoreCase("") ||
mtServiceCode.equalsIgnoreCase("")){
log.error("SendTestMmsAction execute function input params error.");
returnResult = "字段值不能为空!";
ActionContext.getContext().getSession().put("result", returnResult);
return ERROR;
}
Integer mmsID = Integer.valueOf(Integer.parseInt(mmID));
Session sess = HibernateUtil.currentSession();
List resultList = sess.createCriteria(MmsContent.class).
add(Restrictions.eq("contentId", mmsID)).list();
if(resultList != null && resultList.size()>0)
mms = (MmsContent)resultList.get(0);
if (mms == null){
log.error("No MMS Content Found, mmsId = " + mmsID);
returnResult = "没有此彩信,请重新输入彩信编号!";
ActionContext.getContext().getSession().put("result", returnResult);
return ERROR;
//System.out.println("No Content Finded!!!!!!!!!!");
}
else{
log.info("MMS Content Found : " + mms.toString());
returnResult = "彩信发送成功!";
//System.out.println("Mms Content:" + mmsContent.toString());
}
//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();
ActionContext.getContext().getSession().put("result", returnResult);
result = SUCCESS;
} catch (HibernateException e) {
e.printStackTrace();
}
finally{
HibernateUtil.closeSession();
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -