public class CMPP_DELIVER
{
/// <summary>
/// 消息头
/// </summary>
private MessageHeader msgHeader;
/// <summary>
/// 消息头
/// </summary>
public MessageHeader MsgHeader
{
get { return msgHeader; }
set { msgHeader = value; }
}
/// <summary>
/// 消息标识
/// </summary>
private byte[] msg_Id;
/// <summary>
/// 消息标识
/// </summary>
public byte[] Msg_Id
{
get { return msg_Id; }
set { msg_Id = value; }
}
/// <summary>
/// 目的号码
/// </summary>
private string dest_Id;
/// <summary>
/// 目的号码属性
/// </summary>
public string Dest_Id
{
get { return dest_Id; }
set { dest_Id = value; }
}
/// <summary>
/// 业务标识
/// </summary>
private string service_Id;
/// <summary>
/// 业务标识属性
/// </summary>
public string Service_Id
{
get { return service_Id; }
set { service_Id = value; }
}
/// <summary>
/// GSM协议类型
/// </summary>
private uint tP_pid;
/// <summary>
/// GSM协议类型属性
/// </summary>
public uint TP_pid
{
get { return tP_pid; }
set { tP_pid = value; }
}
/// <summary>
/// GSM协议类型
/// </summary>
private uint tP_udhi;
/// <summary>
/// GSM协议类型属性
/// </summary>
public uint TP_udhi
{
get { return tP_udhi; }
set { tP_udhi = value; }
}
/// <summary>
/// 信息格式:
/// 0:ASCII串;
///3:短信写卡操作;
///4:二进制信息;
///8:UCS2编码;
///15:含GB汉字。
/// </summary>
private uint msg_Fmt;
/// <summary>
/// 消息格式属性
/// </summary>
public uint Msg_Fmt
{
get { return msg_Fmt; }
set { msg_Fmt = value; }
}
/// <summary>
/// 源终端MSISDN号码(状态报告时填为CMPP_SUBMIT消息的目的终端号码)
/// </summary>
private string src_terminal_Id;
/// <summary>
/// 源终端MSISDN号码 属性
/// </summary>
public string Src_terminal_Id
{
get { return src_terminal_Id; }
set { src_terminal_Id = value; }
}
/// <summary>
/// 源终端号码类型,0:真实号码;1:伪码。
/// </summary>
private uint src_terminal_type;
/// <summary>
/// 源终端号码类型属性
/// </summary>
public uint Src_terminal_type
{
get { return src_terminal_type; }
set { src_terminal_type = value; }
}
/// <summary>
/// 是否为状态报告:0:非状态报告;1:状态报告。
/// </summary>
private uint registered_Delivery;
/// <summary>
/// 是否为状态报告:0:非状态报告;1:状态报告。
/// </summary>
public uint Registered_Delivery
{
get { return registered_Delivery; }
set { registered_Delivery = value; }
}
/// <summary>
/// 消息长度,取值大于或等于0。
/// </summary>
private uint msg_Length;
/// <summary>
/// 消息长度,取值大于或等于0。
/// </summary>
public uint Msg_Length
{
get { return msg_Length; }
set { msg_Length = value; }
}
/// <summary>
/// 消息内容
/// </summary>
private string msg_Content;
/// <summary>
/// 消息内容
/// </summary>
public string Msg_Content
{
get { return msg_Content; }
set { msg_Content = value; }
}
/// <summary>
/// 点播业务使用的LinkID
/// </summary>
private string linkID;
/// <summary>
/// 点播业务使用的LinkID
/// </summary>
public string LinkID
{
get { return linkID; }
set { linkID = value; }
}
/// <summary>
/// 状态报告
/// </summary>
private CMPP_REPORT cMPP_REPORT;
/// <summary>
/// 状态报告
/// </summary>
public CMPP_REPORT CMPP_REPORT
{
get { return cMPP_REPORT; }
set { cMPP_REPORT = value; }
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="bytes"></param>
public CMPP_DELIVER(byte[] bytes)
{
int i = 0;
byte[] buffer = new byte[MessageHeader.HeaderLength];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.msgHeader = new MessageHeader(buffer);
i += 12;
buffer = new byte[8];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.msg_Id = buffer;
i = i + 8;
buffer = new byte[21];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.dest_Id = BIConvert.Byte2String(buffer);
i = i + 21;
buffer = new byte[10];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.service_Id = BIConvert.Byte2String(buffer);
i += 10;
this.tP_pid = (uint)bytes[i++];
this.tP_udhi = (uint)bytes[i++];
this.msg_Fmt = (uint)bytes[i++];
buffer = new byte[32];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.src_terminal_Id = BIConvert.Byte2String(buffer);
i = i + 32;
this.src_terminal_type = (uint)bytes[i++];
this.registered_Delivery = (uint)bytes[i++];
this.msg_Length = (uint)bytes[i++];
if (this.registered_Delivery.Equals(0))
{
//非状态报告
buffer = new byte[this.msg_Length];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
switch (this.msg_Fmt)
{
case 8:
this.msg_Content = Encoding.BigEndianUnicode.GetString(buffer).Trim();
break;
case 15:
this.msg_Content = Encoding.GetEncoding("gb2312").GetString(buffer).Trim();
break;
case 0: //ascii
case 3://短信写卡操作
case 4://二进制信息
default:
this.msg_Content = Encoding.ASCII.GetString(buffer).ToString();
break;
}
i += (int)this.msg_Length;
}
else
{
if (this.registered_Delivery.Equals(1))
{
//状态报告
this.cMPP_REPORT = new CMPP_REPORT();
buffer = new byte[8];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.Msg_Id = buffer;
i = i + 8;
buffer = new byte[7];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.Stat = BIConvert.Byte2String(buffer);
i = i + 7;
buffer = new byte[10];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.Submit_time = BIConvert.Byte2String(buffer);
i = i + 10;
buffer = new byte[10];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.Done_time = BIConvert.Byte2String(buffer);
i = i + 10;
buffer = new byte[21];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.Dest_terminal_Id = BIConvert.Byte2String(buffer);
i = i + 21;
buffer = new byte[4];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.cMPP_REPORT.SMSC_sequence = BIConvert.Bytes2UInt(buffer);
i = i + 4;
}
}
buffer = new byte[20];
Util.ByteCopyToByte(bytes, i, buffer, 0, buffer.Length);
this.linkID = BIConvert.Byte2String(buffer);
i = i + 20;
}
}