如何使用Quartz.net与ASP.NET [英] How to use Quartz.net with ASP.NET

查看:497
本文介绍了如何使用Quartz.net与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.net应用程序内安装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.net 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的链接:
<一href=\"http://jvilalta.blogspot.com/2009/03/getting-started-with-quartznet-part-1.html\">http://jvilalta.blogspot.com/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: http://jvilalta.blogspot.com/2009/03/getting-started-with-quartznet-part-1.html

这篇关于如何使用Quartz.net与ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