# HG changeset patch # User Sebastien Jodogne # Date 1579625323 -3600 # Node ID 4543ffad256da0ef8ae9687827158f8717f25cd6 # Parent c1e2b91c2ab4f9076f3d23ca8f457d8294e09b6d storage commitment requests/responses to/from self are working diff -r c1e2b91c2ab4 -r 4543ffad256d Core/DicomNetworking/Internals/CommandDispatcher.cpp --- a/Core/DicomNetworking/Internals/CommandDispatcher.cpp Tue Jan 21 17:01:46 2020 +0100 +++ b/Core/DicomNetworking/Internals/CommandDispatcher.cpp Tue Jan 21 17:48:43 2020 +0100 @@ -918,16 +918,27 @@ static void ReadSopSequence(std::vector& sopClassUids, std::vector& sopInstanceUids, DcmDataset& dataset, - const DcmTagKey& tag) + const DcmTagKey& tag, + bool mandatory) { + sopClassUids.clear(); + sopInstanceUids.clear(); + DcmSequenceOfItems* sequence = NULL; if (!dataset.findAndGetSequence(tag, sequence).good() || sequence == NULL) { - char buf[64]; - sprintf(buf, "Missing mandatory sequence in dataset: (%04X,%04X)", - tag.getGroup(), tag.getElement()); - throw OrthancException(ErrorCode_NetworkProtocol, buf); + if (mandatory) + { + char buf[64]; + sprintf(buf, "Missing mandatory sequence in dataset: (%04X,%04X)", + tag.getGroup(), tag.getElement()); + throw OrthancException(ErrorCode_NetworkProtocol, buf); + } + else + { + return; + } } sopClassUids.reserve(sequence->card()); @@ -1011,7 +1022,7 @@ std::vector sopClassUid, sopInstanceUid; ReadSopSequence(sopClassUid, sopInstanceUid, - *dataset, DCM_ReferencedSOPSequence); + *dataset, DCM_ReferencedSOPSequence, true /* mandatory */); LOG(INFO) << "Incoming storage commitment request, with transaction UID: " << transactionUid; @@ -1134,11 +1145,16 @@ std::vector successSopClassUid, successSopInstanceUid; ReadSopSequence(successSopClassUid, successSopInstanceUid, - *dataset, DCM_ReferencedSOPSequence); + *dataset, DCM_ReferencedSOPSequence, + (report.EventTypeID == 1) /* mandatory in the case of success */); std::vector failedSopClassUid, failedSopInstanceUid; - ReadSopSequence(failedSopClassUid, failedSopInstanceUid, - *dataset, DCM_FailedSOPSequence); + + if (report.EventTypeID == 2 /* failures exist */) + { + ReadSopSequence(failedSopClassUid, failedSopInstanceUid, + *dataset, DCM_FailedSOPSequence, true); + } LOG(INFO) << "Incoming storage commitment report, with transaction UID: " << transactionUid; diff -r c1e2b91c2ab4 -r 4543ffad256d OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Jan 21 17:01:46 2020 +0100 +++ b/OrthancServer/main.cpp Tue Jan 21 17:48:43 2020 +0100 @@ -99,21 +99,29 @@ // TODO - Remove this static void Toto(std::string* t) { - std::auto_ptr tt(t); + try + { + std::auto_ptr tt(t); - printf("Sleeping\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - printf("Connect back\n"); + printf("Sleeping\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + printf("Connect back\n"); - RemoteModalityParameters p("STGCMTSCU", "localhost", 11114, ModalityManufacturer_Generic); - DicomUserConnection scu("ORTHANC", p); + //RemoteModalityParameters p("STGCMTSCU", "localhost", 11114, ModalityManufacturer_Generic); + RemoteModalityParameters p("ORTHANC", "localhost", 4242, ModalityManufacturer_Generic); + DicomUserConnection scu("ORTHANC", p); - std::vector a, b, c, d; - a.push_back("a"); b.push_back("b"); - a.push_back("c"); b.push_back("d"); + std::vector a, b, c, d; + a.push_back("a"); b.push_back("b"); + a.push_back("c"); b.push_back("d"); - scu.ReportStorageCommitment(tt->c_str(), a, b, c, d); - //scu.ReportStorageCommitment("transaction", a, b, a, b); + //scu.ReportStorageCommitment(tt->c_str(), a, b, c, d); + scu.ReportStorageCommitment(tt->c_str(), a, b, a, b); + } + catch (OrthancException& e) + { + LOG(ERROR) << "EXCEPTION: " << e.What(); + } /** * "After the N-EVENT-REPORT has been sent, the Transaction UID is