From c386376ca3b83b52f0fe177625ff6a6054633fb1 Mon Sep 17 00:00:00 2001 From: tangxu <tangxu76880903> Date: 星期六, 04 五月 2024 21:38:52 +0800 Subject: [PATCH] 打开定时任务 --- WaterPredict/IStation.ChEr.WebApi.Predict/Startup.cs | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/WaterPredict/IStation.ChEr.WebApi.Predict/Startup.cs b/WaterPredict/IStation.ChEr.WebApi.Predict/Startup.cs index c93f411..b5b4b01 100644 --- a/WaterPredict/IStation.ChEr.WebApi.Predict/Startup.cs +++ b/WaterPredict/IStation.ChEr.WebApi.Predict/Startup.cs @@ -75,28 +75,28 @@ IStation.LogHelper.Info("log4net initial OK"); - - ////瀹氭椂浠诲姟 - //services.AddQuartz(q => - //{ - // // Use a Scoped container to create jobs. I'll touch on this later - // //q.UseMicrosoftDependencyInjectionScopedJobFactory(); - // var jobKey = new JobKey("CalcWaterPredict"); + //瀹氭椂浠诲姟 + services.AddQuartz(q => + { + // Use a Scoped container to create jobs. I'll touch on this later + //q.UseMicrosoftDependencyInjectionScopedJobFactory(); - // // Register the job with the DI container - // q.AddJob<CalcWaterPredictJob>(opts => opts.WithIdentity(jobKey)); + var jobKey = new JobKey("CalcWaterPredict"); - // // Create a trigger for the job - // q.AddTrigger(opts => opts - // .ForJob(jobKey) // link to the CalcWaterPredict - // .WithIdentity("CalcWaterPredict-trigger") // give the trigger a unique name - // .WithCronSchedule("0 06 0/1 * * ? ")); // 姣忓皬鏃朵竴娆★紝姣忔鍦ㄨ灏忔椂鐨�06鍒嗗紑濮嬫墽琛岋細 + // Register the job with the DI container + q.AddJob<CalcWaterPredictJob>(opts => opts.WithIdentity(jobKey)); - //}); + // Create a trigger for the job + q.AddTrigger(opts => opts + .ForJob(jobKey) // link to the CalcWaterPredict + .WithIdentity("CalcWaterPredict-trigger") // give the trigger a unique name + .WithCronSchedule("0 06 0/1 * * ? ")); // 姣忓皬鏃朵竴娆★紝姣忔鍦ㄨ灏忔椂鐨�06鍒嗗紑濮嬫墽琛岋細 - //// Add the Quartz.NET hosted service - //services.AddQuartzHostedService( q => q.WaitForJobsToComplete = true); + }); + + // Add the Quartz.NET hosted service + services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true); } -- Gitblit v1.9.3