using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using MySystem.Models; using System.Threading; using Library; using LitJson; namespace MySystem.Controllers { public class HomeController : Controller { private readonly ILogger _logger; public HomeController(ILogger logger) { _logger = logger; } public IActionResult Index() { return View(); } public IActionResult Error() { string isapi = Request.Headers["Api"].ToString(); if (isapi != "1") { if (Response.StatusCode == 500) { return Redirect("/public/errpage/pc/500.html"); } else if (Response.StatusCode == 502) { return Redirect("/public/errpage/pc/502.html"); } else if (Response.StatusCode == 404) { return Redirect("/public/errpage/pc/404.html"); } } return View(); } private static object o = new object(); public string addmer(string mid, int k = 0) { MerchantConfirmService.Instance.Start(mid, k); return "ok"; } public string test() { PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities(); PxcModels.ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == 80); if (order != null) { TendisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString()); TendisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.MerchantId, order); } order = db.ConsumerOrders.FirstOrDefault(m => m.Id == 81); if (order != null) { TendisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString()); TendisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.MerchantId, order); } ProfitHelper.Instance.StartListenTradeDo(); db.Dispose(); return "ok"; } public string userqrcode(int uid) { WebCMSEntities db = new WebCMSEntities(); Users user = db.Users.FirstOrDefault(m => m.Id == uid); if (user != null) { RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode"); return "ok"; } db.Dispose(); return "fail"; } private void th1() { Thread th = new Thread(th1do); th.IsBackground = true; th.Start(); } private void th1do() { WebCMSEntities db = new WebCMSEntities(); Users user = db.Users.FirstOrDefault(m => m.Id == 2); if (user != null) { user.SeoTitle = "111111"; Thread.Sleep(5000); user.SeoDescription = "222222"; db.SaveChanges(); } db.Dispose(); } private void th2() { Thread th = new Thread(th2do); th.IsBackground = true; th.Start(); } private void th2do() { Thread.Sleep(2000); WebCMSEntities db = new WebCMSEntities(); Users user = db.Users.FirstOrDefault(m => m.Id == 2); if (user != null) { user.SeoKeyword = "看看有没有值写入"; db.SaveChanges(); } db.Dispose(); } } }