code_production/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp

45 lines
1.6 KiB
C++

#include "base/HGDef.h"
#include "base/HGInc.h"
#include "../HGPdtToolDb/HGPdtToolDb.h"
#include <string>
static std::string AnsiToUtf8(const char* text)
{
int wlen = ::MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
WCHAR* pUnicode = new WCHAR[wlen];
::MultiByteToWideChar(CP_ACP, 0, text, -1, pUnicode, wlen);
int len = ::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, NULL, 0, NULL, NULL);
CHAR* pUTF8 = new CHAR[len];
::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, pUTF8, len, NULL, NULL);
delete[] pUnicode;
std::string ret = pUTF8;
delete[] pUTF8;
return ret;
}
int main()
{
HGPdtToolDbUserMgr userMgr = NULL;
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "root", "123456", &userMgr);
if (NULL != userMgr)
{
//HGPdtToolDb_UploadFile(userMgr, "G100", "D:\\config.json");
//HGPdtToolDb_DownloadFile(userMgr, "G100", "D:\\123.txt");
std::string str = AnsiToUtf8("图像质量");
HGPdtToolDb_SetEntryNameCnStr(userMgr, "image_quality", str.c_str());
HGPdtToolDbDevice device = NULL;
HGPdtToolDb_OpenDevice(userMgr, "G654321", &device);
HGPdtToolDb_SetDeviceEntryStatus(device, "image_quality", 1);
HGPdtToolDb_UploadDeviceEntryImage(device, "image_quality", "192.168.1.70", 21, "D:\\1.jpg");
HGPdtToolDb_DownloadDeviceEntryImage(device, "image_quality", "192.168.1.70", 21, 0, "D:\\22.jpg");
//HGPdtToolDb_CloseDevice(device);
HGPdtToolDb_Export(userMgr, "D:\\1.xls");
HGPdtToolDb_DestroyUserMgr(userMgr);
}
return 0;
}