HomeController.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // string data = "{\"Id\":\"6\",\"Sort\":\"0\",\"QueryCount\":\"0\",\"Status\":\"0\",\"CreateDate\":\"\",\"UpdateDate\":\"\",\"SeoTitle\":\"\",\"SeoKeyword\":\"\",\"SeoDescription\":\"\",\"AgentNo\":\"\",\"SnNo\":\"00005702830310395949\",\"UpdateTime\":\"\",\"CreateTime\":\"01/06/2022 19:46:12\",\"Remark\":\"商户入驻\",\"City\":\"成都市\",\"Province\":\"四川省\",\"ProductType\":\"6\",\"MerStatus\":\"\",\"MerAuditDate\":\"\",\"MerRegDate\":\"01/06/2022 19:46:12\",\"MerIdcardNo\":\"624369198812120369\",\"MerMobile\":\"13584849565\",\"MerRealName\":\"唐明皇\",\"AgentName\":\"\",\"MerName\":\"测试商户\",\"MerNo\":\"5678679878\"}";
  24. // string data = "{\"Id\":\"8\",\"Sort\":\"0\",\"QueryCount\":\"0\",\"Status\":\"0\",\"CreateDate\":\"\",\"UpdateDate\":\"\",\"SeoTitle\":\"\",\"SeoKeyword\":\"\",\"SeoDescription\":\"\",\"ProductType\":\"6\",\"AgentNo\":\"\",\"Remark\":\"机具激活\",\"BizEnterName\":\"\",\"BizEnterNo\":\"\",\"MerIdcardNo\":\"624369198812120369\",\"MerRealName\":\"唐明皇\",\"ActivateDate\":\"01/07/2022 17:03:39\",\"ActivateStatus\":\"1\",\"AssessMonthCount\":\"1\",\"AssessMonth\":\"202201\",\"MerRegDate\":\"01/07/2022 17:03:39\",\"SnNo\":\"00005702830310395949\",\"MerMobile\":\"13584849565\",\"MerName\":\"测试商户\",\"MerNo\":\"5678679878\"}";
  25. // string data = "{\"Id\":\"2\",\"Sort\":\"0\",\"QueryCount\":\"0\",\"Status\":\"0\",\"CreateDate\":\"\",\"UpdateDate\":\"\",\"SeoTitle\":\"\",\"SeoKeyword\":\"\",\"SeoDescription\":\"\",\"AgentNo\":\"\",\"ProductType\":\"6\",\"Remark\":\"刷卡交易\",\"SettleMethod\":\"\",\"SettleFee\":\"0.00\",\"BankCardNo\":\"\",\"ReceiptType\":\"KuaiPOS\",\"IsStoreCashier\":\"2\",\"DigAmt\":\"298.00\",\"DigAmtFlag\":\"1\",\"MerMobile\":\"13584849565\",\"DeviceType\":\"1\",\"TradeSnNo\":\"00005702830310395949\",\"BankCardType\":\"0001\",\"SerEntryMode\":\"021\",\"TradeType\":\"1\",\"TradeTime\":\"174840\",\"TradeDate\":\"20220107\",\"ErrorMsg\":\"\",\"ErrorCode\":\"00\",\"TradeStatus\":\"1\",\"DiscountRateFlag\":\"1\",\"BankAuthCode\":\"46498763614\",\"TradeReferNo\":\"T0000002343445654656\",\"TradeAmount\":\"8000.00\",\"MerName\":\"测试商户\",\"TradeSerialNo\":\"T0000002343445654656\",\"MerNo\":\"5678679878\"}";
  26. // string data = "{\"Id\":\"2\",\"Sort\":\"0\",\"QueryCount\":\"0\",\"Status\":\"0\",\"CreateDate\":\"\",\"UpdateDate\":\"\",\"SeoTitle\":\"\",\"SeoKeyword\":\"\",\"SeoDescription\":\"\",\"AgentNo\":\"\",\"ProductType\":\"6\",\"DeviceNetwork\":\"4G\",\"TerminalNo\":\"554569879797\",\"InputModel\":\"\",\"KqTradeSeq\":\"\",\"BillType\":\"1\",\"SourceType\":\"1\",\"BizEnterName\":\"\",\"BizEnterNo\":\"\",\"SmallDouble\":\"1\",\"SettleFee\":\"1.00\",\"SettleMethod\":\"1\",\"FeeAmount\":\"10.00\",\"BankCardNo\":\"3565978645364\",\"DigAmt\":\"298.00\",\"DigAmtFlag\":\"1\",\"TradeSnNo\":\"00005702830310395949\",\"BankCardType\":\"0001\",\"TradeTime\":\"103914\",\"TradeDate\":\"20220108\",\"TradeStatus\":\"1\",\"TradeAmount\":\"8000.00\",\"MerName\":\"测试商户\",\"TradeSerialNo\":\"T0000002343445654656\",\"MerNo\":\"5678679878\"}";
  27. // string data = "{\"Id\":\"1\",\"Sort\":\"0\",\"QueryCount\":\"0\",\"Status\":\"0\",\"CreateDate\":\"\",\"UpdateDate\":\"\",\"SeoTitle\":\"\",\"SeoKeyword\":\"\",\"SeoDescription\":\"\",\"UpdateTime\":\"01/08/2022 14:11:23\",\"CreateTime\":\"01/08/2022 14:11:23\",\"Remark\":\"商户在网达标\",\"NewFlag\":\"1\",\"MerStdStatus\":\"1\",\"MerStdDate\":\"01/08/2022 14:11:23\",\"MerStdStage\":\"1\",\"ActName\":\"测试活动\",\"ActNo\":\"1\",\"MerSnNo\":\"00005702830310395949\",\"MerBindDate\":\"01/08/2022 14:11:23\",\"ProductType\":\"6\",\"MerName\":\"测试商户\",\"AgentName\":\"快闪刷\",\"MerNo\":\"5678679878\"}";
  28. // Dictionary<string, string> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
  29. // ProfitHelper.Instance.StartListenStandardDo(dic);
  30. return View();
  31. }
  32. public IActionResult Error()
  33. {
  34. string isapi = Request.Headers["Api"].ToString();
  35. if (isapi != "1")
  36. {
  37. if (Response.StatusCode == 500)
  38. {
  39. return Redirect("/public/errpage/pc/500.html");
  40. }
  41. else if (Response.StatusCode == 502)
  42. {
  43. return Redirect("/public/errpage/pc/502.html");
  44. }
  45. else if (Response.StatusCode == 404)
  46. {
  47. return Redirect("/public/errpage/pc/404.html");
  48. }
  49. }
  50. return View();
  51. }
  52. private static object o = new object();
  53. public string test()
  54. {
  55. // lock (o)
  56. // {
  57. // function.WriteLog("start:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
  58. // using (WebCMSEntities db = new WebCMSEntities())
  59. // {
  60. // Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  61. // if (user != null)
  62. // {
  63. // string content = function.get_Random(10);
  64. // function.WriteLog("content:" + content);
  65. // user.SeoTitle = content;
  66. // db.SaveChanges();
  67. // }
  68. // }
  69. // function.WriteLog("end:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
  70. // }
  71. th1();
  72. th2();
  73. return "ok";
  74. }
  75. private void th1()
  76. {
  77. Thread th = new Thread(th1do);
  78. th.IsBackground = true;
  79. th.Start();
  80. }
  81. private void th1do()
  82. {
  83. WebCMSEntities db = new WebCMSEntities();
  84. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  85. if (user != null)
  86. {
  87. user.SeoTitle = "111111";
  88. Thread.Sleep(5000);
  89. user.SeoDescription = "222222";
  90. db.SaveChanges();
  91. }
  92. db.Dispose();
  93. }
  94. private void th2()
  95. {
  96. Thread th = new Thread(th2do);
  97. th.IsBackground = true;
  98. th.Start();
  99. }
  100. private void th2do()
  101. {
  102. Thread.Sleep(2000);
  103. WebCMSEntities db = new WebCMSEntities();
  104. Users user = db.Users.FirstOrDefault(m => m.Id == 2);
  105. if (user != null)
  106. {
  107. user.SeoKeyword = "看看有没有值写入";
  108. db.SaveChanges();
  109. }
  110. db.Dispose();
  111. }
  112. }
  113. }