ADO.NET 与 Quartz.NET
我将 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));
I'm using Quartz.NET with a database, i.e. ADO.NET. Problem is, when my jobs are created, they are not being saved to the database at all. Have I configured everything right? I am using SQL Server Express, and the path to my database is 'chris\sqlexpress.Quartz.dbo'.
Relevant parts of config file:
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
Scheduler initilisation and job addition:
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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了类似的问题,并且 web.config 部分似乎被忽略,除非我出于某种原因对属性进行了硬编码。我不喜欢这样,所以最后我编写了一些代码来从 web.config 文件加载属性并将它们设置在我的 StdSchedulerProvider 类中。
我的 web.config 部分是这样的:
Quartz.net 然后开始按照我的意愿登录数据库。不知道为什么让这个工作这么难。
I had similar problems with this and the web.config section seemingly being ignore unless I hard coded the properties for some reason. I didn't like this so in the end I wrote some code to load the properties from the web.config file and set them in my StdSchedulerProvider class instead.
My web.config section is like this:
Quartz.net then started logging in the database as I wanted it to. No idea why it's so hard to get this working.
是的,为任何需要帮助的人解决了这个问题。我的连接字符串是错误的,我必须对服务器信息进行硬编码,如 Quartz.NET 示例中的示例 13 所示。这是一个很棒的框架:)
Right, worked it out for anyone that needs help. My connection string was wrong, and I had to hard code the server information in as in Example 13 in the Quartz.NET examples. It's a great framework :)