diff OrthancServer/main.cpp @ 392:7035f4a5b07b lua-scripting

installing lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Apr 2013 15:41:07 +0200
parents 466c992a9a42
children 9784f19f7e1b
line wrap: on
line diff
--- a/OrthancServer/main.cpp	Tue Apr 30 15:36:24 2013 +0200
+++ b/OrthancServer/main.cpp	Tue Apr 30 15:41:07 2013 +0200
@@ -56,9 +56,6 @@
   MyDicomStore(ServerContext& context) :
     server_(context)
   {
-    LuaContext& lua = server_.GetLuaContext();
-    lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX);
-    lua.Execute("function NewInstanceFilter(dicom, aet) print(dicom['0010,0020'].Value); return true end");
   }
 
   virtual void Handle(const std::string& dicomFile,
@@ -234,6 +231,19 @@
 
     context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false));
 
+    {
+      std::string path = GetGlobalStringParameter("Scripting", "");
+      if (path.size() > 0)
+      {
+        LOG(WARNING) << "Installing the Lua scripts from: " << path;
+        std::string lua;
+        Toolbox::ReadFile(lua, path);
+        context.GetLuaContext().Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX);
+        context.GetLuaContext().Execute(lua);
+      }
+    }
+
+
     try
     {
       context.GetIndex().SetMaximumPatientCount(GetGlobalIntegerParameter("MaximumPatientCount", 0));