You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Server.Core;
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Utils;
|
|
|
|
|
|
|
|
|
|
namespace Server.WinService
|
|
|
|
|
{
|
|
|
|
|
public partial class MainService : ServiceBase
|
|
|
|
|
{
|
|
|
|
|
public MainService()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnStart(string[] args)
|
|
|
|
|
{
|
|
|
|
|
int errCode = 0;
|
|
|
|
|
if (SvrManager.StartAllService(out errCode))
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Log.WriteInfo("服务启动成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Log.WriteInfo(errCode.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定时器
|
|
|
|
|
double time_11 = AppSettingsHelper.GetIntByKey("Time11", 60) * 60 * 1000;//60分钟
|
|
|
|
|
|
|
|
|
|
System.Timers.Timer time11 = new System.Timers.Timer();
|
|
|
|
|
time11.Enabled = true;
|
|
|
|
|
time11.Interval = time_11;
|
|
|
|
|
time11.Start();
|
|
|
|
|
time11.Elapsed += new System.Timers.ElapsedEventHandler(OneHoursEvent);
|
|
|
|
|
|
|
|
|
|
Thread t = new Thread(curEvent);
|
|
|
|
|
t.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnStop()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void OneHoursEvent(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//触发事件时间的小时,如01:30:00触发事件,则这里获取到1
|
|
|
|
|
int intHour = e.SignalTime.Hour;
|
|
|
|
|
if (intHour == 4)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Log.WriteInfo("开始同步基金数据");
|
|
|
|
|
DataSync.DataSyncService.Instance.Initialize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void curEvent()
|
|
|
|
|
{
|
|
|
|
|
//触发事件时间的小时,如01:30:00触发事件,则这里获取到1
|
|
|
|
|
LogHelper.Log.WriteInfo("开始同步基金数据");
|
|
|
|
|
DataSync.DataSyncService.Instance.Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|