大家好,欢迎来到IT知识分享网。
/// <summary>
/// 功能:SP在与ISMG建立应用层连接后向ISMG提交短信。
/// 作者:吕永义
/// 时间:2011年5月19日
/// </summary>
public class CMPP_SUBMIT
{
#region CMPP_SUBMIT的变量和属性
private int bodyLength;
public int BodyLength
{
get { return bodyLength; }
set { bodyLength = value; }
}
public const int Length = 8
+ 1
+ 1
+ 1
+ 1
+ 10
+ 1
+ 32
+ 1
+ 1
+ 1
+ 1
+ 6
+ 2
+ 6
+ 17
+ 17
+ 21
+ 1
//+ 32*DestUsr_tl
+ 1
+ 1
//+ Msg_length
+ 20;
private byte[] msg_Id; // 8 Unsigned Integer 信息标识。
public byte[] Msg_Id
{
get { return msg_Id; }
set { msg_Id = value; }
}
private uint pk_total; // 1 Unsigned Integer 相同Msg_Id的信息总条数,从1开始。
public uint Pk_total
{
get { return pk_total; }
set { pk_total = value; }
}
private uint pk_number; // 1 Unsigned Integer 相同Msg_Id的信息序号,从1开始。
public uint Pk_number
{
get { return pk_number; }
set { pk_number = value; }
}
private uint registered_Delivery; // 1 Unsigned Integer 是否要求返回状态确认报告:
public uint Registered_Delivery
{
get { return registered_Delivery; }
set { registered_Delivery = value; }
}
// 0:不需要;
// 1:需要。
private uint msg_level; // 1 Unsigned Integer 信息级别。
public uint Msg_level
{
get { return msg_level; }
set { msg_level = value; }
}
private string service_Id; // 10 Octet String 业务标识,是数字、字母和符号的组合。
public string Service_Id
{
get { return service_Id; }
set { service_Id = value; }
}
private uint fee_UserType; // 1 Unsigned Integer 计费用户类型字段:
public uint Fee_UserType
{
get { return fee_UserType; }
set { fee_UserType = value; }
}
// 0:对目的终端MSISDN计费;
// 1:对源终端MSISDN计费;
// 2:对SP计费;
// 3:表示本字段无效,对谁计费参见Fee_terminal_Id字段。
private string fee_terminal_Id; // 32 Octet String 被计费用户的号码,当Fee_UserType为3时该值有效,当Fee_UserType为0、1、2时该值无意义。
public string Fee_terminal_Id
{
get { return fee_terminal_Id; }
set { fee_terminal_Id = value; }
}
private uint fee_terminal_type; // 1 Unsigned Integer 被计费用户的号码类型,0:真实号码;1:伪码。
public uint Fee_terminal_type
{
get { return fee_terminal_type; }
set { fee_terminal_type = value; }
}
private uint tP_pId; // 1 Unsigned Integer GSM协议类型。详细是解释请参考GSM03.40中的9.2.3.9。
public uint TP_pId
{
get { return tP_pId; }
set { tP_pId = value; }
}
private uint tP_udhi; // 1 Unsigned Integer GSM协议类型。详细是解释请参考GSM03.40中的9.2.3.23,仅使用1位,右对齐。
public uint TP_udhi
{
get { return tP_udhi; }
set { tP_udhi = value; }
}
private uint msg_Fmt; // 1 Unsigned Integer 信息格式:
public uint Msg_Fmt
{
get { return msg_Fmt; }
set
{
msg_Fmt = value;
if (this.Msg_Content != null)
{
this.SetHeader();
}
}
}
// 0:ASCII串;
// 3:短信写卡操作;
// 4:二进制信息;
// 8:UCS2编码;
// 15:含GB汉字……
private string msg_src; // 6 Octet String 信息内容来源(SP_Id)。
public string Msg_src
{
get { return msg_src; }
set { msg_src = value; }
}
private string feeType; // 2 Octet String 资费类别:
public string FeeType
{
get { return feeType; }
set { feeType = value; }
}
// 01:对”计费用户号码”免费;
// 02:对”计费用户号码”按条计信息费;
// 03:对”计费用户号码”按包月收取信息费。
private string feeCode; // 6 Octet String 资费代码(以分为单位)。
public string FeeCode
{
get { return feeCode; }
set { feeCode = value; }
}
private string valId_Time; // 17 Octet String 存活有效期,格式遵循SMPP3.3协议。
public string ValId_Time
{
get { return valId_Time; }
set { valId_Time = value; }
}
private string at_Time; // 17 Octet String 定时发送时间,格式遵循SMPP3.3协议。
public string At_Time
{
get { return at_Time; }
set { at_Time = value; }
}
private string src_Id; // 21 Octet String 源号码。SP的服务代码或前缀为服务代码的长号码, 网关将该号码完整的填到SMPP协议Submit_SM消息相应的source_addr字段,该号码最终在用户手机上显示为短消息的主叫号码。
public string Src_Id
{
get { return src_Id; }
set { src_Id = value; }
}
private uint destUsr_tl; // 1 Unsigned Integer 接收信息的用户数量(小于100个用户)。
public uint DestUsr_tl
{
get { return destUsr_tl; }
set { destUsr_tl = value; }
}
private string[] dest_terminal_Id; // 32*DestUsr_tl Octet String 接收短信的MSISDN号码。
public string[] Dest_terminal_Id
{
get { return dest_terminal_Id; }
set { dest_terminal_Id = value; }
}
private uint dest_terminal_type; // 1 Unsigned Integer 接收短信的用户的号码类型,0:真实号码;1:伪码。
public uint Dest_terminal_type
{
get { return dest_terminal_type; }
set { dest_terminal_type = value; }
}
private uint msg_Length; // 1 Unsigned Integer 信息长度(Msg_Fmt值为0时:<160个字节;其它<=140个字节),取值大于或等于0。
public uint Msg_Length
{
get { return msg_Length; }
set { msg_Length = value; }
}
private string msg_Content; // Msg_length Octet String 信息内容。
public string Msg_Content
{
get { return msg_Content; }
set
{
msg_Content = value;
}
}
private string linkID; // 20 Octet String 点播业务使用的LinkID,非点播类业务的MT流程不使用该字段。
public string LinkID
{
get { return linkID; }
set { linkID = value; }
}
#endregion
/// <summary>
/// 消息头
/// </summary>
private MessageHeader msgHeader;
/// <summary>
/// 消息头属性
/// </summary>
public MessageHeader MsgHeader
{
get { return msgHeader; }
set { msgHeader = value; }
}
/// <summary>
/// 消息流水号
/// </summary>
private uint sequence_Id;
/// <summary>
/// 消息流水号属性
/// </summary>
public uint Sequence_Id
{
get { return sequence_Id; }
set { sequence_Id = value; }
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name=”Sequence_Id”>消息流水号</param>
public CMPP_SUBMIT(uint sequence_Id)
{
this.sequence_Id = sequence_Id;
}
private byte[] msg_Content_Bytes;
public byte[] Msg_Content_Bytes
{
get { return msg_Content_Bytes; }
set { msg_Content_Bytes = value; }
}
/// <summary>
/// 转化成字节数组
/// </summary>
/// <returns></returns>
public byte[] ToBytes()
{
this.SetHeader();
int i = 0;
byte[] bytes = new byte[MessageHeader.HeaderLength + this.BodyLength];
byte[] buffer = this.MsgHeader.ToBytes();
Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
i = i + 12;
msg_Id = new byte[8];
buffer = msg_Id;
Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
i += 8;
bytes[i++] = (byte)this.Pk_total; //[20,20]
bytes[i++] = (byte)this.Pk_number; //[21,21]
bytes[i++] = (byte)this.Registered_Delivery; //[22,22]
bytes[i++] = (byte)this.Msg_level; //[23,23]
//Service_Id
buffer = new byte[10];
buffer = BIConvert.String2Bytes(this.Service_Id);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //10 //[24,33]
//Fee_UserType
i += 10;
bytes[i++] = (byte)this.Fee_UserType; //[34,34]
//Fee_terminal_Id
buffer = new byte[32];
buffer = BIConvert.String2Bytes(this.Fee_terminal_Id);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //32 //[35,66]
//Fee_terminal_type
i += 32;
bytes[i++] = (byte)this.Fee_terminal_type; //[67,67]
bytes[i++] = (byte)this.TP_pId; //[68,68]
bytes[i++] = (byte)this.TP_udhi; //[69,69]
bytes[i++] = (byte)this.Msg_Fmt; //[70,70]
//Msg_src
buffer = new byte[6];
buffer = BIConvert.String2Bytes(this.Msg_src);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //6 //[71,76]
//FeeType
i += 6;
buffer = new byte[2];
buffer = BIConvert.String2Bytes(this.FeeType);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //2 //[77,78]
//FeeCode
i += 2;
buffer = new byte[6];
buffer = BIConvert.String2Bytes(this.FeeCode);
// buffer = Encoding.ASCII.GetBytes(this._FeeCode);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //6 //[79,84]
//ValId_Time
i += 6;
buffer = new byte[17];
buffer = BIConvert.String2Bytes(this.ValId_Time);
// buffer = Encoding.ASCII.GetBytes(this._ValId_Time);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //17 //[85,101]
//At_Time
i += 17;
buffer = new byte[17];
buffer = BIConvert.String2Bytes(this.At_Time);
// buffer = Encoding.ASCII.GetBytes(this._At_Time);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //17 //[102,118]
//Src_Id
i += 17;
buffer = new byte[21];
buffer = BIConvert.String2Bytes(this.Src_Id);
// buffer = Encoding.ASCII.GetBytes(this._Src_Id);
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //21 //[119,139]
//DestUsr_tl
i += 21;
this.DestUsr_tl = (uint)this.Dest_terminal_Id.Length;
// this._DestUsr_tl = (uint)this._Dest_terminal_Id.Length;
bytes[i++] = (byte)this.DestUsr_tl; //[140,140]
//Dest_terminal_Id
foreach (string s in this.Dest_terminal_Id)
{
buffer = BIConvert.String2Bytes(s);
Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
i += 32;
}
bytes[i++] = (byte)this.Dest_terminal_type;
//Msg_Length
bytes[i++] = (byte)this.Msg_Length;
// buffer = new byte[this.Msg_Length];
Util.ByteCopyToByte(this.Msg_Content_Bytes, 0, bytes, i, this.Msg_Content_Bytes.Length);
//LinkID
i += (int)this.Msg_Length;
buffer = new byte[20];
buffer = BIConvert.String2Bytes(this.LinkID);
Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
i += 20;
return bytes;
}
}
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/23597.html