comparison Samples/Sdl/Loader.cpp @ 680:0eb26f514ac5

loading of slice images
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 16 May 2019 12:33:43 +0200
parents 6f10f9a6676a
children 9723fceccb9f
comparison
equal deleted inserted replaced
679:979963fd3725 680:0eb26f514ac5
352 } 352 }
353 }; 353 };
354 354
355 355
356 private: 356 private:
357 std::string uri_; 357 std::string uri_;
358 HttpHeaders headers_; 358 HttpHeaders headers_;
359 unsigned int timeout_; 359 unsigned int timeout_;
360 bool hasExpectedFormat_;
361 Orthanc::PixelFormat expectedFormat_;
360 362
361 std::auto_ptr< OrthancStone::MessageHandler<SuccessMessage> > successCallback_; 363 std::auto_ptr< OrthancStone::MessageHandler<SuccessMessage> > successCallback_;
362 std::auto_ptr< OrthancStone::MessageHandler<OracleCommandExceptionMessage> > failureCallback_; 364 std::auto_ptr< OrthancStone::MessageHandler<OracleCommandExceptionMessage> > failureCallback_;
363 365
364 public: 366 public:
365 GetOrthancImageCommand() : 367 GetOrthancImageCommand() :
366 uri_("/"), 368 uri_("/"),
367 timeout_(10) 369 timeout_(10),
370 hasExpectedFormat_(false)
368 { 371 {
369 } 372 }
370 373
371 virtual Type GetType() const 374 virtual Type GetType() const
372 { 375 {
373 return Type_GetOrthancImage; 376 return Type_GetOrthancImage;
377 }
378
379 void SetExpectedPixelFormat(Orthanc::PixelFormat format)
380 {
381 hasExpectedFormat_ = true;
382 expectedFormat_ = format;
374 } 383 }
375 384
376 void SetUri(const std::string& uri) 385 void SetUri(const std::string& uri)
377 { 386 {
378 uri_ = uri; 387 uri_ = uri;
451 460
452 default: 461 default:
453 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, 462 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol,
454 "Unsupported HTTP Content-Type for an image: " + 463 "Unsupported HTTP Content-Type for an image: " +
455 std::string(Orthanc::EnumerationToString(contentType))); 464 std::string(Orthanc::EnumerationToString(contentType)));
465 }
466
467 if (hasExpectedFormat_)
468 {
469 if (expectedFormat_ == Orthanc::PixelFormat_SignedGrayscale16 &&
470 image->GetFormat() == Orthanc::PixelFormat_Grayscale16)
471 {
472 image->SetFormat(Orthanc::PixelFormat_SignedGrayscale16);
473 }
474
475 if (expectedFormat_ != image->GetFormat())
476 {
477 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
478 }
456 } 479 }
457 480
458 SuccessMessage message(*this, image.release(), contentType); 481 SuccessMessage message(*this, image.release(), contentType);
459 emitter.EmitMessage(receiver, message); 482 emitter.EmitMessage(receiver, message);
460 } 483 }
513 virtual Type GetType() const 536 virtual Type GetType() const
514 { 537 {
515 return Type_GetOrthancWebViewerJpeg; 538 return Type_GetOrthancWebViewerJpeg;
516 } 539 }
517 540
518 void SetExpectedFormat(Orthanc::PixelFormat format) 541 void SetExpectedPixelFormat(Orthanc::PixelFormat format)
519 { 542 {
520 expectedFormat_ = format; 543 expectedFormat_ = format;
521 } 544 }
522 545
523 void SetInstance(const std::string& instanceId) 546 void SetInstance(const std::string& instanceId)
547 const std::string& value) 570 const std::string& value)
548 { 571 {
549 headers_[key] = value; 572 headers_[key] = value;
550 } 573 }
551 574
552 Orthanc::PixelFormat GetExpectedFormat() const 575 Orthanc::PixelFormat GetExpectedPixelFormat() const
553 { 576 {
554 return expectedFormat_; 577 return expectedFormat_;
555 } 578 }
556 579
557 const std::string& GetInstanceId() const 580 const std::string& GetInstanceId() const
1143 public Orthanc::IDynamicObject /* to be used as a payload of SlicesSorter */ 1166 public Orthanc::IDynamicObject /* to be used as a payload of SlicesSorter */
1144 { 1167 {
1145 private: 1168 private:
1146 struct Data // Struct to ease the copy constructor 1169 struct Data // Struct to ease the copy constructor
1147 { 1170 {
1171 std::string orthancInstanceId_;
1172 std::string studyInstanceUid_;
1173 std::string seriesInstanceUid_;
1174 std::string sopInstanceUid_;
1148 Orthanc::DicomImageInformation imageInformation_; 1175 Orthanc::DicomImageInformation imageInformation_;
1149 OrthancStone::SopClassUid sopClassUid_; 1176 OrthancStone::SopClassUid sopClassUid_;
1150 double thickness_; 1177 double thickness_;
1151 double pixelSpacingX_; 1178 double pixelSpacingX_;
1152 double pixelSpacingY_; 1179 double pixelSpacingY_;
1204 { 1231 {
1205 if (imageInformation_.GetNumberOfFrames() <= 0) 1232 if (imageInformation_.GetNumberOfFrames() <= 0)
1206 { 1233 {
1207 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 1234 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
1208 } 1235 }
1209 1236
1237 if (!dicom.CopyToString(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) ||
1238 !dicom.CopyToString(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) ||
1239 !dicom.CopyToString(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
1240 {
1241 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
1242 }
1243
1210 std::string s; 1244 std::string s;
1211 if (!dicom.CopyToString(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false)) 1245 if (!dicom.CopyToString(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false))
1212 { 1246 {
1213 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 1247 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
1214 } 1248 }
1360 DicomInstanceParameters(const DicomInstanceParameters& other) : 1394 DicomInstanceParameters(const DicomInstanceParameters& other) :
1361 data_(other.data_) 1395 data_(other.data_)
1362 { 1396 {
1363 } 1397 }
1364 1398
1365
1366 DicomInstanceParameters(const Orthanc::DicomMap& dicom) : 1399 DicomInstanceParameters(const Orthanc::DicomMap& dicom) :
1367 data_(dicom) 1400 data_(dicom)
1368 { 1401 {
1369 } 1402 }
1370 1403
1404 void SetOrthancInstanceIdentifier(const std::string& id)
1405 {
1406 data_.orthancInstanceId_ = id;
1407 }
1408
1409 const std::string& GetOrthancInstanceIdentifier() const
1410 {
1411 return data_.orthancInstanceId_;
1412 }
1413
1371 const Orthanc::DicomImageInformation& GetImageInformation() const 1414 const Orthanc::DicomImageInformation& GetImageInformation() const
1372 { 1415 {
1373 return data_.imageInformation_; 1416 return data_.imageInformation_;
1417 }
1418
1419 const std::string& GetStudyInstanceUid() const
1420 {
1421 return data_.studyInstanceUid_;
1422 }
1423
1424 const std::string& GetSeriesInstanceUid() const
1425 {
1426 return data_.seriesInstanceUid_;
1427 }
1428
1429 const std::string& GetSopInstanceUid() const
1430 {
1431 return data_.sopInstanceUid_;
1374 } 1432 }
1375 1433
1376 OrthancStone::SopClassUid GetSopClassUid() const 1434 OrthancStone::SopClassUid GetSopClassUid() const
1377 { 1435 {
1378 return data_.sopClassUid_; 1436 return data_.sopClassUid_;
1658 { 1716 {
1659 assert(slices_.size() == image_->GetDepth()); 1717 assert(slices_.size() == image_->GetDepth());
1660 return *slices_[index]; 1718 return *slices_[index];
1661 } 1719 }
1662 } 1720 }
1721
1722 void SetSliceContent(size_t index,
1723 const Orthanc::ImageAccessor& image)
1724 {
1725 if (!IsGeometryReady())
1726 {
1727 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
1728 }
1729 else if (index >= slices_.size())
1730 {
1731 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
1732 }
1733 else
1734 {
1735 OrthancStone::ImageBuffer3D::SliceWriter writer
1736 (*image_, OrthancStone::VolumeProjection_Axial, index);
1737 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image);
1738 }
1739 }
1663 }; 1740 };
1664 1741
1665 1742
1666 1743
1667 class AxialVolumeOrthancLoader : public OrthancStone::IObserver 1744 class AxialVolumeOrthancLoader : public OrthancStone::IObserver
1668 { 1745 {
1669 private: 1746 private:
1670 class MessageHandler : public Orthanc::IDynamicObject 1747 class MessageHandler : public Orthanc::IDynamicObject
1671 { 1748 {
1672 public: 1749 public:
1673 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const = 0; 1750 virtual void Handle(const Json::Value& body) const
1751 {
1752 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
1753 }
1754
1755 virtual void Handle(const Orthanc::ImageAccessor& image) const
1756 {
1757 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
1758 }
1674 }; 1759 };
1675 1760
1676 void Handle(const OrthancRestApiCommand::SuccessMessage& message) 1761 void Handle(const OrthancRestApiCommand::SuccessMessage& message)
1677 { 1762 {
1678 dynamic_cast<const MessageHandler&>(message.GetOrigin().GetPayload()).Handle(message); 1763 Json::Value body;
1679 } 1764 message.ParseJsonBody(body);
1765
1766 if (body.type() != Json::objectValue)
1767 {
1768 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
1769 }
1770
1771 dynamic_cast<const MessageHandler&>(message.GetOrigin().GetPayload()).Handle(body);
1772 }
1773
1774 void Handle(const Refactoring::GetOrthancImageCommand::SuccessMessage& message)
1775 {
1776 dynamic_cast<const MessageHandler&>(message.GetOrigin().GetPayload()).Handle(message.GetImage());
1777 }
1778
1779 void Handle(const Refactoring::GetOrthancWebViewerJpegCommand::SuccessMessage& message)
1780 {
1781 dynamic_cast<const MessageHandler&>(message.GetOrigin().GetPayload()).Handle(message.GetImage());
1782 }
1783
1784
1785 class LoadSliceImage : public MessageHandler
1786 {
1787 private:
1788 DicomVolumeImage& target_;
1789 size_t slice_;
1790
1791 public:
1792 LoadSliceImage(DicomVolumeImage& target,
1793 size_t slice) :
1794 target_(target),
1795 slice_(slice)
1796 {
1797 }
1798
1799 virtual void Handle(const Orthanc::ImageAccessor& image) const
1800 {
1801 target_.SetSliceContent(slice_, image);
1802 }
1803 };
1680 1804
1681 1805
1682 class LoadSeriesGeometryHandler : public MessageHandler 1806 class LoadSeriesGeometryHandler : public MessageHandler
1683 { 1807 {
1684 private: 1808 private:
1688 LoadSeriesGeometryHandler(AxialVolumeOrthancLoader& that) : 1812 LoadSeriesGeometryHandler(AxialVolumeOrthancLoader& that) :
1689 that_(that) 1813 that_(that)
1690 { 1814 {
1691 } 1815 }
1692 1816
1693 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const 1817 virtual void Handle(const Json::Value& body) const
1694 { 1818 {
1695 Json::Value value; 1819 Json::Value::Members instances = body.getMemberNames();
1696 message.ParseJsonBody(value);
1697
1698 if (value.type() != Json::objectValue)
1699 {
1700 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
1701 }
1702
1703 Json::Value::Members instances = value.getMemberNames();
1704 1820
1705 OrthancStone::SlicesSorter slices; 1821 OrthancStone::SlicesSorter slices;
1706 1822
1707 for (size_t i = 0; i < instances.size(); i++) 1823 for (size_t i = 0; i < instances.size(); i++)
1708 { 1824 {
1709 Orthanc::DicomMap dicom; 1825 Orthanc::DicomMap dicom;
1710 dicom.FromDicomAsJson(value[instances[i]]); 1826 dicom.FromDicomAsJson(body[instances[i]]);
1711 1827
1712 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); 1828 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom));
1829 instance->SetOrthancInstanceIdentifier(instances[i]);
1713 1830
1714 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); 1831 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry();
1715 slices.AddSlice(geometry, instance.release()); 1832 slices.AddSlice(geometry, instance.release());
1716 } 1833 }
1717 1834
1718 that_.image_.SetGeometry(slices); 1835 that_.image_.SetGeometry(slices);
1836
1837 for (size_t i = 0; i < that_.image_.GetSlicesCount(); i++)
1838 {
1839 const DicomInstanceParameters& slice = that_.image_.GetSlice(i);
1840
1841 const std::string& instance = slice.GetOrthancInstanceIdentifier();
1842 if (instance.empty())
1843 {
1844 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
1845 }
1846
1847 #if 0
1848 std::auto_ptr<Refactoring::GetOrthancWebViewerJpegCommand> command(
1849 new Refactoring::GetOrthancWebViewerJpegCommand);
1850 command->SetInstance(instance);
1851 command->SetQuality(95);
1852 #else
1853 std::string uri = "/instances/" + instance;
1854
1855 switch (slice.GetExpectedPixelFormat())
1856 {
1857 case Orthanc::PixelFormat_RGB24:
1858 uri += "/preview";
1859 break;
1860
1861 case Orthanc::PixelFormat_Grayscale16:
1862 uri += "/image-uint16";
1863 break;
1864
1865 case Orthanc::PixelFormat_SignedGrayscale16:
1866 uri += "/image-int16";
1867 break;
1868
1869 default:
1870 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
1871 }
1872
1873 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(
1874 new Refactoring::GetOrthancImageCommand);
1875 command->SetHttpHeader("Accept-Encoding", "gzip");
1876 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam)));
1877 command->SetUri(uri);
1878 #endif
1879
1880 command->SetExpectedPixelFormat(slice.GetExpectedPixelFormat());
1881 command->SetPayload(new LoadSliceImage(that_.image_, i));
1882
1883 that_.oracle_.Schedule(that_, command.release());
1884 }
1719 } 1885 }
1720 }; 1886 };
1721 1887
1722 1888
1723 class LoadInstanceGeometryHandler : public MessageHandler 1889 class LoadInstanceGeometryHandler : public MessageHandler
1729 LoadInstanceGeometryHandler(AxialVolumeOrthancLoader& that) : 1895 LoadInstanceGeometryHandler(AxialVolumeOrthancLoader& that) :
1730 that_(that) 1896 that_(that)
1731 { 1897 {
1732 } 1898 }
1733 1899
1734 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const 1900 virtual void Handle(const Json::Value& body) const
1735 { 1901 {
1736 Json::Value value;
1737 message.ParseJsonBody(value);
1738
1739 if (value.type() != Json::objectValue)
1740 {
1741 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
1742 }
1743
1744 Orthanc::DicomMap dicom; 1902 Orthanc::DicomMap dicom;
1745 dicom.FromDicomAsJson(value); 1903 dicom.FromDicomAsJson(body);
1746 1904
1747 DicomInstanceParameters instance(dicom); 1905 DicomInstanceParameters instance(dicom);
1748 } 1906 }
1749 }; 1907 };
1750 1908
1751 1909
1910 IOracle& oracle_;
1752 bool active_; 1911 bool active_;
1753 DicomVolumeImage image_; 1912 DicomVolumeImage image_;
1754 1913
1755 public: 1914 public:
1756 AxialVolumeOrthancLoader(OrthancStone::IObservable& oracle) : 1915 AxialVolumeOrthancLoader(IOracle& oracle,
1757 IObserver(oracle.GetBroker()), 1916 OrthancStone::IObservable& oracleObservable) :
1917 IObserver(oracleObservable.GetBroker()),
1918 oracle_(oracle),
1758 active_(false) 1919 active_(false)
1759 { 1920 {
1760 oracle.RegisterObserverCallback( 1921 oracleObservable.RegisterObserverCallback(
1761 new OrthancStone::Callable<AxialVolumeOrthancLoader, OrthancRestApiCommand::SuccessMessage> 1922 new OrthancStone::Callable<AxialVolumeOrthancLoader, OrthancRestApiCommand::SuccessMessage>
1762 (*this, &AxialVolumeOrthancLoader::Handle)); 1923 (*this, &AxialVolumeOrthancLoader::Handle));
1763 } 1924
1764 1925 oracleObservable.RegisterObserverCallback(
1765 void LoadSeries(IOracle& oracle, 1926 new OrthancStone::Callable<AxialVolumeOrthancLoader, GetOrthancImageCommand::SuccessMessage>
1766 const std::string& seriesId) 1927 (*this, &AxialVolumeOrthancLoader::Handle));
1928
1929 oracleObservable.RegisterObserverCallback(
1930 new OrthancStone::Callable<AxialVolumeOrthancLoader, GetOrthancWebViewerJpegCommand::SuccessMessage>
1931 (*this, &AxialVolumeOrthancLoader::Handle));
1932 }
1933
1934 void LoadSeries(const std::string& seriesId)
1767 { 1935 {
1768 if (active_) 1936 if (active_)
1769 { 1937 {
1770 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 1938 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
1771 } 1939 }
1774 1942
1775 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); 1943 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand);
1776 command->SetUri("/series/" + seriesId + "/instances-tags"); 1944 command->SetUri("/series/" + seriesId + "/instances-tags");
1777 command->SetPayload(new LoadSeriesGeometryHandler(*this)); 1945 command->SetPayload(new LoadSeriesGeometryHandler(*this));
1778 1946
1779 oracle.Schedule(*this, command.release()); 1947 oracle_.Schedule(*this, command.release());
1780 } 1948 }
1781 1949
1782 void LoadInstance(IOracle& oracle, 1950 void LoadInstance(const std::string& instanceId)
1783 const std::string& instanceId)
1784 { 1951 {
1785 if (active_) 1952 if (active_)
1786 { 1953 {
1787 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 1954 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
1788 } 1955 }
1796 1963
1797 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); 1964 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand);
1798 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3004-000c"); 1965 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3004-000c");
1799 command->SetPayload(new LoadInstanceGeometryHandler(*this)); 1966 command->SetPayload(new LoadInstanceGeometryHandler(*this));
1800 1967
1801 oracle.Schedule(*this, command.release()); 1968 oracle_.Schedule(*this, command.release());
1802 } 1969 }
1803 }; 1970 };
1804 1971
1805 } 1972 }
1806 1973
1864 <Toto, Refactoring::OracleCommandExceptionMessage>(*this, &Toto::Handle)); 2031 <Toto, Refactoring::OracleCommandExceptionMessage>(*this, &Toto::Handle));
1865 } 2032 }
1866 }; 2033 };
1867 2034
1868 2035
1869 void Run(Refactoring::NativeApplicationContext& context) 2036 void Run(Refactoring::NativeApplicationContext& context,
2037 Refactoring::IOracle& oracle)
1870 { 2038 {
1871 std::auto_ptr<Toto> toto; 2039 std::auto_ptr<Toto> toto;
1872 std::auto_ptr<Refactoring::AxialVolumeOrthancLoader> loader1, loader2; 2040 std::auto_ptr<Refactoring::AxialVolumeOrthancLoader> loader1, loader2;
1873 2041
1874 { 2042 {
1875 Refactoring::NativeApplicationContext::WriterLock lock(context); 2043 Refactoring::NativeApplicationContext::WriterLock lock(context);
1876 toto.reset(new Toto(lock.GetOracleObservable())); 2044 toto.reset(new Toto(lock.GetOracleObservable()));
1877 loader1.reset(new Refactoring::AxialVolumeOrthancLoader(lock.GetOracleObservable())); 2045 loader1.reset(new Refactoring::AxialVolumeOrthancLoader(oracle, lock.GetOracleObservable()));
1878 loader2.reset(new Refactoring::AxialVolumeOrthancLoader(lock.GetOracleObservable())); 2046 loader2.reset(new Refactoring::AxialVolumeOrthancLoader(oracle, lock.GetOracleObservable()));
1879 } 2047 }
1880
1881 Refactoring::NativeOracle oracle(context);
1882
1883 {
1884 Orthanc::WebServiceParameters p;
1885 //p.SetUrl("http://localhost:8043/");
1886 p.SetCredentials("orthanc", "orthanc");
1887 oracle.SetOrthancParameters(p);
1888 }
1889
1890 oracle.Start();
1891 2048
1892 if (1) 2049 if (1)
1893 { 2050 {
1894 Json::Value v = Json::objectValue; 2051 Json::Value v = Json::objectValue;
1895 v["Level"] = "Series"; 2052 v["Level"] = "Series";
1953 oracle.Schedule(*toto, command.release()); 2110 oracle.Schedule(*toto, command.release());
1954 } 2111 }
1955 2112
1956 2113
1957 // 2017-11-17-Anonymized 2114 // 2017-11-17-Anonymized
1958 //loader1->LoadSeries(oracle, "cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT 2115 //loader1->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT
1959 loader2->LoadInstance(oracle, "41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE 2116 loader2->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE
1960 2117
1961 // Delphine 2118 // Delphine
1962 loader1->LoadSeries(oracle, "5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT 2119 loader1->LoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT
1963 2120
1964 LOG(WARNING) << "...Waiting for Ctrl-C..."; 2121 LOG(WARNING) << "...Waiting for Ctrl-C...";
1965 Orthanc::SystemToolbox::ServerBarrier(); 2122 Orthanc::SystemToolbox::ServerBarrier();
1966 //boost::this_thread::sleep(boost::posix_time::seconds(1)); 2123 //boost::this_thread::sleep(boost::posix_time::seconds(1));
1967
1968 oracle.Stop();
1969 } 2124 }
1970 2125
1971 2126
1972 2127
1973 /** 2128 /**
1981 Orthanc::Logging::EnableInfoLevel(true); 2136 Orthanc::Logging::EnableInfoLevel(true);
1982 2137
1983 try 2138 try
1984 { 2139 {
1985 Refactoring::NativeApplicationContext context; 2140 Refactoring::NativeApplicationContext context;
1986 Run(context); 2141
2142 Refactoring::NativeOracle oracle(context);
2143
2144 {
2145 Orthanc::WebServiceParameters p;
2146 //p.SetUrl("http://localhost:8043/");
2147 p.SetCredentials("orthanc", "orthanc");
2148 oracle.SetOrthancParameters(p);
2149 }
2150
2151 oracle.Start();
2152
2153 Run(context, oracle);
2154
2155 oracle.Stop();
1987 } 2156 }
1988 catch (Orthanc::OrthancException& e) 2157 catch (Orthanc::OrthancException& e)
1989 { 2158 {
1990 LOG(ERROR) << "EXCEPTION: " << e.What(); 2159 LOG(ERROR) << "EXCEPTION: " << e.What();
1991 } 2160 }