using molilian.core; using dodohold.core; using Microsoft.AspNetCore.Mvc; using Org.BouncyCastle.Ocsp; using System.Text.Json; using System.Runtime.InteropServices; using System.Net; using System.Security.Cryptography; using Microsoft.AspNetCore.Authentication; using TencentCloud.Ecm.V20190719.Models; using COSXML.Network; using System.Linq; using static dodohold.core.ZTOExpress.CreateOrderArgs; using TencentCloud.Lighthouse.V20200324.Models; using TencentCloud.Ame.V20190916.Models; using TencentCloud.Omics.V20221128.Models; using System.Threading.Channels; namespace molilian.api.Controllers { [ApiController] [Route("api/[controller]/[action]")] public class TkEndpointController : ControllerBase { protected IHttpContextAccessor _accessor; TaokeOpenCore core; public TkEndpointController(IHttpContextAccessor accessor) { _accessor = accessor; core = new TaokeOpenCore(); } [HttpPost] public async Task ChangeSuspend([FromForm] JsonElement body) { int accountId = body.Read("accountId"); string endpoint = body.Read("endpoint"); bool release = body.Read("release"); int durationSeconds = body.Read("durationSeconds"); if (release) { TkEndpointManager.ReleaseSuspend(accountId, endpoint, notifyOtherNodes: false); } else { if (durationSeconds > 0) { await TkEndpointManager.SuspendForDurationAsync(accountId, endpoint, TimeSpan.FromSeconds(durationSeconds), TkEndpointManager.SuspendReason.Active, notifyOtherNodes: false); } else { await TkEndpointManager.SuspendAsync(accountId, endpoint, TkEndpointManager.SuspendReason.Active, notifyOtherNodes: false); } } return new APIResult(new { success = true, action = release ? "ReleaseSuspend" : "Suspend", }); } [HttpPost] public async Task GetStatus([FromForm] JsonElement body) { var ids = body.PathReadArray("accountId[]"); var result = await TkEndpointManager.GetStatus(ids); return new APIResult(new { success = true, data = result }); } } }