用户登录、登出通知Wms定时服务的启动预关闭
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
{
|
||||||
|
public class ConditionalBackgroundService : IHostedService
|
||||||
|
{
|
||||||
|
private readonly IHostedService _backgroundService;
|
||||||
|
//private readonly Func<bool> _condition;
|
||||||
|
|
||||||
|
public ConditionalBackgroundService(IHostedService backgroundService)
|
||||||
|
{
|
||||||
|
_backgroundService = backgroundService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _backgroundService.StartAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
public async Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _backgroundService.StopAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -283,7 +283,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
start = end;
|
start = end;
|
||||||
end = Math.Min((end + moveNum), arrary.Length);
|
end = Math.Min((end + moveNum), arrary.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var arr in arrList)
|
foreach (var arr in arrList)
|
||||||
{
|
{
|
||||||
for (int j = 1, len = arr.Length; j <= len; j++)
|
for (int j = 1, len = arr.Length; j <= len; j++)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Startup : AppStartup
|
|||||||
services.AddOverideVisualDev();
|
services.AddOverideVisualDev();
|
||||||
|
|
||||||
//定时任务
|
//定时任务
|
||||||
services.AddHostedService<TimedTaskBackgroundService>();
|
services.AddHostedService(sp => new ConditionalBackgroundService(sp.GetRequiredService<TimedTaskBackgroundService>()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ 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;
|
||||||
|
|
||||||
namespace JNPF.OAuth;
|
namespace JNPF.OAuth;
|
||||||
|
|
||||||
@@ -382,6 +383,10 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
[HttpGet("Logout")]
|
[HttpGet("Logout")]
|
||||||
public async Task Logout([FromQuery] string ticket)
|
public async Task Logout([FromQuery] string ticket)
|
||||||
{
|
{
|
||||||
|
//用户退出时停止Wms定时任务 modify by ly on 20230804
|
||||||
|
var conditionalBackgroundService = App.GetRequiredService<ConditionalBackgroundService>();
|
||||||
|
await conditionalBackgroundService.StopAsync(CancellationToken.None);
|
||||||
|
|
||||||
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;
|
||||||
@@ -672,6 +677,10 @@ public class OAuthService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//启动Wms定时服务 modify by ly on 20230804
|
||||||
|
var conditionalBackgroundService = App.GetRequiredService<ConditionalBackgroundService>();
|
||||||
|
await conditionalBackgroundService.StartAsync(CancellationToken.None);
|
||||||
|
|
||||||
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