Created
February 21, 2022 06:26
-
-
Save alaawahbah/ac1101dff09a9b709c535f92d3809ac0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Quartz; | |
using Quartz.Impl; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
namespace HFZMVC.Jobs | |
{ | |
public class JobManager | |
{ | |
public static JobManager CreatInstance() | |
{ | |
return new JobManager(); | |
} | |
public void Init() | |
{ | |
// define the job and tie it to our HelloJob class | |
IJobDetail job = JobBuilder.Create<CheckMembershipExpiryDateJob>() | |
.WithIdentity("MembershipChecker", "ValidateMembership") // name "myJob", group "group1" | |
.Build(); | |
// Trigger the job to run now, and then every 40 seconds | |
ITrigger trigger = TriggerBuilder.Create() | |
.WithIdentity("MembershipChecker", "ValidateMembership") | |
//.StartNow() | |
.StartAt(DateTimeOffset.Parse("00:00")) | |
.WithSimpleSchedule(x => x | |
.WithIntervalInHours(24) | |
.RepeatForever()) | |
.Build(); | |
ISchedulerFactory schedFact = new StdSchedulerFactory(); | |
// get a scheduler, start the schedular before triggers or anything else | |
IScheduler sched = schedFact.GetScheduler().Result; | |
sched.Start(); | |
//// Tell quartz to schedule the job using our trigger | |
sched.ScheduleJob(job, trigger); | |
} | |
} | |
} | |
using Quartz; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace HFZMVC.Jobs | |
{ | |
public class CheckMembershipExpiryDateJob:IJob | |
{ | |
public Task Execute(IJobExecutionContext context) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment