HomeController.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Microsoft.Extensions.Logging;
  8. using MySystem.Models;
  9. using System.Threading;
  10. using Library;
  11. using LitJson;
  12. namespace MySystem.Controllers
  13. {
  14. public class HomeController : Controller
  15. {
  16. private readonly ILogger<HomeController> _logger;
  17. public HomeController(ILogger<HomeController> logger)
  18. {
  19. _logger = logger;
  20. }
  21. public IActionResult Index()
  22. {
  23. return View();
  24. }
  25. public IActionResult Error()
  26. {
  27. string isapi = Request.Headers["Api"].ToString();
  28. if (isapi != "1")
  29. {
  30. if (Response.StatusCode == 500)
  31. {
  32. return Redirect("/public/errpage/pc/500.html");
  33. }
  34. else if (Response.StatusCode == 502)
  35. {
  36. return Redirect("/public/errpage/pc/502.html");
  37. }
  38. else if (Response.StatusCode == 404)
  39. {
  40. return Redirect("/public/errpage/pc/404.html");
  41. }
  42. }
  43. return View();
  44. }
  45. private static object o = new object();
  46. public string addmer(string mid, int k = 0)
  47. {
  48. MerchantConfirmService.Instance.Start(mid, k);
  49. return "ok";
  50. }
  51. public string test()
  52. {
  53. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  54. PxcModels.ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == 80);
  55. if (order != null)
  56. {
  57. TendisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
  58. TendisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.MerchantId, order);
  59. }
  60. order = db.ConsumerOrders.FirstOrDefault(m => m.Id == 81);
  61. if (order != null)
  62. {
  63. TendisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
  64. TendisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.MerchantId, order);
  65. }
  66. ProfitHelper.Instance.StartListenTradeDo();
  67. db.Dispose();
  68. return "ok";
  69. }
  70. public string userqrcode(int uid)
  71. {
  72. WebCMSEntities db = new WebCMSEntities();
  73. Users user = db.Users.FirstOrDefault(m => m.Id == uid);
  74. if (user != null)
  75. {
  76. RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
  77. return "ok";
  78. }
  79. db.Dispose();
  80. return "fail";
  81. }
  82. private void th1()
  83. {
  84. Thread th = new Thread(th1do);
  85. th.IsBackground = true;
  86. th.Start();
  87. }
  88. private void th1do()
  89. {
  90. WebCMSEntities db = new WebCMSEntities();
  91. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  92. if (user != null)
  93. {
  94. user.SeoTitle = "111111";
  95. Thread.Sleep(5000);
  96. user.SeoDescription = "222222";
  97. db.SaveChanges();
  98. }
  99. db.Dispose();
  100. }
  101. private void th2()
  102. {
  103. Thread th = new Thread(th2do);
  104. th.IsBackground = true;
  105. th.Start();
  106. }
  107. private void th2do()
  108. {
  109. Thread.Sleep(2000);
  110. WebCMSEntities db = new WebCMSEntities();
  111. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  112. if (user != null)
  113. {
  114. user.SeoKeyword = "看看有没有值写入";
  115. db.SaveChanges();
  116. }
  117. db.Dispose();
  118. }
  119. }
  120. }