예제 #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();
 }