wzp
2021-07-28 864986e4cad03f6b9bba9a7e65379db496b62a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
namespace AsiaINFO.SMS.CMPP2
{
    using System;
    using System.Text;
 
    public class CMPP_Msg_Content
    {
        private string _Dest_terminal_Id;
        private string _Done_time;
        private string _Msg_Id;
        private uint _SMSC_sequence;
        private string _Stat;
        private string _Submit_time;
        public const int BodyLength = 60;
 
        public CMPP_Msg_Content(byte[] bytes)
        {
            if (bytes.Length >= 60)
            {
                int srcOffset = 0;
                byte[] dst = new byte[8];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                this._Msg_Id = BitConverter.ToString(dst);
                srcOffset += 8;
                dst = new byte[7];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                this._Stat = Encoding.ASCII.GetString(dst);
                srcOffset += 7;
                dst = new byte[10];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                this._Submit_time = Encoding.ASCII.GetString(dst);
                srcOffset += 10;
                dst = new byte[10];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                this._Submit_time = Encoding.ASCII.GetString(dst);
                srcOffset += 10;
                dst = new byte[(bytes.Length - srcOffset) - 4];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                string str = Encoding.ASCII.GetString(dst).Trim();
                if (str.IndexOf('\0') > 0)
                {
                    str = str.Substring(0, str.IndexOf('\0'));
                }
                if (((str != null) && (str.Length > 11)) && (str.Substring(0, 2) == "86"))
                {
                    str = str.Substring(2, str.Length - 2);
                }
                this._Dest_terminal_Id = str;
                srcOffset += dst.Length;
                dst = new byte[4];
                Buffer.BlockCopy(bytes, srcOffset, dst, 0, dst.Length);
                Array.Reverse(dst);
                this._SMSC_sequence = BitConverter.ToUInt32(dst, 0);
            }
        }
 
        public override string ToString()
        {
            return string.Format("[\r\nMessageBody:\r\n\tBodyLength: {0}\r\n\tDest_terminal_Id: {1}\r\n\tDone_time: {2}\r\n\tMsg_Id: {3}\r\n\tSMSC_sequence: {4}\r\n\tStat: {5}\r\n\tSubmit_time: {6}\r\n]", new object[] { 60, this._Dest_terminal_Id, this._Done_time, this._Msg_Id, this._SMSC_sequence, this._Stat, this._Submit_time });
        }
 
        public string Dest_terminal_Id
        {
            get
            {
                return this._Dest_terminal_Id;
            }
        }
 
        public string Done_time
        {
            get
            {
                return this._Done_time;
            }
        }
 
        public string Msg_Id
        {
            get
            {
                return this._Msg_Id;
            }
        }
 
        public uint SMSC_sequence
        {
            get
            {
                return this._SMSC_sequence;
            }
        }
 
        public string Stat
        {
            get
            {
                return this._Stat;
            }
        }
 
        public string Submit_time
        {
            get
            {
                return this._Submit_time;
            }
        }
    }
}