Пример #1
0
        public List <SMSSendInfo> Get(string com)
        {
            List <SMSSendInfo> list      = new List <SMSSendInfo>();
            DataValues         whereArgs = new DataValues();

            whereArgs.Add("com", com);
            whereArgs.Add("dateTime", DateTime.Now.Ticks);
            whereArgs.Add("state", 0);
            using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
            {
                while (cursor.Next())
                {
                    int    sid     = cursor.GetInt("sid");
                    string phone   = cursor.GetString("phone");
                    string content = cursor.GetString("content");
                    //int state = Convert.ToInt32(row["state"]);
                    //model
                    SMSSendInfo sendInfo = new SMSSendInfo
                    {
                        Id       = sid,
                        Com      = com,
                        Phone    = phone,
                        Message  = content,
                        DateTime = DateTime.Now.Ticks,
                    };
                    list.Add(sendInfo);
                    Set(sendInfo, 1);
                }
            }
            return(list);
        }
Пример #2
0
 public void Set(SMSSendInfo sendInfo, int state)
 {
     DataValues contentValues = new DataValues();
     contentValues.Add("state", state);
     DataValues whereArgs = new DataValues();
     whereArgs.Add("SID", sendInfo.Id);
     _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
 }
Пример #3
0
        public void Set(SMSSendInfo sendInfo, int state)
        {
            DataValues contentValues = new DataValues();

            contentValues.Add("state", state);
            DataValues whereArgs = new DataValues();

            whereArgs.Add("SID", sendInfo.Id);
            _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
        }
Пример #4
0
 private void AddSend(SMSSendInfo sendInfo)
 {
     if (_dictionary.ContainsKey(sendInfo.Com))
     {
         _dictionary[sendInfo.Com].Add(sendInfo);
     }
     else
     {
         _dictionary.Add(sendInfo.Com, new List<SMSSendInfo> { sendInfo });
     }
 }
Пример #5
0
        /// <summary>
        /// Async Send
        /// </summary>
        /// <param name="com"></param>
        /// <param name="phone"></param>
        /// <param name="msg"></param>
        public void AsyncSend(string com, string phone, string msg)
        {
            SMSSendInfo sendInfo = new SMSSendInfo
            {
                Com      = com,
                Phone    = phone,
                Message  = msg,
                DateTime = DateTime.Now.Ticks
            };

            AsyncSend(sendInfo);
        }
Пример #6
0
        /// <summary>
        /// Async send message .
        /// </summary>
        /// <param name="sendInfo"></param>
        internal void AsyncSend(SMSSendInfo sendInfo)
        {
            //添加到发送队列
            _smsQueue.Enqueue(sendInfo);
            if (!_runing)
            {
                _thread = new Thread(RecursionSend);

                _runing = true;

                _thread.Start();
            }
        }
Пример #7
0
 private void AddSend(SMSSendInfo sendInfo)
 {
     if (_dictionary.ContainsKey(sendInfo.Com))
     {
         _dictionary[sendInfo.Com].Add(sendInfo);
     }
     else
     {
         _dictionary.Add(sendInfo.Com, new List <SMSSendInfo> {
             sendInfo
         });
     }
 }
Пример #8
0
 public long Add(SMSSendInfo smsInfo)
 {
     const int defaultNum = 0;
     DataValues contentValues = new DataValues();
     contentValues.Add("SID",null);
     contentValues.Add("COM",smsInfo.Com);
     contentValues.Add("PHONE",smsInfo.Phone);
     contentValues.Add("CONTENT",smsInfo.Message);
     contentValues.Add("DATETIME",smsInfo.DateTime);
     contentValues.Add("STATE",defaultNum);
     int result = _dbHelper.Insert(SMS_SEND, contentValues);
     return result;
 }
