namespace Admin.NET.Core.Job;
///
/// 任务调度
///
public class OnlineUserJob : ISpareTimeWorker
{
///
/// 在线用户清理 服务启动时 自动清空在线用户,防止存在僵尸用户,掉线用户会自动重连
///
[SpareTime(1000, "在线用户清理", Description = "服务启动时运行", DoOnce = true, StartNow = true, ExecuteType = SpareTimeExecuteTypes.Serial)]
public void ClearOnlineUser(SpareTimer timer, long count)
{
Scoped.Create(async (_, scope) =>
{
var services = scope.ServiceProvider;
var rep = services.GetService>();
await rep.AsDeleteable().ExecuteCommandAsync();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("【" + DateTime.Now + "——清空在线人员】\r\n服务重启触发清空在线人员");
});
}
}