我有一个定时的quartz.net作业在我的开发机器上运行良好,但一旦部署到远程服务器上,它就不会触发。我相信这个作业已经安排好了,因为如果我回发,它会告诉我这个作业已经存在(但是我通常会检查回发)。电子邮件代码绝对有效,因为“button1_click”事件成功发送电子邮件。
我知道我对删除服务器有完全或中等信任。我的主人说他们不实行限制,他们知道这会影响它。我还需要做什么才能让它运转?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Quartz;
using Quartz.Impl;
using Quartz.Core;
using Aspose.Network.Mail;
using Aspose.Network;
using Aspose.Network.Mime;
using System.Text;
namespace QuartzTestASP
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
JobDetail jobDetail = new JobDetail("testJob2", null, typeof(testJob));
//Trigger trigger = TriggerUtils.MakeMinutelyTrigger(1, 3);
Trigger trigger = TriggerUtils.MakeSecondlyTrigger(10, 5);
trigger.StartTimeUtc = DateTime.UtcNow;
trigger.Name = "TriggertheTest";
sched.Start();
sched.ScheduleJob(jobDetail, trigger);
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
myutil.sendEmail();
}
}
class testJob : IStatefulJob
{
public testJob() { }
public void Execute(JobExecutionContext context)
{
myutil.sendEmail();
}
}
public static class myutil
{
public static void sendEmail()
{
// tested code lives here and works fine when called from elsewhere
}
}
}