/// <summary> /// 更新ClientSmokeDetector信息 /// </summary> public static void UpdateClientSmokeDetector(ClientSmokeDetector entity) { DataCommand cmd = new DataCommand("UpdateClientSmokeDetector"); cmd.SetParameter <ClientSmokeDetector>(entity); cmd.ExecuteNonQuery(); }
public static int InsertClientSmokeDetector(ClientSmokeDetector entity) { DataCommand cmd = new DataCommand("InsertClientSmokeDetector"); cmd.SetParameter <ClientSmokeDetector>(entity); return(cmd.ExecuteScalar <int>()); }
///// <summary> ///// 更新ClientSmokeDetector信息 ///// </summary> //public static void UpdateClientSmokeDetector(ClientSmokeDetector entity) //{ // CheckClientSmokeDetector(entity,false); // ClientSmokeDetectorDA.UpdateClientSmokeDetector(entity); //} ///// <summary> ///// 删除ClientSmokeDetector信息 ///// </summary> //public static void DeleteClientSmokeDetector(int sysNo) //{ // ClientSmokeDetectorDA.DeleteClientSmokeDetector(sysNo); //} ///// <summary> ///// 分页查询ClientSmokeDetector信息 ///// </summary> //public static QueryResult<ClientSmokeDetector> QueryClientSmokeDetectorList(QF_ClientSmokeDetector filter) //{ // return ClientSmokeDetectorDA.QueryClientSmokeDetectorList(filter); //} /// <summary> /// 检查ClientSmokeDetector信息 /// </summary> private static void CheckClientSmokeDetector(ClientSmokeDetector entity, bool isCreate) { if (!isCreate && entity.SysNo == 0) { throw new BusinessException(LangHelper.GetText("请传入数据主键!")); } if (string.IsNullOrWhiteSpace(entity.SmokeDetectorCode)) { throw new BusinessException(LangHelper.GetText("烟感器编码不能为空!")); } if (entity.SmokeDetectorCode.Length > 32) { throw new BusinessException(LangHelper.GetText("烟感器编码长度不能超过32!")); } if (entity.CellPhone != null && entity.CellPhone.Length > 15) { throw new BusinessException(LangHelper.GetText("手机1长度不能超过15!")); } if (entity.CellPhone2 != null && entity.CellPhone2.Length > 15) { throw new BusinessException(LangHelper.GetText("手机2长度不能超过15!")); } if (entity.CellPhone3 != null && entity.CellPhone3.Length > 15) { throw new BusinessException(LangHelper.GetText("手机3长度不能超过15!")); } }
/// <summary> /// 获取单个ClientSmokeDetector信息 /// </summary> public static ClientSmokeDetector LoadClientSmokeDetector(int sysNo) { DataCommand cmd = new DataCommand("LoadClientSmokeDetector"); cmd.SetParameter("@SysNo", DbType.Int32, sysNo); ClientSmokeDetector result = cmd.ExecuteEntity <ClientSmokeDetector>(); return(result); }
/// <summary> /// 创建ClientSmokeDetector信息 /// </summary> public static int InsertClientSmokeDetector(ClientSmokeDetector entity) { CheckClientSmokeDetector(entity, true); return(ClientSmokeDetectorDA.InsertClientSmokeDetector(entity)); }
public static int InsertClientSmokeDetector(ClientSmokeDetector entity) { return(SmokeDetectorDA.InsertClientSmokeDetector(entity)); }
public ActionResult BindingDevicesApi(string serID) { if (string.IsNullOrEmpty(serID)) { throw new BusinessException("读取设备id失败,请重新扫描"); } var user = ClientService.LoadClient(curentUser.UserSysNo); if (user == null) { UserMgr.Logout(); throw new BusinessException("登录信息已过期,请退出重新进入公众号"); } var ClientSmokeDetectorList = ClientSmokeDetectorProcessor.LoadAllBindClientUser(serID); var temp = ClientSmokeDetectorList.Find(e => string.Equals(e.ClientSysNo, curentUser.UserSysNo)); if (temp != null) { throw new BusinessException("你已绑定过当前设备"); } if (ClientSmokeDetectorList.Count > 0) { throw new BusinessException($"设备已经绑定到“{ClientSmokeDetectorList.FirstOrDefault().Name}”,不能再次绑定"); } var smoke = SmokeDetectorServices.LoadSmokeDetail(serID); if (smoke == null || string.IsNullOrEmpty(smoke.AddressCode) || smoke.Status == SmokeDetectorStatus.Delete) { return(Json(new AjaxResult { Success = true, Code = 1, Message = "设备还未安装入网,请添加设备,如果您是公司用户,请绑定管理员!" })); // throw new BusinessException("设备还未安装入网"); } if (user != null) { ClientSmokeDetector clientSmokeDetector = new ClientSmokeDetector { ClientSysNo = user.SysNo, SmokeDetectorCode = serID, IsDefaultCellPhone = true, CellPhone = user.CellPhone, CellPhone2 = user.CellPhone2, CellPhone3 = user.CellPhone3 }; ClientSmokeDetectorProcessor.InsertClientSmokeDetector(clientSmokeDetector); List <MessageCenter.Entity.ReceiverInfo> receivers = new List <MessageCenter.Entity.ReceiverInfo> { new MessageCenter.Entity.ReceiverInfo { ReceiverNo = user.AppCustomerID, MsgType = MessageCenter.Entity.MsgType.WeiXin } }; var cellphone = clientSmokeDetector.CellPhone ?? clientSmokeDetector.CellPhone2 ?? clientSmokeDetector.CellPhone3 ?? null; if (!string.IsNullOrEmpty(cellphone)) { receivers.Add(new MessageCenter.Entity.ReceiverInfo { ReceiverNo = cellphone, MsgType = MessageCenter.Entity.MsgType.SMS }); } Task.Factory.StartNew(() => { WechatUserBindDevicesTemplate wechatUserBind = new WechatUserBindDevicesTemplate { Title = $"尊敬的{HttpUtility.UrlDecode(curentUser.UserID)}用户", SerID = serID, BindResult = "绑定成功", BindTimeStr = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"), Memo = $"此设备地址为{smoke.AddressName}", // Url = $"http://tfs-code2.chinacloudapp.cn//Smoke/Notice?code= {serID}", MasterID = serID, DateStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),//短信通知时间 Address = smoke.AddressName, }; if (smoke.InstallerSysNo.HasValue && smoke.InstallerSysNo < 0) { wechatUserBind.Address = smoke.Position; wechatUserBind.Memo = smoke.Position; } SendMessageService.SendMessageOnce(wechatUserBind, receivers); }); } return(Json(new AjaxResult { Success = true })); }