using Microsoft.AspNetCore.Mvc;
|
using Rhea.Common;
|
using Tiger.IBusiness;
|
using System.Threading.Tasks;
|
using Tiger.Model;
|
|
namespace Tiger.Api.Controllers.TSK
|
{
|
public partial class TskController : ControllerBase
|
{
|
/// <summary>
|
/// 根据Job实体名称和Job名称添加任务
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> AddJob(ApiAction<TskJobParam> action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<IBizContext>().GetInterfaceService()?.AddJob(action.NewDataEntity(), action.Data)?? new ApiAction($"任务未启用", false));
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
/// <summary>
|
/// 根据Job实体名称和Job名称添加任务
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> AddJob(ApiAction<FluentJobParam> action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<IBizContext>().GetInterfaceService()?.AddJob(action.NewDataEntity(), action.Data) ?? new ApiAction($"任务未启用", false));
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> UpdateJob(ApiAction<TSK_JOB> action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<IBizContext>().GetInterfaceService()?.UpdateJob( action.Data)??new ApiAction($"任务未启用", false));
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
/// <summary>
|
/// 根据Job名称启动任务
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> StartJob(ApiAction action)
|
{
|
ApiAction response = new();
|
try
|
{
|
DI.Resolve<IBizContext>().GetInterfaceService()?.StartJob(action.Data?.ToString());
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
/// <summary>
|
/// 获取单个作业
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> GetJob(ApiAction action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<IBizContext>().GetInterfaceService()?.GetJob(action.Data?.ToString()));
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
/// <summary>
|
/// 获取所有作业
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> GetJobs(ApiAction action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<IBizContext>().GetInterfaceService()?.GetJobs());
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
/// <summary>
|
/// 暂停作业
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> PauseJob(ApiAction action)
|
{
|
ApiAction response = new();
|
try
|
{
|
DI.Resolve<IBizContext>().GetInterfaceService()?.PauseJob(action.Data?.ToString());
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
/// <summary>
|
/// 删除作业
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> RemoveJob(ApiAction action)
|
{
|
ApiAction response = new();
|
try
|
{
|
DI.Resolve<IBizContext>().GetInterfaceService()?.RemoveJob(action.Data?.ToString());
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
|
/// <summary>
|
/// 保存作业
|
/// </summary>
|
/// <param name="action"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("api/[controller]/[action]")]
|
public async Task<IActionResult> SaveTskJob(ApiAction<TskParameter> action)
|
{
|
ApiAction response = new();
|
try
|
{
|
response = response.GetResponse(DI.Resolve<ITskJob>().SaveTskJob(action.Data));
|
}
|
catch (System.Exception ex)
|
{
|
response = response.GetResponse().CatchExceptionWithLog(ex);
|
}
|
return Ok(response);
|
}
|
}
|
}
|