diff --git a/Bootstrap.Admin/Controllers/Api/TasksController.cs b/Bootstrap.Admin/Controllers/Api/TasksController.cs index 29bc80be..f68990b7 100644 --- a/Bootstrap.Admin/Controllers/Api/TasksController.cs +++ b/Bootstrap.Admin/Controllers/Api/TasksController.cs @@ -37,25 +37,6 @@ namespace Bootstrap.Admin.Controllers.Api return true; } - /// - /// - /// - /// - /// - /// - [HttpPut] - public bool Put([FromQuery]string name, [FromServices]IHubContext hub) - { - var sche = TaskServicesManager.GetOrAdd(name); - sche.Triggers[0].RegisterPulseCallback(async t => - { - var success = t.Cancelled ? "Cancelled" : "Success"; - var result = $"{t.Scheduler.LastRuntime.Value.DateTime}: Trigger({t.GetType().Name}) Run({success}) NextRuntime: {t.NextRuntime.Value.DateTime} Elapsed: {t.LastRunElapsedTime.Seconds}s"; - await SignalRManager.SendTaskLog(hub.Clients.All, result); - }); - return true; - } - /// /// /// diff --git a/Bootstrap.Admin/Controllers/Api/TasksLogController.cs b/Bootstrap.Admin/Controllers/Api/TasksLogController.cs new file mode 100644 index 00000000..5c504dda --- /dev/null +++ b/Bootstrap.Admin/Controllers/Api/TasksLogController.cs @@ -0,0 +1,34 @@ +using Longbow.Tasks; +using Longbow.Web.SignalR; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.SignalR; + +namespace Bootstrap.Admin.Controllers.Api +{ + /// + /// + /// + [Route("api/[controller]")] + [ApiController] + public class TasksLogController : ControllerBase + { + /// + /// + /// + /// + /// + /// + [HttpGet] + public bool Get([FromQuery]string name, [FromServices]IHubContext hub) + { + var sche = TaskServicesManager.GetOrAdd(name); + sche.Triggers[0].RegisterPulseCallback(async t => + { + var success = t.Cancelled ? "Cancelled" : "Success"; + var result = $"{t.Scheduler.LastRuntime.Value.DateTime}: Trigger({t.GetType().Name}) Run({success}) NextRuntime: {t.NextRuntime.Value.DateTime} Elapsed: {t.LastRunElapsedTime.Seconds}s"; + await SignalRManager.SendTaskLog(hub.Clients.All, result); + }); + return true; + } + } +} diff --git a/Bootstrap.Admin/wwwroot/js/tasks.js b/Bootstrap.Admin/wwwroot/js/tasks.js index 315ba288..9fa098dd 100644 --- a/Bootstrap.Admin/wwwroot/js/tasks.js +++ b/Bootstrap.Admin/wwwroot/js/tasks.js @@ -48,8 +48,7 @@ 'click .info': function (e, value, row, index) { $taskLogModelTitle.html(row.Name + ' - 任务日志窗口(最新50条)'); $.bc({ - url: 'api/Tasks?name=' + row.Name, - method: 'put' + url: 'api/TasksLog?name=' + row.Name }); $('#dialogLog').modal('show').on('hide.bs.modal', function () { // close hub @@ -68,6 +67,8 @@ while (this.children().length > 50) { this.children().first().remove(); } + result = result.replace("Run(Cancelled)", "Run(Cancelled)"); + result = result.replace("Run(Success)", "Run(Success)"); this.append('
' + result + '
'); }, onclose: function (error) {