changeset 1001:f3929718ea7e lua-scripting

autorouting primitives
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 04 Jul 2014 15:31:42 +0200
parents 13e230bbd882
children b067017a8a5b
files CMakeLists.txt OrthancServer/Scheduler/ServerCommandInstance.cpp OrthancServer/Scheduler/StoreScuCommand.cpp OrthancServer/ServerContext.cpp
diffstat 4 files changed, 47 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Jul 04 14:14:14 2014 +0200
+++ b/CMakeLists.txt	Fri Jul 04 15:31:42 2014 +0200
@@ -154,6 +154,7 @@
   OrthancServer/OrthancMoveRequestHandler.cpp
 
   # From "lua-scripting" branch
+  OrthancServer/Scheduler/DeleteInstanceCommand.cpp
   OrthancServer/Scheduler/ServerCommandInstance.cpp
   OrthancServer/Scheduler/ServerJob.cpp
   OrthancServer/Scheduler/ServerScheduler.cpp
--- a/OrthancServer/Scheduler/ServerCommandInstance.cpp	Fri Jul 04 14:14:14 2014 +0200
+++ b/OrthancServer/Scheduler/ServerCommandInstance.cpp	Fri Jul 04 15:31:42 2014 +0200
@@ -39,7 +39,21 @@
   bool ServerCommandInstance::Execute(IListener& listener)
   {
     ListOfStrings outputs;
-    if (!filter_->Apply(outputs, inputs_))
+
+    bool success = false;
+
+    try
+    {
+      if (filter_->Apply(outputs, inputs_))
+      {
+        success = true;
+      }
+    }
+    catch (OrthancException&)
+    {
+    }
+
+    if (!success)
     {
       listener.SignalFailure(jobId_);
       return true;
--- a/OrthancServer/Scheduler/StoreScuCommand.cpp	Fri Jul 04 14:14:14 2014 +0200
+++ b/OrthancServer/Scheduler/StoreScuCommand.cpp	Fri Jul 04 15:31:42 2014 +0200
@@ -58,6 +58,8 @@
       std::string dicom;
       context_.ReadFile(dicom, *it, FileContentType_Dicom);
       locker.GetConnection().Store(dicom);
+
+      outputs.push_back(*it);
     }
 
     return true;
--- a/OrthancServer/ServerContext.cpp	Fri Jul 04 14:14:14 2014 +0200
+++ b/OrthancServer/ServerContext.cpp	Fri Jul 04 15:31:42 2014 +0200
@@ -43,6 +43,12 @@
 #include <EmbeddedResources.h>
 #include <dcmtk/dcmdata/dcfilefo.h>
 
+
+#include "Scheduler/DeleteInstanceCommand.h"
+#include "Scheduler/StoreScuCommand.h"
+
+
+
 #define ENABLE_DICOM_CACHE  1
 
 static const char* RECEIVED_INSTANCE_FILTER = "ReceivedInstanceFilter";
@@ -131,6 +137,20 @@
       printf("TODO\n");
       std::cout << result;
     }
+
+    {
+      // Autorouting test
+      RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName("sample");
+
+      ServerJob job;
+      ServerCommandInstance& a = job.AddCommand(new StoreScuCommand(*this, p));
+      ServerCommandInstance& b = job.AddCommand(new DeleteInstanceCommand(*this));
+      a.AddInput(instanceId);
+      a.ConnectNext(b);
+
+      job.SetDescription("Autorouting test");
+      scheduler_.Submit(job);
+    }
   }
 
 
@@ -196,8 +216,15 @@
     if (status == StoreStatus_Success ||
         status == StoreStatus_AlreadyStored)
     {
-      DicomInstanceHasher hasher(dicomSummary);
-      ApplyOnStoredInstance(simplified, hasher.HashInstance());
+      try
+      {
+        DicomInstanceHasher hasher(dicomSummary);
+        ApplyOnStoredInstance(simplified, hasher.HashInstance());
+      }
+      catch (OrthancException&)
+      {
+        LOG(ERROR) << "Error when dealing with OnStoredInstance";
+      }
     }
 
     return status;