This commit is contained in:
Chris Chen
2023-08-20 11:28:47 -07:00
parent 2c491b63de
commit ad0bc0e49b
78 changed files with 3640 additions and 5639 deletions
@@ -11,7 +11,8 @@ namespace WebAPI.Services.ScheduledTask
private readonly LineAutoBotService lineAutoBotService;
private readonly ILoggingService loggingService;
private readonly PastoralDomainLogic pastoralDomainLogic;
private DateTime? nextRunningTime = null;
public static DateTime? NextRunningTime = null;
public MorningPrayer(
LineAutoBotService lineAutoBotService,
ILoggingService loggingService,
@@ -21,19 +22,19 @@ namespace WebAPI.Services.ScheduledTask
this.lineAutoBotService = lineAutoBotService;
this.loggingService = loggingService;
this.pastoralDomainLogic = pastoralDomainLogic;
this.SetNextRunningTime();
//this.SetNextRunningTime();
}
public string Description => "Sent out Ark Morning Prayer";
public bool CheckTime(DateTime time)
{
if(nextRunningTime == null)
if(NextRunningTime == null)
{
this.SetNextRunningTime();
return true;
return false;
}
return time >= nextRunningTime.Value;
return time >= NextRunningTime.Value;
}
public Task<bool> RunTask()
@@ -53,8 +54,8 @@ namespace WebAPI.Services.ScheduledTask
}
private void SetNextRunningTime()
{
nextRunningTime = DateTimeHelper.Today().AddDays(1).AddHours(8);
loggingService.Log($"Scheduled Task {this.Description}", nextRunningTime.Value);
NextRunningTime = DateTimeHelper.Today().AddDays(1).AddHours(8);
loggingService.Log($"Scheduled Task {this.Description}", NextRunningTime.Value);
}
}
}