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