2011-06-05 43 views
1

我已经为Quartz.NET创建了数据库。其配置为使用AdoJobStore这样:Quartz.NET和AdoJobStore

 properties["quartz.scheduler.instanceName"] = "TestScheduler"; 
     properties["quartz.scheduler.instanceId"] = "instance_one"; 
     properties["quartz.threadPool.type"] = 
        "Quartz.Simpl.SimpleThreadPool, Quartz"; 
     properties["quartz.threadPool.threadCount"] = "5"; 
     properties["quartz.threadPool.threadPriority"] = "Normal"; 
     properties["quartz.jobStore.misfireThreshold"] = "60000"; 
     properties["quartz.jobStore.type"] = 
        "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"; 
     properties["quartz.jobStore.useProperties"] = "true"; 
     properties["quartz.jobStore.dataSource"] = "default"; 
     properties["quartz.jobStore.tablePrefix"] = "Q"; 
     properties["quartz.jobStore.clustered"] = "true"; 
     // if running MS SQL Server we need this 
     properties["quartz.jobStore.lockHandler.type"] = 
        "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz"; 

     properties["quartz.dataSource.default.connectionString"] = 
        "Server=.;Database=Test;Trusted_Connection=True;"; 
     properties["quartz.dataSource.default.provider"] = "SqlServer-20"; 
     ISchedulerFactory sf = new StdSchedulerFactory(properties); 
     IScheduler sched = sf.GetScheduler(); 

我加入JOB_DETAILS表中的工作,因此,在触发器中添加一个触发器,CRONTRIGGERS表,但我的工作将不会执行。我使用SQL Server Profiler进行检查,Quartz正在执行的查询是SELECT * FROM QSchedulerState。我正在启动调度程序sched.Start();它没有显示在JOB_DETAILS表中。我不知道什么是错的。

任何想法?

谢谢。

回答

2

我同意NinjaNye。您必须使用API​​提交您的作业,因为它需要在运行时绑定类的命名空间。 过程非常simple

// construct job info 
JobDetail jobDetail = new JobDetail("myJob", null, typeof(HelloJob)); 
// fire every hour 
Trigger trigger = TriggerUtils.MakeHourlyTrigger(); 
// start on the next even hour 
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow); 
trigger.Name = "myTrigger"; 
sched.ScheduleJob(jobDetail, trigger); 

正如你可以看到我们传递给我们的JobDetail我们的工作类型:typeof(HelloJob)。 这将被调度程序用来在执行过程中绑定我们的作业。

2

您是否通过sql将您的作业直接添加到表中?如果是这样,请尝试通过代码注册使用api的作业。如果没有别的,你可以检查你添加什么匹配的API生成的数据