HomeController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 test()
  53. {
  54. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  55. for (int i = 677; i <= 691; i++)
  56. {
  57. PxcModels.ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == i);
  58. if (order != null)
  59. {
  60. RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
  61. RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.MerchantId, order);
  62. ProfitHelper.Instance.StartListenTradeDo();
  63. }
  64. }
  65. // PxcModels.Users user = db.Users.First(m => m.Id == 16) ?? new PxcModels.Users();
  66. // 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/");
  67. // path = path.Replace("//", "/");
  68. // string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  69. // MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/bsserver_com/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  70. // PxcModels.ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == 613);
  71. // if (order != null)
  72. // {
  73. // RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.MerchantId, order);
  74. // }
  75. // ProfitHelper.Instance.ReturnStat("613");
  76. db.Dispose();
  77. return "ok";
  78. }
  79. public string setqrcode(int uid)
  80. {
  81. WebCMSEntities db = new WebCMSEntities();
  82. List<Users> users = db.Users.Where(m => m.Id == uid).ToList();
  83. foreach (Users user in users)
  84. {
  85. 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/");
  86. path = path.Replace("//", "/");
  87. string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  88. MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  89. resultpath = resultpath.Replace("bsserver_com/", "");
  90. user.ReferenceQrCode = resultpath;
  91. db.SaveChanges();
  92. RedisDbconn.Instance.Set("Users:" + user.Id, user);
  93. }
  94. return "ok";
  95. }
  96. public string userqrcode(int uid)
  97. {
  98. WebCMSEntities db = new WebCMSEntities();
  99. Users user = db.Users.FirstOrDefault(m => m.Id == uid);
  100. if (user != null)
  101. {
  102. RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
  103. return "ok";
  104. }
  105. db.Dispose();
  106. return "fail";
  107. }
  108. private void th1()
  109. {
  110. Thread th = new Thread(th1do);
  111. th.IsBackground = true;
  112. th.Start();
  113. }
  114. private void th1do()
  115. {
  116. WebCMSEntities db = new WebCMSEntities();
  117. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  118. if (user != null)
  119. {
  120. user.SeoTitle = "111111";
  121. Thread.Sleep(5000);
  122. user.SeoDescription = "222222";
  123. db.SaveChanges();
  124. }
  125. db.Dispose();
  126. }
  127. private void th2()
  128. {
  129. Thread th = new Thread(th2do);
  130. th.IsBackground = true;
  131. th.Start();
  132. }
  133. private void th2do()
  134. {
  135. Thread.Sleep(2000);
  136. WebCMSEntities db = new WebCMSEntities();
  137. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  138. if (user != null)
  139. {
  140. user.SeoKeyword = "看看有没有值写入";
  141. db.SaveChanges();
  142. }
  143. db.Dispose();
  144. }
  145. }
  146. }