BootstrapAdmin/Bootstrap.Admin/Controllers/Api/TasksController.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2019-06-26 12:01:34 +08:00
using Longbow.Tasks;
using Longbow.Web.SignalR;
2018-06-07 00:45:47 +08:00
using Microsoft.AspNetCore.Mvc;
2019-06-26 12:01:34 +08:00
using Microsoft.AspNetCore.SignalR;
using System.Collections.Generic;
2019-06-26 12:01:34 +08:00
using System.Linq;
using System.Threading.Tasks;
2018-06-07 00:45:47 +08:00
namespace Bootstrap.Admin.Controllers.Api
{
2018-06-07 00:45:47 +08:00
/// <summary>
2019-06-26 12:01:34 +08:00
///
/// </summary>
2018-06-07 00:45:47 +08:00
[Route("api/[controller]")]
[ApiController]
public class TasksController : ControllerBase
{
2018-06-07 00:45:47 +08:00
/// <summary>
2019-06-26 12:01:34 +08:00
///
2018-06-07 00:45:47 +08:00
/// </summary>
/// <returns></returns>
[HttpGet]
2019-06-26 12:01:34 +08:00
public IEnumerable<object> Get()
{
TaskServicesManager.GetOrAdd("测试任务", token => Task.Delay(1000), TriggerBuilder.WithCronExpression("*/5 * * * * *"));
return TaskServicesManager.ToList().Select(s => new { s.Name, s.Enabled, s.Status, s.LastRuntime, s.CreatedTime, s.NextRuntime, Triggers = s.Triggers.Count, s.LastRunResult, TriggerExpression = s.Triggers.FirstOrDefault().ToString() });
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpPost]
public bool Post()
{
2019-06-26 12:01:34 +08:00
// UNDONE: 待完善
return true;
}
2019-06-26 12:01:34 +08:00
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpDelete]
public bool Delete() => true;
}
2019-06-26 12:01:34 +08:00
}