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

📄 queryismg.java

📁 亚信java实例 移动短信接口 cmpp3.0
💻 JAVA
字号:
package sample;/*  --------------------------------------------------------------------------    Name:       QueryISMG.cpp    Title:      CMPP API of ISMG for CMPP 1.1    Package:    Send query request to ISMG sample code for Asiainfo CMPP 1.1 API    Written:    2000/12/20  Asiainfo    Revised:        Synopsis:    Editor:     TAB=4 -----------------------------------------------------------------------------*/import aiismg.jcmppapi30.CMPPAPI;import aiismg.jcmppapi30.CMPPQueryResp;import java.io.*;public final class QueryISMG {	public static void main( String argv[] )	{		int			nOutput = 1;		String sResultFile = null;		byte[] sServiceID = new byte[10], sDate = new byte[8];		int			nType = 0, n; 		CMPPQueryResp	theQueryResp = new CMPPQueryResp();		CMPPAPI pCMPPAPI = new CMPPAPI();				// get argument		int nLen;		for(n=0; n<argv.length; n++) {			if(argv[n].compareTo( "-n") == 0) {	        	nOutput = 0;			} else if(argv[n].compareTo( "-d") == 0) {				n++;				if( argv[n].length() > 8 ) {					if(nOutput == 1) {						System.out.println( "Date format is YYYYMMDD!" );					}					System.exit(1);				}				System.arraycopy( argv[n].getBytes(), 0, sDate, 0, argv[n].length() );			} else if(argv[n].compareTo( "-t") == 0) {				n++;				nType = Integer.parseInt(argv[n]);			} else if(argv[n].compareTo( "-s") == 0) {				n++;				if( argv[n].length() > 10 ) {					if(nOutput == 1) {						System.out.println( "ServiceID too long. The length must less than 10!" );					}					System.exit(1);				}				System.arraycopy( argv[n].getBytes(), 0, sServiceID, 0, argv[n].length() );			} else if(argv[n].compareTo( "-f") == 0) {				n++;	      sResultFile = argv[n];			} else {				if(nOutput == 1) {					Usage();				}				System.exit(1);			}		}				if( sResultFile == null) {			if(nOutput == 1) {				System.out.println("No result file!");			}			System.exit(1);			}			if( sDate == null) {			if(nOutput == 1) {				System.out.println("No query date!");			}			System.exit(1);			}		if(nType == 1 && sServiceID == null) {			if(nOutput == 1) {				System.out.println("No serviceid!");			}			System.exit(1);			}			// initiate API		if(pCMPPAPI.InitCMPPAPI( "../config/javacmppc.ini" ) != 0) {			if(nOutput == 1) {				System.out.println("Fail to call InitCMPPAPI!");			}			System.exit(1);			}			if(pCMPPAPI.CMPPQuery(sDate, nType, sServiceID, theQueryResp) != 0) {			if(nOutput == 1) {				System.out.println("Fail to call CMPPQuery!");			}			System.exit(1);			}			// write query result into file		try{			FileOutputStream pFile = new FileOutputStream( sResultFile );			pFile.write( (Integer.toString(theQueryResp.nMT_TLMsg)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMT_TLusr)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMT_Scs)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMT_WT)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMT_FL)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMO_Scs)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMO_WT)).getBytes());			pFile.write( '\n' );			pFile.write( (Integer.toString(theQueryResp.nMO_FL)).getBytes());			pFile.write( '\n' );			pFile.close();		} catch( SecurityException excpt ) {			 if( nOutput == 1 )			   System.err.println( "Fail to create file " + sResultFile );			 System.exit(1);		} catch( FileNotFoundException nfcpt ) {			 if( nOutput == 1 )			   System.err.println( "No such file:" + sResultFile );			 System.exit(1);		} catch( IOException excpt ) {			if( nOutput == 1 )			  System.err.println( "Fail to write file " + sResultFile );			System.exit(1);		}		System.exit(0);	}		public static void Usage( )	{		System.out.println("Usage: QueryISGM [-n] <-d date> <-t type> <-s serviceid> <-f result_file>" );		System.out.println("       -n: no message output");		System.out.println("       -d: qeury date, format=yyyymmdd.");			System.out.println("       -t: qeury type, 0=total, 1=serviceid.");			System.out.println("       -s: serviceid.");		System.out.println("       -f: result file name.");		System.out.println("e.g.:  QueryISGM -d 20001220 -t 1 -s 00001 -f query.txt" );	}}

⌨️ 快捷键说明

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