HomeController.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using DllEapEntity;
  7. using Microsoft.AspNetCore.Mvc;
  8. using WebMainHsms.Models;
  9. using Cksoft.Unity;
  10. using DllEapDal;
  11. using DllBusinessServer;
  12. namespace WebMainHsms.Controllers
  13. {
  14. public class HomeController : Controller
  15. {
  16. public IBusinessServer CurrSec { get; set; }
  17. //自动注入服务
  18. public HomeController(IBusinessServer psecs)
  19. {
  20. CurrSec = psecs;
  21. }
  22. public IActionResult Index()
  23. {
  24. //CurrSec.StartAll();
  25. //List<MacOrder> lists = CurrSec.GetMacOrder();
  26. return View();
  27. }
  28. public IActionResult About()
  29. {
  30. ViewData["Message"] = "Your application description page.";
  31. return View();
  32. }
  33. public IActionResult Contact()
  34. {
  35. ViewData["Message"] = "Your contact page.";
  36. return View();
  37. }
  38. public IActionResult Privacy()
  39. {
  40. return View();
  41. }
  42. [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
  43. public IActionResult Error()
  44. {
  45. return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
  46. }
  47. public ActionResult GetStatus()
  48. {
  49. try
  50. {
  51. string temperrorinfo = "";
  52. int result = CurrSec.GetStatus(ref temperrorinfo);
  53. return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
  54. }
  55. catch (Exception ex)
  56. {
  57. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  58. }
  59. }
  60. public ActionResult Start()
  61. {
  62. try
  63. {
  64. string temperrorinfo = "";
  65. int result = CurrSec.Start(ref temperrorinfo);
  66. return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
  67. }
  68. catch (Exception ex)
  69. {
  70. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  71. }
  72. }
  73. public ActionResult GetInfo()
  74. {
  75. try
  76. {
  77. List<ServerInfo> info = CurrSec.GetInfo();
  78. return Json(info);
  79. }
  80. catch (Exception ex)
  81. {
  82. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  83. }
  84. }
  85. [HttpPost]
  86. public ActionResult GetCount()
  87. {
  88. try
  89. {
  90. long result = CurrSec.GetAccount();
  91. return Content(new { resultcode = 1, errorinfo = result }.ToJson());
  92. }
  93. catch (Exception ex)
  94. {
  95. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  96. }
  97. }
  98. public ActionResult Stop()
  99. {
  100. try
  101. {
  102. string temperrorinfo = "";
  103. int result = CurrSec.Stop(ref temperrorinfo);
  104. return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
  105. }
  106. catch (Exception ex)
  107. {
  108. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  109. }
  110. }
  111. public ActionResult ClearInfo()
  112. {
  113. try
  114. {
  115. string temperrorinfo = "";
  116. int result = CurrSec.ClearInfo(ref temperrorinfo);
  117. return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
  118. }
  119. catch (Exception ex)
  120. {
  121. return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
  122. }
  123. }
  124. }
  125. }