using System; using System.Collections.Generic; using System.IO; using System.Threading; using Library; using LitJson; using MySystem; public class CreateTableHelper { public readonly static CreateTableHelper Instance = new CreateTableHelper(); private CreateTableHelper() { } public void Start() { Thread th = new Thread(DoWorks); th.IsBackground = true; th.Start(); } public void DoWorks() { while (true) { if(DateTime.Now.Day > 25 && DateTime.Now.Hour > 0 && DateTime.Now.Hour < 3) { try { string month = DateTime.Now.AddMonths(1).ToString("yyyyMM"); if(string.IsNullOrEmpty(RedisDbconn.Instance.Get("TradeRecord" + month))) { CustomerSqlConn.op(AppConfig.Base.CreateTradeRecord.Replace("#DateTime#", month), AppConfig.Base.RdsSqlConn); RedisDbconn.Instance.Set("TradeRecord" + month, "1"); int sec = 3600 * 12 * 35; RedisDbconn.Instance.SetExpire("TradeRecord" + month, sec); Thread.Sleep(2000); } } catch (Exception ex) { LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "创建分表异常"); } Thread.Sleep(5000); } else { Thread.Sleep(3600000); } } } }