1
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 定时任务
|
||||
/// added by ly on 20230802
|
||||
/// </summary>
|
||||
public class TimedTaskBackgroundService : BackgroundService
|
||||
public class TimedTaskBackgroundService : IHostedService
|
||||
{
|
||||
private ISendMessageService? _sendService;
|
||||
|
||||
@@ -50,8 +50,6 @@ namespace Tnb.WarehouseMgr
|
||||
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private Task TimedTask(Func<CancellationTokenSource, Task> action, CancellationTokenSource cts, List<string>? toUserIds = default)
|
||||
{
|
||||
var token = cts.Token;
|
||||
|
||||
@@ -64,7 +64,9 @@ public class Startup : AppStartup
|
||||
services.AddOverideVisualDev();
|
||||
|
||||
//定时任务
|
||||
services.AddHostedService<TimedTaskBackgroundService>();
|
||||
//services.AddHostedService<TimedTaskBackgroundService>();
|
||||
//services.AddSingleton<TimedTaskBackgroundService>();
|
||||
//services.AddHostedService(sp => new ConditionalBackgroundService(sp.GetRequiredService<TimedTaskBackgroundService>()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ using JNPF.Common.Core.Handlers;
|
||||
using JNPF.Message.Interfaces.Message;
|
||||
using JNPF.Extras.DatabaseAccessor.SqlSugar.Models;
|
||||
using Aop.Api.Domain;
|
||||
using Tnb.WarehouseMgr;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace JNPF.OAuth;
|
||||
|
||||
@@ -140,6 +143,8 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
|
||||
private readonly IMHandler _imHandler;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="OAuthService"/>类型的新实例.
|
||||
/// </summary>
|
||||
@@ -382,10 +387,14 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
[HttpGet("Logout")]
|
||||
public async Task Logout([FromQuery] string ticket)
|
||||
{
|
||||
|
||||
var tenantId = _userManager.TenantId ?? "default";
|
||||
var userId = _userManager.UserId ?? "admim";
|
||||
var httpContext = _httpContextAccessor.HttpContext;
|
||||
httpContext.SignoutToSwagger();
|
||||
//用户退出时停止Wms定时任务 modify by ly on 20230804
|
||||
var timedTaskService = ActivatorUtilities.CreateInstance<TimedTaskBackgroundService>(httpContext.RequestServices);
|
||||
await timedTaskService.StopAsync(CancellationToken.None);
|
||||
|
||||
// 清除IM中的webSocket
|
||||
var list = await GetOnlineUserList(tenantId);
|
||||
@@ -672,6 +681,12 @@ public class OAuthService : IDynamicApiController, ITransient
|
||||
}
|
||||
}
|
||||
|
||||
//启动Wms定时服务 modify by ly on 20230804
|
||||
//var conditionalBackgroundService = App.GetRequiredService<ConditionalBackgroundService>();
|
||||
//await conditionalBackgroundService.StartAsync(CancellationToken.None);
|
||||
var httpContext = _httpContextAccessor.HttpContext;
|
||||
var timedTaskService = ActivatorUtilities.CreateInstance<TimedTaskBackgroundService>(httpContext.RequestServices);
|
||||
await timedTaskService.StartAsync(default);
|
||||
return new
|
||||
{
|
||||
theme = user.Theme == null ? "classic" : user.Theme,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
|
||||
<ProjectReference Include="..\..\message\Tnb.Message.Interfaces\Tnb.Message.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr\Tnb.WarehouseMgr.csproj" />
|
||||
<ProjectReference Include="..\Tnb.Systems.Interfaces\Tnb.Systems.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user