public ActionResult <TaskInfo> GetTask([FromRoute, Required] string?taskId) { var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, taskId, StringComparison.OrdinalIgnoreCase)); if (task == null) { return(NotFound()); } return(ScheduledTaskHelpers.GetTaskInfo(task)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>IEnumerable{TaskInfo}.</returns> /// <exception cref="ResourceNotFoundException">Task not found</exception> public object Get(GetScheduledTask request) { var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); if (task == null) { throw new ResourceNotFoundException("Task not found"); } var result = ScheduledTaskHelpers.GetTaskInfo(task); return(ToOptimizedResult(result)); }
public IEnumerable <TaskInfo> GetTasks( [FromQuery] bool?isHidden, [FromQuery] bool?isEnabled) { IEnumerable <IScheduledTaskWorker> tasks = _taskManager.ScheduledTasks.OrderBy(o => o.Name); foreach (var task in tasks) { if (task.ScheduledTask is IConfigurableScheduledTask scheduledTask) { if (isHidden.HasValue && isHidden.Value != scheduledTask.IsHidden) { continue; } if (isEnabled.HasValue && isEnabled.Value != scheduledTask.IsEnabled) { continue; } } yield return(ScheduledTaskHelpers.GetTaskInfo(task)); } }