HomeController.cs 4.1 KB

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