예제 #1
0
        public ActionResult UpdateSmokeInfo(string code, string newDeviceID, string addressSysNo, string position)
        {
            if (addressSysNo == null)
            {
                throw new BusinessException("位置信息错误,请重新选择后再试。");
            }
            int sysNo = int.Parse(addressSysNo);

            if (sysNo == 0)
            {
                throw new BusinessException("位置信息错误,请重新选择后再试。");
            }
            Address address = AddressService.LoadAddress(sysNo);

            if (address == null)
            {
                throw new BusinessException("位置信息错误,请重新选择后再试。");
            }
            if (string.IsNullOrWhiteSpace(newDeviceID))
            {
                throw new BusinessException("请填写ONENET编号!。");
            }
            SmokeDetector result = SmokeDetectorServices.LoadSmokeDetectorByDeviceID(newDeviceID);

            if (result != null && result.Code != code)
            {
                throw new BusinessException("已存在该ONENET编号!。");
            }
            SmokeDetector smoke = SmokeDetectorServices.IsUniquenessCode(code);

            if (smoke != null)
            {
                //List<Address> addressList = AddressService.LoadSubsetAddressByAddressSysNo(smoke.CompanySysNo, sysNo);
                //if (addressList != null && addressList.Count > 0)
                //{
                //    throw new BusinessException("请选择详细地址!。");
                //}
                smoke.DeviceId    = newDeviceID;
                smoke.AddressCode = address.Code;
                smoke.AddressName = address.PathName;
                smoke.Position    = position;
                SmokeDetectorServices.UpdateSmokeDetector(smoke);
                return(Json(new AjaxResult()
                {
                    Success = true
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new AjaxResult()
                {
                    Success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }