Update Happiness Task
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user