package com.steering.common;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.lang.Thread;
import java.util.ArrayList;

import com.steering.comm.db.DBCommon;
import CoreFS.SA01.CoreIComponent;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

public class AutoAction extends CoreIComponent {

	public AutoAction() {

	}
	
	public void run(){
		Timer timer = new Timer(true);
		timer.schedule(new SynchronousAction(),0, 1*60*1000);//1 minute a time
		Timer timer2 = new Timer(true);
		timer2.schedule(new SynchronousAction2(),0, 1*60*60*24*1000);//1 day a time
	}

	public void close(){
	}

	public class SynchronousAction extends TimerTask {
		public void run() {
			synchronousData();
		}
	}
	
	public void synchronousData() {
		ArrayList<String> sqllist = new ArrayList<String>();
		ArrayList<Object[]> parmlist = new ArrayList<Object[]>();
		try {
			String sqlModify = CoreXmlSqlParsersFactory.getSql("AutoAction.UpdateTrust_State");
			sqllist.add(sqlModify);
			Object[] myParam = new Object[0];
			parmlist.add(myParam);
			
			String sqlModify2 = CoreXmlSqlParsersFactory.getSql("AutoAction.UpdateTermtare_State");
			sqllist.add(sqlModify2);
			Object[] myParam2 = new Object[0];
			parmlist.add(myParam2);
			this.getDao("KgDao").ExcuteTransction(sqllist, parmlist);
		}catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
	
	public class SynchronousAction2 extends TimerTask {
		public void run() {
			synchronousData2();
		}
	}
	
	public void synchronousData2() {
		ArrayList<String> sqllist = new ArrayList<String>();
		ArrayList<Object[]> parmlist = new ArrayList<Object[]>();
		try {
			String sqlModify = CoreXmlSqlParsersFactory.getSql("AutoAction.DeleteStrapTemp");
			sqllist.add(sqlModify);
			Object[] myParam = new Object[0];
			parmlist.add(myParam);
			
			this.getDao("KgDao").ExcuteTransction(sqllist, parmlist);
		}catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
}
