小编典典

带有Quartz.NET的ADO.NET

sql

我正在将Quartz.NET与数据库(即ADO.NET)一起使用。问题是,创建我的作业时,它们根本没有保存到数据库中。我是否配置正确了一切?我正在使用SQL
Server Express,数据库的路径为“ chris \ sqlexpress.Quartz.dbo”。

配置文件的相关部分:

quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
quartz.jobStore.dataSource = default
quartz.jobStore.tablePrefix = QRTZ_
quartz.jobStore.clustered = true
quartz.jobStore.lockHandler.type = Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz
quartz.jobStore.driverDelegateType = Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz
quartz.dataSource.default.connectionString =
Server=localhost;Database=Quartz;Trusted_Connection=True;";
quartz.dataSource.default.provider = SqlServer-20
quartz.jobStore.useProperties = true

调度程序初始化和作业添加:

ISchedulerFactory schedService = new StdSchedulerFactory();
IScheduler sched = schedService.GetScheduler();

JobDetail jobDetail = new JobDetail("1", "1", typeof(copyJob));
jobDetail.JobDataMap["initialPath"] = initpath;
jobDetail.JobDataMap["targetPath"] = targetpath;
jobDetail.JobDataMap["regex"] = regex;

CronTrigger trigger = new CronTrigger("trigger1", "group1", "1", "1", TextBox4.Text);
sched.AddJob(jobDetail, true);
DateTime ft = sched.ScheduleJob(trigger);
ft = TimeZoneInfo.ConvertTimeFromUtc(ft, trigger.TimeZone);

Response.Write(string.Format("{0} has been scheduled to run at: {1} and repeat based on expression: {2}", jobDetail.FullName, ft.ToString("r"), trigger.CronExpressionString));

阅读 198

收藏
2021-04-22

共1个答案

小编典典

对,为需要帮助的人解决。我的连接字符串错误,我不得不按照Quartz.NET示例中的示例13来对服务器信息进行硬编码。这是一个很棒的框架:)

2021-04-22