public async Task StartAsync(CancellationToken cancellationToken) { // Lịch reset trạng thái học sinh SchedulerResetStudentStatus = await _schedulerFactory.GetScheduler(); SchedulerResetStudentStatus.JobFactory = _jobFactory; this._jobMetadataReset = new JobMetadata(Guid.NewGuid(), typeof(UpdateStudentStatusJob), "Reset Student Status Job", "0 0 0 * * ?"); var jobReset = CreateJob(_jobMetadataReset); var triggerReset = CreateTrigger(_jobMetadataReset); await SchedulerResetStudentStatus.ScheduleJob(jobReset, triggerReset, cancellationToken); await SchedulerResetStudentStatus.Start(cancellationToken); //Lập lịch check student status SchedulerCheckStudentStatus = await _schedulerFactory.GetScheduler(); SchedulerCheckStudentStatus.JobFactory = _jobFactory; this._jobMetadataCheck = new JobMetadata(Guid.NewGuid(), typeof(CheckStudentStatusJob), "Check Student Status Job", "0 */1 * * * ?"); var jobCheck = CreateJob(_jobMetadataCheck); var triggerCheck = CreateTrigger(_jobMetadataCheck); await SchedulerCheckStudentStatus.ScheduleJob(jobCheck, triggerCheck, cancellationToken); await SchedulerCheckStudentStatus.Start(cancellationToken); }
public async Task StopAsync(CancellationToken cancellationToken) { await SchedulerResetStudentStatus?.Shutdown(cancellationToken); }