Mercurial > hg > orthanc
comparison OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp @ 4733:1db3b79d97bd
Error code and description of jobs are now saved into the Orthanc database
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Jun 2021 14:25:37 +0200 |
parents | d9473bd5ed43 |
children | a046e91cc76f |
comparison
equal
deleted
inserted
replaced
4732:3709565bee7f | 4733:1db3b79d97bd |
---|---|
37 static const char* JOBS = "Jobs"; | 37 static const char* JOBS = "Jobs"; |
38 static const char* JOBS_REGISTRY = "JobsRegistry"; | 38 static const char* JOBS_REGISTRY = "JobsRegistry"; |
39 static const char* CREATION_TIME = "CreationTime"; | 39 static const char* CREATION_TIME = "CreationTime"; |
40 static const char* LAST_CHANGE_TIME = "LastChangeTime"; | 40 static const char* LAST_CHANGE_TIME = "LastChangeTime"; |
41 static const char* RUNTIME = "Runtime"; | 41 static const char* RUNTIME = "Runtime"; |
42 static const char* ERROR_CODE = "ErrorCode"; | |
43 static const char* ERROR_DETAILS = "ErrorDetails"; | |
42 | 44 |
43 | 45 |
44 class JobsRegistry::JobHandler : public boost::noncopyable | 46 class JobsRegistry::JobHandler : public boost::noncopyable |
45 { | 47 { |
46 private: | 48 private: |
274 target[STATE] = EnumerationToString(state_); | 276 target[STATE] = EnumerationToString(state_); |
275 target[PRIORITY] = priority_; | 277 target[PRIORITY] = priority_; |
276 target[CREATION_TIME] = boost::posix_time::to_iso_string(creationTime_); | 278 target[CREATION_TIME] = boost::posix_time::to_iso_string(creationTime_); |
277 target[LAST_CHANGE_TIME] = boost::posix_time::to_iso_string(lastStateChangeTime_); | 279 target[LAST_CHANGE_TIME] = boost::posix_time::to_iso_string(lastStateChangeTime_); |
278 target[RUNTIME] = static_cast<unsigned int>(runtime_.total_milliseconds()); | 280 target[RUNTIME] = static_cast<unsigned int>(runtime_.total_milliseconds()); |
281 | |
282 // New in Orthanc 1.9.5 | |
283 target[ERROR_CODE] = static_cast<int>(lastStatus_.GetErrorCode()); | |
284 target[ERROR_DETAILS] = lastStatus_.GetDetails(); | |
285 | |
279 return true; | 286 return true; |
280 } | 287 } |
281 else | 288 else |
282 { | 289 { |
283 LOG(TRACE) << "Job backup is not supported for job of type: " << jobType_; | 290 LOG(TRACE) << "Job backup is not supported for job of type: " << jobType_; |
305 | 312 |
306 job_.reset(unserializer.UnserializeJob(serialized[JOB])); | 313 job_.reset(unserializer.UnserializeJob(serialized[JOB])); |
307 job_->GetJobType(jobType_); | 314 job_->GetJobType(jobType_); |
308 job_->Start(); | 315 job_->Start(); |
309 | 316 |
310 lastStatus_ = JobStatus(ErrorCode_Success, "", *job_); | 317 ErrorCode errorCode; |
318 if (serialized.isMember(ERROR_CODE)) | |
319 { | |
320 errorCode = static_cast<ErrorCode>(SerializationToolbox::ReadInteger(serialized, ERROR_CODE)); | |
321 } | |
322 else | |
323 { | |
324 errorCode = ErrorCode_Success; // Backward compatibility with Orthanc <= 1.9.4 | |
325 } | |
326 | |
327 std::string details; | |
328 if (serialized.isMember(ERROR_DETAILS)) // Backward compatibility with Orthanc <= 1.9.4 | |
329 { | |
330 details = SerializationToolbox::ReadString(serialized, ERROR_DETAILS); | |
331 } | |
332 | |
333 lastStatus_ = JobStatus(errorCode, details, *job_); | |
311 } | 334 } |
312 }; | 335 }; |
313 | 336 |
314 | 337 |
315 bool JobsRegistry::PriorityComparator::operator() (JobHandler* const& a, | 338 bool JobsRegistry::PriorityComparator::operator() (JobHandler* const& a, |