Closed blackholeearth closed 2 years ago
In my project, I keep the jobid, jobtype and cron express in database as a config. Then call back the job from database. Everything work fine after restart.
using (SqlConnection conn = new(strConstr))
{
conn.Open();
using (SqlCommand cmd = new("HangFire.RecurringJob", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
string? jobid = dr["jobid"].ToString();
string? cron = dr["Cron"].ToString();
RecurringJob.AddOrUpdate(jobid, () => JobType.AutoMail(jobid), cron, TimeZoneInfo.Local);
};
};
};
conn.Close();
};
Ok. So you are not converting actual piece of code. I'm Relieved.
just the job id. Thanks.
i read that hangfire tasks/jobs can survive agains application restart/shutdowns ? it says that for persistance , hangfire uses mssql , sqllite , litedb , postgresql, or your-fav-db.
im more interested in this: how can hangfire convert my task (c# code block, ) into string . is it possible in c# ?? or did i misunderstood ?