参考了:c# .net framework 4.5.2 , Quartz.NET 3.0.7 – runliuv – 博客园 (cnblogs.com)
https://www.cnblogs.com/personblog/p/11277527.html,
Quartz.NET 作业调度(一):Test – 简书
自己要轮询的任务:
using log4net;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace WzsrmyyApi.QuartzTask
{
[DisallowConcurrentExecution]
public class ReportJob : IJob
{
public Task Execute(IJobExecutionContext context)
{
return Task.Run(() =>
{
foo();
});
}
public static readonly ILog logger 服务器托管网= LogManager.GetLogger("SendMsgJob");
public void foo()
{
BigDataSupervisionBll bll = new BigDataSupervisionBll();
BigDataSupervisionOtherBll otherBll = new BigDataSupervisionOtherBll();
try
{
var dic = bll.SplitCount(otherBll.GetChargesRecordOneDay());
int dictNum = 0; string type = "charges_record";
for (int i = dictNum; i
轮询的任务的建立
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WzsrmyyApi.QuartzTask
{
public class ReportJobScheduler
{
public static async void Start()
{
try
{
string thisJob = "ReportJob";
string groupName = "gp" + thisJob;
string jobName = "job" + thisJob;
string triggerName = "trigger" + thisJob;
// 创建作业调度池
ISchedulerFactory factory = new StdSchedulerFactory();
IScheduler scheduler = await factory.GetSc服务器托管网heduler();
// 创建作业
IJobDetail job = JobBuilder.Create()
.WithIdentity(jobName, groupName)
.Build();
// 创建触发器,
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(triggerName, groupName)
.StartNow()
.WithCronSchedule("0 0 22 ? * * ")//每天晚上十点
.Build();
//.WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()//每10s执行一次
// 加入到作业调度池中
await scheduler.ScheduleJob(job, trigger);
// 开始运行
await scheduler.Start();
}
catch (Exception ex)
{
//日志
}
}
}
}
最后在程序启动的时候进行注册:
protected void Application_Start()
{
log4net.Config.XmlConfigurator.Configure();//系统日志配置
QuartzTask.ReportJobScheduler.Start();//
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
以上就是简单的代码使用 。Quartz.net的使用可以通过两种方式调用:一是通过代码的方式,而是通过配置文件的方式;
详细些的可以参考:Quartz.Net详解-CSDN博客
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
1.算术运算符 1.1 expr命令 expr 是 evaluate expressions 的缩写,译为“求值表达式”。Shell expr 是一个功能强大,并且比较复杂的命令,它除了可以实现整数计算,还可以结合一些选项对字符串进行处理,例如计算字符串长度、…