示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EmiService"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 public EmiService(SmsServer server)
 {
     ReferredServer = server;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EmiProtocol"/> class.
        /// </summary>
        /// <param name="trame">The original RAW trame of the current message, starts with STX charactor and ends with ETX charactor</param>
        /// <param name="server">The server.</param>
        public EmiProtocol(string trame, SmsServer server)
        {
            if (referedServer == null)
            {
                referedServer = server;
            }
            OriginalTrame = trame;
            string[] pairs = trame.Split(SEP);
            TRN = pairs[0].Substring(1);
            LRN = pairs[1];
            OR  = pairs[2].ToUpper();
            OT  = pairs[3];

            if (OR == "O")
            {
                // OPERATION
                switch (OT)
                {
                case "51":
                    AdC  = pairs[4];
                    OAdC = pairs[5];
                    AC   = pairs[6];
                    NRq  = pairs[7];
                    NAdC = pairs[8];
                    NT   = pairs[9];
                    NPID = pairs[10];
                    LRq  = pairs[11];
                    LRAd = pairs[12];
                    LPID = pairs[13];
                    DD   = pairs[14];
                    DDT  = pairs[15];
                    VP   = pairs[16];
                    RPID = pairs[17];
                    MT   = pairs[22];
                    NB   = pairs[23];
                    AMsg = pairs[24];
                    NMsg = pairs[24];
                    TMsg = pairs[24];
                    MMS  = pairs[25];
                    PR   = pairs[26];
                    MCLs = pairs[28];
                    RPI  = pairs[29];
                    OTOA = pairs[32];
                    XSer = pairs[34];
                    break;

                case "60":
                    OAdC = pairs[4];
                    OTON = pairs[5];
                    ONPI = pairs[6];
                    STYP = pairs[7];
                    PWD  = System.Text.ASCIIEncoding.ASCII.GetString(HexStringToByteArray(pairs[8]));
                    NPWD = System.Text.ASCIIEncoding.ASCII.GetString(HexStringToByteArray(pairs[9]));
                    VERS = pairs[10];
                    OPID = pairs[14];
                    break;
                }
            }
            else
            {
                // RESPONSE Nothing to do.
            }
        }