using System; using System.Threading; using System.Threading.Tasks; using FastEndpoints; using FrameworkBLL.SystemJob; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.SystemJob { public class CancelSystemJob : BaseEndpoint> { private readonly ISystemJobBLL _SystemJobBLL; public CancelSystemJob(ISystemJobBLL systemJobBLL) { _SystemJobBLL = systemJobBLL; } public override void Configure() { Put("/SystemJob/CancelSystemJob"); AllowAnonymous(); } public record CancelSystemJobParameters( [property: FromHeader] string Login, [property: QueryParam] int SysJobId ); protected override async Task> ExecuteAsync(CancelSystemJobParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SystemJobBLL.CancelSystemJob(req.SysJobId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }