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;
|
2016-11-17 09:41:13 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-06-26 12:01:34 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-11-17 09:41:13 +08:00
|
|
|
|
|
2018-06-07 00:45:47 +08:00
|
|
|
|
namespace Bootstrap.Admin.Controllers.Api
|
2016-11-17 09:41:13 +08:00
|
|
|
|
{
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <summary>
|
2019-06-26 12:01:34 +08:00
|
|
|
|
///
|
2017-03-30 15:32:49 +08:00
|
|
|
|
/// </summary>
|
2018-06-07 00:45:47 +08:00
|
|
|
|
[Route("api/[controller]")]
|
2018-11-24 15:12:44 +08:00
|
|
|
|
[ApiController]
|
|
|
|
|
public class TasksController : ControllerBase
|
2016-11-17 09:41:13 +08:00
|
|
|
|
{
|
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>
|
2017-03-30 15:32:49 +08:00
|
|
|
|
/// <returns></returns>
|
2016-11-17 09:41:13 +08:00
|
|
|
|
[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()
|
2016-11-17 09:41:13 +08:00
|
|
|
|
{
|
2019-06-26 12:01:34 +08:00
|
|
|
|
// UNDONE: 待完善
|
|
|
|
|
return true;
|
2016-11-17 09:41:13 +08:00
|
|
|
|
}
|
2019-06-26 12:01:34 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpDelete]
|
|
|
|
|
public bool Delete() => true;
|
2016-11-17 09:41:13 +08:00
|
|
|
|
}
|
2019-06-26 12:01:34 +08:00
|
|
|
|
}
|