HomeController.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.PxcModels;
  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. // PxcModels.Users user = db.Users.First(m => m.Id == 16) ?? new PxcModels.Users();
  68. // string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "p/user-inviteregist-1?Id=" + user.Id, function.MD5_16(user.Id.ToString() + "8745"), "/bsserver_com/static/ReferenceQrCode/");
  69. // path = path.Replace("//", "/");
  70. // string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  71. // MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/bsserver_com/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  72. ProfitHelper.Instance.ReturnStat("476");
  73. db.Dispose();
  74. return "ok";
  75. }
  76. public string setqrcode()
  77. {
  78. WebCMSEntities db = new WebCMSEntities();
  79. List<Users> users = db.Users.ToList();
  80. foreach (Users user in users)
  81. {
  82. string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "p/user-inviteregist-1?Id=" + user.Id, function.MD5_16(user.Id.ToString() + "8745"), "/bsserver_com/static/ReferenceQrCode/");
  83. path = path.Replace("//", "/");
  84. string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  85. MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  86. resultpath = resultpath.Replace("bsserver_com/", "");
  87. user.ReferenceQrCode = resultpath;
  88. db.SaveChanges();
  89. BothdisDbconn.Instance.Set("Users:" + user.Id, user);
  90. }
  91. return "ok";
  92. }
  93. public string userqrcode(int uid)
  94. {
  95. WebCMSEntities db = new WebCMSEntities();
  96. Users user = db.Users.FirstOrDefault(m => m.Id == uid);
  97. if (user != null)
  98. {
  99. RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
  100. return "ok";
  101. }
  102. db.Dispose();
  103. return "fail";
  104. }
  105. private void th1()
  106. {
  107. Thread th = new Thread(th1do);
  108. th.IsBackground = true;
  109. th.Start();
  110. }
  111. private void th1do()
  112. {
  113. WebCMSEntities db = new WebCMSEntities();
  114. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  115. if (user != null)
  116. {
  117. user.SeoTitle = "111111";
  118. Thread.Sleep(5000);
  119. user.SeoDescription = "222222";
  120. db.SaveChanges();
  121. }
  122. db.Dispose();
  123. }
  124. private void th2()
  125. {
  126. Thread th = new Thread(th2do);
  127. th.IsBackground = true;
  128. th.Start();
  129. }
  130. private void th2do()
  131. {
  132. Thread.Sleep(2000);
  133. WebCMSEntities db = new WebCMSEntities();
  134. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  135. if (user != null)
  136. {
  137. user.SeoKeyword = "看看有没有值写入";
  138. db.SaveChanges();
  139. }
  140. db.Dispose();
  141. }
  142. }
  143. }