Ejemplo n.º 1
0
        /// <summary>
        /// 注册音响
        /// </summary>
        /// <param name="msg">user:wali_Server type:other
        /// msg:wali_Server;8;8212;ALL;H4sIAAAAAAAAAG2RsU7DMBCG38VzVOUcN6TZGBlggBGh6ORcUkuJHdlJI1RVYmFn4ykQAyuv04G3wIlLRBHy4u/+/3y/zvd7dkPjLUljS5b3dqCIFcpf44jJrdKosSWWM5RZUiUgCKsL5qUGnasmH8s8lrTDBm3rMZDcotbULKwkzWbgsAbBIRYiSeOT1s1CEqhFOeGGryDNVlm2gpgHpUOLLN/72cZNkY7PH1+vbxEHiPz522A60pPp8+n48v6/6RCeNbZfcnbGqV4ZHaICCJHGsPlJaqmWpqTfcV2PPS3tM8E58gX7x26yXl4V16Tr0gy+rFqsw2q8AeK1LzW1myP5H+jM6Bc7nAYMjuxsHbFRxR3ZHVl2ePgGQ/XuYsMBAAA=$/r$</param>
        public static void RegSoundHost(string msg)
        {
            string msg64j = EncryptionHelp.Decrypt(msg.Split(';')[4].Replace("$/r$", ""), true);//解密"设备无法识别@打开窗帘"

            msg64j = msg64j.Replace("[", "").Replace("]", "");
            SoundHost _SoundHost = JsonConvert.DeserializeObject <SoundHost>(msg64j);//反序列化

            using (HsfDBContext hsfDBContext = new HsfDBContext())
            {
                sound_host sound_Host = new sound_host()
                {
                    id          = Guid.NewGuid().ToString(),
                    chinaname   = _SoundHost.chinaname,
                    classfid    = _SoundHost.classfid,
                    deviceid    = _SoundHost.deviceid,
                    devip       = _SoundHost.devip,
                    devmac      = _SoundHost.devmac,
                    devport     = _SoundHost.devport,
                    devposition = _SoundHost.devposition,
                    devregcode  = _SoundHost.devregcode,
                    devtype     = _SoundHost.devtype,
                    imageid     = _SoundHost.imageid,
                    lgsort      = _SoundHost.lgsort,
                    userid      = _SoundHost.userid,
                    playstate   = 1,//是否自身播放音乐状态反转,0:否,1:是
                    createtime  = DateTime.Now
                };
                hsfDBContext.sound_host.Add(sound_Host);
                hsfDBContext.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 注册音响
        /// </summary>
        /// <param name="msg">user:wali_Server type:other
        /// msg:wali_Server;8;8212;ALL;H4sIAAAAAAAAAG2RsU7DMBCG38VzVOUcN6TZGBlggBGh6ORcUkuJHdlJI1RVYmFn4ykQAyuv04G3wIlLRBHy4u/+/3y/zvd7dkPjLUljS5b3dqCIFcpf44jJrdKosSWWM5RZUiUgCKsL5qUGnasmH8s8lrTDBm3rMZDcotbULKwkzWbgsAbBIRYiSeOT1s1CEqhFOeGGryDNVlm2gpgHpUOLLN/72cZNkY7PH1+vbxEHiPz522A60pPp8+n48v6/6RCeNbZfcnbGqV4ZHaICCJHGsPlJaqmWpqTfcV2PPS3tM8E58gX7x26yXl4V16Tr0gy+rFqsw2q8AeK1LzW1myP5H+jM6Bc7nAYMjuxsHbFRxR3ZHVl2ePgGQ/XuYsMBAAA=$/r$</param>
        public static string RegSoundBinding(string msg)
        {
            string msg64j = EncryptionHelp.Decrypt(msg.Split(';')[4].Replace("$/r$", ""), true);//解密"设备无法识别@打开窗帘"

            msg64j = msg64j.Replace("[", "").Replace("]", "");
            SoundHost _SoundHost = JsonConvert.DeserializeObject <SoundHost>(msg64j);//反序列化

            if (!string.IsNullOrEmpty(_SoundHost.userid))
            {
                using (HsfDBContext hsfDBContext = new HsfDBContext())
                {
                    _SoundHost.userid = GetNewUserId_Server(_SoundHost.userid);
                    //根据音响的设备id:devmac去判断,有的话软删除,没有的话注册新增
                    var soundhostEntity = hsfDBContext.sound_host.Where(t => t.devmac == _SoundHost.devmac && t.deletemark == 0).FirstOrDefault();
                    if (soundhostEntity != null)
                    {
                        soundhostEntity.deletemark  = 1;//软删除old记录
                        soundhostEntity.modifiytime = DateTime.Now;

                        BindNewHost(hsfDBContext, _SoundHost);
                        return($"Binding OK Again");
                    }
                    else
                    {
                        BindNewHost(hsfDBContext, _SoundHost);
                        return($"Binding OK");
                    }
                }
            }
            else
            {
                return($"Binding Fail");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 绑定新的主机
        /// </summary>
        /// <param name="hsfDBContext"></param>
        /// <param name="_SoundHost"></param>
        public static void BindNewHost(HsfDBContext hsfDBContext, SoundHost _SoundHost)
        {
            sound_host sound_Host = GetNewSoundHost(_SoundHost);

            hsfDBContext.sound_host.Add(sound_Host);
            hsfDBContext.SaveChanges();
            using (RedisHashService service = new RedisHashService())
            {
                //service.Set<string>(_SoundHost.devmac, _SoundHost.userid);//缓存主机与音响的绑定关系
                service.SetEntryInHash("Sound_Host", _SoundHost.devmac, _SoundHost.userid);//缓存主机与音响的绑定关系,重复绑定覆盖
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加音响
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="_SoundHost"></param>
        /// <returns></returns>
        public static sound_host GetNewSoundHost(SoundHost _SoundHost)
        {
            sound_host sound_Host = new sound_host()
            {
                id          = Guid.NewGuid().ToString(),
                chinaname   = _SoundHost.chinaname,
                classfid    = _SoundHost.classfid,
                deviceid    = _SoundHost.deviceid,
                devip       = _SoundHost.devip,
                devmac      = _SoundHost.devmac,//音响设备id,手填
                devport     = _SoundHost.devport,
                devposition = _SoundHost.devposition,
                devregcode  = _SoundHost.devregcode,
                devtype     = _SoundHost.devtype,
                imageid     = _SoundHost.imageid,
                lgsort      = _SoundHost.lgsort,
                userid      = _SoundHost.userid, //wali_Server主机名称
                playstate   = 1,                 //是否自身播放音乐状态反转,0:否,1:是
                deletemark  = 0,                 //删除标记
                createtime  = DateTime.Now
            };

            return(sound_Host);
        }