HomeController.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. StatService.Instance.dosomething("2022-03-13");
  55. return "ok";
  56. }
  57. public string setqrcode(int uid)
  58. {
  59. WebCMSEntities db = new WebCMSEntities();
  60. List<Users> users = db.Users.Where(m => m.Id == uid).ToList();
  61. foreach (Users user in users)
  62. {
  63. 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/");
  64. path = path.Replace("//", "/");
  65. string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  66. MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  67. resultpath = resultpath.Replace("bsserver_com/", "");
  68. user.ReferenceQrCode = resultpath;
  69. db.SaveChanges();
  70. RedisDbconn.Instance.Set("Users:" + user.Id, user);
  71. }
  72. return "ok";
  73. }
  74. public string userqrcode(int uid)
  75. {
  76. WebCMSEntities db = new WebCMSEntities();
  77. Users user = db.Users.FirstOrDefault(m => m.Id == uid);
  78. if (user != null)
  79. {
  80. RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
  81. return "ok";
  82. }
  83. db.Dispose();
  84. return "fail";
  85. }
  86. private void th1()
  87. {
  88. Thread th = new Thread(th1do);
  89. th.IsBackground = true;
  90. th.Start();
  91. }
  92. private void th1do()
  93. {
  94. WebCMSEntities db = new WebCMSEntities();
  95. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  96. if (user != null)
  97. {
  98. user.SeoTitle = "111111";
  99. Thread.Sleep(5000);
  100. user.SeoDescription = "222222";
  101. db.SaveChanges();
  102. }
  103. db.Dispose();
  104. }
  105. private void th2()
  106. {
  107. Thread th = new Thread(th2do);
  108. th.IsBackground = true;
  109. th.Start();
  110. }
  111. private void th2do()
  112. {
  113. Thread.Sleep(2000);
  114. WebCMSEntities db = new WebCMSEntities();
  115. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  116. if (user != null)
  117. {
  118. user.SeoKeyword = "看看有没有值写入";
  119. db.SaveChanges();
  120. }
  121. db.Dispose();
  122. }
  123. }
  124. }