如何使用Quartz.net与ASP.NET

编程入门 行业动态 更新时间:2024-10-28 06:26:51
本文介绍了如何使用Quartz与ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不知道如何在ASP.NET使用Quartz.dll中。凡写code计划作业每天早上触发邮件?如果请一些身体知道它plz帮助我...

I don't know how to use Quartz.dll in ASP.NET. Where to write the code for scheduling jobs to trigger mail every morning? Please if some body knows about it plz help me...

编辑:我发现的如何PRO方式使用Quartz.NET?的是真正有用的。

I found HOW TO use Quartz.NET in PRO way? to be really useful.

推荐答案

您有几个选项,这取决于你想要做什么,你想怎么设置它。例如,你可以作为一个独立的窗口serviceor你也可以将它嵌入到你的asp应用程序内安装Quartz.Net服务器。

You have a couple of options, depending on what you want to do and how you want to set it up. For example, you can install a Quartz.Net server as a standalone windows serviceor you can also embed it inside your asp application.

如果你想运行它嵌入,那么你可以从你说Global.asax的,这样启动服务器(从源$ C ​​$ C的例子,例如#12):

If you want to run it embedded, then you can start the server from say your global.asax, like this (from the source code examples, example #12):

NameValueCollection properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "RemoteServer"; // set thread pool info properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "5"; properties["quartz.threadPool.threadPriority"] = "Normal"; ISchedulerFactory sf = new StdSchedulerFactory(properties); IScheduler sched = sf.GetScheduler(); sched.Start();

如果你运行它作为一种服务,你会远程连接到像这样(例如从#12):

If you run it as a service, you would connect remotely to it like this (from example #12):

NameValueCollection properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "RemoteClient"; // set thread pool info properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "5"; properties["quartz.threadPool.threadPriority"] = "Normal"; // set remoting expoter properties["quartz.scheduler.proxy"] = "true"; properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler"; // First we must get a reference to a scheduler ISchedulerFactory sf = new StdSchedulerFactory(properties); IScheduler sched = sf.GetScheduler();

一旦你到调度的引用(无论是通过远程或者是因为你有一个嵌入的实例),您可以安排这样的工作:

Once you have a reference to the scheduler (be it via remoting or because you have an embedded instance) you can schedule jobs like this:

// define the job and ask it to run JobDetail job = new JobDetail("remotelyAddedJob", "default", typeof(SimpleJob)); JobDataMap map = new JobDataMap(); map.Put("msg", "Your remotely added job has executed!"); job.JobDataMap = map; CronTrigger trigger = new CronTrigger("remotelyAddedTrigger", "default", "remotelyAddedJob", "default", DateTime.UtcNow, null, "/5 * * ? * *"); // schedule the job sched.ScheduleJob(job, trigger);

下面是一些帖子,我写的人开始使用Quartz.Net的链接:jvilalta.blogspot/2009/03/getting-started-with-quartznet-part-1.html

Here's a link to some posts I wrote for people getting started with Quartz.Net: jvilalta.blogspot/2009/03/getting-started-with-quartznet-part-1.html

更多推荐

如何使用Quartz.net与ASP.NET

本文发布于:2023-11-05 21:10:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   Quartz   net   ASP   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!