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

📄 userinterface.java

📁 短信开发汇总
💻 JAVA
📖 第 1 页 / 共 2 页
字号:


/**
 * <p>Title: smsproc</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author vienna
 * @version 1.0
 */
import java.io.*;
import java.util.*;
import java.text.*;

public class UserInterface {
    static private SynSocket recv_comm=new SynSocket();
    static private DataBuffer recv_buffer=new DataBuffer();
    static private SynSocket send_comm=new SynSocket();
    static private DataBuffer send_buffer=new DataBuffer();
    static Seq seq=null;
    public UserInterface() {
        super();
    }
    public int InitSGIPAPI(ErrorCode err){
        return GlobalVar.InitSGIP(err);
    }
    public int SGIPSend(String sSPNumber,
                         String sChargeNumber,
                         String sUserNumber,
                         String sCorpID,
                         String sServiceType,
                         int nFeeType,
                         String sFeeValue,
                         String sGivenValue,
                         int nAgentFlag,
                         int nMorelatetoMTFlag,
                         int nPriority,
                         String sExpireTime,
                         String sScheduleTime,
                         int nReportFlag,
                         int nTP_pid,
                         int nTP_udhi,
                         int nMessageCoding,
                         int nMessageType,
                         int nMessageLength,
                         byte[] sMessageContent,
                         byte[] sReserve,
                         ErrorCode nErrorCode){
         int MsgLen=0;
         byte[] MsgContent;
         if(nErrorCode==null){
             GlobalVar.WriteSysLog("UserInterface","SGIPSend","nErrorCode can't be null",GlobalVar.SYSTEM_APPLICATION_ERROR_1);
             return 1;
         }
         if(nAgentFlag > 1 || nAgentFlag < 0){
             nErrorCode.setErrorCodeString("AgentFlag有误!");
             return 1;
         }
         if(nMorelatetoMTFlag > 4 || nMorelatetoMTFlag < 0){
             nErrorCode.setErrorCodeString("MorelatetoMTFlag有误!");
             return 1;
         }
         if(nPriority > 9 || nPriority < 0){
             nErrorCode.setErrorCodeString("Priority有误!");
             return 1;
         }
         if(nFeeType > 4 || nFeeType < 0 ){
             nErrorCode.setErrorCodeString("FeeType有误!");
             nErrorCode.setErrorCodeValue(GlobalVar.INVALID_FEETYPE);
             return 1;
         }
         if(nReportFlag > 3 || nReportFlag < 0){
             return 1;
         }
         if(nMessageCoding > 255 || nMessageCoding < 0){
             nErrorCode.setErrorCodeString("msgCoding有误!");
             nErrorCode.setErrorCodeValue(GlobalVar.INVALID_SHORT_MESSAGE_LEN);
             return 1;
         }
         if(nMessageType !=0){
             return 1;
         }
         if(sServiceType==null){
             nErrorCode.setErrorCodeString("ServiceType有误!");
             nErrorCode.setErrorCodeValue(GlobalVar.INVALID_SERVICE_ID);
             return 1;
         }
         if(nTP_pid!=0){
             return 1;
         }
         if(nTP_udhi!=0){
             return 1;
         }
         if(sFeeValue==null){
             return 1;
         }
         if(sFeeValue.length()>6){
             return 1;
         }
         if(sGivenValue==null){
             return 1;
         }
         if(sGivenValue.length()>6){
             return 1;
         }
         if(sExpireTime==null){
             return 1;
         }
         if(!sExpireTime.equals("") && sExpireTime.length()!=16){
             return 1;
         }
         if(sScheduleTime==null){
             return 1;
         }
         if(!sScheduleTime.equals("") && sScheduleTime.length()!=16){
             return 1;
         }
         if(sSPNumber==null){
             return 1;
         }
         if(ValidCheck.isValidLength(sSPNumber,1,21)==false){
             return 1;
         }
         if(ValidCheck.isNumberString(sSPNumber)==false){
             return 1;
         }
         if(sCorpID==null){
             return 1;
         }
         if(ValidCheck.isValidLength(sCorpID,1,5)==false){
             return 1;
         }
         if(ValidCheck.isNumberString(sCorpID)==false){
             return 1;
         }
         if(sChargeNumber==null){
             return 1;
         }
         if(ValidCheck.isValidLength(sChargeNumber,1,21)==false){
             return 1;
         }
         if(ValidCheck.isNumberString(sChargeNumber)==false){
             return 1;
         }
         if(sUserNumber==null){
             return 1;
         }
         if(ValidCheck.isValidLength(sUserNumber,1,21)==false){
             return 1;
         }
         if(ValidCheck.isNumberString(sUserNumber)==false){
             return 1;
         }
         if(nMessageLength < 0){
             return 1;
         }
         if(nMessageLength==0){
             if(sMessageContent==null){
                 return 1;
             }
             if(sMessageContent.length==0){
                 return 1;
             }
             String FileName=new String(sMessageContent);
             File MsgFile=null;
             FileInputStream MsgFileStream=null;
             try{
                 MsgFile=new File(FileName);
                 MsgFileStream=new FileInputStream(MsgFile);
             }
             catch(Exception ex){
                 nErrorCode.setErrorCodeString("msglen为0,msg不是有效文件!");
                 return 1;
             }
             long len=MsgFile.length();
             if(len==0){
                 return 1;
             }
         }
         else{
             if(sMessageContent.length<nMessageLength){
                 nErrorCode.setErrorCodeString("MessageContetn短消息内容小于指定的长度!");
                 return 1;
             }
             MsgLen=nMessageLength;
             MsgContent=sMessageContent;
         }
         SynSocket comm=new SynSocket();
         int ret=comm.LoginSGIP(1,nErrorCode);
         if(ret!=0){
             return 1;
         }
         String s=new String("60123"+GlobalVar.getSequenceNo());
         SGIP_Submit submit=new SGIP_Submit();
         submit.SPNumber=sSPNumber.getBytes();
         submit.ChargeNumber=sChargeNumber.getBytes();
         submit.UserCount=1;
         submit.UserNumber[0]=sUserNumber.getBytes();
         submit.CorpID=sCorpID.getBytes();
         submit.ServiceType=sServiceType.getBytes();
         submit.FeeType=nFeeType;
         submit.FeeValue=sFeeValue.getBytes();
         submit.GivenValue=sGivenValue.getBytes();
         submit.AgentFlag=nAgentFlag;
         submit.MorelatetoMTFlag=nMorelatetoMTFlag;
         submit.Priority=nPriority;
         submit.ExpireTime=sExpireTime.getBytes();
         submit.ScheduleTime=sScheduleTime.getBytes();
         submit.ReportFlag=nReportFlag;
         submit.TP_pid=nTP_pid;
         submit.TP_udhi=nTP_pid;
         submit.MessageCoding=nMessageCoding;
         submit.MessageType=nMessageType;
         submit.MessageLength=nMessageLength;
         submit.MessageContent=sMessageContent;
         submit.Reserve=sReserve;
         submit.head.PacketLength=submit.Length();
         submit.head.RequestID=GlobalVar.ID_SGIP_SUBMIT;
         submit.head.Seq1=Integer.parseInt(s);
         submit.head.Seq2=2;
         submit.head.Seq3=3;

         ret=submit.WriteProtocolData(comm.getDataOutputStream());
         if(ret!=0){
             nErrorCode.setErrorCodeString("发送submit消息失败");
             comm.CloseSocket();
             return 1;
         }
         ret=comm.FlushOutputData();
         if(ret!=0){
             nErrorCode.setErrorCodeString("发送Submit消息失败");
             comm.CloseSocket();
             return 1;
         }
         int count=0;
         DataBuffer buffer=new DataBuffer();
         ret=comm.setSoTimeout(10);
         if(ret!=0){
             nErrorCode.setErrorCodeString("设置timeout失败");
             comm.CloseSocket();
             return 1;
         }
         for(;;){
             ret=comm.synRecvData(buffer);
             if(ret!=0){
                 nErrorCode.setErrorCodeString("接收submit resp消息失败");
                 comm.CloseSocket();
                 return 1;
             }

⌨️ 快捷键说明

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