/// <summary> /// 推送短信 /// </summary> /// <param name="sms">消息</param> /// <param name="users">用户列表</param> public void Send(Model.Entity.DeviceSMS sms, List <Model.Entity.User> users) { foreach (var user in users) { this.Send(sms, user); } }
/// <summary> /// 推送短信 /// </summary> /// <param name="sms">短信</param> /// <param name="user">用户</param> public void Send(Model.Entity.DeviceSMS sms, Model.Entity.User user) { if (user == null) { return; } Model.Entity.UserNotification un = new Model.Entity.UserNotification { UserID = user.UserID, Type = 3, DeviceID = sms.DeviceID, ObjectId = sms.DeviceSMSID, Get = false, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, Notification = false }; this.NewUserNotification(un); return; #pragma warning disable CS0162 // 检测到无法访问的代码 if (user.LoginType == 2 && !string.IsNullOrEmpty(user.AppID) && user.AppID.Length == 64 && user.Notification) #pragma warning restore CS0162 // 检测到无法访问的代码 { var getList = Logic.Notification.GetInstance().GetNotificationCount(user.UserID); var getTotal = getList.Sum(s => s.Message + s.Voice + s.SMS + s.Photo); YW.Notification.Notification alert = new YW.Notification.Notification(user.AppID); alert.Payload.Alert.Body = GetNotificationDescription(8, sms); if (user.NotificationSound) { alert.Payload.Sound = "default"; } alert.Payload.CustomItems.Add("Content", new object[] { 8, sms.DeviceID, sms.Phone }); alert.UserNotification = un; alert.Payload.Badge = getTotal; this.GetServer(user.Project).QueueNotification(alert); } }
/// <summary> /// 获取一个需要发送的短信 /// </summary> /// <param name="deviceId"></param> /// <returns></returns> public Model.Entity.DeviceSMS GetOne(int deviceId) { Model.Entity.DeviceSMS deviceSms = null; const string sqlCommond = "select Top 1 * from DeviceSMS where DeviceID=@deviceId and Type=1 and (State=0 or (State=1 and datediff(s,UpdateTime,getdate())>30)) order by DeviceSMSID asc"; DbParameter[] dp = new DbParameter[] { Data.DBHelper.CreateInDbParameter("@deviceId", DbType.Int32, deviceId) }; DataSet ds = Data.DBHelper.GetInstance().ExecuteAdapter(sqlCommond, dp); var list = base.TableToList <Model.Entity.DeviceSMS>(ds); if (list.Count > 0) { deviceSms = list[0]; } return(deviceSms); }
public void Save(Model.Entity.DeviceSMS obj) { base.Save(obj); if (obj.DeviceSMSID != 0) { if (_dictionaryById.ContainsKey(obj.DeviceSMSID)) { obj.UpdateTime = DateTime.Now; if (obj != _dictionaryById[obj.DeviceSMSID]) { base.CopyValue <Model.Entity.DeviceException>(obj, _dictionaryById[obj.DeviceSMSID]); } } else { obj.CreateTime = DateTime.Now; obj.UpdateTime = DateTime.Now; _dictionaryById.Add(obj.DeviceSMSID, obj); } } }