public CMPP_MSG_QUERY_RESP(byte[] bs) { header = new CMPP_MSG_Header(bs); int index = CMPP_MSG_Header.HeaderLength; _time = BitConverter.ToString(bs, index, 8); index = index + 8; this._queryType = bs[index++]; this._queryCode = BitConverter.ToString(bs, index, 10); index = index + 10; this._MT_TLMsg = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MT_Tlusr = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MT_Scs = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MT_WT = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MT_FL = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MO_Scs = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MO_WT = BIConvert.Bytes2UInt(bs, index); index = index + 4; this._MO_FL = BIConvert.Bytes2UInt(bs, index); }
public byte[] ToBytes() //返回当前对象的字节数组印象 { byte[] reVal = new Byte[CMPP_MSG_Header.HeaderLength + this.BodyLength]; header.toBytes().CopyTo(reVal, 0); //消息头 getSourceAdd().CopyTo(reVal, CMPP_MSG_Header.HeaderLength); //源地址 企业代码 getMd5Code().CopyTo(reVal, CMPP_MSG_Header.HeaderLength + 6); //认证md5 reVal[CMPP_MSG_Header.HeaderLength + 6 + 16] = this.ver; //版本字节 BIConvert.Int2Bytes(Convert.ToUInt32(this._timestamp)).CopyTo(reVal, CMPP_MSG_Header.HeaderLength + 6 + 16 + 1); return(reVal); }
private void init() { int index = 0; byte[] temp = new byte[CMPP_MSG_Header.HeaderLength]; for (int i = 0; i < CMPP_MSG_Header.HeaderLength; i++) { temp[i] = initValue[i]; index = i; } index += 1;//指到正确位置 header = new CMPP_MSG_Header(temp); for (int i = 0; i < 8; i++) { Msg_Id[i] = initValue[index + i]; } BIConvert.DumpBytes(Msg_Id, "C:\\Submit_resp_MsgID.txt"); }
public CMPP_MSG_Header(CMPP_COMMAND_ID Command_ID) //发送前 { BIConvert.Int2Bytes((uint)Command_ID).CopyTo(initValue, 4); }
public CMPP_MSG_DELIVER(byte[] bs) { header = new CMPP_MSG_Header(bs); int index = CMPP_MSG_Header.HeaderLength; this._msgid = BitConverter.ToUInt64(bs, index); index += 8; this._destid = Encoding.ASCII.GetString(bs, index, 21); index = index + 21; this._svccode = Encoding.ASCII.GetString(bs, index, 10); index = index + 10; this._tpid = (int)bs[index++]; this._udhi = (int)bs[index++]; this._msgfmt = (int)bs[index++]; this._srctid = Encoding.ASCII.GetString(bs, index, 21); index += 21; if (bs[index++] == 1) { this._isReport = true; } else { this._isReport = false; } this._msglength = (int)bs[index++]; if (!this._isReport) { switch (this._msgfmt) { case (int)Msg_Format.ASCII: this._msg = Encoding.ASCII.GetString(bs, index, this._msglength); index += this._msglength; break; case (int)Msg_Format.BINARY: this._msg = Encoding.Default.GetString(bs, index, this._msglength); index += this._msglength; break; case (int)Msg_Format.GB2312: this._msg = Encoding.Default.GetString(bs, index, this._msglength); index += this._msglength; break; case (int)Msg_Format.UCS2: this._msg = Encoding.BigEndianUnicode.GetString(bs, index, this._msglength); index += this._msglength; break; default: break; } } else {//状态报告 this._reportForMsgid = BitConverter.ToUInt64(bs, index); index += 8; this._reportState = BitConverter.ToString(bs, index, 7); index += 7; this._submitTime = BitConverter.ToString(bs, index, 10); index += 10; this._doneTime = BitConverter.ToString(bs, index, 10); index += 10; this._reportDesttid = BitConverter.ToString(bs, index, 21); index += 21; this._smscSequence = (int)BIConvert.Bytes2UInt(bs, index); } }