public string GetPinInfo(string newLockId, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } Dictionary <string, string> ret = new Dictionary <string, string>(); try { NewLockManager managerNew = new NewLockManager(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); string returnFiled = managerNew.checkIsNullFild(dic); if (returnFiled != string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "字段" + returnFiled + "不允许为空!"); return(JSONHelper.ToJson(ret)); } //判断是否授权 if (managerNew.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!managerNew.GetIsInterfacePermissions("4", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断是否已经获取网关地址 string sql = "select * from Rent_NewLock_Process where NewLockID='" + newLockId + "'"; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count <= 0) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); return(JSONHelper.ToJson(ret)); } if (dt.Rows[0]["GatewayId"].ToString() == "" || dt.Rows[0]["DevKey"].ToString() == "" || dt.Rows[0]["IsCreateGateway"].ToString() == "") { ret.Add("ret", "1"); ret.Add("msg", "请先配置好网关,在获取PIN码"); return(JSONHelper.ToJson(ret)); } //添加pin码 string addLockInfo = managerNew.createAddLock(dt.Rows[0]["GatewayId"].ToString(), newLockId); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(addLockInfo); if (returnInfo["ret"].ToString() == "0") { ret.Add("ret", "0"); } else { ret.Add("ret", "1"); } ret.Add("msg", returnInfo["msg"].ToString()); } catch (Exception ex) { ret.Add("ret", "1"); ret.Add("msg", ex.Message); } return(JSONHelper.ToJson(ret)); }