Esempio n. 1
0
        /// <summary>
        /// Get phonebook memory storage
        /// </summary>
        public BaseResult <GenericTypeResult <PhoneBookInfo> > GetInfo()
        {
            string        response = "";
            PhoneBookInfo info     = null;
            BaseResult <GenericTypeResult <PhoneBookInfo> > ret = new BaseResult <GenericTypeResult <PhoneBookInfo> >();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connection.Connector.Execute(Command.Get(Commands.CPBS));
            s.Stop();

            Match match = new Regex(@"\+CPBS: " + (char)34 + "(.*[A-Z].*)" + (char)34 + @",(\d+),(\d+)").Match(response);

            if (match.Success)
            {
                info           = new PhoneBookInfo();
                info.Memory    = match.Groups[1].Value;
                info.Used      = Convert.ToInt32(match.Groups[2].Value);
                info.Available = Convert.ToInt32(match.Groups[3].Value);
                response       = Connection.Connector.Execute(Command.Check(Commands.CPBR));
                match          = new Regex(@"\+CPBR: \((.*[0-9-].*)\),(\d+),(\d+)").Match(response);
                if (match.Success)
                {
                    info.MaxLengthPhoneNumber = Convert.ToInt32(match.Groups[2].Value);
                    info.MaxLengthName        = Convert.ToInt32(match.Groups[3].Value);
                }
                ret.Response.Result = info;
            }
            ret.ExecutionTime = s.Elapsed;
            return(ret);
        }
Esempio n. 2
0
        /// <summary>
        /// Get phonebook memory storage
        /// </summary> 
        public BaseResult<GenericTypeResult<PhoneBookInfo>> GetInfo()
        { 
            string response = ""; 
            PhoneBookInfo info = null;
            BaseResult<GenericTypeResult<PhoneBookInfo>> ret = new BaseResult<GenericTypeResult<PhoneBookInfo>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connection.Connector.Execute(Command.Get(Commands.CPBS));
            s.Stop();

            Match match = new Regex(@"\+CPBS: " + (char)34 + "(.*[A-Z].*)" + (char)34 + @",(\d+),(\d+)").Match(response);
            if (match.Success)
            {
                info = new PhoneBookInfo();
                info.Memory = match.Groups[1].Value;
                info.Used = Convert.ToInt32(match.Groups[2].Value);
                info.Available = Convert.ToInt32(match.Groups[3].Value);
                response = Connection.Connector.Execute(Command.Check(Commands.CPBR));
                match = new Regex(@"\+CPBR: \((.*[0-9-].*)\),(\d+),(\d+)").Match(response);
                if (match.Success)
                {
                    info.MaxLengthPhoneNumber = Convert.ToInt32(match.Groups[2].Value);
                    info.MaxLengthName = Convert.ToInt32(match.Groups[3].Value);
                }
                ret.Response.Result = info;
            }
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }