c# - JobData is not persisted after each execution in Quartz.net -


i have job want keep track of 50 latest runs. reason doesn't seem state stored in simple prototyp:

[persistjobdataafterexecution] public class apijob : ijob {     private const string jobrunskey = "jobruns";     private const int historytokeep = 50;     private const string urlkey = "url";      public void execute(ijobexecutioncontext context)     {         var jobdatamap = context.jobdetail.jobdatamap;          var url = context.jobdetail.jobdatamap.getstring(urlkey);         var client = new restclient(url);         var request = new restrequest(method.post);         var response = client.execute(request);         var runs = new list<jobrun>();         if (jobdatamap.containskey(jobrunskey))         {             runs = (list<jobrun>) jobdatamap[jobrunskey];         }          console.writeline("i'm running fast!");          runs.insert(0, new jobrun(){message = "hello", result = jobresult.ok, timeforrun = datetime.utcnow});         while (runs.count > historytokeep)         {             runs.removeat(historytokeep);         }         jobdatamap.put(jobrunskey, runs);      } } 

i try store new list jobdatamap.put(jobrunskey, runs) next time trigger job key missing jobdatamap. suggestions?

you don't have jobrun class marked serializable.

this should work

[serializable] public class jobrun {     public string message       ;     public string result        ;     public datetime timeforrun  ; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -