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.
DS7/JobScheduler/Program.cs

148 lines
3.6 KiB
C#

3 years ago
using log4net;
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace JobScheduler
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main()
{
#region 正式入口
1 year ago
//ServiceBase[] ServicesToRun;
//ServicesToRun = new ServiceBase[]
//{
// new JobService()
//};
//ServiceBase.Run(ServicesToRun);
3 years ago
#endregion
#region 测试用入口
1 year ago
try
{
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.ListenerManager.AddSchedulerListener(new SchedulerListener());
scheduler.Start();
}
catch (Exception e)
{
ILog log = LogManager.GetLogger(typeof(SchedulerListener));
log.Debug($"error:{e.Message}");
}
3 years ago
#endregion
}
class SchedulerListener : ISchedulerListener
{
ILog log = LogManager.GetLogger(typeof(SchedulerListener));
public void JobAdded(IJobDetail jobDetail)
{
log.Debug($"JobAdded:{jobDetail.Key}");
}
public void JobDeleted(JobKey jobKey)
{
log.Debug($"JobDeleted:{jobKey}");
}
public void JobPaused(JobKey jobKey)
{
log.Debug($"JobPaused:{jobKey}");
}
public void JobResumed(JobKey jobKey)
{
log.Debug($"JobResumed:{jobKey}");
}
public void JobScheduled(ITrigger trigger)
{
}
public void JobsPaused(string jobGroup)
{
}
public void JobsResumed(string jobGroup)
{
}
public void JobUnscheduled(TriggerKey triggerKey)
{
}
public void SchedulerError(string msg, SchedulerException cause)
{
log.Error($"SchedulerError:{msg}");
log.Error($"{cause.Message}");
log.Error($"{cause.StackTrace}");
if (cause.InnerException != null)
{
log.Error(cause.InnerException.Message);
log.Error(cause.InnerException.StackTrace);
}
}
public void SchedulerInStandbyMode()
{
}
public void SchedulerShutdown()
{
}
public void SchedulerShuttingdown()
{
}
public void SchedulerStarted()
{
log.Debug($"启动");
}
public void SchedulerStarting()
{
}
public void SchedulingDataCleared()
{
}
public void TriggerFinalized(ITrigger trigger)
{
log.Debug($"TriggerFinalized:{trigger.Key}");
}
public void TriggerPaused(TriggerKey triggerKey)
{
log.Debug($"TriggerPaused:{triggerKey}");
}
public void TriggerResumed(TriggerKey triggerKey)
{
log.Debug($"TriggerResumed:{triggerKey}");
}
public void TriggersPaused(string triggerGroup)
{
}
public void TriggersResumed(string triggerGroup)
{
}
}
}
}