comparison OrthancServer/ServerContext.cpp @ 1285:5730f374e4e6

Access to called AET and remote AET from Lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Feb 2015 15:00:42 +0100
parents 21ea32170764
children 6e7e5ed91c2d
comparison
equal deleted inserted replaced
1284:21ea32170764 1285:5730f374e4e6
209 } 209 }
210 210
211 211
212 void ServerContext::ApplyLuaOnStoredInstance(const std::string& instanceId, 212 void ServerContext::ApplyLuaOnStoredInstance(const std::string& instanceId,
213 const Json::Value& simplifiedDicom, 213 const Json::Value& simplifiedDicom,
214 const Json::Value& metadata) 214 const Json::Value& metadata,
215 const std::string& remoteAet,
216 const std::string& calledAet)
215 { 217 {
216 LuaContextLocker locker(*this); 218 LuaContextLocker locker(*this);
217 219
218 if (locker.GetLua().IsExistingFunction(ON_STORED_INSTANCE)) 220 if (locker.GetLua().IsExistingFunction(ON_STORED_INSTANCE))
219 { 221 {
221 223
222 LuaFunctionCall call(locker.GetLua(), ON_STORED_INSTANCE); 224 LuaFunctionCall call(locker.GetLua(), ON_STORED_INSTANCE);
223 call.PushString(instanceId); 225 call.PushString(instanceId);
224 call.PushJson(simplifiedDicom); 226 call.PushJson(simplifiedDicom);
225 call.PushJson(metadata); 227 call.PushJson(metadata);
228 call.PushJson(remoteAet);
229 call.PushJson(calledAet);
226 call.Execute(); 230 call.Execute();
227 231
228 Json::Value operations; 232 Json::Value operations;
229 LuaFunctionCall call2(locker.GetLua(), "_AccessJob"); 233 LuaFunctionCall call2(locker.GetLua(), "_AccessJob");
230 call2.ExecuteToJson(operations); 234 call2.ExecuteToJson(operations);
358 metadata[EnumerationToString(it->first)] = it->second; 362 metadata[EnumerationToString(it->first)] = it->second;
359 } 363 }
360 364
361 try 365 try
362 { 366 {
363 ApplyLuaOnStoredInstance(resultPublicId, simplified, metadata); 367 ApplyLuaOnStoredInstance(resultPublicId, simplified, metadata,
368 dicom.GetRemoteAet(), dicom.GetCalledAet());
364 } 369 }
365 catch (OrthancException& e) 370 catch (OrthancException& e)
366 { 371 {
367 LOG(ERROR) << "Error in OnStoredInstance callback (Lua): " << e.What(); 372 LOG(ERROR) << "Error in " << ON_STORED_INSTANCE << " callback (Lua): " << e.What();
368 } 373 }
369 374
370 if (plugins_ != NULL) 375 if (plugins_ != NULL)
371 { 376 {
372 try 377 try
373 { 378 {
374 plugins_->SignalStoredInstance(dicom, resultPublicId); 379 plugins_->SignalStoredInstance(dicom, resultPublicId);
375 } 380 }
376 catch (OrthancException& e) 381 catch (OrthancException& e)
377 { 382 {
378 LOG(ERROR) << "Error in OnStoredInstance callback (plugins): " << e.What(); 383 LOG(ERROR) << "Error in " << ON_STORED_INSTANCE << " callback (plugins): " << e.What();
379 } 384 }
380 } 385 }
381 } 386 }
382 387
383 return status; 388 return status;