Ejemplo n.º 1
0
        public void RequestMessage(object state)
        {
            System.Collections.Generic.Dictionary<string, SMSSender>.ValueCollection valueCollection = _smsPool.Values;
            SMSSender[] smsSenders = new SMSSender[valueCollection.Count];
            valueCollection.CopyTo(smsSenders,0);
            foreach (SMSSender smsSender in smsSenders)
            {
                InvokeEventLog(String.Format("请求数据:{0}", smsSender.Name));
                List<SMSSendInfo> list = _smsQueue.Get(smsSender.Name);
                foreach (SMSSendInfo smsSendInfo in list)
                {
                    smsSender.AsyncSend(smsSendInfo);

                    InvokeEventLog(String.Format("压入:{0}", smsSendInfo));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add SMS Modem to SMS Modem Pool.
        /// 根据指定的 COM 端口标志和波特率创建发送器并返回该对象
        /// </summary>
        /// <param name="port"></param>
        /// <param name="bute"></param>
        public SMSSender CreateModem(string port, int bute)
        {
            SMSSender smsSender = new SMSSender(port,bute);
            if (smsSender.Init())
            {
                smsSender.Sent += smsSender_Sent;
                smsSender.Received += smsSender_Received;
                //
                if(!_smsPool.ContainsKey(port))
                {
                    _smsPool.Add(port, smsSender);
                }

                InvokeEventLog(String.Format("插入设备:{0},{1}",port,bute));

                _ports.Remove(port);
            }
            else
            {
                InvokeEventLog(String.Format("初始化失败:{0}", port));

                return null;
            }
            return smsSender;
        }