46 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
| 
 | |
| using Microsoft.Extensions.Configuration;
 | |
| using Microsoft.Extensions.DependencyInjection;
 | |
| 
 | |
| namespace IRaCIS.Core.API
 | |
| {
 | |
|     public  static class QuartZSetup
 | |
|     {
 | |
|         public static void AddQuartZSetup(this IServiceCollection services, IConfiguration configuration)
 | |
|         {
 | |
|             //services.AddTransient<CacheTrialStatusQuartZJob>();
 | |
| 
 | |
|             //services.AddQuartz(q =>
 | |
|             //{
 | |
|             //    // base quartz scheduler, job and trigger configuration
 | |
| 
 | |
|             //    // as of 3.3.2 this also injects scoped services (like EF DbContext) without problems
 | |
|             //    q.UseMicrosoftDependencyInjectionJobFactory();
 | |
| 
 | |
|             //    // 基本Quartz调度器、作业和触发器配置
 | |
|             //    var jobKey = new JobKey("RegularTrialWork", "regularWorkGroup");
 | |
|             //    q.AddJob<CacheTrialStatusQuartZJob>(jobKey, j => j
 | |
|             //        .WithDescription("Trial regular work")
 | |
|             //    );
 | |
|             //    q.AddTrigger(t => t
 | |
|             //        .WithIdentity("TrialStatusTrigger")
 | |
|             //        .ForJob(jobKey)
 | |
|             //        //.StartNow()
 | |
|             //        //.WithSimpleSchedule(x => x.WithInterval(TimeSpan.FromSeconds(15))//开始秒数 15s
 | |
|             //        //    .RepeatForever())//持续工作
 | |
|             //        .WithCronSchedule("0 0 0/2 * * ?")//每小时执行一次
 | |
|             //        .WithDescription("My regular trial work trigger")
 | |
|             //    );
 | |
|             //});
 | |
| 
 | |
|             //// ASP.NET Core hosting
 | |
|             //services.AddQuartzServer(options =>
 | |
|             //{
 | |
|             //    // when shutting down we want jobs to complete gracefully
 | |
|             //    options.WaitForJobsToComplete = true;
 | |
|             //});
 | |
| 
 | |
|         }
 | |
|     }
 | |
| }
 |