fix: 尝试修复hub的scantask的key的问题
This commit is contained in:
parent
4c9b9cd3d6
commit
0932c8ba75
|
@ -70,7 +70,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
||||||
private readonly IHubContext<DigitalTubesHub, IDigitalTubesReceiver> _hubContext;
|
private readonly IHubContext<DigitalTubesHub, IDigitalTubesReceiver> _hubContext;
|
||||||
private readonly Database.UserManager _userManager = new();
|
private readonly Database.UserManager _userManager = new();
|
||||||
|
|
||||||
private ConcurrentDictionary<(string, string), DigitalTubesScanTaskInfo> _scanTasks = new();
|
private ConcurrentDictionary<string, DigitalTubesScanTaskInfo> _scanTasks = new();
|
||||||
|
|
||||||
public DigitalTubesHub(IHubContext<DigitalTubesHub, IDigitalTubesReceiver> hubContext)
|
public DigitalTubesHub(IHubContext<DigitalTubesHub, IDigitalTubesReceiver> hubContext)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +160,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryGetValue(key, out var existing) && existing.IsRunning)
|
if (_scanTasks.TryGetValue(key, out var existing) && existing.IsRunning)
|
||||||
return true;
|
return true;
|
||||||
|
@ -187,7 +187,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryRemove(key, out var scanInfo))
|
if (_scanTasks.TryRemove(key, out var scanInfo))
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryGetValue(key, out var scanInfo) && scanInfo.IsRunning)
|
if (_scanTasks.TryGetValue(key, out var scanInfo) && scanInfo.IsRunning)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +239,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryGetValue(key, out var scanInfo))
|
if (_scanTasks.TryGetValue(key, out var scanInfo))
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
|
||||||
private readonly IHubContext<OscilloscopeHub, IOscilloscopeReceiver> _hubContext;
|
private readonly IHubContext<OscilloscopeHub, IOscilloscopeReceiver> _hubContext;
|
||||||
private readonly Database.UserManager _userManager = new();
|
private readonly Database.UserManager _userManager = new();
|
||||||
|
|
||||||
private ConcurrentDictionary<(string, string), OscilloscopeScanTaskInfo> _scanTasks = new();
|
private ConcurrentDictionary<string, OscilloscopeScanTaskInfo> _scanTasks = new();
|
||||||
|
|
||||||
public OscilloscopeHub(IHubContext<OscilloscopeHub, IOscilloscopeReceiver> hubContext)
|
public OscilloscopeHub(IHubContext<OscilloscopeHub, IOscilloscopeReceiver> hubContext)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +176,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
|
var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
|
||||||
|
|
||||||
if (_scanTasks.TryGetValue(key, out var existing))
|
if (_scanTasks.TryGetValue(key, out var existing))
|
||||||
|
@ -210,7 +210,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
|
var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
|
||||||
|
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryRemove(key, out var taskInfo))
|
if (_scanTasks.TryRemove(key, out var taskInfo))
|
||||||
{
|
{
|
||||||
|
@ -383,7 +383,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
|
||||||
var key = (board.ID.ToString(), Context.ConnectionId);
|
var key = board.ID.ToString();
|
||||||
|
|
||||||
if (_scanTasks.TryGetValue(key, out var scanInfo))
|
if (_scanTasks.TryGetValue(key, out var scanInfo))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue