diff OrthancServer/ServerContext.cpp @ 3165:1fe524e211af

New configuration option: "SaveJobs" to specify whether jobs are stored in the database
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Jan 2019 18:24:13 +0100
parents ac72032d69a2
children 8ea7c4546c3a
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Thu Jan 24 18:06:13 2019 +0100
+++ b/OrthancServer/ServerContext.cpp	Thu Jan 24 18:24:13 2019 +0100
@@ -196,21 +196,24 @@
 
   void ServerContext::SaveJobsEngine()
   {
-    VLOG(1) << "Serializing the content of the jobs engine";
+    if (saveJobs_)
+    {
+      VLOG(1) << "Serializing the content of the jobs engine";
     
-    try
-    {
-      Json::Value value;
-      jobsEngine_.GetRegistry().Serialize(value);
+      try
+      {
+        Json::Value value;
+        jobsEngine_.GetRegistry().Serialize(value);
 
-      Json::FastWriter writer;
-      std::string serialized = writer.write(value);
+        Json::FastWriter writer;
+        std::string serialized = writer.write(value);
 
-      index_.SetGlobalProperty(GlobalProperty_JobsRegistry, serialized);
-    }
-    catch (OrthancException& e)
-    {
-      LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What();
+        index_.SetGlobalProperty(GlobalProperty_JobsRegistry, serialized);
+      }
+      catch (OrthancException& e)
+      {
+        LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What();
+      }
     }
   }
 
@@ -245,6 +248,7 @@
         new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1)));
       defaultLocalAet_ = lock.GetConfiguration().GetStringParameter("DicomAet", "ORTHANC");
       jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2));
+      saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true);
     }
 
     jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);