多用户锁定
parent
f3e6922882
commit
d6d7339bca
|
|
@ -1,5 +1,6 @@
|
|||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Math;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using HidSharp;
|
||||
using Infrastructure;
|
||||
|
|
@ -639,7 +640,8 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
dict.TryGetValue("ConnectTime", out var connectTimeStr);
|
||||
dict.TryGetValue("DeviceSn", out var deviceSn);
|
||||
dict.TryGetValue("IsLock", out var isLockStr);
|
||||
MqttClientResp mqttClientResp = new MqttClientResp{
|
||||
MqttClientResp mqttClientResp = new MqttClientResp
|
||||
{
|
||||
ClientId = clientId ?? "",
|
||||
UserId = userId ?? "",
|
||||
UserName = userName ?? "",
|
||||
|
|
@ -733,21 +735,28 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
string lockSetKey = "locked_devices";
|
||||
|
||||
// 查询所有锁定用户
|
||||
var existingLocked = await _cache.SetMembersAsync(lockSetKey);
|
||||
//var existingLocked = await _cache.SetMembersAsync(lockSetKey);
|
||||
|
||||
// 如果设备锁定,并且锁定的用户不是当前用户,则拒绝
|
||||
if (existingLocked.Length > 0 && info.IsLock == true)
|
||||
//// 如果设备锁定,并且锁定的用户不是当前用户,则拒绝
|
||||
//if (existingLocked.Length > 0 && info.IsLock == true)
|
||||
//{
|
||||
// bool isCurrentUserLocked = existingLocked.Any(u => u == info.DeviceSn);
|
||||
// if (isCurrentUserLocked)
|
||||
// {
|
||||
// result.Code = 400;
|
||||
// result.Message = "已有用户处于锁定状态,不能添加新的锁定用户。";
|
||||
// result.Result = false;
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
var existingLocked = ParseClient(await _cache.HashGetAllAsync($"client:{info.DeviceSn}"));
|
||||
if (existingLocked.DeviceSn == info.DeviceSn && existingLocked.UserId != info.UserId && existingLocked.IsLock)
|
||||
{
|
||||
bool isCurrentUserLocked = existingLocked.Any(u => u == info.DeviceSn);
|
||||
if (isCurrentUserLocked)
|
||||
{
|
||||
result.Code = 400;
|
||||
result.Message = "已有其他用户处于锁定状态,不能添加新的锁定用户。";
|
||||
result.Result = false;
|
||||
return result;
|
||||
}
|
||||
result.Code = 400;
|
||||
result.Message = "已有用户处于锁定状态,不能添加新的锁定用户。";
|
||||
result.Result = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
// 存客户端信息
|
||||
_cache.HashSetAsync(clientKey, new HashEntry[]
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue