using System; using System.Collections.Generic; using System.Threading; using System.Linq; using System.Data; using MySystem; using MySystem.Models; using Library; using LitJson; /// /// 每月1号重置机具首个标记和是否执行首个标记 /// public class ResetPosFirstFlagAndIsExecuteService { public readonly static ResetPosFirstFlagAndIsExecuteService Instance = new ResetPosFirstFlagAndIsExecuteService(); private ResetPosFirstFlagAndIsExecuteService() { } public void Start() { Thread th = new Thread(doSomething); th.IsBackground = true; th.Start(); } private void doSomething() { while (true) { try { DataTable dt = CustomerSqlConn.dtable("UPDATE PosMachinesTwo SET FirstFlag=1,IsExecute=1 WHERE IsExecute=0 AND Id IN(SELECT Id FROM(SELECT c.Id FROM(SELECT MerIdcardNo,MIN(Id) Id FROM PosMerchantInfo WHERE MerIdcardNo IS NOT NULL AND MerIdcardNo !='' AND MerIdcardNo NOT LIKE '%*%' GROUP BY MerIdcardNo)a LEFT JOIN (SELECT Id,MerIdcardNo,KqSnNo FROM PosMerchantInfo WHERE MerIdcardNo IS NOT NULL AND MerIdcardNo !='' AND MerIdcardNo NOT LIKE '%*%')b ON a.Id=b.Id LEFT JOIN (SELECT Id,PosSn FROM PosMachinesTwo) c ON b.KqSnNo=c.PosSn)d)", MysqlConn.SqlConnStr); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月1号重置机具首个标记和是否执行首个标记线程异常"); } Thread.Sleep(600000); } } }