C# 计划任务-在服务器上计划时间调用的aspx页
我有一个asp.net网站。现在我想有一个C# 计划任务-在服务器上计划时间调用的aspx页,c#,asp.net,windows,scheduled-tasks,web-farm,C#,Asp.net,Windows,Scheduled Tasks,Web Farm,我有一个asp.net网站。现在我想有一个.aspx页面,每天在特定时间调用。(不带窗口计划程序/windows服务) 我希望在没有窗口调度程序和windows服务的情况下完成此任务,因为某些客户端无法访问windows Server内核/控制台,因此无法安装服务或窗口任务调度程序 基本上, 我需要在没有在Windows操作系统上安装任何东西的情况下执行计划任务。 没有.exe或窗口服务 因为我在一个web服务器场上托管应用程序 我不想用一台专用的窗口计算机来设置exe或windows服务或窗口
.aspx
页面,每天在特定时间调用。(不带窗口计划程序/windows服务)
我希望在没有窗口调度程序和windows服务的情况下完成此任务,因为某些客户端无法访问windows Server内核/控制台,因此无法安装服务或窗口任务调度程序
基本上,
我需要在没有在Windows操作系统上安装任何东西的情况下执行计划任务。
没有.exe或窗口服务
因为我在一个web服务器场上托管应用程序
我不想用一台专用的窗口计算机来设置exe或windows服务或窗口任务调度程序来调用.aspx
页面
任何帮助都将不胜感激
谢谢试试看,这是一款运行在asp.net上的作业处理器
代码如下所示:
RecurringJob.AddOrUpdate(
()=>YourJobHere(),
Cron.Daily);
试试看,这是一个运行在asp.net上的作业处理器
代码如下所示:
RecurringJob.AddOrUpdate(
()=>YourJobHere(),
Cron.Daily);
在花了大约30-35个小时找到解决方案后,我找到了解决方法。它在C#
中提供。使用Quartz我们可以非常轻松地调度或调用任何作业/C#函数
我们只需要在Global.asax文件的Application\u Start
事件中启动我们的作业
更多的了解,你可以参考下面的代码,这是完美的工作为我
Gloabl.asax:-
void Application_Start(object sender, EventArgs e)
{
SchedulerUtil schedulerUtil = new SchedulerUtil();
schedulerUtil.StartJob();
}
public class JobSchedulerClass : IJob
{
public void Execute(IJobExecutionContext context)
{
Common obj = new Common();
obj.ScheduledPageLoadFunction();
}
}
课堂计划rutil.cs:-
public void StartJob()
{
IScheduler iPageRunCodeScheduler;
string SCHEDULE_RUN_TIME = "05:00"; // 05:00 AM
// Grab the Scheduler instance from the Factory
iPageRunCodeScheduler = StdSchedulerFactory.GetDefaultScheduler();
TimeSpan schedularTime = TimeSpan.Parse(SCHEDULE_RUN_TIME);
iPageRunCodeScheduler.Start();
DbCls obj = new DbCls();
// define the job and tie it to our class
DateTime scheduleStartDate = DateTime.Now.Date.AddDays((DateTime.Now.TimeOfDay > schedularTime) ? 1 : 0).Add(schedularTime);
//IJobDetail job = JobBuilder.Create<Unity.Web.Areas.Admin.Controllers.CommonController.DeleteExportFolder>()
IJobDetail job = JobBuilder.Create<JobSchedulerClass>() // JobSchedulerClass need to create this class which implement IJob
.WithIdentity("job1", "jobGrp1")
.Build();
// Trigger the job to run now, and then repeat every 10 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "jobGrp1")
//.StartNow()
.StartAt(scheduleStartDate)
.WithSimpleSchedule(x => x
//.WithIntervalInHours(24)
.WithIntervalInSeconds(15)
.RepeatForever())
.Build();
// Tell quartz to schedule the job using our trigger
iPageRunCodeScheduler.ScheduleJob(job, trigger);
}
在花了大约30-35个小时找到解决方案后,我找到了解决办法。它在C#
中提供。使用Quartz我们可以非常轻松地调度或调用任何作业/C#函数
我们只需要在Global.asax文件的Application\u Start
事件中启动我们的作业
更多的了解,你可以参考下面的代码,这是完美的工作为我
Gloabl.asax:-
void Application_Start(object sender, EventArgs e)
{
SchedulerUtil schedulerUtil = new SchedulerUtil();
schedulerUtil.StartJob();
}
public class JobSchedulerClass : IJob
{
public void Execute(IJobExecutionContext context)
{
Common obj = new Common();
obj.ScheduledPageLoadFunction();
}
}
课堂计划rutil.cs:-
public void StartJob()
{
IScheduler iPageRunCodeScheduler;
string SCHEDULE_RUN_TIME = "05:00"; // 05:00 AM
// Grab the Scheduler instance from the Factory
iPageRunCodeScheduler = StdSchedulerFactory.GetDefaultScheduler();
TimeSpan schedularTime = TimeSpan.Parse(SCHEDULE_RUN_TIME);
iPageRunCodeScheduler.Start();
DbCls obj = new DbCls();
// define the job and tie it to our class
DateTime scheduleStartDate = DateTime.Now.Date.AddDays((DateTime.Now.TimeOfDay > schedularTime) ? 1 : 0).Add(schedularTime);
//IJobDetail job = JobBuilder.Create<Unity.Web.Areas.Admin.Controllers.CommonController.DeleteExportFolder>()
IJobDetail job = JobBuilder.Create<JobSchedulerClass>() // JobSchedulerClass need to create this class which implement IJob
.WithIdentity("job1", "jobGrp1")
.Build();
// Trigger the job to run now, and then repeat every 10 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "jobGrp1")
//.StartNow()
.StartAt(scheduleStartDate)
.WithSimpleSchedule(x => x
//.WithIntervalInHours(24)
.WithIntervalInSeconds(15)
.RepeatForever())
.Build();
// Tell quartz to schedule the job using our trigger
iPageRunCodeScheduler.ScheduleJob(job, trigger);
}