public string NewOpenDoor(string newLockId, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); dic.Add("UserId", userId); 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("9", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } string lockId = managerNew.getDeviceID(newLockId, "DeviceID"); if (lockId == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); return(JSONHelper.ToJson(ret)); } //开锁 string open = managerNew.openDoorSDK(lockId, userId); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(open); if (returnInfo["ret"].ToString() == "0") { ret.Add("ret", "0"); } else { ret.Add("ret", "1"); } ret.Add("msg", returnInfo["msg"].ToString()); return(JSONHelper.ToJson(ret)); }
public string GetNewFamilyInfo(string newLockId, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } Dictionary <string, string> ret = new Dictionary <string, string>(); NewLockManager manager = new NewLockManager(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); string returnFiled = manager.checkIsNullFild(dic); if (returnFiled != string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "字段" + returnFiled + "不允许为空!"); return(JSONHelper.ToJson(ret)); } //判断是否授权 if (manager.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!manager.GetIsInterfacePermissions("7", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } RentInfoHelper helper = new RentInfoHelper(); ret.Add("ret", "0"); ret.Add("msg", helper.GetJSONInfo("select * from v_EnterpriseHomeLock_view where NewLockID='" + newLockId + "'")); return(JSONHelper.ToJson(ret)); }
public string NewSelPasswordICcard(string newLockId, int type, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); dic.Add("type", type.ToString()); 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("12", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } if (type != 1 && type != 2) { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } string lockId = managerNew.getDeviceID(newLockId, "DeviceID"); string UserId = managerNew.getDeviceID(newLockId, "UserId"); if (lockId == string.Empty || userId == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); return(JSONHelper.ToJson(ret)); } RentInfoHelper helper = new RentInfoHelper(); if (type == 1) { ret.Add("ret", "0"); ret.Add("msg", helper.GetJSONInfo("select ID,LockID,ICCard,StartDate,EndDate,IsValid,UserId from v_RentICCard_view where LockID='" + lockId + " and Status='0' and UserId='" + UserId + "'and ICCard is not null and len(ICCard)>0")); return(JSONHelper.ToJson(ret)); } else { ret.Add("ret", "0"); ret.Add("msg", helper.GetJSONInfo("select ID,LockID,Password,StartDate,EndDate,IsValid,UserId from v_RentPass_view where LockID='" + lockId + "' and Status='0' and UserId='" + UserId + "'and IsAdd is not null and len(IsAdd)>0")); return(JSONHelper.ToJson(ret)); } }
public string NewDelPasswordICcard(string id, string type, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } string returnInfo = string.Empty; NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("id", id); dic.Add("type", type); dic.Add("userId", userId); 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("11", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } if (type != "1" && type != "2") { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } string sql = string.Empty; //校验删除的密码和卡片是否属于该企业 if (type == "1") { sql = "select * from v_RentPass_view where Status='0' and UserId='" + userId + "'and IsAdd is not null and len(IsAdd)>0 and ID='" + id + "'"; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count > 0) { returnInfo = managerNew.DeletePassword(id); } else { ret.Add("ret", "1"); ret.Add("msg", "未查到该密码,无法删除!"); return(JSONHelper.ToJson(ret)); } } else if (type == "2") { sql = "select ID from v_RentICCard_view where Status='0' and UserId='" + userId + "'and ICCard is not null and len(ICCard)>0 and ID='" + id + "'"; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count > 0) { returnInfo = managerNew.DeleteICCard(id); } else { ret.Add("ret", "1"); ret.Add("msg", "未查到该卡片,无法删除!"); return(JSONHelper.ToJson(ret)); } } return(returnInfo); }
public string NewAddPasswordICcard(string newLockId, string type, string pwdAndCard, string startTime, string endTime, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); dic.Add("type", type); if (type == "1" || type == "2") { if (pwdAndCard == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "永久录入字段pwdAndCard不允许为空!"); return(JSONHelper.ToJson(ret)); } else { dic.Add("pwdAndCard", pwdAndCard); } } dic.Add("startTime", startTime); dic.Add("endTime", endTime); 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("10", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } string[] strArr = { "1", "2", "3", "4" }; bool exists = ((IList)strArr).Contains(type); if (!exists) { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } string deviceId = managerNew.getDeviceID(newLockId, "DeviceID"); string UserId = managerNew.getDeviceID(newLockId, "UserId"); if (deviceId == string.Empty || userId == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); return(JSONHelper.ToJson(ret)); } return(managerNew.GetPostInterface(deviceId, UserId, type, pwdAndCard, startTime, endTime)); }
public string CreateHomeLock(string address, string familyName, string userId, string city, string ownerName, string ownerMobile, string ownerId, string ownerAddress, string homeStatus) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } Dictionary <string, string> ret = new Dictionary <string, string>(); try { NewLockManager manager = new NewLockManager(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("address", address); dic.Add("familyName", familyName); dic.Add("userId", userId); dic.Add("city", city); dic.Add("ownerName", ownerName); dic.Add("ownerMobile", ownerMobile); dic.Add("ownerId", ownerId); dic.Add("ownerAddress", ownerAddress); dic.Add("homeStatus", homeStatus); string returnFiled = manager.checkIsNullFild(dic); if (returnFiled != string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "字段" + returnFiled + "不允许为空!"); return(JSONHelper.ToJson(ret)); } if (manager.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!manager.GetIsInterfacePermissions("1", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } if (!manager.checkidcard(ownerId)) //身份证格式校验 { ret.Add("ret", "1"); ret.Add("msg", "房主身份证号(ownerId)格式校验错误!"); return(JSONHelper.ToJson(ret)); } if (!manager.IsTelephone(ownerMobile)) //手机号格式校验 { ret.Add("ret", "1"); ret.Add("msg", "房主手机号格式(ownerMobile)校验错误!"); return(JSONHelper.ToJson(ret)); } if (homeStatus != "1" && homeStatus != "2") { ret.Add("ret", "1"); ret.Add("msg", "homeStatus参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } LogManager.WriteLog("Start......"); string deviceID = Guid.NewGuid().ToString("N"); string sql = string.Empty; //请求远程创建家庭接口 string familyReturn = manager.createHomeInfo(deviceID); LogManager.WriteLog("Start......" + familyReturn); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(familyReturn); if (returnInfo["ret"].ToString() == "0") { string dateTime = DateTime.Now.ToString(); //信息记录 sql = "insert into Rent_NewLock_Process output inserted.NewLockId values('" + Guid.NewGuid().ToString() + "', '" + userId + "', '" + deviceID + "', '" + address + "', '','','true','','','','','" + dateTime + "','','" + familyName + "', '" + city + "')"; LogManager.WriteLog("SQL:" + sql); DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; sql = "select * from Rent_NewLock_Process where NewLockID='" + dt.Rows[0]["NewLockID"].ToString() + "'"; LogManager.WriteLog("SQL:" + sql); //锁房屋绑定 DataTable dtInfo = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; sql = "insert into Rent_Locks values('" + dtInfo.Rows[0]["DeviceID"].ToString() + "', 1, '0', 'NoConfiguration', '0', '" + dateTime + "', '0', '0', '" + dt.Rows[0]["NewLockID"].ToString() + "')"; LogManager.WriteLog("SQL:" + sql); MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); //家庭信息创建 sql = "insert into Enterprise_Homeowner_Info values('" + Guid.NewGuid().ToString() + "', '" + ownerName + "', '" + ownerMobile + "', '" + ownerId + "', '" + ownerAddress + "', '" + homeStatus + "', '" + userId + "', '" + dt.Rows[0]["NewLockID"].ToString() + "', '" + dateTime + "', '', '', '')"; LogManager.WriteLog("SQL:" + sql); MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); ret.Add("ret", "0"); ret.Add("msg", dt.Rows[0]["NewLockID"].ToString()); } 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)); }
public string DeleteGatewayLock(string newLockID, int type, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } Dictionary <string, string> ret = new Dictionary <string, string>(); try { string LockInfo = string.Empty; NewLockManager managerNew = new NewLockManager(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockID", newLockID); dic.Add("type", type.ToString()); 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("5", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } if (type == 1) //删除网关 { LockInfo = managerNew.deleteGateway(newLockID); } else if (type == 2) //删除锁 { LockInfo = managerNew.deleteAddLock(newLockID); } else if (type == 3) //强制删除网关 { LockInfo = managerNew.forceDelGate(newLockID); } else if (type == 4) //删除家庭 { LockInfo = managerNew.deleteFamily(newLockID); } else { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(LockInfo); if (returnInfo["ret"].ToString() == "0") { ret.Add("ret", "0"); string lockId = managerNew.getDeviceID(newLockID, "DeviceID"); //删除所有密码 string delSqlPass = "******" + lockId + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSqlPass)); //删除所有卡片 string delSqlIc = "Update Rent_Locks_ICCards set IsValid='0' where LockID='" + lockId + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSqlIc)); if (type == 2) { string delSqlLock = "Update Rent_NewLock_Process set IsDeleteLock='' where NewLockID='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSqlLock)); } else if (type == 3) { string delSqlGate = "Update Rent_NewLock_Process set IsDeleteGateway='true', PinInfo='',IsCreateLock='', IsDeleteLock='' , IsCreateGateway='', GatewayId='', DevKey='' where NewLockID='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSqlGate)); } else if (type == 4) //删除家庭 { string delSql = string.Empty; delSql = "delete from Rent_NewLock_Process where NewLockID='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSql)); delSql = "delete from Rent_Locks where Memo='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSql)); delSql = "delete from Enterprise_Homeowner_Info where NewLockID='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(delSql)); } } 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)); }
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)); }
public string AddGateway(string gatewayId, string devKey, 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("gatewayId", gatewayId); dic.Add("devKey", devKey); 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("3", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //网关查询 string selSql = "select * from Rent_NewLock_Process where GatewayId='" + gatewayId + "' and DevKey='" + devKey + "'and IsCreateGateway='true'"; DataTable d1 = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(selSql)).Tables[0]; if (d1.Rows.Count > 0) { ret.Add("ret", "1"); ret.Add("msg", "网关存在,请先解绑在绑定!"); return(JSONHelper.ToJson(ret)); } //添加网关 string addGatewayInfo = managerNew.createAddGateway(gatewayId, devKey, newLockID); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(addGatewayInfo); if (returnInfo["ret"].ToString() == "0") { string sql = "Update Rent_NewLock_Process set GatewayId='" + gatewayId + "', DevKey='" + devKey + "', UpdatedOn='" + DateTime.Now.ToString() + "'where NewLockID='" + newLockID + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); 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)); }
public string GetHomeLockReturnInfo(string newLockId, int type, 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); dic.Add("type", type.ToString()); 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("2", 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)); } ret.Add("ret", "0"); if (type == 1) { ret.Add("msg", dt.Rows[0]["IsCreateGateway"].ToString()); } else if (type == 2) { ret.Add("msg", dt.Rows[0]["IsCreateLock"].ToString()); } else if (type == 3) { ret.Add("msg", dt.Rows[0]["PinInfo"].ToString()); } else if (type == 4) { ret.Add("msg", dt.Rows[0]["IsDeleteGateway"].ToString()); } else if (type == 5) { ret.Add("msg", dt.Rows[0]["IsDeleteLock"].ToString()); } else { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } } catch (Exception ex) { ret.Add("ret", "1"); ret.Add("msg", ex.Message); } return(JSONHelper.ToJson(ret)); }
public string DataBindInfo(string gatewayJson, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); string sql = string.Empty; Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("gatewayJson", gatewayJson); dic.Add("userId", userId); 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("13", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } Dictionary <string, object> retRequest = new Dictionary <string, object>(); retRequest = JSONHelper.FromJson <Dictionary <string, object> >(gatewayJson); try { //查询锁信息 sql = "select * from Rent_NewLock_Process where GatewayId= '" + retRequest["D-id"].ToString() + "' and DevKey='" + retRequest["D-key"].ToString() + "'"; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count <= 0) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); } else { //查询用户表信息(通过我们app添加) sql = "select * from CF_User where LoginName='" + dt.Rows[0]["UserId"].ToString() + "'"; DataTable dtUser = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; //查询SDK添加 sql = "select * from Enterprise_Homeowner_Info where NewLockID='" + dt.Rows[0]["NewLockID"].ToString() + "'"; DataTable dtSDK = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dtUser.Rows.Count <= 0 && dtSDK.Rows.Count <= 0) { ret.Add("ret", "1"); ret.Add("msg", "获取用户信息失败!"); } else { var item = new Hashtable(); if (dtUser.Rows.Count > 0) { item["userName"] = dtUser.Rows[0]["RealName"].ToString(); item["userMoblie"] = dtUser.Rows[0]["LoginName"].ToString(); } else { item["userName"] = dtSDK.Rows[0]["EnterpriseHomeownerName"].ToString(); item["userMoblie"] = dtSDK.Rows[0]["EnterpriseHomeownerMobile"].ToString(); } item["NewLockId"] = dt.Rows[0]["NewLockID"].ToString(); ret.Add("ret", "0"); ret.Add("msg", JSONHelper.ToJson(item)); } } } catch (Exception ex) { ret.Add("ret", "1"); ret.Add("msg", ex.Message); } return(JSONHelper.ToJson(ret)); }