using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Configuration; using AutoFileCopyNet; using AutoFileCopyNet.HaiTianFileAnalytic; using AutoFileCopyNet.Q5DFileAnalytic; namespace AutoFileAnalyticService { partial class Q5DFileAnalyticService : ServiceBase { public Q5DFileAnalyticService() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: 在此处添加代码以启动服务。 } protected override void OnStop() { // TODO: 在此处添加代码以执行停止服务所需的关闭操作。 } private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { lock (this) { // TODO: 在此处添加代码以启动服务。 int ht_frequency = int.Parse(ConfigurationSettings.AppSettings["frequency"].ToString()); Q5D job = new Q5D(); LogFileAccess.WriteLogFile("Q5D数据文件kaishi:-----------------" + ht_frequency + "-----------" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); job.Run(); System.Threading.Thread.Sleep(ht_frequency * 60000); timer.Interval = ht_frequency * 60000; LogFileAccess.WriteLogFile("Q5D数据文件jieshu:-----------------" + timer.Interval + "-----------" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } } catch (Exception ex) { LogFileAccess.WriteLogFile("Q5D数据文件解析服务启动失败" + ex.Message + ex.Source + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } } } }