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.Runtime.InteropServices; using System.Threading; using Quartz; using Quartz.Impl; namespace SiaSun.LMS.WinService { public partial class WMSService : ServiceBase { ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); IScheduler scheduler; public WMSService() { InitializeComponent(); } protected override void OnStart(string[] args) { try { Program._BaseUrl = SiaSun.LMS.Common.StringUtil.GetConfig("SiaSunSrvUrl"); scheduler = schedulerFactory.GetScheduler(); scheduler.Start(); Program.sysLog.Info("启动定时调度作业成功。"); } catch (Exception ex) { Program.sysLog.Info("启动定时调度作业失败。"+ex.Message); } try { ServiceHostGroup.StartAllConfiguredServices(); } catch (Exception ex) { Program.sysLog.Info(string.Format("启动新松立库系统应用服务失败。{0}",ex.Message )); } } protected override void OnStop() { try { scheduler.Shutdown(); Program.sysLog.Info("停止定时调度作业成功。"); } catch (Exception ex) { Program.sysLog.Info("停止定时调度作业失败。" + ex.Message); } try { ServiceHostGroup.CloseAllServices(); } catch (Exception ex) { Program.sysLog.Info(string.Format("停止新松立库系统应用服务失败。 {0}", ex.Message)); } } } }