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); }
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); }
private void AddSend(SMSSendInfo sendInfo) { if (_dictionary.ContainsKey(sendInfo.Com)) { _dictionary[sendInfo.Com].Add(sendInfo); } else { _dictionary.Add(sendInfo.Com, new List<SMSSendInfo> { sendInfo }); } }
/// <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); }
/// <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(); } }
private void AddSend(SMSSendInfo sendInfo) { if (_dictionary.ContainsKey(sendInfo.Com)) { _dictionary[sendInfo.Com].Add(sendInfo); } else { _dictionary.Add(sendInfo.Com, new List <SMSSendInfo> { sendInfo }); } }
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; }
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); }
/// <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 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); }
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); } }
/// <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; }
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); } }
public ReceiveEventArgs() { SmsInfo = new SMSSendInfo(); }
internal static void AddReceivedMessage(SMSSendInfo smsInfo) { //throw new System.NotImplementedException(); }
internal static void AddSendMessage(SMSSendInfo sendInfo) { SMSQueue.Instance.AddSend(sendInfo); }
public SentEventArgs() { Result = new bool(); SmsInfo = new SMSSendInfo(); }
public void AsyncSend(SMSSendInfo smsInfo) { _smsQueue.Add(smsInfo); InvokeEventLog(String.Format("发送:{0}", smsInfo)); }
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; }