HomeController.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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<IList<IDictionary<string, string>>> LogSelectResult(string condi)
  68. {
  69. string[] condiList = condi.Split('|');
  70. string logstore = "connect-log";
  71. string topic = condiList[0];
  72. string keyword = condiList[1];
  73. string month = condiList[2];
  74. if(topic.EndsWith("推送消息"))
  75. {
  76. logstore = "spserver";
  77. }
  78. IList<IDictionary<string, string>> logs = await SLS.GetLogs(logstore, topic, "* and content: " + keyword, DateTimeOffset.Now.AddMonths(-int.Parse(month)));
  79. return logs;
  80. }
  81. }
  82. }