i need to trigger a job at particular time on particular weekdays. these weekdays are also dynamic and should be fetched from db.Also the job should trigger or repeat itself for particular count. let us say a Job j should trigger on every mon, wed, fri, for repeat count 15 i.e for 3 * 5 = 15 so it should trigger for next 3 weeks.
i tried using cronexpression as below but could not find how to stop a job from triggering after certain count.
StringBuilder cronString = new StringBuilder("0 0 12 ? * ");
if (plandata.Sunday == true)
cronString.Append("SUN,");
if (plandata.Monday == true)
cronString.Append("MON,");
if (plandata.Tuesday == true)
cronString.Append("TUE,");
if (plandata.Wednesday == true)
cronString.Append("WED,");
if (plandata.Thursday == true)
cronString.Append("THU");
if (plandata.Friday == true)
cronString.Append("FRI,");
if (plandata.Saturday == true)
cronString.Append("SAT,");
cronString.Append(" *");
IJobDetail job = JobBuilder.Create<Demo>()
.Build();
ITrigger trigger = TriggerBuilder.Create()
//.StartAt((DateTime)plandata.StartDate)
.StartNow()
.WithPriority(1)
.WithCronSchedule(cronString.ToString())
.Build();
Please suggest me something so that i can achieve what i need.