SvrReportController.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Data.Entity;
  5. using System.Data.Entity.Migrations;
  6. using System.Data.SqlClient;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Web.Http;
  12. using DevExpress.XtraBars;
  13. using XdCxRhDW.App.Model;
  14. using XdCxRhDW.App.Service;
  15. using XdCxRhDW.Dto;
  16. using XdCxRhDW.WebApi;
  17. namespace XdCxRhDW.App.Controllers
  18. {
  19. /// <summary>
  20. /// 服务状态上报接口
  21. /// </summary>
  22. public class SvrReportController : BaseController
  23. {
  24. FileWriterService _service;
  25. public SvrReportController(FileWriterService service)
  26. {
  27. _service = service;
  28. }
  29. /// <summary>
  30. /// 服务状态上报
  31. /// </summary>
  32. /// <param name="dto">服务状态信息</param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public async Task<AjaxResult> Report(SvrStateReportDto dto)
  36. {
  37. try
  38. {
  39. if (!string.IsNullOrWhiteSpace(dto.BaseHttpAddr))
  40. {
  41. if (dto.BaseHttpAddr.EndsWith("/"))
  42. dto.BaseHttpAddr = dto.BaseHttpAddr + "api/";
  43. else
  44. dto.BaseHttpAddr = dto.BaseHttpAddr + "/api/";
  45. }
  46. if (dto.ModuleType == EnumModuleType.Soft)
  47. {
  48. Messenger.Defalut.Pub("服务状态改变", dto);
  49. }
  50. if (dto.ID == 0)
  51. _service.WriteStateRes(dto);
  52. return Success();
  53. }
  54. catch (Exception ex)
  55. {
  56. await XdCxRhDW.UI.Lib.LogHelper.Error("服务状态上报处理出错!", ex);
  57. return Error("服务状态上报处理出错");
  58. }
  59. }
  60. }
  61. }