Update Happiness Task

This commit is contained in:
Chris Chen
2022-10-02 09:50:42 -07:00
parent b33c0d8286
commit f9a5dc5e34
43 changed files with 4904 additions and 623 deletions
+16 -2
View File
@@ -1,6 +1,7 @@
using Church.Net.Utility;
using System;
using System.Threading.Tasks;
using WebAPI.Logics;
using WebAPI.Services.Interfaces;
namespace WebAPI.Services.ScheduledTask
@@ -9,14 +10,17 @@ namespace WebAPI.Services.ScheduledTask
{
private readonly LineAutoBotService lineAutoBotService;
private readonly ILoggingService loggingService;
private readonly PastoralDomainLogic pastoralDomainLogic;
private DateTime? nextRunningTime = null;
public MorningPrayer(
LineAutoBotService lineAutoBotService,
ILoggingService loggingService
ILoggingService loggingService,
PastoralDomainLogic pastoralDomainLogic
)
{
this.lineAutoBotService = lineAutoBotService;
this.loggingService = loggingService;
this.pastoralDomainLogic = pastoralDomainLogic;
this.SetNextRunningTime();
}
public string Description => "Sent out Ark Morning Prayer";
@@ -35,7 +39,17 @@ namespace WebAPI.Services.ScheduledTask
public Task<bool> RunTask()
{
SetNextRunningTime();
return lineAutoBotService.PushCommandMessage(LineGroup.Ark, "#pray");
return Task.Run(async () =>
{
var list = pastoralDomainLogic.GetAll(p => p.Type == Church.Net.Entity.DomainType.CellGroup);
foreach (var group in list)
{
await lineAutoBotService.PushCommandMessage(group, "#pray");
}
return true;
});
}
private void SetNextRunningTime()
{