Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -173,7 +173,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
public override Task StopAsync(CancellationToken cancellationToken)
|
public override Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
IsStarted = false;
|
IsStarted = false;
|
||||||
return Task.FromResult(IsStarted);
|
return Task.CompletedTask;
|
||||||
//return base.StopAsync(cancellationToken);
|
//return base.StopAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
private readonly BackgroundService _backgroundService; //added by ly on 20230916
|
private readonly BackgroundService _backgroundService; //added by ly on 20230916
|
||||||
private static CancellationTokenSource stopTimedTaskSvcCTS = new();
|
private static CancellationTokenSource stopTimedTaskSvcCTS = new();
|
||||||
private static Dictionary<string, Func<BackgroundService, object>> _fetchPropValue = new();
|
private static Dictionary<string, Func<BackgroundService, bool>> _fetchPropValue = new();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -296,21 +296,16 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
//modify by ly on 20230918 登录成功后启动定时服务
|
//modify by ly on 20230918 登录成功后启动定时服务
|
||||||
if (!userId.IsNullOrWhiteSpace())
|
if (!userId.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
if (!_fetchPropValue.TryGetValue("IsStarted", out var action))
|
||||||
//if (!_fetchPropValue.TryGetValue("IsStarted", out var action))
|
{
|
||||||
//{
|
var isStartedProp = _backgroundService.GetType().GetProperty("IsStarted");
|
||||||
// var isStartedProp = _backgroundService.GetType().GetProperty("IsStarted");
|
var paramExp = Expression.Parameter(typeof(BackgroundService), "_backgroundSvc");
|
||||||
// var paramExp = Expression.Parameter(typeof(BackgroundService), "_backgroundSvc");
|
var propExp = Expression.Property(Expression.ConvertChecked(paramExp, isStartedProp.DeclaringType), isStartedProp.GetGetMethod());
|
||||||
// var propExp = Expression.Property(paramExp, isStartedProp);
|
var body = Expression.Lambda<Func<BackgroundService, Boolean>>(propExp, paramExp);
|
||||||
// var body = Expression.Lambda<Func<BackgroundService, object>>(propExp, paramExp);
|
action = body.Compile();
|
||||||
// action = body.Compile();
|
_fetchPropValue["IsStarted"] = action;
|
||||||
// _fetchPropValue["IsStarted"] = action;
|
}
|
||||||
//}
|
if (!action?.Invoke(_backgroundService) ?? false)
|
||||||
//if(!action?.Invoke(_backgroundService)?.ParseToBool() ?? false)
|
|
||||||
//{
|
|
||||||
// await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token);
|
|
||||||
//}
|
|
||||||
if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted)
|
|
||||||
{
|
{
|
||||||
await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token);
|
await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using JNPF.Common.Configuration;
|
||||||
|
|
||||||
namespace Tnb.Vengine;
|
namespace Tnb.Vengine;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user