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)); }