I am using the simple scheduler of the Quartz.net library. I have 7 different triggers. The sequence is like this.
First: every 120 minutes.
Second: every 12 hours.
Third: every 5 minutes.
Fourth: every 3 minutes.
Fifth: every 29 seconds.
Sixth: every 10 seconds.
Seventh: every 5 seconds.
It's a bit complicated as you see it. I have a problem like this. First Trigger needs to work every two hours. But after a few runs, it stops by itself. It does not work at all. The others are working and they are OK. I'm sorry for my bad english.
private int bultengetir = 120; // min
private int baslayanmacsil = 29; //sec
private int kuponsonuclandir = 5;//5 min
private int canliorangetir = 10; //sec
private int canlimacgetir = 7; //sec
private int canlimacsil = 12;//hour
private int videoeslestir = 3; //min
private DateTimeOffset g_bultengetir = DateTimeOffset.UtcNow.AddMinutes(0);//10
private DateTimeOffset g_baslayanmacsil = DateTimeOffset.UtcNow.AddMinutes(5);//5
private DateTimeOffset g_canlimacgetir = DateTimeOffset.UtcNow.AddMinutes(10);//10
private DateTimeOffset g_canliorangetir = DateTimeOffset.UtcNow.AddMinutes(11);//55
private DateTimeOffset g_canlimacsil = DateTimeOffset.UtcNow.AddMinutes(12);//5
private DateTimeOffset g_kuponsonuclandir = DateTimeOffset.UtcNow.AddMinutes(15);//15
private DateTimeOffset g_videoeslestir = DateTimeOffset.UtcNow.AddMinutes(15);//7
public void RunJobs()
{
CanliMaclariGetir();
CanliOranlariGetir();
BultenGetir();
BaslayanMaclariSil();
CanliMaclariSil();
KuponlariSonuclandir();
VideoEslestir();
}
private void BultenGetir()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<BultenGetir>()
.WithIdentity("bultengetir")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInMinutes(bultengetir).RepeatForever())
.StartAt(g_bultengetir)
.Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "BultenGetir Görev Emri",
Description = "BultenGetir Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "BultenGetir()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void BaslayanMaclariSil()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<BaslayanMaclariSil>()
.WithIdentity("baslayansil")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInSeconds(baslayanmacsil).RepeatForever())
.StartAt(g_baslayanmacsil)
.Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "BaslayanMaclariSil Görev Emri",
Description = "BaslayanMaclariSil Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "BaslayanMaclariSil()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void KuponlariSonuclandir()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<KuponlariSonuclandir>()
.WithIdentity("kuponsonuclandir")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInMinutes(kuponsonuclandir).RepeatForever())
.StartAt(g_kuponsonuclandir)
.Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "KuponlariSonuclandir Görev Emri",
Description = "KuponlariSonuclandir Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "KuponlariSonuclandir()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void CanliOranlariGetir()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<CanliOranlar>()
.WithIdentity("canliorangetir")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInSeconds(canliorangetir).RepeatForever()).StartAt(g_canliorangetir).Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "CanliOranlariGetir Görev Emri",
Description = "CanliOranlariGetir Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "CanliOranlariGetir()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void CanliMaclariGetir()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<CanliMaclar>()
.WithIdentity("canlimacgetir")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInSeconds(canlimacgetir).RepeatForever()).StartAt(g_canlimacgetir).Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "CanliMaclariGetir Görev Emri",
Description = "CanliMaclariGetir Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "CanliMaclariGetir()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void CanliMaclariSil()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<CanliSil>()
.WithIdentity("canlimacsil")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInHours(canlimacsil).RepeatForever())
.StartAt(g_canlimacsil)
.Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "CanliMaclariSil Görev Emri",
Description = "CanliMaclariSil Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "CanliMaclariSil()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
private void VideoEslestir()
{
try
{
ISchedulerFactory schfack = new StdSchedulerFactory();
IScheduler scheduler = schfack.GetScheduler();
IJobDetail jobdetay = JobBuilder.Create<VideoEslestir>()
.WithIdentity("videoeslestir")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(s => s.WithIntervalInMinutes(videoeslestir).RepeatForever())
.StartAt(g_videoeslestir)
.Build();
scheduler.ScheduleJob(jobdetay, trigger);
scheduler.Start();
Log log = new Log()
{
Name = "VideoEslestir Görev Emri",
Description = "VideoEslestir Görev Emri Verildi.",
Start = DateTime.Now,
Finish = DateTime.Now,
TotalMilliSecond = 0,
Type = 6
};
DbWork db = new DbWork();
db.LogEkle(log);
}
catch (Exception ex)
{
string h_mesaj = ex.Message.ToString();
string icerik = "";
if (ex.InnerException != null) { icerik = ex.InnerException.ToString(); }
string h_yer = ex.StackTrace.ToString();
dal.HataEkle("", "Gorevler Katmanı > Gorev_Zamanlayici.cs", "videoeslestir()", DateTime.Now, h_mesaj, icerik, h_yer);
}
}
bin
folder – MuzzleloaderRunJobs
method and give it your other methods as parameterprivate void BultenGetir(IScheduler scheduler)
– Armendariz