public async Task <IActionResult> GetTaskRunInfo(int id /* taskId */) { // We better not check permission here. var lastExecutionInfo = await _taskStore.GetLastExecutionInfoByTaskIdAsync(id); var task = lastExecutionInfo?.Task ?? await _taskStore.GetTaskByIdAsync(id); if (task == null) { return(NotFound()); } var model = await task.MapAsync(lastExecutionInfo); var lastRunHtml = await this.InvokeViewAsync("_LastRun", model); var nextRunHtml = await this.InvokeViewAsync("_NextRun", model); return(Json(new { lastRunHtml, nextRunHtml })); }
private async Task Run(int taskId, HttpContext context, ITaskStore taskStore, ITaskExecutor executor, IDictionary <string, string> taskParameters) { var task = await taskStore.GetTaskByIdAsync(taskId); if (task == null) { context.Response.StatusCode = StatusCodes.Status404NotFound; return; } await Virtualize(context, taskParameters); await executor.ExecuteAsync(task, context, taskParameters); context.Response.StatusCode = StatusCodes.Status200OK; await context.Response.WriteAsync($"Task '{task.Name}' executed."); }
public async Task <IViewComponentResult> InvokeAsync(int taskId, string returnUrl, bool cancellable = true, bool reloadPage = false) { var lastExecutionInfo = await _taskStore.GetLastExecutionInfoByTaskIdAsync(taskId); var task = lastExecutionInfo?.Task ?? await _taskStore.GetTaskByIdAsync(taskId); if (task == null) { return(Empty()); } var model = await task.MapAsync(lastExecutionInfo); ViewBag.CanRead = await _permissionService.AuthorizeAsync(Permissions.System.ScheduleTask.Read); ViewBag.CanExecute = await _permissionService.AuthorizeAsync(Permissions.System.ScheduleTask.Execute); ViewBag.ReturnUrl = returnUrl; ViewBag.Cancellable = cancellable; ViewBag.ReloadPage = reloadPage; return(View(model)); }