Пример #9
0
        private SMSSendInfo GetSend(string Com)
        {
            SMSSendInfo smsInfo = null;

            if (_dictionary.ContainsKey(Com))
            {
                smsInfo = _dictionary[Com].FirstOrDefault();
                if (smsInfo != null)
                {
                    _dictionary[Com].Remove(smsInfo);
                }
            }
            return(smsInfo);
        }
Пример #10
0
        /// <summary>
        /// modem received event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _gsmModem_OnRecieved(object sender, SMSEventArgs e)
        {
            SMSSendInfo smsInfo  = new SMSSendInfo();
            GsmModem    gsmModem = sender as GsmModem;

            if (gsmModem != null)
            {
                smsInfo.Com     = gsmModem.Name;
                smsInfo.Phone   = e.SmsInfo.Number;
                smsInfo.Message = e.SmsInfo.Message;
                ReceiveEventArgs args = new ReceiveEventArgs();
                args.SmsInfo = smsInfo;
                OnReceived(args);
            }
        }
Пример #11
0
        public long Add(SMSSendInfo smsInfo)
        {
            const int  defaultNum    = 0;
            DataValues contentValues = new DataValues();

            contentValues.Add("SID", null);
            contentValues.Add("COM", smsInfo.Com);
            contentValues.Add("PHONE", smsInfo.Phone);
            contentValues.Add("CONTENT", smsInfo.Message);
            contentValues.Add("DATETIME", smsInfo.DateTime);
            contentValues.Add("STATE", defaultNum);
            int result = _dbHelper.Insert(SMS_SEND, contentValues);

            return(result);
        }
Пример #12
0
        private void PublishMessage()
        {
            List <SMSEnity> list = GetAllMsg();

            foreach (SMSEnity info in list)
            {
                SMSSendInfo smsSendInfo = new SMSSendInfo
                {
                    Com     = Name,
                    Phone   = info.Number,
                    Message = info.Message
                };
                ReceiveEventArgs receiveEventArgs = new ReceiveEventArgs();
                receiveEventArgs.SmsInfo = smsSendInfo;
                OnReceived(receiveEventArgs);
            }
        }
Пример #13
0
        /// <summary>
        /// recursion get message to send.
        /// </summary>
        private void RecursionSend()
        {
            while (_runing && _smsQueue.Count > 0)
            {
                SMSSendInfo smsInfo = _smsQueue.Dequeue();
                //
                System.Console.WriteLine("弹出:{0}", smsInfo);

                string        phone         = smsInfo.Phone;
                string        message       = smsInfo.Message;
                bool          result        = SendMsg(phone, message);
                SentEventArgs sentEventArgs = new SentEventArgs();
                sentEventArgs.SmsInfo = smsInfo;
                if (result)
                {
                    sentEventArgs.Result = true;
                    OnSent(sentEventArgs);
                }
                else
                {
                    if ((++smsInfo.Reply) < _maxReply)
                    {
                        _smsQueue.Enqueue(smsInfo);
                    }
                    else
                    {
                        sentEventArgs.Result = false;
                        OnSent(sentEventArgs);
                    }
                }
                //检查SIM卡信息
                if (_smsQueue.Count == 0)
                {
                    PublishMessage();
                    //wait time set 3000
                    Thread.Sleep(3000);
                }
            }
            _runing = false;
        }
Пример #14
0
 private void PublishMessage()
 {
     List<SMSEnity> list = GetAllMsg();
     foreach (SMSEnity info in list)
     {
         SMSSendInfo smsSendInfo = new SMSSendInfo
                                       {
                                           Com = Name,
                                           Phone = info.Number,
                                           Message = info.Message
                                       };
         ReceiveEventArgs receiveEventArgs = new ReceiveEventArgs();
         receiveEventArgs.SmsInfo = smsSendInfo;
         OnReceived(receiveEventArgs);
     }
 }
