SMGP协议之Submit

    /// <summary>
    /// 功能:消息包
    /// 作者:吕永义
    /// 时间:2011年3月30号
    /// </summary>
    public class Submit
    {
        #region 变量或者属性

        /// <summary>
        /// 消息头
        /// </summary>
        private MessageHeader msgHeader;

        /// <summary>
        /// 消息头
        /// </summary>
        public MessageHeader MsgHeader
        {
            get { return msgHeader; }
            set { msgHeader = value; }
        }

        /// <summary>
        /// 消息流水号
        /// </summary>
        private uint sequenceID;

        /// <summary>
        /// 消息流水号
        /// </summary>
        public uint SequenceID
        {
            get { return sequenceID; }
            set { sequenceID = value; }
        }

        /// <summary>
        /// 包体长度
        /// </summary>
        private int bodyLength;

        /// <summary>
        /// 包体的长度
        /// </summary>
        public int BodyLength
        {
            get { return bodyLength; }
            set { bodyLength = value; }
        }

        public const int Length =
            1                           //MsgType 短消息类型
            + 1                         // NeedReportSP是否要求返还状态报告
            + 1                         //Priority 短消息发送优先级
            + 10                        //ServiceID 业务代码
            + 2                       //FeeType 收费类型
            + 6                         //FeeCode资费代码
            + 6                         //FixedFee 包月份/封顶费
            + 1                         //MsgFormat 短消息格式
            + 17                         //ValidTime短消息有效时间
            + 17                         //AtTime短消息定时发送时间
            + 21                          //SrcTermID短消息发送方代码
            + 21                          //ChargeTermID计费用户号码
            + 1                          //DestTermIDCount 短消息接收号码总数
            //短消息接收号码缺省
            + 1                          //MsgLength短消息长度

           //短消息内容

            + 8;                          //Reserve 保留

        /// <summary>
        /// 短消息类型
        /// </summary>
        private uint msgType;

        /// <summary>
        /// 短消息类型
        /// </summary>
        public uint MsgType
        {
            get { return msgType; }
            set { msgType = value; }
        }

        /// <summary>
        /// SP要求是否返回状态报告
        /// </summary>
        private uint needReport;

        /// <summary>
        /// SP要求是否返回状态报告
        /// </summary>
        public uint NeedReport
        {
            get { return needReport; }
            set { needReport = value; }
        }


        /// <summary>
        /// 短消息发送的优先级
        /// </summary>
        private uint priority;

        /// <summary>
        /// 短消息发送的优先级
        /// </summary>
        public uint Priority
        {
            get { return priority; }
            set { priority = value; }
        }

        /// <summary>
        /// 业务代码
        /// </summary>
        private string serviceID;

        /// <summary>
        /// 业务代码
        /// </summary>
        public string ServiceID
        {
            get { return serviceID; }
            set { serviceID = value; }
        }

        /// <summary>
        /// 收费类型
        /// </summary>
        private string feeType;

        /// <summary>
        /// 收费类型
        /// </summary>
        public string FeeType
        {
            get { return feeType; }
            set { feeType = value; }
        }

        /// <summary>
        /// 资费代码
        /// </summary>
        private string feeCode;

        /// <summary>
        /// 资费代码
        /// </summary>
        public string FeeCode
        {
            get { return feeCode; }
            set { feeCode = value; }
        }

        /// <summary>
        /// 包月费
        /// </summary>
        private string fixedFee;

        /// <summary>
        /// 包月份/封顶费
        /// </summary>
        public string FixedFee
        {
            get { return fixedFee; }
            set { fixedFee = value; }
        }

        /// <summary>
        /// 短消息格式
        /// </summary>
        private uint msgFormat;

        /// <summary>
        /// 短消息格式
        /// </summary>
        public uint MsgFormat
        {
            get { return msgFormat; }
            set { msgFormat = value; }
        }

        /// <summary>
        /// 短消息有效时间
        /// </summary>
        private string validTime;

        /// <summary>
        /// 短消息有效时间
        /// </summary>
        public string ValidTime
        {
            get { return validTime; }
            set { validTime = value; }
        }

        /// <summary>
        /// 短消息定时时间
        /// </summary>
        private string atTime;

        /// <summary>
        /// 短消息定时发送时间
        /// </summary>
        public string AtTime
        {
            get { return atTime; }
            set { atTime = value; }
        }

        /// <summary>
        /// 短信发送方号码
        /// </summary>
        private string srcTermID;

        /// <summary>
        /// 短信发送方号码
        /// </summary>
        public string SrcTermID
        {
            get { return srcTermID; }
            set { srcTermID = value; }
        }

        /// <summary>
        /// 计费用户号码
        /// </summary>
        private string chargeTermID;

        /// <summary>
        /// 计费用户号码
        /// </summary>
        public string ChargeTermID
        {
            get { return chargeTermID; }
            set { chargeTermID = value; }
        }

        /// <summary>
        /// 短消息接收号码总数
        /// </summary>
        private uint destTermIDCount;

        /// <summary>
        /// 短消息接收的号码总数
        /// </summary>
        public uint DestTermIDCount
        {
            get { return destTermIDCount; }
            set { destTermIDCount = value; }
        }

        /// <summary>
        /// 短消息接收号码
        /// </summary>
        private string[] destTermID;

        /// <summary>
        /// 短消息接收号码
        /// </summary>
        public string[] DestTermID
        {
            get { return destTermID; }
            set { destTermID = value; }
        }

        /// <summary>
        /// 短消息长度
        /// </summary>
        private uint msgLength;

        /// <summary>
        /// 短消息长度
        /// </summary>
        public uint MsgLength
        {
            get { return msgLength; }
            set { msgLength = value; }
        }

        /// <summary>
        /// 短消息内容
        /// </summary>
        private string msgContent;

        /// <summary>
        /// 短消息内容
        /// </summary>
        public string MsgContent
        {
            get { return msgContent; }
            set { msgContent = value; }
        }

        /// <summary>
        /// 保留字段
        /// </summary>
        private string reserve;

        /// <summary>
        /// 保留字段
        /// </summary>
        public string Reserve
        {
            get { return reserve; }
            set { reserve = value; }
        }

        /// <summary>
        /// 交易标识
        /// </summary>
        private string linkID;

        /// <summary>
        /// 交易标识
        /// </summary>
        public string LinkID
        {
            get { return linkID; }
            set { linkID = value; }
        }

        /// <summary>
        /// 业务代码
        /// </summary>
        private string mServiceID;

        /// <summary>
        /// 业务代码
        /// </summary>
        public string MServiceID
        {
            get { return mServiceID; }
            set { mServiceID = value; }
        }

        /// <summary>
        /// 企业代码
        /// </summary>
        private string sPID;

        /// <summary>
        /// 企业代码
        /// </summary>
        public string SPID
        {
            get { return sPID; }
            set { sPID = value; }
        }

        /// <summary>
        /// 消息内容转成的数组
        /// </summary>
        private byte[] msgContent_Bytes;

        /// <summary>
        /// 消息内容转成的数组
        /// </summary>
        public byte[] MsgContent_Bytes
        {
            get { return msgContent_Bytes; }
            set { msgContent_Bytes = value; }
        }

        /// <summary>
        /// 消息总条数
        /// </summary>
        private byte pkTotal;

        /// <summary>
        /// 消息总条数
        /// </summary>
        public byte PkTotal
        {
            get { return pkTotal; }
            set { pkTotal = value; }
        }

        /// <summary>
        /// 消息的序号
        /// </summary>
        private byte pkNumber;

        /// <summary>
        /// 消息的序号
        /// </summary>
        public byte PkNumber
        {
            get { return pkNumber; }
            set { pkNumber = value; }
        }

        #endregion


        #region 方法

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sequenceID">消息流水号</param>
        public Submit(uint sequenceID)
        {
            this.sequenceID = sequenceID;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sequenceID">消息流水号</param>
        /// <param name="msgContent_Bytes">消息内容转成的Byte数组</param>
        public Submit(uint sequenceID, byte[] msgContent_Bytes)
        {
            this.sequenceID = sequenceID;
            this.msgContent_Bytes = msgContent_Bytes;
        }

        /// <summary>
        /// 初始化一些数据
        /// </summary>
        private void SetHeader()
        {
            switch (this.msgFormat)
            {
                case 8:
                    msgContent_Bytes = Encoding.BigEndianUnicode.GetBytes(this.msgContent);
                    break;
                case 15: //gb2312
                    msgContent_Bytes = Encoding.GetEncoding("gb2312").GetBytes(this.msgContent);
                    break;
                case 0: //ascii
                case 3: //短信写卡操作
                case 4: //二进制信息
                default:
                    // msg_Content_Bytes=new ASCIIEncoding().GetBytes(this.msgContent);
                    msgContent_Bytes = Encoding.ASCII.GetBytes(this.msgContent);
                    break;
            }

            this.msgLength = (uint)MsgContent_Bytes.Length;
            this.bodyLength = (int)(Length + 21 * this.destTermID.Length + this.msgLength);
            this.msgHeader = new MessageHeader((uint)(MessageHeader.HeaderLength + this.bodyLength), RequestID.Submit, this.sequenceID);
        }

        /// <summary>
        /// 根据江苏省CDMA要求更改
        /// 初始化一些数据
        /// </summary>
        private void SetTHeader()
        {
            switch (this.msgFormat)
            {
                case 8:
                    msgContent_Bytes = Encoding.BigEndianUnicode.GetBytes(this.msgContent);
                    break;
                case 15: //gb2312
                    msgContent_Bytes = Encoding.GetEncoding("gb2312").GetBytes(this.msgContent);
                    break;
                case 0: //ascii
                case 3: //短信写卡操作
                case 4: //二进制信息
                default:
                    // msg_Content_Bytes=new ASCIIEncoding().GetBytes(this.msgContent);
                    msgContent_Bytes = Encoding.ASCII.GetBytes(this.msgContent);
                    break;
            }

            this.msgLength = (uint)MsgContent_Bytes.Length;
            this.bodyLength = (int)(Length + 21 * this.destTermID.Length + this.msgLength) + 2 + 2 + 20 + 2 + 2 + 21 + 2 + 2 + 8;
            this.msgHeader = new MessageHeader((uint)(MessageHeader.HeaderLength + this.bodyLength), RequestID.Submit, this.sequenceID);
        }

        /// <summary>
        /// 初始化数据,根据长短信更改
        /// </summary>
        private void SetLHeader()
        {
            this.msgLength = (uint)MsgContent_Bytes.Length;
            this.bodyLength = (int)(Length + 21 * this.destTermID.Length + this.msgLength)
            + 2 + 2 + 1 //tp_pid
            + 2 + 2 + 1 //tp_udhi
            + 2 + 2 + 20 //linkid
            + 2 + 2 + 8 //msgsrc
            + 2 + 2 + 21 //mserviceid
            + 2 + 2 + 1 //pktotal
            + 2 + 2 + 1 //pknumber
            ;
            this.msgHeader = new MessageHeader((uint)(MessageHeader.HeaderLength + this.bodyLength), RequestID.Submit, this.sequenceID);

        }

        /// <summary>
        /// 转化成bytes字节数组
        /// </summary>
        /// <returns></returns>
        public byte[] ToBytes()
        {
            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);//msgHeader消息头
            i = i + 12;
            bytes[i++] = (byte)this.msgType;//msgType短信类型
            bytes[i++] = (byte)this.needReport;//needReportSP是否要求返回状态报告
            bytes[i++] = (byte)this.priority;
            buffer = BIConvert.String2Bytes(this.serviceID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//serviceID业务代码
            i = i + 10;
            buffer = BIConvert.String2Bytes(this.feeType);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeType收费类型
            i = i + 2;
            buffer = BIConvert.String2Bytes(this.feeCode);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeCode 资费代码
            i = i + 6;
            buffer = BIConvert.String2Bytes(this.fixedFee);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length); //fixedFee 包月费/封顶费
            i = i + 6;
            bytes[i++] = (byte)this.msgFormat; //msgFormat 短消息格式
            buffer = BIConvert.String2Bytes(this.validTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);// validTime 短消息有效时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.atTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//atTime 短消息定时发送时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.srcTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//srcTermID 发送方代码
            i = i + 21;
            buffer = BIConvert.String2Bytes(this.chargeTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//chargeTermID 计费用户号码
            i = i + 21;

            bytes[i++] = (byte)this.destTermIDCount;//destTermIDCount 接收消息的号码总数

            #region 接收消息的号码

            for (int k = 0; k < destTermIDCount; k++)
            {
                buffer = BIConvert.String2Bytes(this.destTermID[k]);
                Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
                i = i + 21;
            }

            #endregion

            bytes[i++] = (byte)this.msgLength;// msgLength消息长度
            buffer = this.msgContent_Bytes;

            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//msgContent_Bytes消息内容
            i = i + buffer.Length;

            buffer = BIConvert.String2Bytes(this.reserve);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//reserve 保留字
            i = i + 8;
            return bytes;
        }


        /// <summary>
        /// 转化成字节数组
        /// 配合江苏省CDMA网关调整做了调整
        /// 吕永义
        /// 2011年5月9日
        /// </summary>
        /// <returns></returns>
        public byte[] ToTBytes()
        {
            SetTHeader();

            int i = 0;

            byte[] bytes = new byte[MessageHeader.HeaderLength + this.bodyLength];
            byte[] buffer = this.msgHeader.ToBytes();
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//msgHeader消息头
            i = i + 12;
            bytes[i++] = (byte)this.msgType;//msgType短信类型
            bytes[i++] = (byte)this.needReport;//needReportSP是否要求返回状态报告
            bytes[i++] = (byte)this.priority;
            buffer = BIConvert.String2Bytes(this.serviceID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//serviceID业务代码
            i = i + 10;
            buffer = BIConvert.String2Bytes(this.feeType);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeType收费类型
            i = i + 2;
            buffer = BIConvert.String2Bytes(this.feeCode);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeCode 资费代码
            i = i + 6;
            buffer = BIConvert.String2Bytes(this.fixedFee);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length); //fixedFee 包月费/封顶费
            i = i + 6;
            bytes[i++] = (byte)this.msgFormat; //msgFormat 短消息格式
            buffer = BIConvert.String2Bytes(this.validTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);// validTime 短消息有效时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.atTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//atTime 短消息定时发送时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.srcTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//srcTermID 发送方代码
            i = i + 21;
            buffer = BIConvert.String2Bytes(this.chargeTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//chargeTermID 计费用户号码
            i = i + 21;

            bytes[i++] = (byte)this.destTermIDCount;//destTermIDCount 接收消息的号码总数

            #region 接收消息的号码

            for (int k = 0; k < destTermIDCount; k++)
            {
                buffer = BIConvert.String2Bytes(this.destTermID[k]);
                Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
                i = i + 21;
            }

            #endregion

            bytes[i++] = (byte)this.msgLength;// msgLength消息长度
            buffer = this.msgContent_Bytes;

            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//msgContent_Bytes消息内容
            i = i + buffer.Length;

            buffer = BIConvert.String2Bytes(this.reserve);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//reserve 保留字
            i = i + 8;


            #region linkID

            short tag = 3;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            short length = 20;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            buffer = BIConvert.String2Bytes(this.linkID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 20;

            #endregion

            #region mServiceID

            tag = 18;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 21;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;


            buffer = BIConvert.String2Bytes(this.serviceID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 21;

            #endregion

            #region MsgSrc

            tag = 16;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 8;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            buffer = BIConvert.String2Bytes(this.sPID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 8;

            #endregion

            return bytes;

        }

        /// <summary>
        /// 转化成字节数组
        /// 长短信发送
        /// </summary>
        /// <returns></returns>
        public byte[] ToLBytes()
        {
            SetLHeader();

            int i = 0;

            byte[] bytes = new byte[MessageHeader.HeaderLength + this.bodyLength];
            byte[] buffer = this.msgHeader.ToBytes();
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//msgHeader消息头
            i = i + 12;
            bytes[i++] = (byte)this.msgType;//msgType短信类型
            bytes[i++] = (byte)this.needReport;//needReportSP是否要求返回状态报告
            bytes[i++] = (byte)this.priority;
            buffer = BIConvert.String2Bytes(this.serviceID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//serviceID业务代码
            i = i + 10;
            buffer = BIConvert.String2Bytes(this.feeType);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeType收费类型
            i = i + 2;
            buffer = BIConvert.String2Bytes(this.feeCode);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//feeCode 资费代码
            i = i + 6;
            buffer = BIConvert.String2Bytes(this.fixedFee);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length); //fixedFee 包月费/封顶费
            i = i + 6;
            bytes[i++] = (byte)this.msgFormat; //msgFormat 短消息格式
            buffer = BIConvert.String2Bytes(this.validTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);// validTime 短消息有效时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.atTime);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//atTime 短消息定时发送时间
            i = i + 17;
            buffer = BIConvert.String2Bytes(this.srcTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//srcTermID 发送方代码
            i = i + 21;
            buffer = BIConvert.String2Bytes(this.chargeTermID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//chargeTermID 计费用户号码
            i = i + 21;

            bytes[i++] = (byte)this.destTermIDCount;//destTermIDCount 接收消息的号码总数

            #region 接收消息的号码

            for (int k = 0; k < destTermIDCount; k++)
            {
                buffer = BIConvert.String2Bytes(this.destTermID[k]);
                Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);
                i = i + 21;
            }

            #endregion

            bytes[i++] = (byte)this.msgLength;// msgLength消息长度
            buffer = this.msgContent_Bytes;

            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//msgContent_Bytes消息内容
            i = i + buffer.Length;

            buffer = BIConvert.String2Bytes(this.reserve);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//reserve 保留字
            i = i + 8;

            #region Tp_pid

            short tag = 1;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            short length = 1;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            bytes[i++] = 0x00;


            #endregion

            #region Tp_udhi

            tag = 2;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 1;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            bytes[i++] = 0x40;

            #endregion

            #region LinkID

            tag = 3;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 20;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            buffer = BIConvert.String2Bytes(this.linkID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 20;

 

            #endregion

            #region MsgSrc

            tag = 16;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 8;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            buffer = BIConvert.String2Bytes(this.sPID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 8;


            #endregion

            #region MServiceID

            tag = 18;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 21;
            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;


            buffer = BIConvert.String2Bytes(this.serviceID);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//linkid
            i = i + 21;

            #endregion

            #region PkTotal

            tag = 9;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 1;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            bytes[i++]=this.pkTotal;

            #endregion

            #region PkNumber

            tag = 10;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(tag);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//tag
            i = i + 2;

            length = 1;

            buffer = new byte[2];
            buffer = BIConvert.Shrot2Bytes(length);
            Util.ByteCopyToByte(buffer, 0, bytes, i, buffer.Length);//length
            i = i + 2;

            bytes[i++] = this.pkNumber;

            #endregion


            return bytes;

        }

        #endregion


    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值