Пример #1
0
        private void InitSerialPort(BasicInformation connection)
        {
            //// let the connection remains open until the server is closed/disposed
            connection.Connector.Open();

            connection.OnBeginExecuting();
 
            BaseResult<GenericTypeResult<string>> manufacturer = connection.GetManufacturer();
            if (!string.IsNullOrEmpty(manufacturer.Response.Result))
            {
                connection.GetServiceCenter();
                connection.SetErrorMessageFormat(1);
                connection.GetOperator();

                PhoneBook pb = new PhoneBook(connection);
                pb.SetPhoneBookMemory(MemoryStorage.SIMOwnNumber);
                pb.GetInfo();

                SMS sms = new SMS(connection);
                sms.SetMessageStorage(MemoryStorage.MobilePhonebook, MemoryStorage.MobilePhonebook, MemoryStorage.MobilePhonebook);
                sms.SetMessageFormat(connection.PDUMode);

                string prefixOwnNumber = string.Empty;
                if (string.IsNullOrEmpty(prefixOwnNumber))
                {
                    GSMServer.Configuration.IConfiguration configuration = ObjectPool.Instance.Resolve<GSMServer.Configuration.IConfiguration>();
                    prefixOwnNumber = ((ApplicationSettings)configuration).General.PrefixOwnNumber;
                }

                BaseResult<GenericTypeResult<List<PhoneNumberInfo>>> list = pb.ReadPhoneBook(MemoryStorage.SIMOwnNumber, 1, -1);
                if (list.Response.Result.Count > 0)
                {
                    foreach (PhoneNumberInfo info in list.Response.Result)
                    {
                        if (info.Name.Equals(prefixOwnNumber))
                        {
                            connection.OwnNumber = info.PhoneNumber;
                            break;
                        }
                    }
                }
                portColletion.Add(connection);
            }
            connection.OnEndExecuting();
        }