SvrReportController.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Data.SqlClient;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using DW5S.DTO;
  10. using DW5S.WebApi;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.Extensions.Logging;
  13. namespace DW5S.App.Controllers
  14. {
  15. /// <summary>
  16. /// 服务状态上报接口
  17. /// </summary>
  18. public class SvrReportController : BaseController
  19. {
  20. [Autowired]
  21. private readonly ILogger logger;
  22. /// <summary>
  23. /// 服务状态上报
  24. /// </summary>
  25. /// <param name="dto">服务状态信息</param>
  26. /// <returns></returns>
  27. [HttpPost]
  28. public AjaxResult Report(SvrStateReportDto dto)
  29. {
  30. try
  31. {
  32. if (!string.IsNullOrWhiteSpace(dto.BaseHttpAddr))
  33. {
  34. if (dto.BaseHttpAddr.EndsWith("/"))
  35. dto.BaseHttpAddr = dto.BaseHttpAddr + "api/";
  36. else
  37. dto.BaseHttpAddr = dto.BaseHttpAddr + "/api/";
  38. }
  39. Messenger.Defalut.Pub("服务状态改变", dto);
  40. return Success();
  41. }
  42. catch (Exception ex)
  43. {
  44. string msg = "服务状态处理出错";
  45. logger.LogError(ex, msg);
  46. return Error(msg);
  47. }
  48. }
  49. }
  50. }