From 767076a513bca4c7324b5cc5bd0359e3859f93d5 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 19 Sep 2023 09:14:41 +0800 Subject: [PATCH] 1 --- system/Tnb.OAuth/OAuthService.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/system/Tnb.OAuth/OAuthService.cs b/system/Tnb.OAuth/OAuthService.cs index d9e0a43e..ed3bb917 100644 --- a/system/Tnb.OAuth/OAuthService.cs +++ b/system/Tnb.OAuth/OAuthService.cs @@ -44,6 +44,7 @@ using Aop.Api.Domain; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using bf = System.Reflection.BindingFlags; +using System.Linq.Expressions; namespace JNPF.OAuth; @@ -145,6 +146,7 @@ public class OAuthService : IDynamicApiController, ITransient private readonly BackgroundService _backgroundService; //added by ly on 20230916 private static CancellationTokenSource stopTimedTaskSvcCTS = new(); + private static Dictionary> _fetchPropValue = new(); /// @@ -295,14 +297,25 @@ public class OAuthService : IDynamicApiController, ITransient if (!userId.IsNullOrWhiteSpace()) { var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted"); + //if (!_fetchPropValue.TryGetValue("IsStarted", out var action)) + //{ + // var isStartedProp = _backgroundService.GetType().GetProperty("IsStarted"); + // var paramExp = Expression.Parameter(typeof(BackgroundService), "_backgroundSvc"); + // var propExp = Expression.Property(paramExp, isStartedProp); + // var body = Expression.Lambda>(propExp, paramExp); + // action = body.Compile(); + // _fetchPropValue["IsStarted"] = action; + //} + //if(!action?.Invoke(_backgroundService)?.ParseToBool() ?? false) + //{ + // await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token); + //} if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted) { await _backgroundService.StartAsync(stopTimedTaskSvcCTS.Token); } } - - var loginOutput = new CurrentUserOutput(); loginOutput.userInfo = await _userManager.GetUserInfo();