HomeController.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. // 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. db.Dispose();
  73. return "ok";
  74. }
  75. public string userqrcode(int uid)
  76. {
  77. WebCMSEntities db = new WebCMSEntities();
  78. Users user = db.Users.FirstOrDefault(m => m.Id == uid);
  79. if (user != null)
  80. {
  81. RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
  82. return "ok";
  83. }
  84. db.Dispose();
  85. return "fail";
  86. }
  87. private void th1()
  88. {
  89. Thread th = new Thread(th1do);
  90. th.IsBackground = true;
  91. th.Start();
  92. }
  93. private void th1do()
  94. {
  95. WebCMSEntities db = new WebCMSEntities();
  96. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  97. if (user != null)
  98. {
  99. user.SeoTitle = "111111";
  100. Thread.Sleep(5000);
  101. user.SeoDescription = "222222";
  102. db.SaveChanges();
  103. }
  104. db.Dispose();
  105. }
  106. private void th2()
  107. {
  108. Thread th = new Thread(th2do);
  109. th.IsBackground = true;
  110. th.Start();
  111. }
  112. private void th2do()
  113. {
  114. Thread.Sleep(2000);
  115. WebCMSEntities db = new WebCMSEntities();
  116. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  117. if (user != null)
  118. {
  119. user.SeoKeyword = "看看有没有值写入";
  120. db.SaveChanges();
  121. }
  122. db.Dispose();
  123. }
  124. }
  125. }