DuGuYang 3 rokov pred
rodič
commit
6afdca5d8a
1 zmenil súbory, kde vykonal 0 pridanie a 56 odobranie
  1. 0 56
      AppStart/Helper/BanProductByTimeService.cs

+ 0 - 56
AppStart/Helper/BanProductByTimeService.cs

@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 定时下架商品
-    /// </summary>
-    public class BanProductByTimeService
-    {
-        public readonly static BanProductByTimeService Instance = new BanProductByTimeService();
-        private BanProductByTimeService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                WebCMSEntities db = new WebCMSEntities();
-                var check = db.Products.Any(m => m.Status == 1 && m.EndDate <= DateTime.Now);
-                if (check)
-                {
-                    try
-                    {
-                        var lists = db.Products.Where(m => m.Status == 1 && m.EndDate <= DateTime.Now).ToList();
-                        foreach (var item in lists)
-                        {
-                            var list = lists.FirstOrDefault(m => m.Id == item.Id);
-                            list.Status = 0;
-                            list.EndDate = null;
-                            list.UpdateMan = "商品自动下架";
-                        }
-                        db.SaveChanges();
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具预扣费消息推送异常");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-    }
-}