예제 #1
0
        public ActionResult DeleteDetector(string code, bool isdelete)
        {
            SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code);

            if (detector == null)
            {
                throw new BusinessException(string.Format("编号为【{0}】的设备不存在", code));
            }

            if (isdelete)
            {
                DeleteDeviceRequest send = new DeleteDeviceRequest()
                {
                    DeviceID = detector.DeviceId
                };
                DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send);
                SmokeDetectorServices.DeleteSmokeDetector(detector, CurrUser);
                SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code);
                return(Json(new AjaxResult()
                {
                    Success = true
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                DeleteDeviceRequest send = new DeleteDeviceRequest()
                {
                    DeviceID = detector.DeviceId
                };
                DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send);
                if (sendRes.IsSuccess)
                {
                    //更新本地设备状态
                    SmokeDetectorServices.DeleteSmokeDetector(detector, CurrUser);
                    SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code);
                    return(Json(new AjaxResult()
                    {
                        Success = true
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new AjaxResult()
                    {
                        Success = false, Message = "删除失败,ONENET平台返回消息:" + sendRes.msg
                    }, JsonRequestBehavior.AllowGet));
                }
            }
        }
예제 #2
0
        public JsonResult DeleteDetector(string code)
        {
            //if (curentUser.UserType != UserType.Installer)
            //{
            //    throw new BusinessException("您不是安装人员,不能删除当前设备");
            //}
            SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code);

            if (detector == null)
            {
                throw new BusinessException(string.Format("编号为【{0}】的设备不存在", code));
            }
            if (curentUser.UserType == UserType.Installer)
            {
                if (detector.InstallerSysNo != curentUser.ManagerSysNo)
                {
                    throw new BusinessException("您没有安装过当前设备,无权删除");
                }
            }
            else
            {
                if (detector.InstallerSysNo != -curentUser.UserSysNo)
                {
                    throw new BusinessException("您没有安装过当前设备,无权删除");
                }
            }

            DeleteDeviceRequest send = new DeleteDeviceRequest()
            {
                DeviceID = detector.DeviceId
            };
            DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send);
            CurrentUser         current = new CurrentUser
            {
                UserSysNo       = curentUser.UserSysNo,
                UserDisplayName = curentUser.UserDisplayName
            };

            SmokeDetectorServices.DeleteSmokeDetector(detector, current);
            SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code);
            return(Json(new AjaxResult()
            {
                Success = true
            }, JsonRequestBehavior.AllowGet));
        }