SvrReportController.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Serilog;
  14. using XdCxRhDW.App.Model;
  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. /// <summary>
  25. /// 服务状态上报
  26. /// </summary>
  27. /// <param name="dto">服务状态信息</param>
  28. /// <returns></returns>
  29. [HttpPost]
  30. public AjaxResult Report(SvrStateReportDto dto)
  31. {
  32. try
  33. {
  34. Messenger.Defalut.Pub("服务状态改变", dto);
  35. return Success();
  36. }
  37. catch (Exception ex)
  38. {
  39. Serilog.Log.Error(ex, "服务状态上报处理出错!");
  40. return Error("服务状态上报处理出错");
  41. }
  42. }
  43. }
  44. public class ItemSvrEventArgs
  45. {
  46. /// <summary>
  47. /// 错误码
  48. /// </summary>
  49. public int code { get; set; }
  50. /// <summary>
  51. /// 消息
  52. /// </summary>
  53. public string msg { get; set; }
  54. /// <summary>
  55. /// 服务
  56. /// </summary>
  57. public ModelSvrs modelSvrs { get; set; }
  58. }
  59. public static class TaskSvr
  60. {
  61. public static event Func<ItemSvrEventArgs> EventTaskSvr;
  62. public static ItemSvrEventArgs GetTaskSvt()
  63. {
  64. return EventTaskSvr?.Invoke();
  65. }
  66. }
  67. }