using System.Collections.Concurrent;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Job;
using log4net;
using Service.WaterCool.Client;
namespace Service.Job;
///
/// 每秒发送水冷
///
[Scope]
public class SendWaterCoolJob : AbstractCronJob
{
private static readonly ILog Log = LogManager.GetLogger(typeof(SendWaterCoolJob));
protected override Task Handle()
{
ConcurrentDictionary waterCool = WaterCoolClientMgr.Dictionary;
if (waterCool.Values.Count <= 0)
{
return Task.CompletedTask;
}
foreach (var waterCoolClient in waterCool)
{
WaterCoolClient client = waterCoolClient.Value;
if (client.IsConnect && client.IsWaterCoolSend)
{
client.Send();
}
}
Log.Info($"水冷发送成功");
return Task.CompletedTask;
}
protected override string Key()
{
return "SendWaterCoolJob";
}
protected override string Cron()
{
return "* * * * * ? *";
}
}