feat: Add CEcho & GetPACSSetting method to ReconClient
This commit is contained in:
@@ -24,6 +24,7 @@ struct PACSSetting
|
|||||||
std::string ServerAETitle;
|
std::string ServerAETitle;
|
||||||
std::string ServerIP;
|
std::string ServerIP;
|
||||||
int Port = 0;
|
int Port = 0;
|
||||||
|
bool StorageCommitment = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MPPSSetting
|
struct MPPSSetting
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace
|
|||||||
const char *QUERY_TRANSFER_URL = "/Transfer/Query/";
|
const char *QUERY_TRANSFER_URL = "/Transfer/Query/";
|
||||||
const char *SET_PACS_URL = "/Transfer/Setting/";
|
const char *SET_PACS_URL = "/Transfer/Setting/";
|
||||||
const char *SET_MPPS_URL = "/Transfer/MSetting/";
|
const char *SET_MPPS_URL = "/Transfer/MSetting/";
|
||||||
|
const char *GET_PACS_URL = "/Transfer/Setting/";
|
||||||
|
const char *ECHO_URL = "/Transfer/Echo/";
|
||||||
}
|
}
|
||||||
|
|
||||||
ReconClient::ReconClient(std::string aCerPath, std::string aKeyPath)
|
ReconClient::ReconClient(std::string aCerPath, std::string aKeyPath)
|
||||||
@@ -93,6 +94,34 @@ RequestResult ReconClient::Create(const Scan &aScan)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RequestResult ReconClient::Echo(const std::string& aIP, int aPort, const std::string& aAETitle)
|
||||||
|
{
|
||||||
|
cJSON *obj = cJSON_CreateObject();
|
||||||
|
cJSON_AddStringToObject(obj, "IP", aIP.data());
|
||||||
|
cJSON_AddStringToObject(obj, "AETitle", aAETitle.data());
|
||||||
|
cJSON_AddNumberToObject(obj, "Port", aPort);
|
||||||
|
char *str = cJSON_Print(obj);
|
||||||
|
cJSON_Delete(obj);
|
||||||
|
std::string content;
|
||||||
|
content.append(str);
|
||||||
|
free(str);
|
||||||
|
auto resp = mRequest.post(mHost + ECHO_URL, content, mHeaders);
|
||||||
|
if (resp.isResponsed() == false){
|
||||||
|
mErrorMessage = resp.getContent();
|
||||||
|
return RequestResult::ConnectFail(mErrorMessage);
|
||||||
|
}
|
||||||
|
if (resp.httpCode() == 200)
|
||||||
|
{
|
||||||
|
|
||||||
|
return RequestResult::Success();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mErrorMessage = resp.getContent();
|
||||||
|
return RequestResult::Fail(mErrorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RequestResult ReconClient::QueryScan(const std::string &aScanID, int &state)
|
RequestResult ReconClient::QueryScan(const std::string &aScanID, int &state)
|
||||||
{
|
{
|
||||||
cJSON *obj = cJSON_CreateObject();
|
cJSON *obj = cJSON_CreateObject();
|
||||||
@@ -122,6 +151,7 @@ RequestResult ReconClient::QueryScan(const std::string &aScanID, int &state)
|
|||||||
return RequestResult::Success();
|
return RequestResult::Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (scans)cJSON_Delete(scans);
|
||||||
mErrorMessage = "get null from server";
|
mErrorMessage = "get null from server";
|
||||||
return RequestResult::Fail(mErrorMessage);
|
return RequestResult::Fail(mErrorMessage);
|
||||||
}
|
}
|
||||||
@@ -193,6 +223,67 @@ RequestResult ReconClient::SetPACSSetting(const PACSSetting &aSetting)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RequestResult ReconClient::GetPACSSetting(std::vector<PACSSetting> &aSettings)
|
||||||
|
{
|
||||||
|
std::string content;
|
||||||
|
content.append("1");
|
||||||
|
auto resp = mRequest.post(mHost + GET_PACS_URL, content, mHeaders);
|
||||||
|
if (resp.isResponsed() == false){
|
||||||
|
mErrorMessage = resp.getContent();
|
||||||
|
return RequestResult::ConnectFail(mErrorMessage);
|
||||||
|
}
|
||||||
|
if (resp.httpCode() == 200)
|
||||||
|
{
|
||||||
|
cJSON *setting = cJSON_Parse(resp.getContent().data());
|
||||||
|
cJSON* storagePoints = cJSON_GetObjectItem(setting,"StoragePoints");
|
||||||
|
if (storagePoints == NULL ){
|
||||||
|
mErrorMessage = "Can't get storagePoints from server";
|
||||||
|
cJSON_Delete(setting);
|
||||||
|
return RequestResult::Fail(mErrorMessage);
|
||||||
|
}
|
||||||
|
int storagePointsCount = cJSON_GetArraySize(storagePoints);
|
||||||
|
if (storagePointsCount == 0){
|
||||||
|
mErrorMessage = "Get null storagePoints from server";
|
||||||
|
cJSON_Delete(setting);
|
||||||
|
return RequestResult::Fail(mErrorMessage);
|
||||||
|
}
|
||||||
|
cJSON* AETitleObj = cJSON_GetObjectItem(setting,"AETitle");
|
||||||
|
if (AETitleObj == NULL)
|
||||||
|
{
|
||||||
|
mErrorMessage = "Can't get AETitle from server";
|
||||||
|
cJSON_Delete(setting);
|
||||||
|
return RequestResult::Fail(mErrorMessage);
|
||||||
|
}
|
||||||
|
std::string aetitle = AETitleObj->valuestring;
|
||||||
|
for (size_t i = 0; i < storagePointsCount; i++)
|
||||||
|
{
|
||||||
|
cJSON* storagePoint = cJSON_GetArrayItem(storagePoints,i);
|
||||||
|
if (storagePoint == NULL) continue;
|
||||||
|
cJSON* ServerAETitle = cJSON_GetObjectItem(storagePoint,"ServerAETitle");
|
||||||
|
if (ServerAETitle == NULL) continue;
|
||||||
|
cJSON* ServerIP = cJSON_GetObjectItem(storagePoint,"ServerIP");
|
||||||
|
if (ServerIP == NULL) continue;
|
||||||
|
cJSON* Port = cJSON_GetObjectItem(storagePoint,"Port");
|
||||||
|
if (Port == NULL) continue;
|
||||||
|
cJSON* StorageCommitment = cJSON_GetObjectItem(storagePoint,"StorageCommitment");
|
||||||
|
if (StorageCommitment == NULL) continue;
|
||||||
|
PACSSetting readedSetting;
|
||||||
|
readedSetting.AETitle = aetitle;
|
||||||
|
readedSetting.ServerAETitle = ServerAETitle->valuestring;
|
||||||
|
readedSetting.ServerIP = ServerIP->valuestring;
|
||||||
|
readedSetting.Port = Port->valueint;
|
||||||
|
readedSetting.StorageCommitment = StorageCommitment->valueint == 1;
|
||||||
|
aSettings.push_back(readedSetting);
|
||||||
|
}
|
||||||
|
return RequestResult::Success();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mErrorMessage = resp.getContent();
|
||||||
|
return RequestResult::Fail(mErrorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RequestResult ReconClient::SetMPPSSetting(const MPPSSetting &aSetting)
|
RequestResult ReconClient::SetMPPSSetting(const MPPSSetting &aSetting)
|
||||||
{
|
{
|
||||||
cJSON *obj = cJSON_CreateObject();
|
cJSON *obj = cJSON_CreateObject();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "RequestResult.h"
|
#include "RequestResult.h"
|
||||||
#include "ProtocolStructs.h"
|
#include "ProtocolStructs.h"
|
||||||
|
#include <vector>
|
||||||
class ReconClient
|
class ReconClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -12,9 +13,12 @@ public:
|
|||||||
void SetHost(const std::string &aHost);
|
void SetHost(const std::string &aHost);
|
||||||
RequestResult CheckActive();
|
RequestResult CheckActive();
|
||||||
RequestResult Create(const Scan &aScan);
|
RequestResult Create(const Scan &aScan);
|
||||||
|
RequestResult Echo(const std::string& aIP, int aPort, const std::string& aAETitle);
|
||||||
RequestResult QueryScan(const std::string &aScanID, int &state);
|
RequestResult QueryScan(const std::string &aScanID, int &state);
|
||||||
RequestResult QueryVersion();
|
RequestResult QueryVersion();
|
||||||
RequestResult SetPACSSetting(const PACSSetting &aSetting);
|
RequestResult SetPACSSetting(const PACSSetting &aSetting);
|
||||||
|
RequestResult GetPACSSetting(std::vector<PACSSetting> &aSetting);
|
||||||
|
|
||||||
RequestResult SetMPPSSetting(const MPPSSetting &aSetting);
|
RequestResult SetMPPSSetting(const MPPSSetting &aSetting);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user