Ejemplo n.º 1
0
        public List <DecodedMessage> GetUnreadMsg()
        {
            List <DecodedMessage> list = new List <DecodedMessage>();

            string[] strArray = null;
            string   str      = string.Empty;
            string   str2     = this.SendAT("AT+CMGL=0");
            bool     flag     = str2.Contains("OK");

            if (flag)
            {
                strArray = str2.Split(new char[]
                {
                    '\r'
                });
            }
            PDUEncoding pduEncoding = new PDUEncoding();

            string[] array = strArray;
            for (int i = 0; i < array.Length; i++)
            {
                string strPDU = array[i];
                bool   flag2  = strPDU != null && strPDU.Length > 18;
                if (flag2)
                {
                    list.Add(pduEncoding.PDUDecoder(strPDU));
                }
            }
            return(list);
        }
Ejemplo n.º 2
0
        public DecodedMessage ReadMsgByIndex(int index)
        {
            string      str         = string.Empty;
            PDUEncoding pduEncoding = new PDUEncoding();
            string      str2;

            try
            {
                str2 = this.SendAT("AT+CMGR=" + index.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            bool flag = str2.Trim() == "ERROR";

            if (flag)
            {
                throw new Exception("没有此短信");
            }
            string strPDU = str2.Split(new char[]
            {
                '\r'
            })[2];
            bool autoDelMsg = this.AutoDelMsg;

            if (autoDelMsg)
            {
                try
                {
                    this.DeleteMsgByIndex(index);
                }
                catch
                {
                }
            }
            return(pduEncoding.PDUDecoder(strPDU));
        }