1
This commit is contained in:
@@ -51,6 +51,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private static Lazy<Dictionary<string, IWHStorageService>> _stroageMapLazy;
|
private static Lazy<Dictionary<string, IWHStorageService>> _stroageMapLazy;
|
||||||
|
private static Dictionary<string, IWHStorageService> _storeMap = new(StringComparer.OrdinalIgnoreCase);
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
private readonly ChannelWriter<NotifyMessage> _channelWriter;
|
private readonly ChannelWriter<NotifyMessage> _channelWriter;
|
||||||
|
|
||||||
@@ -61,9 +62,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
static BaseWareHouseService()
|
static BaseWareHouseService()
|
||||||
{
|
{
|
||||||
_stroageMapLazy = new Lazy<Dictionary<string, IWHStorageService>>(() =>
|
//_stroageMapLazy = new Lazy<Dictionary<string, IWHStorageService>>(() =>
|
||||||
{
|
{
|
||||||
Dictionary<string, IWHStorageService> map = new(StringComparer.OrdinalIgnoreCase);
|
//Dictionary<string, IWHStorageService> map = new(StringComparer.OrdinalIgnoreCase);
|
||||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
||||||
foreach (var serviceType in serviceTypes)
|
foreach (var serviceType in serviceTypes)
|
||||||
{
|
{
|
||||||
@@ -72,18 +73,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
||||||
if (obj == null) continue;
|
if (obj == null) continue;
|
||||||
map[callerName] = obj;
|
_storeMap[callerName] = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
//return map;
|
||||||
});
|
}
|
||||||
|
//);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)
|
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)
|
||||||
{
|
{
|
||||||
asscessToken = asscessToken.Replace("Bearer ", "").Replace("bearer ", "");
|
asscessToken = asscessToken?.Replace("Bearer ", "").Replace("bearer ", "");
|
||||||
var at = asscessToken ?? UserManager.AsscessToken;
|
var at = asscessToken ?? UserManager.AsscessToken;
|
||||||
var claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
var claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
||||||
ClaimsIdentity toKen = new ClaimsIdentity();
|
ClaimsIdentity toKen = new ClaimsIdentity();
|
||||||
@@ -144,9 +146,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
[NonAction]
|
[NonAction]
|
||||||
protected async Task DoUpdate(WareHouseUpInput input)
|
protected async Task DoUpdate(WareHouseUpInput input)
|
||||||
{
|
{
|
||||||
if (_stroageMapLazy.Value.ContainsKey(input.loginType))
|
if (_storeMap.ContainsKey(input.loginType))
|
||||||
{
|
{
|
||||||
await _stroageMapLazy.Value[input.loginType].Do(input);
|
await _storeMap[input.loginType].Do(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[NonAction]
|
[NonAction]
|
||||||
|
|||||||
@@ -170,6 +170,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
IsStarted = false;
|
||||||
|
return base.StopAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
private Task TaskDelay(TimeSpanUnit timeType, int interval)
|
private Task TaskDelay(TimeSpanUnit timeType, int interval)
|
||||||
{
|
{
|
||||||
Task delayTask = timeType switch
|
Task delayTask = timeType switch
|
||||||
|
|||||||
@@ -289,18 +289,15 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
if (type.IsNullOrEmpty()) type = "Web"; // 默认为Web端菜单目录
|
if (type.IsNullOrEmpty()) type = "Web"; // 默认为Web端菜单目录
|
||||||
|
|
||||||
|
|
||||||
var userId = _userManager.UserId;
|
var userId = _userManager.UserId;
|
||||||
|
|
||||||
//modify by ly on 20230918 登录成功后启动定时服务
|
//modify by ly on 20230918 登录成功后启动定时服务
|
||||||
if (!userId.IsNullOrWhiteSpace())
|
if (!userId.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
||||||
|
|
||||||
if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted)
|
if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted)
|
||||||
{
|
{
|
||||||
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
await _backgroundService.StartAsync(CancellationToken.None);
|
||||||
await _backgroundService.StartAsync(cancellationTokenSource.Token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,12 +402,8 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
[HttpGet("Logout")]
|
[HttpGet("Logout")]
|
||||||
public async Task Logout([FromQuery] string ticket)
|
public async Task Logout([FromQuery] string ticket)
|
||||||
{
|
{
|
||||||
//await _cacheManager.DelAsync("AsscessToken");
|
|
||||||
|
|
||||||
|
await _backgroundService.StopAsync(CancellationToken.None);
|
||||||
//modify by ly on 20230918
|
|
||||||
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
|
||||||
isStartedProperty?.SetValue(_backgroundService, false);
|
|
||||||
|
|
||||||
UserManager.AsscessToken = string.Empty;
|
UserManager.AsscessToken = string.Empty;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user