41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using JiShe.ServicePro.Core;
|
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JiShe.IoT.Jobs
|
|
{
|
|
/// <summary>
|
|
/// 缓存设备数据到redis
|
|
/// </summary>
|
|
public class CacheDeviceDataToRedisJob : SystemBackGroundWorkService
|
|
{
|
|
private readonly ILogger<CacheDeviceDataToRedisJob> _logger;
|
|
public readonly DeviceAppService _meterAppService;
|
|
public CacheDeviceDataToRedisJob(ILogger<CacheDeviceDataToRedisJob> logger, DeviceAppService meterAppService) : base(logger)
|
|
{
|
|
_logger = logger;
|
|
_meterAppService = meterAppService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定时执行
|
|
/// </summary>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
protected override Task DoWorkAsync(CancellationToken cancellationToken)
|
|
{
|
|
return _meterAppService.CacheDeviceDataToRedisAsync();
|
|
}
|
|
|
|
protected override TimeSpan GetInterval()
|
|
{
|
|
return TimeSpan.FromHours(1);
|
|
}
|
|
}
|
|
}
|