Esempio n. 1
0
 /// <summary>
 /// 推送语音信息
 /// </summary>
 /// <param name="voice">语音</param>
 /// <param name="users">用户列表</param>
 public void Send(Model.Entity.DeviceVoice voice, List <Model.Entity.User> users)
 {
     foreach (var user in users)
     {
         this.Send(voice, user);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 推送语音信息
        /// </summary>
        /// <param name="voice">语音</param>
        /// <param name="user">用户</param>
        public void Send(Model.Entity.DeviceVoice voice, Model.Entity.User user)
        {
            if (user == null || voice == null)
            {
                return;
            }

            Model.Entity.UserNotification un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                Type         = 2,
                DeviceID     = voice.DeviceID,
                ObjectId     = voice.DeviceVoiceId,
                Get          = false,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Notification = false
            };
            if (voice.Type == 3 && user.UserID == voice.ObjectId) //如果是自己发的,则不通知自己
            {
                un.Notification = true;
            }
            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(1, voice);
                if (user.NotificationSound)
                {
                    alert.Payload.Sound = "default";
                }
                alert.Payload.CustomItems.Add("Content",
                                              new object[] { 1, voice.DeviceID, "" });

                alert.UserNotification = un;
                alert.Payload.Badge    = getTotal;
                this.GetServer(user.Project).QueueNotification(alert);
            }
        }
Esempio n. 3
0
        public Model.Entity.DeviceVoice GetNewOne(int deviceId) //Get one Devices
        {
            //状态 0 正在接收 1接收完成 2正在发送 3 发送完成
            Model.Entity.DeviceVoice obj = null;
            const string             sql =
                "SELECT Top 1 * FROM Devicevoice WHERE DeviceId = @DeviceId and (Type=3 or Type =4) AND (State=1 or State=2 or State=4) order by CreateTime asc";

            DbParameter[] commandParameters = new DbParameter[]
            {
                DBHelper.CreateInDbParameter("@DeviceId", DbType.Int32, deviceId),
            };
            var ds   = DBHelper.GetInstance().ExecuteAdapter(CommandType.Text, sql, commandParameters);
            var list = base.TableToList <Model.Entity.DeviceVoice>(ds);

            if (list.Count > 0)
            {
                obj = list[0];
            }
            return(obj);
        }
Esempio n. 4
0
 public void Save(Model.Entity.DeviceVoice obj)
 {
     base.Save(obj);
     if (obj.DeviceVoiceId != 0)
     {
         if (_dictionaryById.ContainsKey(obj.DeviceVoiceId))
         {
             obj.UpdateTime = DateTime.Now;
             if (obj != _dictionaryById[obj.DeviceVoiceId])
             {
                 base.CopyValue <Model.Entity.DeviceVoice>(obj, _dictionaryById[obj.DeviceVoiceId]);
             }
         }
         else
         {
             obj.CreateTime = DateTime.Now;
             obj.UpdateTime = DateTime.Now;
             _dictionaryById.Add(obj.DeviceVoiceId, obj);
         }
     }
 }
Esempio n. 5
0
        public Model.Entity.DeviceVoice GetByDeviceIdAndMark(int deviceId, string mark)
        {
            Model.Entity.DeviceVoice obj = new Model.Entity.DeviceVoice();
            const string             sql =
                "select top 1 [DeviceVoice].DeviceVoiceID from [DeviceVoice] where [DeviceVoice].[DeviceId]=@DeviceId and [DeviceVoice].[Mark]=@Mark and ([DeviceVoice].[Type]=2 or [DeviceVoice].[Type]=4)";

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

            if (deviceVoiceId != null)
            {
                return(this.Get((int)deviceVoiceId));
            }
            else
            {
                return(null);
            }
        }