async Task CheckTasks() { List <ScheduledTask> tasks = new List <ScheduledTask>(); ScheduledTaskFilter filter = new ScheduledTaskFilter { DueTime = DateTime.Now }; while (true) { Page <ScheduledTask> page = await scheduledtaskservice.List(filter); tasks.AddRange(page.Result); if (page.Result.Length == 0 || !page.Continue.HasValue) { break; } filter.Continue = page.Continue; } foreach (ScheduledTask task in tasks) { switch (task.WorkableType) { case WorkableType.Workflow: await workflowexecutor.Execute(await workflowcompiler.BuildWorkflow(task.WorkableName), new Dictionary <string, object>(), false); break; case WorkableType.Script: await scriptexecutor.Execute(task.WorkableName, task.WorkableRevision); break; } try { await scheduledtaskservice.UpdateExecution(task.Id, task.NextExecutionTime()); } catch (Exception e) { logger.LogError(e, $"Unable to reschedule task '{task.Id}'"); } } }
public Task <Page <ScheduledTask> > ListScripts([FromQuery] ScheduledTaskFilter filter) { return(scheduledtaskservice.List(filter)); }