Delete try catch from ReconClient.
This commit is contained in:
@@ -17,4 +17,12 @@ struct TaskQueryResult
|
||||
bool Start ;
|
||||
};
|
||||
|
||||
struct PACSSetting
|
||||
{
|
||||
std::string AETitle;
|
||||
std::string ServerAETitle;
|
||||
std::string ServerIP;
|
||||
int Port = 0;;
|
||||
};
|
||||
|
||||
#endif // __SCAN_H__
|
||||
@@ -10,6 +10,7 @@ namespace {
|
||||
const char* QUERY_VERSION_URL = "/Version/";
|
||||
const char* QUERY_RECON_URL = "/Task/Query/";
|
||||
const char* QUERY_TRANSFER_URL = "/Transfer/Query/";
|
||||
const char* SET_PACS_URL = "/Transfer/Setting/";
|
||||
}
|
||||
namespace Recon {
|
||||
|
||||
@@ -46,11 +47,13 @@ namespace Recon {
|
||||
content.append(str);
|
||||
free(str);
|
||||
auto resp = mRequest.post(mHost+CREATE_URL,content,mHeaders);
|
||||
if (resp.httpCode() == 201){
|
||||
if (resp->httpCode() == 201){
|
||||
delete resp;
|
||||
return RequestResult::Success();
|
||||
}
|
||||
else{
|
||||
mErrorMessage = resp.getContent();
|
||||
mErrorMessage = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
}
|
||||
}
|
||||
@@ -65,8 +68,9 @@ namespace Recon {
|
||||
content.append(str);
|
||||
free(str);
|
||||
auto resp = mRequest.post(mHost+QUERY_SCAN_URL,content,mHeaders);
|
||||
if (resp.httpCode() == 200){
|
||||
cJSON * scans = cJSON_Parse(resp.getContent().data());
|
||||
if (resp->httpCode() == 200){
|
||||
cJSON * scans = cJSON_Parse(resp->getContent().data());
|
||||
delete resp;
|
||||
int size = cJSON_GetArraySize(scans);
|
||||
if (size == 1){
|
||||
cJSON * scaninf = cJSON_GetArrayItem(scans, 0);
|
||||
@@ -81,7 +85,8 @@ namespace Recon {
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
}
|
||||
else{
|
||||
mErrorMessage = resp.getContent();
|
||||
mErrorMessage = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
}
|
||||
}
|
||||
@@ -96,16 +101,18 @@ namespace Recon {
|
||||
content.append(str);
|
||||
free(str);
|
||||
auto resp = mRequest.post(mHost+QUERY_RECON_URL,content,mHeaders);
|
||||
if (resp.httpCode() == 204){
|
||||
if (resp->httpCode() == 204){
|
||||
delete resp;
|
||||
return RequestResult::Success();
|
||||
}
|
||||
else if (resp.httpCode() == 200){
|
||||
|
||||
aReconID = resp.getContent();
|
||||
else if (resp->httpCode() == 200){
|
||||
aReconID = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Success(aReconID);
|
||||
}
|
||||
else{
|
||||
mErrorMessage = resp.getContent();
|
||||
mErrorMessage = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
|
||||
}
|
||||
@@ -121,8 +128,9 @@ namespace Recon {
|
||||
content.append(str);
|
||||
free(str);
|
||||
auto resp = mRequest.post(mHost+QUERY_RECON_URL,content,mHeaders);
|
||||
if (resp.httpCode() == 200){
|
||||
cJSON * task = cJSON_Parse(resp.getContent().data());
|
||||
if (resp->httpCode() == 200){
|
||||
cJSON * task = cJSON_Parse(resp->getContent().data());
|
||||
delete resp;
|
||||
aTask.ReconID = cJSON_GetObjectItem(task, "ReconID")->valuestring;
|
||||
aTask.ScanID= cJSON_GetObjectItem(task, "ScanID")->valuestring;
|
||||
aTask.Start = cJSON_GetObjectItem(task, "Start")->valueint!=0;
|
||||
@@ -131,7 +139,40 @@ namespace Recon {
|
||||
return RequestResult::Success();
|
||||
}
|
||||
else{
|
||||
mErrorMessage = resp.getContent();
|
||||
mErrorMessage = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
RequestResult ReconClient::SetPACSSetting(const PACSSetting& aSetting)
|
||||
{
|
||||
cJSON * obj = cJSON_CreateObject();
|
||||
if (!aSetting.AETitle.empty()){
|
||||
cJSON_AddStringToObject(obj, "AETitle", aSetting.AETitle.c_str());
|
||||
}
|
||||
if (!aSetting.ServerIP.empty()){
|
||||
cJSON_AddStringToObject(obj, "IP", aSetting.ServerIP.c_str());
|
||||
}
|
||||
if (!aSetting.ServerAETitle.empty()){
|
||||
cJSON_AddStringToObject(obj, "ServerAETitle", aSetting.ServerAETitle.c_str());
|
||||
}
|
||||
if (aSetting.Port>0){
|
||||
cJSON_AddNumberToObject(obj, "Port", aSetting.Port);
|
||||
}
|
||||
char* str = cJSON_Print(obj);
|
||||
cJSON_Delete(obj);
|
||||
std::string content;
|
||||
content.append(str);
|
||||
free(str);
|
||||
auto resp = mRequest.post(mHost+SET_PACS_URL,content,mHeaders);
|
||||
if (resp->httpCode() == 200){
|
||||
delete resp;
|
||||
return RequestResult::Success();
|
||||
}
|
||||
else{
|
||||
mErrorMessage = resp->getContent();
|
||||
delete resp;
|
||||
return RequestResult::Fail(mErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Recon {
|
||||
RequestResult QueryReconID(const std::string& aScanID, std::string& aReconID);
|
||||
RequestResult QueryReconTask(const std::string& aReconID, TaskQueryResult& aTask);
|
||||
RequestResult QueryVersion();
|
||||
RequestResult SetPACSSetting(const PACSSetting& aSetting);
|
||||
|
||||
private:
|
||||
std::string mVersionContent;
|
||||
|
||||
5
thirdParty/Req/pub/include/Request.h
vendored
5
thirdParty/Req/pub/include/Request.h
vendored
@@ -15,9 +15,10 @@ namespace Req {
|
||||
Request &operator=(Request &&) = delete;
|
||||
Request &operator=(const Request &) = delete;
|
||||
~Request();
|
||||
bool isValid();
|
||||
void setClientCertificate(const std::string &cerPath, const std::string &keyPath);
|
||||
void setVerbose(bool verbose);
|
||||
Response post(const std::string& url, const std::string &body = std::string(),
|
||||
Response* post(const std::string& url, const std::string &body = std::string(),
|
||||
const std::unordered_map<std::string, std::string>& headers =
|
||||
std::unordered_map<std::string, std::string>());
|
||||
|
||||
@@ -27,6 +28,8 @@ namespace Req {
|
||||
std::string mCert;
|
||||
std::string mKey;
|
||||
bool mVerbose;
|
||||
bool mValid;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // __REQUEST_H__
|
||||
3
thirdParty/Req/pub/include/Response.h
vendored
3
thirdParty/Req/pub/include/Response.h
vendored
@@ -7,6 +7,7 @@ namespace Req {
|
||||
{
|
||||
public:
|
||||
Response();
|
||||
static Response* ErrorResponse(const std::string & content);
|
||||
Response(Response &&) = default;
|
||||
Response(const Response &) = default;
|
||||
Response &operator=(Response &&) = delete;
|
||||
@@ -15,9 +16,11 @@ namespace Req {
|
||||
long httpCode();
|
||||
void setHttpCode(long code);
|
||||
std::string& getContent();
|
||||
bool isResponsed();
|
||||
private:
|
||||
long mHttpCode = 404;
|
||||
std::string mContent;
|
||||
bool mResponsed;
|
||||
};
|
||||
};
|
||||
#endif // __RESPONSE_H__
|
||||
BIN
thirdParty/Req/pub/lib/libReq.so
vendored
BIN
thirdParty/Req/pub/lib/libReq.so
vendored
Binary file not shown.
Reference in New Issue
Block a user