Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
        }
Beispiel #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 });
     }
 }
Beispiel #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);
        }
Beispiel #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();
            }
        }
Beispiel #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
         });
     }
 }
Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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;
        }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
 public ReceiveEventArgs()
 {
     SmsInfo = new SMSSendInfo();
 }
Beispiel #17
0
 internal static void AddReceivedMessage(SMSSendInfo smsInfo)
 {
     //throw new System.NotImplementedException();
 }
Beispiel #18
0
 internal static void AddSendMessage(SMSSendInfo sendInfo)
 {
     SMSQueue.Instance.AddSend(sendInfo);
 }
Beispiel #19
0
 internal static void AddSendMessage(SMSSendInfo sendInfo)
 {
     SMSQueue.Instance.AddSend(sendInfo);
 }
 public SentEventArgs()
 {
     Result = new bool();
     SmsInfo = new SMSSendInfo();
 }
Beispiel #21
0
        public void AsyncSend(SMSSendInfo smsInfo)
        {
            _smsQueue.Add(smsInfo);

            InvokeEventLog(String.Format("发送:{0}", smsInfo));
        }
 /// <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);
 }
Beispiel #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();
            }
        }
Beispiel #24
0
 internal static void AddReceivedMessage(SMSSendInfo smsInfo)
 {
     //throw new System.NotImplementedException();
 }
Beispiel #25
0
 public SentEventArgs()
 {
     Result  = new bool();
     SmsInfo = new SMSSendInfo();
 }
        public void AsyncSend(SMSSendInfo smsInfo)
        {
            _smsQueue.Add(smsInfo);

            InvokeEventLog(String.Format("发送:{0}", smsInfo));
        }
Beispiel #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;
 }
Beispiel #28
0
 public ReceiveEventArgs()
 {
     SmsInfo = new SMSSendInfo();
 }