执行代码清理,修复warning
This commit is contained in:
@@ -31,20 +31,11 @@ namespace Tnb.WarehouseMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
private static Lazy<Dictionary<string, IWHStorageService>> _stroageMapLazy;
|
||||
private static readonly Lazy<Dictionary<string, IWHStorageService>> _stroageMapLazy;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public static SemaphoreSlim s_taskExecuteSemaphore = new SemaphoreSlim(1);
|
||||
public static SemaphoreSlim s_taskExecuteSemaphore = new(1);
|
||||
|
||||
|
||||
|
||||
private IEventPublisher _eventPublisher;
|
||||
|
||||
|
||||
protected IEventPublisher EventPublisher
|
||||
{
|
||||
set { _eventPublisher = value; }
|
||||
get { return _eventPublisher; }
|
||||
}
|
||||
protected IEventPublisher? EventPublisher { set; get; }
|
||||
|
||||
|
||||
|
||||
@@ -54,14 +45,17 @@ namespace Tnb.WarehouseMgr
|
||||
_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)
|
||||
List<Type> serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
||||
foreach (Type? serviceType in serviceTypes)
|
||||
{
|
||||
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
|
||||
string callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
|
||||
if (!callerName.IsNullOrEmpty())
|
||||
{
|
||||
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
|
||||
if (obj == null) continue;
|
||||
if (Activator.CreateInstance(serviceType) is not IWHStorageService obj)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
map[callerName] = obj;
|
||||
}
|
||||
}
|
||||
@@ -73,31 +67,30 @@ namespace Tnb.WarehouseMgr
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)
|
||||
{
|
||||
asscessToken = asscessToken?.Replace("Bearer ", "").Replace("bearer ", "");
|
||||
var at = asscessToken ?? UserManager.AsscessToken;
|
||||
var claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
||||
ClaimsIdentity toKen = new ClaimsIdentity();
|
||||
string at = asscessToken ?? UserManager.AsscessToken;
|
||||
IEnumerable<Claim>? claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
||||
ClaimsIdentity toKen = new();
|
||||
foreach (Claim item in claims)
|
||||
{
|
||||
toKen.AddClaim(item);
|
||||
}
|
||||
var curUser = new ClaimsPrincipal(toKen);
|
||||
ClaimsPrincipal curUser = new(toKen);
|
||||
return Task.FromResult(curUser);
|
||||
}
|
||||
|
||||
|
||||
protected Task SetUserEntity(IUserManager userManager, ClaimsPrincipal principal)
|
||||
=> Task.Run(() =>
|
||||
{
|
||||
FieldInfo fieldInfo = userManager.GetType().GetField("_user", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfo != null)
|
||||
{
|
||||
fieldInfo.SetValue(userManager, principal);
|
||||
}
|
||||
});
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
FieldInfo fieldInfo = userManager.GetType().GetField("_user", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
fieldInfo?.SetValue(userManager, principal);
|
||||
});
|
||||
}
|
||||
|
||||
protected Task InvokeGenPretaskExcute()
|
||||
{
|
||||
var wareHouseSvc = App.GetRequiredService<IWareHouseService>();
|
||||
IWareHouseService wareHouseSvc = App.GetRequiredService<IWareHouseService>();
|
||||
return wareHouseSvc.GenTaskExecute();
|
||||
}
|
||||
|
||||
@@ -112,15 +105,23 @@ namespace Tnb.WarehouseMgr
|
||||
protected Task<bool> IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest)
|
||||
{
|
||||
bool isMatch = false;
|
||||
if (carry == null) throw new ArgumentNullException(nameof(carry));
|
||||
if (locDest == null) throw new ArgumentNullException(nameof(locDest));
|
||||
if (carry == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(carry));
|
||||
}
|
||||
|
||||
if (locDest == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(locDest));
|
||||
}
|
||||
|
||||
if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
|
||||
{
|
||||
JArray? jsonArr = null;
|
||||
try
|
||||
{
|
||||
jsonArr = JArray.Parse(locDest.carrystd_id);
|
||||
var locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
|
||||
string?[] locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
|
||||
isMatch = locCarryStdArr.Contains(carry.carrystd_id);
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException jex)
|
||||
@@ -140,7 +141,7 @@ namespace Tnb.WarehouseMgr
|
||||
[NonAction]
|
||||
protected Task<int> GetRealFloor(int floor)
|
||||
{
|
||||
var realFloor = 0;
|
||||
int realFloor = 0;
|
||||
if (floor == 4)
|
||||
{
|
||||
realFloor = 5;
|
||||
@@ -164,7 +165,7 @@ namespace Tnb.WarehouseMgr
|
||||
[NonAction]
|
||||
protected async Task Publish(string taskName)
|
||||
{
|
||||
await _eventPublisher.PublishAsync(new TaskStatusChangeSource(EventSubscribeEventConsts.TASKSTATUSCHANGE_EVENTID, taskName));
|
||||
await EventPublisher.PublishAsync(new TaskStatusChangeSource(EventSubscribeEventConsts.TASKSTATUSCHANGE_EVENTID, taskName));
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
@@ -188,7 +189,7 @@ namespace Tnb.WarehouseMgr
|
||||
[NonAction]
|
||||
protected void BarCodePrint(List<string> barCodes)
|
||||
{
|
||||
var tcs = new TaskCompletionSource();
|
||||
TaskCompletionSource tcs = new();
|
||||
// open port.
|
||||
try
|
||||
{
|
||||
@@ -213,8 +214,8 @@ namespace Tnb.WarehouseMgr
|
||||
int len1 = 128, len2 = 128;
|
||||
buf1 = new byte[len1];
|
||||
buf2 = new byte[len2];
|
||||
PPLBUtility.B_EnumUSB(pbuf);
|
||||
PPLBUtility.B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
|
||||
_ = PPLBUtility.B_EnumUSB(pbuf);
|
||||
_ = PPLBUtility.B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
|
||||
sw = 1;
|
||||
if (1 == sw)
|
||||
{
|
||||
@@ -238,14 +239,14 @@ namespace Tnb.WarehouseMgr
|
||||
if (2 == sw)
|
||||
{
|
||||
//Immediate Error Report.
|
||||
PPLBUtility.B_WriteData(1, encAscII.GetBytes("^ee\r\n"), 5);//^ee
|
||||
_ = PPLBUtility.B_WriteData(1, encAscII.GetBytes("^ee\r\n"), 5);//^ee
|
||||
ret = PPLBUtility.B_ReadData(pbuf, 4, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(PPLBUtility.szSavePath);
|
||||
_ = System.IO.Directory.CreateDirectory(PPLBUtility.szSavePath);
|
||||
ret = PPLBUtility.B_CreatePrn(0, PPLBUtility.szSaveFile);// open file.
|
||||
strmsg += "Open ";
|
||||
strmsg += PPLBUtility.szSaveFile;
|
||||
@@ -259,15 +260,17 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
if (0 != ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// sample setting.
|
||||
PPLBUtility.B_Set_Originpoint(0, 0);
|
||||
PPLBUtility.B_Select_Option(2);
|
||||
PPLBUtility.B_Set_Darkness(8);
|
||||
PPLBUtility.B_Del_Pcx("*");// delete all picture.
|
||||
_ = PPLBUtility.B_Set_Originpoint(0, 0);
|
||||
_ = PPLBUtility.B_Select_Option(2);
|
||||
_ = PPLBUtility.B_Set_Darkness(8);
|
||||
_ = PPLBUtility.B_Del_Pcx("*");// delete all picture.
|
||||
//PPLBUtility.B_Set_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm. 254 * 3, 30
|
||||
PPLBUtility.B_Set_Labwidth(80 * 8);
|
||||
_ = PPLBUtility.B_Set_Labwidth(80 * 8);
|
||||
//var labelWidth = 640; //254 * 3; // 标签宽度
|
||||
//var barcodeWidth = 320; // 条码宽度
|
||||
//var barcodeX = (labelWidth - barcodeWidth) / 2;
|
||||
@@ -275,14 +278,14 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
|
||||
|
||||
foreach (var code in barCodes)
|
||||
foreach (string code in barCodes)
|
||||
{
|
||||
//print text, true type text.
|
||||
PPLBUtility.B_Prn_Text(200, 50, 0, 2, 2, 2, 'N', code);
|
||||
_ = PPLBUtility.B_Prn_Text(200, 50, 0, 2, 2, 2, 'N', code);
|
||||
//barcode.
|
||||
PPLBUtility.B_Prn_Barcode(50, 100, 0, "1", 3, 5, 70, 'B', code);//have a counter
|
||||
// output.
|
||||
PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
_ = PPLBUtility.B_Prn_Barcode(50, 100, 0, "1", 3, 5, 70, 'B', code);//have a counter
|
||||
// output.
|
||||
_ = PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user