我正在创建一个使用 Quartz.NET(带有 ADO.NET DB 存储)的项目。有核心组件,即执行作业的组件(目前的控制台应用程序,将是 Windows 服务),以及多个 Web 表单,用户可以在其中添加作业和编辑作业(编辑数据映射值以使其具体化)。
我在从所有页面访问调度程序时遇到了一些问题——核心组件和“添加作业”页面运行良好,完全没有问题。但在他们中,我基本上都在这样做:
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "schedService";
properties["quartz.scheduler.instanceId"] = "sched1";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "10";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
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"] = "Data Source=CHRIS\\SQLEXPRESS;Initial Catalog=Scheduler;Integrated Security=True;Pooling=False";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
ISchedulerFactory schedService = new StdSchedulerFactory(properties);
IScheduler sched = schedService.GetScheduler();
当我在编辑页面中执行相同操作时,它会通知我已经有一个名为 this 的调度程序。
我知道我可能正在做一些非常愚蠢的事情,但是有什么方法可以在我的所有页面中声明调度程序以便我可以访问它们?