定时服务启动方式调整,并调整相关业务代码
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
@@ -41,6 +42,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Print;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -79,9 +81,10 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
}
|
||||
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity()
|
||||
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)
|
||||
{
|
||||
var claims = JWTEncryption.ReadJwtToken(UserManager.AsscessToken)?.Claims;
|
||||
var at = asscessToken ?? UserManager.AsscessToken;
|
||||
var claims = JWTEncryption.ReadJwtToken(at)?.Claims;
|
||||
ClaimsIdentity toKen = new ClaimsIdentity();
|
||||
foreach (Claim item in claims)
|
||||
{
|
||||
@@ -150,6 +153,165 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
/// <summary>
|
||||
/// 条码打印
|
||||
/// </summary>
|
||||
/// <param name="barCodes">条码</param>
|
||||
/// <returns></returns>
|
||||
protected Task BarCodePrint(List<string> barCodes)
|
||||
{
|
||||
var tcs = new TaskCompletionSource();
|
||||
// open port.
|
||||
try
|
||||
{
|
||||
int nLen, ret, sw;
|
||||
byte[] pbuf = new byte[128];
|
||||
string strmsg;
|
||||
|
||||
IntPtr ver;
|
||||
System.Text.Encoding encAscII = System.Text.Encoding.ASCII;
|
||||
System.Text.Encoding encUnicode = System.Text.Encoding.Unicode;
|
||||
|
||||
// dll version.
|
||||
ver = PPLBUtility.B_Get_DLL_Version(0);
|
||||
// search port.
|
||||
nLen = PPLBUtility.B_GetUSBBufferLen() + 1;
|
||||
strmsg = "DLL ";
|
||||
strmsg += Marshal.PtrToStringAnsi(ver);
|
||||
strmsg += "\r\n";
|
||||
if (nLen > 1)
|
||||
{
|
||||
byte[] buf1, buf2;
|
||||
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);
|
||||
sw = 1;
|
||||
if (1 == sw)
|
||||
{
|
||||
ret = PPLBUtility.B_CreatePrn(12, encAscII.GetString(buf2, 0, len2));// open usb.
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = PPLBUtility.B_CreateUSBPort(1);// must call B_GetUSBBufferLen() function fisrt.
|
||||
}
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += "Open USB fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += "Open USB:\r\nDevice name: ";
|
||||
strmsg += encAscII.GetString(buf1, 0, len1);
|
||||
strmsg += "\r\nDevice path: ";
|
||||
strmsg += encAscII.GetString(buf2, 0, len2);
|
||||
//sw = 2;
|
||||
if (2 == sw)
|
||||
{
|
||||
//Immediate Error Report.
|
||||
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);
|
||||
ret = PPLBUtility.B_CreatePrn(0, PPLBUtility.szSaveFile);// open file.
|
||||
strmsg += "Open ";
|
||||
strmsg += PPLBUtility.szSaveFile;
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += " file fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += " file succeed!";
|
||||
}
|
||||
}
|
||||
if (0 != ret)
|
||||
return null;
|
||||
|
||||
// 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_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm.
|
||||
|
||||
|
||||
foreach (var code in barCodes)
|
||||
{
|
||||
//print text, true type text.
|
||||
PPLBUtility.B_Prn_Text(200, 50, 0, 2, 2, 2, 'N', code);
|
||||
//barcode.
|
||||
PPLBUtility.B_Prn_Barcode(160, 100, 0, "E80", 8, 500, 70, 'N', code);//have a counter
|
||||
// output.
|
||||
PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tcs.SetException(ex);
|
||||
JNPF.Logging.Log.Error("条码打印时出现错误", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// close port.
|
||||
//PPLBUtility.B_ClosePrn();
|
||||
}
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
#region 斑马打印
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
/// <param name="zplStr"></param>
|
||||
/// <returns></returns>
|
||||
//[NonAction]
|
||||
//protected async Task Print(string zplStr)
|
||||
//{
|
||||
// var zpl_string = @$"^XA
|
||||
// ^XA^LH0,0^LL100^PW580
|
||||
// ^FX 文本
|
||||
// ^FO 80,100^BCN,100,10^FDQA,Hello world^FS
|
||||
// ^FO 150,200^A0N 80,50^FD Hello world^FS
|
||||
// ^XZ";
|
||||
// List<DiscoveredPrinter> printerList = await GetUSBPrinters();
|
||||
// if (printerList?.Count > 0)
|
||||
// {
|
||||
// // in this case, we arbitrarily are printing to the first found printer
|
||||
// DiscoveredPrinter discoveredPrinter = printerList[0];
|
||||
// Connection connection = discoveredPrinter.GetConnection();
|
||||
// connection.Open();
|
||||
// connection.Write(Encoding.UTF8.GetBytes(zplStr));
|
||||
// }
|
||||
//}
|
||||
|
||||
//private Task<List<DiscoveredPrinter>> GetUSBPrinters()
|
||||
//{
|
||||
// var tcs = new TaskCompletionSource<List<DiscoveredPrinter>>();
|
||||
// List<DiscoveredPrinter> printerList = new();
|
||||
// try
|
||||
// {
|
||||
// foreach (DiscoveredUsbPrinter usbPrinter in UsbDiscoverer.GetZebraUsbPrinters())
|
||||
// {
|
||||
// printerList.Add(usbPrinter);
|
||||
// Console.WriteLine(usbPrinter);
|
||||
// }
|
||||
// }
|
||||
// catch (ConnectionException e)
|
||||
// {
|
||||
// JNPF.Logging.Log.Error("获取本地打印机时出错", e);
|
||||
// tcs.SetException(e);
|
||||
// }
|
||||
// Console.WriteLine("Done discovering local printers.");
|
||||
// tcs.SetResult(printerList);
|
||||
// return tcs.Task;
|
||||
//}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Api响应结果
|
||||
|
||||
@@ -151,8 +151,8 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost]
|
||||
public async Task IsMinStorage(CancellationTokenSource? cts = default)
|
||||
{
|
||||
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
var curUser = await GetUserIdentity();
|
||||
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity();
|
||||
var curDb = _db.CopyNew();
|
||||
try
|
||||
{
|
||||
@@ -193,11 +193,11 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
outstock =
|
||||
{
|
||||
org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value,
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = "28135837838101",//单据类型:自动补货单
|
||||
warehouse_id = "1",
|
||||
create_id= curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value,
|
||||
create_id= _userManager.UserId,
|
||||
}
|
||||
};
|
||||
foreach (var d in dics)
|
||||
@@ -221,7 +221,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
RequestURL = App.HttpContext?.Request?.Path,
|
||||
RequestMethod = App.HttpContext?.Request?.Method,
|
||||
userIdentity = curUser,
|
||||
userIdentity = await GetUserIdentity(_userManager.ToKen),
|
||||
};
|
||||
var timedTaskEx = ex.ToTimedTaskException(ei);
|
||||
cts?.Cancel();
|
||||
|
||||
1093
WarehouseMgr/Tnb.WarehouseMgr/Print/PPLBUtility.cs
Normal file
1093
WarehouseMgr/Tnb.WarehouseMgr/Print/PPLBUtility.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
public class TimedTaskBackgroundService : BackgroundService
|
||||
{
|
||||
public bool IsStarted { get; set; }
|
||||
private IEventPublisher _eventPublisher = default!;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private static Dictionary<string, Func<CancellationTokenSource?, Task>> _timedFuncMap = new(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -59,6 +60,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
IsStarted = true;
|
||||
var queueTask = Task.Run(async () =>
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)\common.props" />
|
||||
|
||||
@@ -18,4 +18,22 @@
|
||||
<ProjectReference Include="..\Tnb.WarehouseMgr.Interfaces\Tnb.WarehouseMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Library\x64\WinPort.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Library\x64\Winpplb.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ZebraLib\SdkApi.Core.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ZebraLib\SdkApi.Desktop.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ZebraLib\SdkApi.Desktop.Usb.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -218,5 +218,16 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 条码打印
|
||||
/// </summary>
|
||||
/// <param name="barCodes"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task BarCodePrint(List<string> barCodes)
|
||||
{
|
||||
await base.BarCodePrint(barCodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using System.Reflection;
|
||||
using Tnb.WarehouseMgr.Print;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -375,6 +377,146 @@ namespace Tnb.WarehouseMgr
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试获取路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetTest()
|
||||
{
|
||||
//D:\Workspce\tianyi\TuoTong-LowCodePlatform-BackEnd\apihost\Tnb.API.Entry\bin\Debug\net6.0\
|
||||
var dllPath = Path.Combine(AppContext.BaseDirectory, @"Library\x64");
|
||||
var files = Directory.GetFiles(dllPath);
|
||||
return dllPath;
|
||||
}
|
||||
|
||||
|
||||
public async Task<dynamic> PrintTest(List<string> barCodes)
|
||||
{
|
||||
// open port.
|
||||
int nLen, ret, sw;
|
||||
byte[] pbuf = new byte[128];
|
||||
string strmsg;
|
||||
|
||||
IntPtr ver;
|
||||
System.Text.Encoding encAscII = System.Text.Encoding.ASCII;
|
||||
System.Text.Encoding encUnicode = System.Text.Encoding.Unicode;
|
||||
|
||||
// dll version.
|
||||
ver = PPLBUtility.B_Get_DLL_Version(0);
|
||||
// search port.
|
||||
nLen = PPLBUtility.B_GetUSBBufferLen() + 1;
|
||||
strmsg = "DLL ";
|
||||
strmsg += Marshal.PtrToStringAnsi(ver);
|
||||
strmsg += "\r\n";
|
||||
if (nLen > 1)
|
||||
{
|
||||
byte[] buf1, buf2;
|
||||
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);
|
||||
sw = 1;
|
||||
if (1 == sw)
|
||||
{
|
||||
ret = PPLBUtility.B_CreatePrn(12, encAscII.GetString(buf2, 0, len2));// open usb.
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = PPLBUtility.B_CreateUSBPort(1);// must call B_GetUSBBufferLen() function fisrt.
|
||||
}
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += "Open USB fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += "Open USB:\r\nDevice name: ";
|
||||
strmsg += encAscII.GetString(buf1, 0, len1);
|
||||
strmsg += "\r\nDevice path: ";
|
||||
strmsg += encAscII.GetString(buf2, 0, len2);
|
||||
//sw = 2;
|
||||
if (2 == sw)
|
||||
{
|
||||
//Immediate Error Report.
|
||||
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);
|
||||
ret = PPLBUtility.B_CreatePrn(0, PPLBUtility.szSaveFile);// open file.
|
||||
strmsg += "Open ";
|
||||
strmsg += PPLBUtility.szSaveFile;
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += " file fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += " file succeed!";
|
||||
}
|
||||
}
|
||||
if (0 != ret)
|
||||
return null;
|
||||
|
||||
// sample setting.
|
||||
//B_Set_DebugDialog(1);
|
||||
//var sznop2 = "测试";
|
||||
//var sznop1 = "测试2";
|
||||
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_WriteData(0, encAscII.GetBytes(sznop2), sznop2.Length);
|
||||
//PPLBUtility.B_WriteData(1, encAscII.GetBytes(sznop1), sznop1.Length);
|
||||
//When using standard label, and the printer is Intelli Print mode or Smart Print mode,
|
||||
//When calling this function and giving the correct label information,
|
||||
//the immediate print function will be enabled according to the label length setting.
|
||||
PPLBUtility.B_Set_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm.
|
||||
|
||||
//draw box.
|
||||
//PPLBUtility.B_Draw_Box(20, 20, 4, 760, 560);
|
||||
//PPLBUtility.B_Draw_Line('O', 400, 20, 4, 540);
|
||||
|
||||
//print text, true type text.
|
||||
PPLBUtility.B_Prn_Text(250, 50, 0, 2, 2, 2, 'N', "PPLB Lib Example");
|
||||
//PPLBUtility.B_Prn_Text_TrueType(30, 100, 30, "Arial", 1, 400, 0, 0, 0, "AA", "TrueType Font");//save in printer.
|
||||
//PPLBUtility.B_Prn_Text_TrueType_W(30, 160, 20, 20, "Times New Roman", 1, 400, 0, 0, 0, "AB", "TT_W: 多字元測試");
|
||||
//PPLBUtility.B_Prn_Text_TrueType_Uni(30, 220, 30, "Times New Roman", 1, 400, 0, 0, 0, "AC", Encoding.Unicode.GetBytes("TT_Uni: 多字元測試"), 1);//UTF-16
|
||||
//encUnicode.GetBytes("\xFEFF", 0, 1, pbuf, 0);//UTF-16.//pbuf[0]=0xFF,pbuf[1]=0xFE;
|
||||
//encUnicode.GetBytes("TT_UniB: 多字元測試", 0, 14, pbuf, 2);//copy mutil byte.
|
||||
//encUnicode.GetBytes("\x0000", 0, 1, pbuf, 30);//null.//pbuf[30]=0x00,pbuf[31]=0x00;
|
||||
//PPLBUtility.B_Prn_Text_TrueType_UniB(30, 280, 30, "Times New Roman", 1, 400, 0, 0, 0, "AD", pbuf, 0);//Byte Order Mark.
|
||||
|
||||
var labelWth = 800;
|
||||
var barcodeWth = 508;
|
||||
var x = (labelWth - barcodeWth) / 2;
|
||||
|
||||
//barcode.
|
||||
PPLBUtility.B_Prn_Barcode(150, 100, 0, "E80", 8, 500, 70, 'N', "1234<+10>");//have a counter
|
||||
//PPLBUtility.B_Bar2d_QR(420, 200, 1, 3, 'M', 'A', 0, 0, 0, "QR CODE");
|
||||
|
||||
//picture.
|
||||
//PPLBUtility.B_Get_Graphic_ColorBMP(420, 280, "bb.bmp");// Color bmp file.
|
||||
//PPLBUtility.B_Get_Graphic_ColorBMPEx(420, 320, 200, 150, 2, "bb1", "bb.bmp");//180 angle.
|
||||
//IntPtr himage = LoadImage(IntPtr.Zero, "bb.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
//PPLBUtility.B_Get_Graphic_ColorBMP_HBitmap(630, 280, 250, 80, 1, "bb2", himage);//90 angle.
|
||||
//if (IntPtr.Zero != himage)
|
||||
// DeleteObject(himage);
|
||||
|
||||
// output.
|
||||
PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
|
||||
// close port.
|
||||
PPLBUtility.B_ClosePrn();
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据出库申请单ID获取申请单明细信息
|
||||
/// </summary>
|
||||
|
||||
@@ -97,8 +97,8 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, Timed(Name = nameof(PackSortingByAdd))]
|
||||
public async Task PackSortingByAdd(CancellationTokenSource? cts = default)
|
||||
{
|
||||
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
var curUser = await GetUserIdentity();
|
||||
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity();
|
||||
|
||||
//Console.WriteLine($"ThreadID:{Thread.CurrentThread.ManagedThreadId}\t Thread pool: {Thread.CurrentThread.IsThreadPoolThread}");
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
RequestURL = App.HttpContext?.Request?.Path,
|
||||
RequestMethod = App.HttpContext?.Request?.Method,
|
||||
userIdentity = curUser,
|
||||
userIdentity = await GetUserIdentity(_userManager.ToKen),
|
||||
};
|
||||
var timedTaskEx = ex.ToTimedTaskException(ei);
|
||||
cts?.Cancel();
|
||||
|
||||
@@ -80,8 +80,8 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, Timed(Name = nameof(KittingOutByAdd))]
|
||||
public async Task KittingOutByAdd(CancellationTokenSource? cts = default)
|
||||
{
|
||||
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
var curUser = await GetUserIdentity();
|
||||
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity();
|
||||
var curDb = _db.CopyNew();
|
||||
try
|
||||
{
|
||||
@@ -136,8 +136,8 @@ namespace Tnb.WarehouseMgr
|
||||
setSortingH.id = SnowflakeIdHelper.NextId();
|
||||
setSortingH.kittingout_id = ko.id;
|
||||
setSortingH.seq = ko.seq;
|
||||
setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value;
|
||||
setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value;
|
||||
setSortingH.org_id = _userManager.User.OrganizeId;
|
||||
setSortingH.create_id = _userManager.UserId;
|
||||
setSortingH.create_time = DateTime.Now;
|
||||
await curDb.Insertable(setSortingH).ExecuteCommandAsync();
|
||||
|
||||
@@ -148,8 +148,8 @@ namespace Tnb.WarehouseMgr
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.bill_id = setSortingH.id;
|
||||
x.warehouse_id = setSortingH.warehouse_id;
|
||||
x.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value;
|
||||
x.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value;
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
});
|
||||
await curDb.Insertable(setSortDetails).ExecuteCommandAsync();
|
||||
@@ -171,7 +171,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
RequestURL = App.HttpContext?.Request?.Path,
|
||||
RequestMethod = App.HttpContext?.Request?.Method,
|
||||
userIdentity = curUser,
|
||||
userIdentity = await GetUserIdentity(_userManager.ToKen),
|
||||
};
|
||||
var timedTaskEx = ex.ToTimedTaskException(ei);
|
||||
cts?.Cancel();
|
||||
@@ -185,8 +185,8 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, Timed(Name = nameof(KittingOutByIsToBeShipped))]
|
||||
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
|
||||
{
|
||||
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
var curUser = await GetUserIdentity();
|
||||
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity();
|
||||
var curDb = _db.CopyNew();
|
||||
try
|
||||
{
|
||||
@@ -225,7 +225,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
WmsPretaskH preTask = new()
|
||||
{
|
||||
org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value,
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
startlocation_id = sPoint?.location_id!,
|
||||
startlocation_code = sPoint?.location_code!,
|
||||
endlocation_id = ePoint?.location_id!,
|
||||
@@ -246,7 +246,7 @@ namespace Tnb.WarehouseMgr
|
||||
area_code = it.Key,
|
||||
require_id = ko.id,
|
||||
require_code = ko.bill_code,
|
||||
create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
source_id = ko.source_id,
|
||||
source_code = ko.source_code
|
||||
@@ -278,7 +278,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
RequestURL = App.HttpContext?.Request?.Path,
|
||||
RequestMethod = App.HttpContext?.Request?.Method,
|
||||
userIdentity = curUser,
|
||||
userIdentity = await GetUserIdentity(_userManager.ToKen),
|
||||
};
|
||||
var timedTaskEx = ex.ToTimedTaskException(ei);
|
||||
cts?.Cancel();
|
||||
|
||||
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Core.dll
Normal file
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Core.dll
Normal file
Binary file not shown.
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Desktop.Usb.dll
Normal file
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Desktop.Usb.dll
Normal file
Binary file not shown.
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Desktop.dll
Normal file
BIN
WarehouseMgr/Tnb.WarehouseMgr/ZebraLib/SdkApi.Desktop.dll
Normal file
Binary file not shown.
@@ -64,8 +64,10 @@ public class Startup : AppStartup
|
||||
services.AddOverideVisualDev();
|
||||
//注册任务消息通知 added by ly on 20230814
|
||||
services.AddTaskMessageNotify();
|
||||
|
||||
services.AddSingleton<BackgroundService, TimedTaskBackgroundService>();
|
||||
//定时任务
|
||||
services.AddHostedService<TimedTaskBackgroundService>();
|
||||
//services.AddHostedService<TimedTaskBackgroundService>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ using JNPF.Extras.DatabaseAccessor.SqlSugar.Models;
|
||||
using Aop.Api.Domain;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using bf = System.Reflection.BindingFlags;
|
||||
|
||||
namespace JNPF.OAuth;
|
||||
|
||||
@@ -142,6 +143,8 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
|
||||
private readonly IMHandler _imHandler;
|
||||
|
||||
private readonly BackgroundService _backgroundService; //added by ly on 20230916
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -165,7 +168,8 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
ICacheManager cacheManager,
|
||||
IUserManager userManager,
|
||||
IEventPublisher eventPublisher,
|
||||
IMHandler imHandler)
|
||||
IMHandler imHandler,
|
||||
BackgroundService backgroundService)
|
||||
{
|
||||
_captchaHandler = captchaHandler;
|
||||
_userRepository = userRepository;
|
||||
@@ -185,6 +189,7 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
_userManager = userManager;
|
||||
_eventPublisher = eventPublisher;
|
||||
_imHandler = imHandler;
|
||||
_backgroundService = backgroundService;
|
||||
}
|
||||
|
||||
#region Get
|
||||
@@ -287,6 +292,20 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
|
||||
var userId = _userManager.UserId;
|
||||
|
||||
//modify by ly on 20230918 登录成功后启动定时服务
|
||||
if (!userId.IsNullOrWhiteSpace())
|
||||
{
|
||||
var isStartedProperty = _backgroundService.GetType().GetProperty("IsStarted");
|
||||
|
||||
if (isStartedProperty?.GetValue(_backgroundService) is bool isStarted && !isStarted)
|
||||
{
|
||||
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||
await _backgroundService.StartAsync(cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var loginOutput = new CurrentUserOutput();
|
||||
loginOutput.userInfo = await _userManager.GetUserInfo();
|
||||
|
||||
@@ -388,6 +407,9 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
{
|
||||
//await _cacheManager.DelAsync("AsscessToken");
|
||||
|
||||
|
||||
//modify by ly on 20230918
|
||||
_backgroundService.PropertySetValue("IsStarted", false);
|
||||
UserManager.AsscessToken = string.Empty;
|
||||
|
||||
var tenantId = _userManager.TenantId ?? "default";
|
||||
|
||||
Reference in New Issue
Block a user