继续调整,原逻辑有问题
This commit is contained in:
@@ -173,7 +173,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
public override Task StopAsync(CancellationToken cancellationToken)
|
public override Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
IsStarted = false;
|
IsStarted = false;
|
||||||
return base.StopAsync(cancellationToken);
|
return Task.FromResult(IsStarted);
|
||||||
|
//return base.StopAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task TaskDelay(TimeSpanUnit timeType, int interval)
|
private Task TaskDelay(TimeSpanUnit timeType, int interval)
|
||||||
|
|||||||
@@ -144,8 +144,7 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
private readonly IMHandler _imHandler;
|
private readonly IMHandler _imHandler;
|
||||||
|
|
||||||
private readonly BackgroundService _backgroundService; //added by ly on 20230916
|
private readonly BackgroundService _backgroundService; //added by ly on 20230916
|
||||||
private static Dictionary<string, bool> _hostSvcRun = new();
|
private static CancellationTokenSource stopTimedTaskSvcCTS = new();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -295,17 +294,11 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
//modify by ly on 20230918 登录成功后启动定时服务
|
//modify by ly on 20230918 登录成功后启动定时服务
|
||||||
if (!userId.IsNullOrWhiteSpace())
|
if (!userId.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
if (!_hostSvcRun.TryGetValue("IsStarted", out bool isStarted))
|
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
||||||
|
if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted)
|
||||||
{
|
{
|
||||||
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token);
|
||||||
isStarted = Convert.ToBoolean(isStartedProperty?.GetValue(_backgroundService));
|
|
||||||
_hostSvcRun["IsStarted"] = isStarted;
|
|
||||||
}
|
}
|
||||||
if (!isStarted)
|
|
||||||
{
|
|
||||||
await _backgroundService.StartAsync(CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -409,9 +402,9 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
[HttpGet("Logout")]
|
[HttpGet("Logout")]
|
||||||
public async Task Logout([FromQuery] string ticket)
|
public async Task Logout([FromQuery] string ticket)
|
||||||
{
|
{
|
||||||
|
//modify by ly on 20230918
|
||||||
await _backgroundService.StopAsync(CancellationToken.None);
|
await _backgroundService.StopAsync(stopTimedTaskSvcCTS.Token);
|
||||||
|
stopTimedTaskSvcCTS.Cancel();
|
||||||
UserManager.AsscessToken = string.Empty;
|
UserManager.AsscessToken = string.Empty;
|
||||||
|
|
||||||
var tenantId = _userManager.TenantId ?? "default";
|
var tenantId = _userManager.TenantId ?? "default";
|
||||||
|
|||||||
Reference in New Issue
Block a user