SceduleController.cs 807 B

12345678910111213141516171819202122232425262728
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Quartz;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using wispro.sp.api.Job;
  9. namespace wispro.sp.api.Controllers
  10. {
  11. [Route("api/[controller]/[action]")]
  12. [ApiController]
  13. public class ScheduleController : ControllerBase
  14. {
  15. public void Start()
  16. {
  17. JobKey jobKey = new JobKey("ImportReportData");
  18. var trigger = TriggerBuilder.Create()
  19. .WithDescription("导入每月报表")
  20. .WithSchedule(CronScheduleBuilder.CronSchedule("0 0/2 * * * ? *").WithMisfireHandlingInstructionDoNothing())
  21. .Build();
  22. QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
  23. }
  24. }
  25. }