解决出库签收,当前用户空引用bug
This commit is contained in:
@@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.OpenXmlFormats.Dml;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using SqlSugar;
|
||||
@@ -47,7 +48,7 @@ namespace Tnb.WarehouseMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
private static Dictionary<string, IWHStorageService> _stroageMap = new(StringComparer.OrdinalIgnoreCase);
|
||||
private static Lazy<Dictionary<string, IWHStorageService>> _stroageMap;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private readonly ChannelWriter<NotifyMessage> _channelWriter;
|
||||
|
||||
@@ -58,24 +59,29 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
static BaseWareHouseService()
|
||||
{
|
||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
||||
foreach (var serviceType in serviceTypes)
|
||||
_stroageMap = new Lazy<Dictionary<string, IWHStorageService>>(() =>
|
||||
{
|
||||
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
|
||||
if (!callerName.IsNullOrEmpty())
|
||||
Dictionary<string, IWHStorageService> map = new(StringComparer.OrdinalIgnoreCase);
|
||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
||||
foreach (var serviceType in serviceTypes)
|
||||
{
|
||||
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
||||
if (obj == null) continue;
|
||||
_stroageMap[callerName] = obj;
|
||||
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
|
||||
if (!callerName.IsNullOrEmpty())
|
||||
{
|
||||
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
||||
if (obj == null) continue;
|
||||
map[callerName] = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity(string? sToken = null)
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity()
|
||||
{
|
||||
var at = sToken ?? UserManager.AsscessToken;
|
||||
at = at.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase) ? at.TrimStart("Bearer ") : at;
|
||||
var claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
||||
var claims = JWTEncryption.ReadJwtToken(UserManager.AsscessToken)?.Claims;
|
||||
ClaimsIdentity toKen = new ClaimsIdentity();
|
||||
foreach (Claim item in claims)
|
||||
{
|
||||
@@ -115,6 +121,9 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return Task.FromResult(isMatch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发布消息
|
||||
/// </summary>
|
||||
@@ -131,9 +140,9 @@ namespace Tnb.WarehouseMgr
|
||||
[NonAction]
|
||||
protected async Task DoUpdate(WareHouseUpInput input)
|
||||
{
|
||||
if (_stroageMap.ContainsKey(input.loginType))
|
||||
if (_stroageMap.Value.ContainsKey(input.loginType))
|
||||
{
|
||||
await _stroageMap[input.loginType].Do(input);
|
||||
await _stroageMap.Value[input.loginType].Do(input);
|
||||
}
|
||||
}
|
||||
[NonAction]
|
||||
|
||||
Reference in New Issue
Block a user