BaseWareHouseService 类静态函数打回原形,改为延迟加载,以避免未登录使用用户情况
This commit is contained in:
@@ -64,6 +64,9 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
static BaseWareHouseService()
|
||||
{
|
||||
_stroageMapLazy = new Lazy<Dictionary<string, IWHStorageService>>(() =>
|
||||
{
|
||||
Dictionary<string, IWHStorageService> map = new();
|
||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
||||
foreach (var serviceType in serviceTypes)
|
||||
{
|
||||
@@ -72,9 +75,12 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
||||
if (obj == null) continue;
|
||||
_storeMap[callerName] = obj;
|
||||
map[callerName] = obj;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)
|
||||
@@ -140,9 +146,9 @@ namespace Tnb.WarehouseMgr
|
||||
[NonAction]
|
||||
protected async Task DoUpdate(WareHouseUpInput input)
|
||||
{
|
||||
if (_storeMap.ContainsKey(input.loginType))
|
||||
if (_stroageMapLazy.Value.ContainsKey(input.loginType))
|
||||
{
|
||||
await _storeMap[input.loginType].Do(input);
|
||||
await _stroageMapLazy.Value[input.loginType].Do(input);
|
||||
}
|
||||
}
|
||||
[NonAction]
|
||||
|
||||
Reference in New Issue
Block a user