/// <summary> /// 推送报警 /// </summary> /// <param name="ex">报警</param> /// <param name="users">用户列表</param> public void Send(Model.Entity.DeviceException ex, List <Model.Entity.User> users) { foreach (var user in users) { this.Send(ex, user); } }
/// <summary> /// 推送报警 /// </summary> /// <param name="ex">报警</param> /// <param name="user">用户</param> public void Send(Model.Entity.DeviceException ex, Model.Entity.User user) { if (user == null) { return; } Model.Entity.UserNotification un = new Model.Entity.UserNotification { UserID = user.UserID, Type = 4, DeviceID = ex.DeviceID, ObjectId = ex.DeviceExceptionID, 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(ex.Type, ex); if (user.NotificationSound) { alert.Payload.Sound = "default"; } alert.Payload.CustomItems.Add("Content", new object[] { ex.Type, ex.DeviceID, "" }); alert.UserNotification = un; alert.Payload.Badge = getTotal; this.GetServer(user.Project).QueueNotification(alert); } }
public void Save(Model.Entity.DeviceException obj) { base.Save(obj); if (obj.DeviceExceptionID != 0) { if (_dictionaryById.ContainsKey(obj.DeviceExceptionID)) { if (obj != _dictionaryById[obj.DeviceExceptionID]) { base.CopyValue <Model.Entity.DeviceException>(obj, _dictionaryById[obj.DeviceExceptionID]); } } else { obj.CreateTime = DateTime.Now; _dictionaryById.Add(obj.DeviceExceptionID, obj); } } }