示例#1
0
 /// <summary>
 /// 推送相片信息
 /// </summary>
 /// <param name="photo">语音</param>
 /// <param name="users">用户列表</param>
 public void Send(Model.Entity.DevicePhoto photo, List <Model.Entity.User> users)
 {
     foreach (var user in users)
     {
         this.Send(photo, user);
     }
 }
示例#2
0
        /// <summary>
        /// 推送相片信息
        /// </summary>
        /// <param name="photo">语音</param>
        /// <param name="user">用户</param>
        public void Send(Model.Entity.DevicePhoto photo, Model.Entity.User user)
        {
            if (user == null)
            {
                return;
            }

            Model.Entity.UserNotification un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                Type         = 7,
                DeviceID     = photo.DeviceID,
                ObjectId     = photo.DevicePhotoId,
                Get          = false,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Notification = false
            };
            this.NewUserNotification(un);
            return;

#pragma warning disable CS0162 // 检测到无法访问的代码
            if (!un.Notification && 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(11, photo);
                if (user.NotificationSound)
                {
                    alert.Payload.Sound = "default";
                }
                alert.Payload.CustomItems.Add("Content",
                                              new object[] { 11, photo.DeviceID, "" });
                alert.UserNotification = un;
                alert.Payload.Badge    = getTotal;
                this.GetServer(user.Project).QueueNotification(alert);
            }
        }
示例#3
0
        public Model.Entity.DevicePhoto GetByDeviceIdAndMark(int deviceId, string mark)
        {
            Model.Entity.DevicePhoto obj = new Model.Entity.DevicePhoto();
            const string             sql =
                "select top 1 [DevicePhoto].DevicePhotoID from [DevicePhoto] where [DevicePhoto].[DeviceId]=@DeviceId and [DevicePhoto].[Mark]=@Mark";

            DbParameter[] commandParameters = new DbParameter[]
            {
                Data.DBHelper.CreateInDbParameter("@DeviceId", DbType.Int32, deviceId),
                Data.DBHelper.CreateInDbParameter("@Mark", DbType.String, mark)
            };
            var devicePhotoId = Data.DBHelper.GetInstance().ExecuteScalar(CommandType.Text, sql, commandParameters);

            if (devicePhotoId != null)
            {
                return(this.Get((int)devicePhotoId));
            }
            else
            {
                return(null);
            }
        }
示例#4
0
 public void Save(Model.Entity.DevicePhoto obj)
 {
     base.Save(obj);
     if (obj.DevicePhotoId != 0)
     {
         lock (_dictionaryById)
         {
             if (_dictionaryById.ContainsKey(obj.DevicePhotoId))
             {
                 obj.UpdateTime = DateTime.Now;
                 if (obj != _dictionaryById[obj.DevicePhotoId])
                 {
                     base.CopyValue <Model.Entity.DevicePhoto>(obj, _dictionaryById[obj.DevicePhotoId]);
                 }
             }
             else
             {
                 obj.CreateTime = DateTime.Now;
                 obj.UpdateTime = DateTime.Now;
                 _dictionaryById.Add(obj.DevicePhotoId, obj);
             }
         }
     }
 }