HomeController.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System.Collections.Generic;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Logging;
  4. using MySystem.MainModels;
  5. using System.Linq;
  6. using Library;
  7. using LitJson;
  8. using System.Threading.Tasks;
  9. using System;
  10. namespace MySystem.Controllers
  11. {
  12. public class HomeController : Controller
  13. {
  14. private readonly ILogger<HomeController> _logger;
  15. public HomeController(ILogger<HomeController> logger)
  16. {
  17. _logger = logger;
  18. }
  19. public IActionResult Index()
  20. {
  21. return View();
  22. }
  23. public IActionResult Error()
  24. {
  25. string isapi = Request.Headers["Api"].ToString();
  26. if (isapi != "1")
  27. {
  28. if (Response.StatusCode == 500)
  29. {
  30. return Redirect("/public/errpage/pc/500.html");
  31. }
  32. else if (Response.StatusCode == 502)
  33. {
  34. return Redirect("/public/errpage/pc/502.html");
  35. }
  36. else if (Response.StatusCode == 404)
  37. {
  38. return Redirect("/public/errpage/pc/404.html");
  39. }
  40. }
  41. return View();
  42. }
  43. public string setFee(string merNo, string sn, decimal fee, int addRate = 0)
  44. {
  45. string content = PublicImportDataService.Instance.SetFee(merNo, sn, fee, addRate);
  46. JsonData obj = JsonMapper.ToObject(content);
  47. if (obj["code"].ToString() == "000000")
  48. {
  49. content += "|" + PublicImportDataService.Instance.Decrypt(obj["data"].ToString());
  50. }
  51. return content;
  52. }
  53. public string test()
  54. {
  55. List<string> list = new List<string>();
  56. foreach(string sub in list)
  57. {
  58. string url = "https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_MACHINE_PRIZE_CONFIG_DIVISION&m=" + sub + "&ids=3";
  59. string content = function.GetWebRequest(url);
  60. }
  61. return "ok";
  62. }
  63. public ActionResult LogSelect()
  64. {
  65. return View();
  66. }
  67. public async Task<string> LogSelectResult(string condi)
  68. {
  69. string result = "";
  70. string[] condiList = condi.Split('|');
  71. string logstore = "connect-log";
  72. string topic = condiList[0];
  73. string keyword = condiList[1];
  74. string month = condiList[2];
  75. if(topic.EndsWith("推送消息"))
  76. {
  77. logstore = "spserver";
  78. }
  79. IList<IDictionary<string, string>> logs = await SLS.GetLogs(logstore, topic, "* and content: " + keyword, DateTimeOffset.Now.AddMonths(-int.Parse(month)));
  80. foreach(IDictionary<string, string> log in logs)
  81. {
  82. result += log["__tag__:datetime"] + "\n";
  83. result += log["content"] + "\n";
  84. result += "\n--------------------------------------------------------------------------------------------------\n\n";
  85. }
  86. return result;
  87. }
  88. }
  89. }