123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq;
- using Microsoft.Extensions.Hosting;
- using MySystem.PxcModels;
- using MySystem;
- public class TeamTopService : BackgroundService
- {
- protected override async Task ExecuteAsync(CancellationToken stoppingToken)
- {
- while (!stoppingToken.IsCancellationRequested)
- {
- int timespan = 1000 * 60 * 60;
- await Task.Delay(timespan).ContinueWith(tsk =>
- {
- WebCMSEntities db = new WebCMSEntities();
- //首页-特训营-排行榜-个人
- var personTops = db.TeamPersonDayTop.Select(m => new { m.Id, m.ActMerNum }).OrderByDescending(m => m.ActMerNum).ToList();
- RedisDbconn.Instance.Clear("TeamPersonDayTop");
- foreach (var sub in personTops)
- {
- RedisDbconn.Instance.AddList("TeamPersonDayTop", sub.Id);
- }
- //首页-特训营-排行榜-团队
- var teamTops = db.TeamDayTop.Select(m => new { m.Id, m.ActMerNum }).OrderByDescending(m => m.ActMerNum).ToList();
- RedisDbconn.Instance.Clear("TeamDayTop");
- foreach (var sub in teamTops)
- {
- RedisDbconn.Instance.AddList("TeamDayTop", sub.Id);
- }
- db.Dispose();
- });
- }
- }
- }
|