SvrReportController.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Repostory;
  11. using DW5S.WebApi;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Serilog;
  14. namespace DW5S.Controllers
  15. {
  16. /// <summary>
  17. /// 服务状态上报接口
  18. /// </summary>
  19. public class SvrReportController : BaseController
  20. {
  21. ILogger logger { get; set; }
  22. IUnitOfWork unitOfWork { get; set; }
  23. /// <summary>
  24. /// 服务状态上报
  25. /// </summary>
  26. /// <param name="dto">服务状态信息</param>
  27. /// <returns></returns>
  28. [HttpPost]
  29. public AjaxResult Report(SvrStateReportDto dto)
  30. {
  31. try
  32. {
  33. if (!string.IsNullOrWhiteSpace(dto.BaseHttpAddr))
  34. {
  35. if (dto.BaseHttpAddr.EndsWith("/"))
  36. dto.BaseHttpAddr = dto.BaseHttpAddr + "api/";
  37. else
  38. dto.BaseHttpAddr = dto.BaseHttpAddr + "/api/";
  39. }
  40. Messenger.Defalut.Pub("服务状态改变", dto);
  41. return Success();
  42. }
  43. catch (Exception ex)
  44. {
  45. string msg = "服务状态处理出错";
  46. logger.Error(ex, msg);
  47. return Error(msg);
  48. }
  49. }
  50. }
  51. }