예제 #1
0
        public ResponseData UpdateDevicePanel(DevicePanelViewModel dpvm)
        {
            ResponseData rd = new ResponseData();
            //获取设备信息
            DeviceModel dm = new DeviceService().FindDevice(dpvm.DeviceSn, dpvm.Token);

            if (dm == null)
            {
                rd.Success = false;
                rd.Message = "设备不存在";
                return(rd);
            }
            #region 验证用户权限
            bool bRet = new DeviceService().CheckDeviceAuth(dm, dpvm.Account, dpvm.Token, 2);
            if (!bRet)
            {
                rd.Success = false;
                rd.Message = "用户没有权限修改设备信息";
                return(rd);
            }
            #endregion
            DevicePanelModel dpm = _dpr.Find(dpvm.DeviceSn, dpvm.Id);
            if (dpm == null)
            {
                rd.Success = false;
                rd.Message = "该设备面板不存在";
                return(rd);
            }
            dpm.PanelName = dpvm.PanelName;
            try
            {
                _dpr.Save(dpm);
                rd.Success = true;
                rd.Message = "修改设备面板名称成功";
            }
            catch (Exception ex)
            {
                rd.Success = false;
                rd.Message = "修改设备面板失败" + ex.Message;
            }
            return(rd);
        }
예제 #2
0
        public ResponseData UpdateDeviceDataDefine(DeviceDataDefineViewModel ddvm)
        {
            ResponseData rd = new ResponseData();
            //获取设备信息
            DeviceModel dm = new DeviceService().FindDevice(ddvm.DeviceSn, ddvm.Token);

            if (dm == null)
            {
                rd.Success = false;
                rd.Message = "设备不存在";
                return(rd);
            }
            #region 验证用户权限
            bool bRet = new DeviceService().CheckDeviceAuth(dm, ddvm.Account, ddvm.Token, 2);
            if (!bRet)
            {
                rd.Success = false;
                rd.Message = "用户没有权限修改设备信息";
                return(rd);
            }
            #endregion
            var dv = _ddr.Find(ddvm.Id);
            dv.DataKey      = ddvm.DataKey;
            dv.DataName     = ddvm.DataName;
            dv.DataType     = ddvm.DataType;
            dv.DefaultValue = ddvm.DefaultValue;
            dv.Unit         = ddvm.Unit;
            try
            {
                _ddr.Save(dv);
                rd.Success = true;
                rd.Message = "修改设备定义数据成功";
            }
            catch (Exception)
            {
                rd.Success = false;
                rd.Message = "修改设备定义数据失败";
            }
            return(rd);
        }
예제 #3
0
        public ResponseData UpdateDeviceVideo(DeviceVideoViewModel dvm)
        {
            ResponseData rd = new ResponseData();
            //获取设备信息
            DeviceModel dm = new DeviceService().FindDevice(dvm.DeviceSn, dvm.Token);

            if (dm == null)
            {
                rd.Success = false;
                rd.Message = "设备不存在";
                return(rd);
            }
            #region 验证用户权限
            bool bRet = new DeviceService().CheckDeviceAuth(dm, dvm.Account, dvm.Token, 2);
            if (!bRet)
            {
                rd.Success = false;
                rd.Message = "用户没有权限修改设备信息";
                return(rd);
            }
            #endregion
            var dv = _dvr.Find(dvm.Id);
            dv.VideoName    = dvm.VideoName;
            dv.Url          = dvm.Url;
            dv.VideoSn      = dvm.VideoSn;
            dv.Channel      = dvm.Channel;
            dv.SecurityCode = dvm.SecurityCode;
            try
            {
                _dvr.Save(dv);
                rd.Success = true;
                rd.Message = "修改设备视频信息成功";
            }
            catch (Exception)
            {
                rd.Success = false;
                rd.Message = "修改设备视频信息失败";
            }
            return(rd);
        }
예제 #4
0
        public ResponseData UpdateDeviceControlData(DeviceControlDataViewModel dcdvm)
        {
            ResponseData rd = new ResponseData();
            //获取设备信息
            DeviceModel dm = new DeviceService().FindDevice(dcdvm.DeviceSn, dcdvm.Token);

            if (dm == null)
            {
                rd.Success = false;
                rd.Message = "设备不存在";
                return(rd);
            }
            #region 验证用户权限
            bool bRet = new DeviceService().CheckDeviceAuth(dm, dcdvm.Account, dcdvm.Token, 2);
            if (!bRet)
            {
                rd.Success = false;
                rd.Message = "用户没有权限修改设备信息";
                return(rd);
            }
            #endregion
            var dv = _dcdr.Find(dcdvm.Id);
            dv.ControlName  = dcdvm.ControlName;
            dv.DataValue    = dcdvm.DataValue;
            dv.DataDefineId = dcdvm.DataDefineId;
            try
            {
                _dcdr.Save(dv);
                rd.Success = true;
                rd.Message = "更新设备控制数据成功";
            }
            catch (Exception)
            {
                rd.Success = false;
                rd.Message = "更新设备控制数据失败";
            }
            return(rd);
        }
예제 #5
0
        public ResponseData DeleteDeviceImage(DeviceImageViewModel divm)
        {
            ResponseData rd = new ResponseData();
            //获取设备信息
            DeviceModel dm = new DeviceService().FindDevice(divm.DeviceSn, divm.Token);

            if (dm == null)
            {
                rd.Success = false;
                rd.Message = "设备不存在";
                return(rd);
            }
            #region 验证用户权限
            bool bRet = new DeviceService().CheckDeviceAuth(dm, divm.Account, divm.Token, 2);
            if (!bRet)
            {
                rd.Success = false;
                rd.Message = "用户没有权限修改设备信息";
                return(rd);
            }
            #endregion
            var dv = _dir.Find(divm.Id);
            try
            {
                //需要先删除图片

                _dir.Remove(dv);
                rd.Success = true;
                rd.Message = "删除图片成功";
            }
            catch (Exception)
            {
                rd.Success = false;
                rd.Message = "删除图片失败";
            }
            return(rd);
        }