12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using AdService.Service;
- namespace AdService.Controllers
- {
- /// <summary>
- /// 采集接口
- /// </summary>
- public class AdController : BaseController
- {
- ILogger logger { get; set; }
- private AdcService AdcService { get; set; }
- /// <summary>
- /// 开始采集
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<AjaxResult<AdcResultDto>> StartAd(List<AdSatChDto> dtos)
- {
- try
- {
- if (!dtos.Any())
- {
- return new AjaxResult<AdcResultDto>();
- }
- var res = await AdcService.Instance.StartTestAsync(dtos);
- return Success(res);
- }
- catch (Exception ex)
- {
- logger.LogError("开始采集异常:"+ex.Message);
- return Error<AdcResultDto>("开始采集异常");
- }
- }
- /// <summary>
- /// 停止采集
- /// </summary>
- [HttpPost]
- public async Task<AjaxResult> StopAdc()
- {
- var res = await Task.Run(() =>
- {
- try
- {
- AdcService.Instance.StopAd();
- return Success();
- }
- catch (Exception ex)
- {
- logger.LogError("停止采集异常:" + ex.Message);
- return Error("停止采集异常");
- }
- });
- return res;
- }
- }
- }
|