Exemple #1
0
 /// <summary>
 /// 推送系统消息
 /// </summary>
 /// <param name="notification">消息</param>
 /// <param name="users">用户列表</param>
 public void Send(Model.Entity.Notification notification, List <Model.Entity.User> users)
 {
     if (notification.NotificationID == 0)
     {
         this.Save(notification);
     }
     foreach (var user in users)
     {
         this.Send(notification, user);
     }
 }
Exemple #2
0
        /// <summary>
        /// 推送系统消息
        /// </summary>
        /// <param name="notification">消息</param>
        /// <param name="user">用户</param>
        public void Send(Model.Entity.Notification notification, Model.Entity.User user)
        {
            if (notification.NotificationID == 0)
            {
                this.Save(notification);
            }

            if (user == null)
            {
                return;
            }

            var un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                DeviceID     = notification.DeviceID,
                Type         = notification.DeviceID == 0 ? 5 : 1,
                ObjectId     = notification.NotificationID,
                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(notification.Type,
                                                                      notification);
                if (user.NotificationSound)
                {
                    alert.Payload.Sound = "default";
                }
                alert.Payload.CustomItems.Add("Content",
                                              new object[]
                {
                    notification.Type, notification.DeviceID, notification.Content
                });
                alert.UserNotification = un;
                alert.Tag           = notification;
                alert.Payload.Badge = getTotal;
                this.GetServer(user.Project).QueueNotification(alert);
            }
        }
Exemple #3
0
        private void service_NotificationSuccess(object sender, YW.Notification.Notification notification)
        {
            //如果是绑定相关,则不设置成推送成功
            if (notification.UserNotification.Type == 1)
            {
                Model.Entity.Notification item = (Model.Entity.Notification)notification.Tag;
                if (item.Type == 2 || item.Type == 3 || item.Type == 4 || item.Type == 9)
                {
                    return;
                }
            }

            UpdateUserNotificationStatus(notification.UserNotification.UserID, notification.UserNotification.UserNotificationId, true);
            Console.WriteLine(string.Format("Notification Success: {0}", notification.ToString()));
        }
Exemple #4
0
 public void Save(Model.Entity.Notification obj)
 {
     obj.NotificationID = 0;
     base.Save(obj);
     _dictionaryById.TryAdd(obj.NotificationID, obj);
 }