public static void Start(HttpMonitor monitor) { IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler(); scheduler.Start(); var jobDataMap = new JobDataMap(); jobDataMap.Add("monitor", monitor); IJobDetail job = JobBuilder.Create<ReportJob>().SetJobData(jobDataMap).Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity(monitor.Name, monitor.Group) .WithSimpleSchedule(t => t.WithIntervalInSeconds(monitor.MonitoringFrequency) .RepeatForever()) .Build(); scheduler.ScheduleJob(job, trigger); LogHelper.PureLog(string.Format("{0}:已开启【{1}】\r\n", DateTime.Now, monitor.Name), string.Format("StartMonitorLog_{0}.txt", DateTime.Now.ToString("yyyyMMdd"))); }
//http://localhost:40082/Home/Shutdown?name=adams&group=admin public static void Shutdown(HttpMonitor monitor) { IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler(); scheduler.UnscheduleJob(new TriggerKey(monitor.Name, monitor.Group)); LogHelper.PureLog(string.Format("{0}:已停止【{1}】\r\n", DateTime.Now, monitor.Name), string.Format("ShutdownMonitorLog_{0}.txt", DateTime.Now.ToString("yyyyMMdd"))); }