初步可用后台
This commit is contained in:
@@ -52,6 +52,42 @@ namespace JXCMS.Core.TimingTask
|
||||
{
|
||||
return await _scheduler.DeleteJobs(jobKeys);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Corn表达式的运行时间
|
||||
/// </summary>
|
||||
/// <param name="cron">表达式</param>
|
||||
/// <param name="times">计算次数</param>
|
||||
/// <param name="startTime">开始时间</param>
|
||||
/// <returns></returns>
|
||||
public static string GetCronSchedule(String cron, int times, DateTimeOffset startTime)
|
||||
{
|
||||
String timeSchedule = "";
|
||||
if (!CronExpression.IsValidExpression(cron))
|
||||
{
|
||||
return "Cron表达式不合法!";
|
||||
}
|
||||
try
|
||||
{
|
||||
ITrigger trigger1 = TriggerBuilder.Create()
|
||||
|
||||
.WithCronSchedule(cron)
|
||||
.StartNow()
|
||||
.Build();
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
DateTimeOffset? s = trigger1.GetFireTimeAfter(startTime);
|
||||
DateTime? time = s?.LocalDateTime;
|
||||
timeSchedule = time?.ToString("F");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
timeSchedule = "未知时间";
|
||||
}
|
||||
|
||||
return timeSchedule;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user