c# .net framework 4.5.2 , Quartz.NET 3.0.7
2021-01-26 15:12
标签:except out turn str tail time hide jobs cond 参考了:https://www.cnblogs.com/personblog/p/11277527.html, https://www.jianshu.com/p/b8e7e4deb60a .NET MVC 中的示例: ReportJob.cs -- ReportJobScheduler.cs -- Application_Start() -- c# .net framework 4.5.2 , Quartz.NET 3.0.7 标签:except out turn str tail time hide jobs cond 原文地址:https://www.cnblogs.com/runliuv/p/11976385.htmlusing Quartz;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Quartz研究.MyJob.GetWxQdSubMchId
{
[DisallowConcurrentExecution]
public class ReportJob : IJob
{
public Task Execute(IJobExecutionContext context)
{
return Task.Run(() =>
{
foo();
});
}
public void foo()
{
try
{
var reportDirectory = string.Format("~/reports/{0}/", DateTime.Now.ToString("yyyy-MM"));
reportDirectory = System.Web.Hosting.HostingEnvironment.MapPath(reportDirectory);
if (!Directory.Exists(reportDirectory))
{
Directory.CreateDirectory(reportDirectory);
}
var dailyReportFullPath = string.Format("{0}report_{1}.log", reportDirectory, DateTime.Now.Day);
var logContent = string.Format("{0}==>>{1}{2}", DateTime.Now, "create new log.", Environment.NewLine);
File.AppendAllText(dailyReportFullPath, logContent);
}
catch (Exception ex)
{
//日志
}
}
}
}
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Quartz研究.MyJob.GetWxQdSubMchId
{
public class ReportJobScheduler
{
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace Quartz研究
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
Quartz研究.MyJob.GetWxQdSubMchId.ReportJobScheduler.Start();
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
文章标题:c# .net framework 4.5.2 , Quartz.NET 3.0.7
文章链接:http://soscw.com/index.php/essay/47319.html