// GET: ScheduleInfoes public async Task <IActionResult> Index() { if (_scheduler == null) { _scheduler = await JobCenter.GetSchedulerAsync(); } if (!_scheduler.IsStarted) { await _scheduler.Start(); } if (_consumer == null) { BuildConsumers(); } var infos = JobCenter.Manager.GetAllScheduleList().ToListAsync(); foreach (var item in await infos) { if (item.RunStatus == (int)JobStatus.Enabled || item.RunStatus == (int)JobStatus.Waiting) { StartTask(item.Id, false); } } return(View(await infos)); }
public static void StartRemindJobs(DateTime recordedOn, out ObservableCollection <Diary> diaries) { DateTime start = new DateTime(recordedOn.Year, recordedOn.Month, 1); DateTime end = GetNextMonthFirstDate(recordedOn); string sql = $"SELECT * FROM Diary WHERE RecordDate >= '{start:yyyy-MM-dd}' AND RecordDate < '{end:yyyy-MM-dd}'"; diaries = new ObservableCollection <Diary>(new DiaryDAL().GetDiaries(sql)); foreach (var item in diaries.Where(a => a.IsRemindRequired).ToList()) { JobCenter.StartScheduleJobAsync(item).Wait(); } }
public async void StopTask(int?id) { var scheduleInfo = JobCenter.Manager.Single <ScheduleInfo>(a => a.Id == id); await JobCenter.PauseScheduleJobAsync(scheduleInfo); }
public async void StartTask(int?id, [FromQuery] bool?doatonce) { var scheduleInfo = JobCenter.Manager.Single <ScheduleInfo>(a => a.Id == id); bool atonce = doatonce != null && doatonce.Value; await JobCenter.StartScheduleJobAsync(scheduleInfo, atonce); }