using System; using System.Collections.Generic; using System.Threading; using System.Linq; using System.Data; using MySystem; using MySystem.PxcModels; using Library; using LitJson; public class WifiRefundHelper { public readonly static WifiRefundHelper Instance = new WifiRefundHelper(); private WifiRefundHelper() { } public void Start() { Thread th = new Thread(DoWorks); th.IsBackground = true; th.Start(); } private void DoWorks() { while (true) { try { string content = RedisDbconn.Instance.RPop("WifiRefundQueue"); if(!string.IsNullOrEmpty(content)) { DoSomething(content); } else { Thread.Sleep(60000); } } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI退款异常"); } } } public void DoSomething(string OrderNo) { WebCMSEntities db = new WebCMSEntities(); WifiTradeRecord edit = db.WifiTradeRecord.FirstOrDefault(m => m.OrderNo == OrderNo); if(edit != null) { edit.DoMonths = edit.Duration + 1; edit.Status = -1; db.SaveChanges(); } db.Dispose(); } }