tangxu
2024-05-04 c386376ca3b83b52f0fe177625ff6a6054633fb1
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);
        }