Quartz 在真实服务器中不工作
Quartz is not working in real server
我可以访问数据库,ftp 可以访问我的实时服务器。我想安排一个任务。我在 Quartz.net (ASP.Net C#) 中做了一个计划,它在本地服务器上运行良好,当我将它上传到服务器时,我没有输出。我在任务的顶部和底部添加了一个文件写入命令,这些文件正在写入目的地。这是我写的代码
public partial class saaiTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestClass t = new TestClass();
t.method("start");
ISchedulerFactory factory = new StdSchedulerFactory();
IScheduler scheduler = factory.GetScheduler();
IJobDetail job = JobBuilder.Create<TestClass>()
.WithIdentity("name", "group")
.Build();
ITrigger triggerCron = TriggerBuilder.Create()
.WithCronSchedule("0 0/1 * 1/1 * ? *")
.StartNow()
.Build();
scheduler.ScheduleJob(job, triggerCron);
scheduler.Start();
Thread.Sleep(TimeSpan.FromMinutes(10));
scheduler.Shutdown();
t.method("stop");
}
}
public class TestClass : IJob
{
public void Execute(IJobExecutionContext context)
{
this.method("job");
}
public void method(string filename)
{
StreamWriter file2 = new StreamWriter(HostingEnvironment.MapPath("~\test\" + filename + ".txt"), true);
file2.WriteLine("Write Time : " + DateTime.Now);
file2.Close();
}
}
我从 运行 这个页面开始安排,我试着把它添加到 Global.asax
。我应该怎么做才能在我的实时服务器中启动调度程序,是否可以从服务器停止调度,如果可以,解决方案是什么?
我希望这篇 link 能满足您的需求 Simulate a Windows Service using ASP.NET to run scheduled jobs
Quartz 使用 windows 服务,使用 Hangfire instead which doesn't need windows services. This Hangfire, a must for adding background tasks in ASP.NET link 将帮助您入门
我可以访问数据库,ftp 可以访问我的实时服务器。我想安排一个任务。我在 Quartz.net (ASP.Net C#) 中做了一个计划,它在本地服务器上运行良好,当我将它上传到服务器时,我没有输出。我在任务的顶部和底部添加了一个文件写入命令,这些文件正在写入目的地。这是我写的代码
public partial class saaiTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestClass t = new TestClass();
t.method("start");
ISchedulerFactory factory = new StdSchedulerFactory();
IScheduler scheduler = factory.GetScheduler();
IJobDetail job = JobBuilder.Create<TestClass>()
.WithIdentity("name", "group")
.Build();
ITrigger triggerCron = TriggerBuilder.Create()
.WithCronSchedule("0 0/1 * 1/1 * ? *")
.StartNow()
.Build();
scheduler.ScheduleJob(job, triggerCron);
scheduler.Start();
Thread.Sleep(TimeSpan.FromMinutes(10));
scheduler.Shutdown();
t.method("stop");
}
}
public class TestClass : IJob
{
public void Execute(IJobExecutionContext context)
{
this.method("job");
}
public void method(string filename)
{
StreamWriter file2 = new StreamWriter(HostingEnvironment.MapPath("~\test\" + filename + ".txt"), true);
file2.WriteLine("Write Time : " + DateTime.Now);
file2.Close();
}
}
我从 运行 这个页面开始安排,我试着把它添加到 Global.asax
。我应该怎么做才能在我的实时服务器中启动调度程序,是否可以从服务器停止调度,如果可以,解决方案是什么?
我希望这篇 link 能满足您的需求 Simulate a Windows Service using ASP.NET to run scheduled jobs
Quartz 使用 windows 服务,使用 Hangfire instead which doesn't need windows services. This Hangfire, a must for adding background tasks in ASP.NET link 将帮助您入门