public bool TryLoadJob(string filename) { try { using (var stream = File.OpenRead(filename)) _ctx.Jobs.Enqueue(MailJob.CreateSerializer().Deserialize(stream) as MailJob); return(true); } catch (Exception ex) { _ctx.Logger.Error(ex, $"Failed to load job {filename}"); } return(false); }
public void SaveJob(string filename, MailJob job) { using (var stream = File.Open(filename, FileMode.Create)) MailJob.CreateSerializer().Serialize(stream, job); }