HomeController.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. return PublicImportDataService.Instance.LePassGetExpiredIdCardUrl("5546616071");
  63. // string content = "MzdEcXp6ZkcvODlXL1NNWDhrRVAzemRTZC9zTityQlpXRHVxcGdLQlpRZz0=";
  64. // return PublicImportDataService.Instance.AesDecryptForIv(content);
  65. }
  66. public ActionResult LogSelect()
  67. {
  68. return View();
  69. }
  70. public async Task<string> LogSelectResult(string condi)
  71. {
  72. string result = "";
  73. string[] condiList = condi.Split('|');
  74. string logstore = "connect-log";
  75. string topic = condiList[0];
  76. string keyword = condiList[1];
  77. string month = condiList[2];
  78. if(topic.EndsWith("推送消息"))
  79. {
  80. logstore = "spserver";
  81. }
  82. IList<IDictionary<string, string>> logs = await SLS.GetLogs(logstore, topic, "* and content: " + keyword, DateTimeOffset.Now.AddMonths(-int.Parse(month)));
  83. foreach(IDictionary<string, string> log in logs)
  84. {
  85. result += log["__tag__:datetime"] + "\n";
  86. result += log["content"] + "\n";
  87. result += "\n--------------------------------------------------------------------------------------------------\n\n";
  88. }
  89. return result;
  90. }
  91. }
  92. }