void ServerScheduler::GetListOfJobs(ListOfStrings& jobs) { boost::mutex::scoped_lock lock(mutex_); jobs.clear(); for (Jobs::const_iterator it = jobs_.begin(); it != jobs_.end(); ++it) { jobs.push_back(it->first); } }
bool StorePeerCommand::Apply(ListOfStrings& outputs, const ListOfStrings& inputs) { // Configure the HTTP client HttpClient client; client.SetProxy(Configuration::GetGlobalStringParameter("HttpProxy", "")); if (peer_.GetUsername().size() != 0 && peer_.GetPassword().size() != 0) { client.SetCredentials(peer_.GetUsername().c_str(), peer_.GetPassword().c_str()); } client.SetUrl(peer_.GetUrl() + "instances"); client.SetMethod(HttpMethod_Post); for (ListOfStrings::const_iterator it = inputs.begin(); it != inputs.end(); ++it) { LOG(INFO) << "Sending resource " << *it << " to peer \"" << peer_.GetUrl() << "\""; try { context_.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); std::string answer; if (!client.Apply(answer)) { LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << peer_.GetUrl() << "\""; throw OrthancException(ErrorCode_NetworkProtocol); } // Only chain with other commands if this command succeeds outputs.push_back(*it); } catch (OrthancException& e) { LOG(ERROR) << "Unable to forward to an Orthanc peer in a Lua script (instance " << *it << ", peer " << peer_.GetUrl() << "): " << e.What(); if (!ignoreExceptions_) { throw; } } } return true; }
bool StoreScuCommand::Apply(ListOfStrings& outputs, const ListOfStrings& inputs) { ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), localAet_, modality_); for (ListOfStrings::const_iterator it = inputs.begin(); it != inputs.end(); ++it) { LOG(INFO) << "Sending resource " << *it << " to modality \"" << modality_.GetApplicationEntityTitle() << "\""; try { std::string dicom; context_.ReadFile(dicom, *it, FileContentType_Dicom); locker.GetConnection().Store(dicom, moveOriginatorID_); // Only chain with other commands if this command succeeds outputs.push_back(*it); } catch (OrthancException& e) { // Ignore transmission errors (e.g. if the remote modality is // powered off) LOG(ERROR) << "Unable to forward to a modality in a Lua script (instance " << *it << "): " << e.What(); if (!ignoreExceptions_) { throw; } } } return true; }