日期:2014-05-16 浏览次数:20467 次
#region 启动服务按钮
private void startservice_Click(object sender, EventArgs e)
{
this.Enabled = false; //服务启动后,按钮不可用
stopservice.Enabled = true; //停止按钮可用
dataOperation = new DataOperation();
sqlconn = dataOperation.getSqlConn();
sqlconn.Open();
dataOperation.DataImport(sqlconn); //将Access数据库数据导入到SQL Server
dataOperation.CheckException(sqlconn); //导入过程中,如有异常值,则添加报警日志记录到SQL Server
timer.Interval = 1000 * 20; //每隔5分钟进行一次数据导入
timer.Tick += new EventHandler(OnTimedEvent);
timer.Enabled = true;
timer.Start();
//thread = new Thread(new ThreadStart(threadService));
//thread.IsBackground = true; //作为后台线程
//thread.Start();
}
#endregion
#region 每隔一定时间间隔导入一批数据到SQL Server
private void OnTimedEvent(object source, EventArgs e)
{
dataOperation.DataImport(sqlconn); //将Access数据库数据导入到SQL Server
dataOperation.CheckException(sqlconn); //导入过程中,如有异常值,则添加报警日志记录到SQL Server
}
#endregion