123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Linq;
- using System.Data;
- using MySystem;
- using MySystem.Models;
- using Library;
- using LitJson;
- /// <summary>
- /// 每月1号重置机具首个标记和是否执行首个标记
- /// </summary>
- 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);
- }
- }
- }
|