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服务重启触发清空在线用户");
});
}
}