面对通过AdoJobStore存储工作的问题

时间:2013-11-30 10:06:42

标签: c# triggers quartz-scheduler ado odp.net

我已成功连接到AdoJobStore的Oracle DB。但是当我尝试添加作业时,我遇到以下异常。

  

异常来源:Quartz异常方法:Void   StoreJob(Quartz.Impl.AdoJobStore.ConnectionAndTransactionHolder,   Quartz.IJobDetail,Boolean)异常StackTrace:at   Quartz.Impl.AdoJobStore.JobStoreSupport.StoreJob(ConnectionAndTransactionHolder   conn,IJobDetail newJob,Boolean replaceExisting)in   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ AdoJobStore \ JobStoreSupport.cs:行   922在   Quartz.Impl.AdoJobStore.JobStoreSupport。<> c_ DisplayClass4.b _3(ConnectionAndTransactionHolder conn)in   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ AdoJobStore \ JobStoreSupport.cs:行   848在   Quartz.Impl.AdoJobStore.JobStoreSupport.ExecuteInNonManagedTXLock [T](字符串   lockName,Func 2 txCallback, Func 3 txValidator)in   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ AdoJobStore \ JobStoreSupport.cs:行   3514在   Quartz.Impl.AdoJobStore.JobStoreSupport.ExecuteInNonManagedTXLock [T](字符串   lockName,Func 2 txCallback) in c:\Work\OpenSource\Quartz.NET\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 3432 at Quartz.Impl.AdoJobStore.JobStoreTX.ExecuteInLock[T](String lockName, Func 2 txCallback)in   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ AdoJobStore \ JobStoreTX.cs:行   76点   Quartz.Impl.AdoJobStore.JobStoreSupport.StoreJobAndTrigger(IJobDetail   newJob,IOperableTrigger newTrigger)in   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ AdoJobStore \ JobStoreSupport.cs:行   845 at Quartz.Core.QuartzScheduler.ScheduleJob(IJobDetail   jobDetail,ITrigger触发器)   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\核心\ QuartzScheduler.cs:行   718 at Quartz.Impl.StdScheduler.ScheduleJob(IJobDetail jobDetail,   ITrigger触发器)   C:\工作\开源\ Quartz.NET \ quartznet的\ src \水晶\默认地将Impl \ StdScheduler.cs:行   262在TestScheduling.TestScheduleJob.Run()中   C:\ Users \ jwesly \ documents \ visual studio   2010 \ Projects \ TestScheduling \ TestScheduling \ TestScheduleJob.cs:第25行   的>异常消息:无法存储作业:值不属于   预期范围。

以下是我安排工作的代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using Quartz.Impl;
using System.IO;

namespace TestScheduling
{
    class TestScheduleJob : ITaskScheduler
    {
        IScheduler sched;
        public void Run()
        {
            try
            {
                JobDataMap jobdata = new JobDataMap();
                jobdata.Add("mtid", "value");
                IJobDetail job = JobBuilder.Create<TestJob>().WithIdentity("job1", "group1").UsingJobData(jobdata).RequestRecovery(true).Build();
                DateTimeOffset dt = new DateTimeOffset(DateTime.Now.AddSeconds(10));
                ISimpleTrigger trig = (ISimpleTrigger)TriggerBuilder.Create().StartAt(dt).WithSimpleSchedule(x => x.WithIntervalInSeconds(10).WithRepeatCount(5)).Build();
                ISchedulerFactory sf = new StdSchedulerFactory();
                sched = sf.GetScheduler();
                sched.ScheduleJob(job, trig);
                sched.Start();
            }
            catch (Exception e)
            {
                StreamWriter streamWriter = new StreamWriter(new FileStream("C:\\test_schedule_job_error.txt", FileMode.Append));
                String exceptionEntry = "Exception Source:\n" + e.Source + "\n" + "Exception Method:\n" + e.TargetSite + "\n" + "Exception StackTrace:\n" + e.StackTrace + "\n" + "Exception Message:\n" + e.Message;
                streamWriter.WriteLine(exceptionEntry);
                streamWriter.Close();
                throw e;
            }
            finally
            {
            }
        }
        public void Stop()
        {
            if (sched != null)
            {
                sched.Shutdown();
            }
        }
    }
}

请帮助!!!

1 个答案:

答案 0 :(得分:0)

您应该使用OracleDelegate而不是StdAdoDelegate。使用

定义配置
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.OracleDelegate, Quartz";