Пример #15
0
 /// <summary>
 /// modem received event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _gsmModem_OnRecieved(object sender, SMSEventArgs e)
 {
     SMSSendInfo smsInfo = new SMSSendInfo();
     GsmModem gsmModem = sender as GsmModem;
     if (gsmModem != null)
     {
         smsInfo.Com = gsmModem.Name;
         smsInfo.Phone = e.SmsInfo.Number;
         smsInfo.Message = e.SmsInfo.Message;
         ReceiveEventArgs args = new ReceiveEventArgs();
         args.SmsInfo = smsInfo;
         OnReceived(args);
     }
 }
Пример #16
0
 public ReceiveEventArgs()
 {
     SmsInfo = new SMSSendInfo();
 }
Пример #17
0
 internal static void AddReceivedMessage(SMSSendInfo smsInfo)
 {
     //throw new System.NotImplementedException();
 }
Пример #18
0
 internal static void AddSendMessage(SMSSendInfo sendInfo)
 {
     SMSQueue.Instance.AddSend(sendInfo);
 }
Пример #19
0
 internal static void AddSendMessage(SMSSendInfo sendInfo)
 {
     SMSQueue.Instance.AddSend(sendInfo);
 }
Пример #20
0
 public SentEventArgs()
 {
     Result = new bool();
     SmsInfo = new SMSSendInfo();
 }
Пример #21
0
        public void AsyncSend(SMSSendInfo smsInfo)
        {
            _smsQueue.Add(smsInfo);

            InvokeEventLog(String.Format("发送:{0}", smsInfo));
        }
Пример #22
0
 /// <summary>
 /// Async Send
 /// </summary>
 /// <param name="com"></param>
 /// <param name="phone"></param>
 /// <param name="msg"></param>
 public void AsyncSend(string com, string phone, string msg)
 {
     SMSSendInfo sendInfo = new SMSSendInfo
                                {
                                    Com = com,
                                    Phone = phone,
                                    Message = msg,
                                    DateTime = DateTime.Now.Ticks
                                };
     AsyncSend(sendInfo);
 }
Пример #23
0
        /// <summary>
        /// Async send message .
        /// </summary>
        /// <param name="sendInfo"></param>
        internal void AsyncSend(SMSSendInfo sendInfo)
        {
            //添加到发送队列
            _smsQueue.Enqueue(sendInfo);
            if (!_runing)
            {
                
                _thread = new Thread(RecursionSend);

                _runing = true;

                _thread.Start();
            }
        }
Пример #24
0
 internal static void AddReceivedMessage(SMSSendInfo smsInfo)
 {
     //throw new System.NotImplementedException();
 }
Пример #25
0
 public SentEventArgs()
 {
     Result  = new bool();
     SmsInfo = new SMSSendInfo();
 }
Пример #26
0
        public void AsyncSend(SMSSendInfo smsInfo)
        {
            _smsQueue.Add(smsInfo);

            InvokeEventLog(String.Format("发送:{0}", smsInfo));
        }
Пример #27
0
 public List<SMSSendInfo> Get(string com)
 {
     List<SMSSendInfo> list = new List<SMSSendInfo>();
     DataValues whereArgs = new DataValues();
     whereArgs.Add("com",com);
     whereArgs.Add("dateTime",DateTime.Now.Ticks);
     whereArgs.Add("state", 0);
     using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
     {
         while (cursor.Next())
         {
             int sid = cursor.GetInt("sid");
             string phone = cursor.GetString("phone");
             string content = cursor.GetString("content");
             //int state = Convert.ToInt32(row["state"]);
             //model
             SMSSendInfo sendInfo = new SMSSendInfo
             {
                 Id = sid,
                 Com = com,
                 Phone = phone,
                 Message = content,
                 DateTime = DateTime.Now.Ticks,
             };
             list.Add(sendInfo);
             Set(sendInfo, 1);
         }
     }
     return list;
 }
Пример #28
0
 public ReceiveEventArgs()
 {
     SmsInfo = new SMSSendInfo();
 }