This commit is contained in:
13038267101 2022-12-15 19:53:51 +08:00
commit b11649ea9e
19 changed files with 544 additions and 145 deletions

View File

@ -25,6 +25,7 @@ win32 {
contains(QT_ARCH, i386) {
LIBS += -L../../../sdk/lib/win/x86/Release -lHGBase -lHGImgFmt -lHGImgProc
LIBS += -L../../../sdk/lib/win/x86/OEM/huagao -lsane
LIBS += -L../../code/base/Debug/ -ltest
CONFIG(release, debug|release) {
LIBS += -L../../db/Release -lHGPdtToolDb
DESTDIR = ../../../release/win/x86/Release
@ -36,7 +37,6 @@ win32 {
contains(QT_ARCH, x86_64){
LIBS += -L../../../sdk/lib/win/x64/Release -lHGBase -lHGImgFmt -lHGImgProc
LIBS += -L../../../sdk/lib/win/x64/OEM/huagao -lsane
CONFIG(release, debug|release) {
LIBS += -L../../db/x64/Release -lHGPdtToolDb
DESTDIR = ../../../release/win/x64/Release
@ -62,8 +62,10 @@ SOURCES += \
dialog_uploadcfgfile.cpp \
form_maininterface.cpp \
form_texttips.cpp \
hgscanner.cpp \
main.cpp \
mainwindow.cpp
mainwindow.cpp \
ui_helper.cpp
HEADERS += \
HGImgView.h \
@ -76,7 +78,9 @@ HEADERS += \
dialog_uploadcfgfile.h \
form_maininterface.h \
form_texttips.h \
mainwindow.h
hgscanner.h \
mainwindow.h \
ui_helper.h
FORMS += \
dialog_accountmanage.ui \

View File

@ -189,12 +189,12 @@
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="85"/>
<location filename="dialog_login.cpp" line="80"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="85"/>
<location filename="dialog_login.cpp" line="80"/>
<source>Login failed: </source>
<translation> </translation>
</message>
@ -257,7 +257,7 @@
<message>
<location filename="dialog_uploadcfgfile.ui" line="32"/>
<source>select file</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="43"/>
@ -270,34 +270,34 @@
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="24"/>
<location filename="dialog_uploadcfgfile.cpp" line="25"/>
<source>Browse directory</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="24"/>
<location filename="dialog_uploadcfgfile.cpp" line="25"/>
<source>config(*json)</source>
<translation>(*json)</translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="36"/>
<location filename="dialog_uploadcfgfile.cpp" line="45"/>
<location filename="dialog_uploadcfgfile.cpp" line="49"/>
<location filename="dialog_uploadcfgfile.cpp" line="37"/>
<location filename="dialog_uploadcfgfile.cpp" line="46"/>
<location filename="dialog_uploadcfgfile.cpp" line="51"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="36"/>
<location filename="dialog_uploadcfgfile.cpp" line="37"/>
<source>empty filename</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="45"/>
<location filename="dialog_uploadcfgfile.cpp" line="46"/>
<source>upload succeed</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.cpp" line="49"/>
<location filename="dialog_uploadcfgfile.cpp" line="51"/>
<source>upload failed: </source>
<translation> </translation>
</message>
@ -340,12 +340,12 @@
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="60"/>
<location filename="form_maininterface.cpp" line="77"/>
<source>HGPDTTOOLDB_TITLE_DIAL_SWITCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="65"/>
<location filename="form_maininterface.cpp" line="82"/>
<source>HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE</source>
<translation type="unfinished"></translation>
</message>
@ -411,37 +411,53 @@
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="88"/>
<location filename="mainwindow.cpp" line="157"/>
<source>Account login elsewhere</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="160"/>
<source>Network connection lost</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="163"/>
<source>You have been forced offline by the administrator account</source>
<translation>线</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="169"/>
<location filename="mainwindow.cpp" line="204"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="88"/>
<location filename="mainwindow.cpp" line="204"/>
<source>cannot create more table</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="135"/>
<location filename="mainwindow.cpp" line="250"/>
<source>Illegal user</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="139"/>
<location filename="mainwindow.cpp" line="254"/>
<source>Wrong password</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="143"/>
<location filename="mainwindow.cpp" line="258"/>
<source>Database error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="147"/>
<location filename="mainwindow.cpp" line="262"/>
<source>connect error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="151"/>
<location filename="mainwindow.cpp" line="266"/>
<source>Failed</source>
<translation></translation>
</message>

View File

@ -4,6 +4,7 @@
#include <QJsonArray>
#include <QDir>
#include <QFileInfo>
#include <QDebug>
AnalysisJson::AnalysisJson(QString path)
{
@ -23,7 +24,13 @@ std::vector<AnalysisJson::json_node> AnalysisJson::GetNode()
if(!m_json.isObject())
return nodes;
auto obj = m_json.object();
for(auto key : obj.keys())
auto keys = obj.keys().toVector();
std::sort(keys.begin(),keys.end(),[](QString x,QString y){
return x.toInt()<y.toInt();
});
for(auto key : keys)
{
if(key != "global")
nodes.push_back(json_node{obj[key].toObject()["title"].toString(),

View File

@ -3,10 +3,10 @@
#include <QMessageBox>
#include "mainwindow.h"
Dialog_logIn::Dialog_logIn(QWidget *parent) :
QDialog(parent),
m_pdtToolDbuserMgr(nullptr),
Dialog_logIn::Dialog_logIn(class MainWindow *mainwindow) :
QDialog(nullptr),
ui(new Ui::Dialog_logIn)
, m_mainwindow(mainwindow)
{
ui->setupUi(this);
@ -36,11 +36,6 @@ Dialog_logIn::~Dialog_logIn()
delete ui;
}
HGPdtToolDbUserMgr Dialog_logIn::GetUserMgr()
{
return m_pdtToolDbuserMgr;
}
void Dialog_logIn::mousePressEvent(QMouseEvent *event)
{
if(event->button()==Qt::LeftButton)
@ -74,9 +69,9 @@ void Dialog_logIn::on_pbtn_login_clicked()
QString host = ui->lineEdit_host->text();
QString port = ui->lineEdit_port->text();
HGResult ret = HGPdtToolDb_CreateUserMgr(host.toStdString().c_str(), port.toInt(),
account.toStdString().c_str(), password.toStdString().c_str(), &m_pdtToolDbuserMgr);
if (NULL != m_pdtToolDbuserMgr)
HGResult ret = HGPdtToolDb_CreateUserMgr(host.toStdString().c_str(), port.toInt(), account.toStdString().c_str(), password.toStdString().c_str(),
MainWindow::PdtToolDbUserEventFunc, m_mainwindow, &m_mainwindow->m_pdtToolDbuserMgr);
if (NULL != m_mainwindow->m_pdtToolDbuserMgr)
{
accept();
}

View File

@ -13,11 +13,9 @@ class Dialog_logIn : public QDialog
Q_OBJECT
public:
explicit Dialog_logIn(QWidget *parent = nullptr);
explicit Dialog_logIn(class MainWindow *mainwindow);
~Dialog_logIn();
HGPdtToolDbUserMgr GetUserMgr();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
@ -35,8 +33,8 @@ private slots:
private:
Ui::Dialog_logIn *ui;
class MainWindow *m_mainwindow;
HGPdtToolDbUserMgr m_pdtToolDbuserMgr;
QPoint m_startPos;
QPoint m_endPos;
bool m_leftMousePressed;

View File

@ -12,6 +12,7 @@ Dialog_uploadCfgFile::Dialog_uploadCfgFile(HGPdtToolDbUserMgr pdtToolDbuserMgr,
ui(new Ui::Dialog_uploadCfgFile)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
}
Dialog_uploadCfgFile::~Dialog_uploadCfgFile()

View File

@ -17,7 +17,7 @@ Form_mainInterface::Form_mainInterface(QWidget *parent)
ui->stackedWidget->addWidget(m_textTips);
ui->stackedWidget->addWidget(m_view);
QString path("../../doc/newconfig.json");
QString path("../../doc/config.json");
AnalysisJson analysisJson(path);
std::vector<AnalysisJson::json_node> list_jsonNode = analysisJson.GetNode();

View File

@ -15,16 +15,15 @@ int main(int argc, char *argv[])
while (1)
{
Dialog_logIn login;
MainWindow w;
Dialog_logIn login(&w);
if (login.exec())
{
HGPdtToolDbUserMgr userMgr = login.GetUserMgr();
assert(nullptr != userMgr);
MainWindow w(userMgr);
w.Init();
w.showMaximized();
a.exec();
w.Deinit();
if (w.isExitApp())
{
break;

View File

@ -9,27 +9,23 @@
#include "dialog_uploadcfgfile.h"
#include "hgscanner.h"
MainWindow::MainWindow(HGPdtToolDbUserMgr userMgr, QWidget *parent)
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_pdtToolDbuserMgr(userMgr)
, m_pdtToolDbuserMgr(nullptr)
, m_form_mainInterface(nullptr)
, m_top_splitter(nullptr)
, m_bot_splitter(nullptr)
, m_splitterCount(1)
, m_handle(nullptr)
, m_isLogOut(false)
{
ui->setupUi(this);
setWindowIcon(QIcon(":image/image_rsc/logo/logo.ico"));
HGUInt userType = 0;
HGPdtToolDb_GetUserType(m_pdtToolDbuserMgr, &userType);
if (userType == HGPDTTOOLDB_USERTYPE_NORMAL)
ui->act_manage->setVisible(false);
HGChar userName[128];
HGPdtToolDb_GetUserName(m_pdtToolDbuserMgr, userName, 128);
setWindowTitle(userName);
connect(this, SIGNAL(sane_dev_arrive(QString)), this, SLOT(on_sane_dev_arrive(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(user_event(int)), this, SLOT(on_user_event(int)), Qt::QueuedConnection);
m_top_splitter = new QSplitter(Qt::Horizontal);
m_bot_splitter = new QSplitter(Qt::Horizontal);
@ -42,15 +38,41 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr userMgr, QWidget *parent)
vLayout->setStretch(0, 1);
vLayout->setStretch(1, 0);
this->centralWidget()->setLayout(vLayout);
test();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::Init()
{
assert(nullptr != m_pdtToolDbuserMgr);
HGUInt userType = 0;
HGPdtToolDb_GetUserType(m_pdtToolDbuserMgr, &userType);
if (userType == HGPDTTOOLDB_USERTYPE_NORMAL)
ui->act_manage->setVisible(false);
HGChar userName[128];
HGPdtToolDb_GetUserName(m_pdtToolDbuserMgr, userName, 128);
setWindowTitle(userName);
SANE_Int v = 0;
sane_init_ex(&v, sane_ex_callback, this);
}
void MainWindow::Deinit()
{
// if (nullptr != m_handle)
// {
// sane_close(m_handle);
// m_handle = nullptr;
// }
// sane_exit();
HGPdtToolDb_DestroyUserMgr(m_pdtToolDbuserMgr);
m_pdtToolDbuserMgr = NULL;
delete ui;
}
bool MainWindow::isExitApp()
@ -58,7 +80,41 @@ bool MainWindow::isExitApp()
return !m_isLogOut;
}
std::vector<std::string> MainWindow::get_devices()
void HGAPI MainWindow::PdtToolDbUserEventFunc(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param)
{
MainWindow *p = (MainWindow *)param;
if (0 != event)
{
emit p->user_event(event);
}
}
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param)
{
(void)hdev;
(void)len;
MainWindow *p = (MainWindow *)param;
switch (code)
{
case SANE_EVENT_DEVICE_ARRIVED:
{
SANE_Device_Ex* sane_dev = (SANE_Device_Ex*)data;
emit p->sane_dev_arrive(sane_dev->name);
}
break;
case SANE_EVENT_DEVICE_LEFT:
{
SANE_Device* sane_dev = (SANE_Device*)data;
emit p->sane_dev_remove(sane_dev->name);
}
break;
}
return 0;
}
std::vector<std::string> MainWindow::getDevices()
{
std::vector<std::string> name;
const SANE_Device** devs_list;
@ -77,59 +133,45 @@ std::vector<std::string> MainWindow::get_devices()
return name;
}
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
void MainWindow::on_sane_dev_arrive(QString devName)
{
switch (code)
// SANE_Status ret = sane_open(devName.toStdString().c_str(), &m_handle);
// ui_helper* helper;
// hgscanner* hg = new hgscanner(m_handle);
// helper = dynamic_cast<hgscanner*>(hg);
// func_test_go(L"test-31", L"null", helper);
}
void MainWindow::on_sane_dev_remove(QString devName)
{
}
void MainWindow::on_user_event(int event)
{
QString tips;
switch (event)
{
case SANE_EVENT_DEVICE_ARRIVED:
(SANE_Device*)data;
case 1:
tips = tr("Account login elsewhere");
break;
case SANE_EVENT_DEVICE_LEFT:
(SANE_Device*)data;
case 2:
tips = tr("Network connection lost");
break;
case SANE_EVENT_WORKING:
(char*)data;
case 3:
tips = tr("You have been forced offline by the administrator account");
break;
case SANE_EVENT_SCAN_FINISHED:
(char*)data;
break;
case SANE_EVENT_STATUS:
(char*)data;
break;
case SANE_EVENT_ERROR:
(char*)data;
break;
case SANE_EVENT_IMAGE_OK:
SANE_Image* sane_img = (SANE_Image*)data;
default:
break;
}
// sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
return 0;
}
void MainWindow::test()
{
SANE_Handle devHandle;
SANE_Status status = SANE_STATUS_GOOD;
SANE_Int version_code = 0;
status = sane_init_ex(&version_code, sane_ex_callback, NULL);
Sleep(2000);
const SANE_Device** device_list;
//status = sane_get_devices(&device_list, SANE_TRUE);
std::vector<std::string> name = get_devices();
// SANE_String_Const n = name[0].c_str();
int len = name[0].size();
char* buf = new char[len];
strcpy(buf, name[0].c_str());
sane_open(buf, &devHandle);
ui_helper* helper;
hgscanner* hg = new hgscanner(devHandle);
helper = dynamic_cast<hgscanner*>(hg);
// sane_ex_callback1();
func_test_go(L"test-35", L"null", helper);
QMessageBox::information(this, (tr("tips")), tips);
m_isLogOut = true;
close();
}
void MainWindow::on_act_newDevice_triggered()
{
m_splitterCount++;
@ -190,7 +232,6 @@ void MainWindow::on_act_export_triggered()
void MainWindow::on_act_logOut_triggered()
{
HGPdtToolDb_DestroyUserMgr(m_pdtToolDbuserMgr);
m_isLogOut = true;
close();
}
@ -230,6 +271,6 @@ QString MainWindow::getLogInfo(HGResult ret)
void MainWindow::on_act_upload_triggered()
{
// Dialog_uploadCfgFile dlg(m_pdtToolDbuserMgr, this);
//dlg.exec();
Dialog_uploadCfgFile dlg(m_pdtToolDbuserMgr, this);
dlg.exec();
}

View File

@ -12,19 +12,36 @@ namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
{
friend class Dialog_logIn;
Q_OBJECT
public:
MainWindow(HGPdtToolDbUserMgr userMgr, QWidget *parent = nullptr);
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void Init();
void Deinit();
static QString getLogInfo(HGResult ret);
bool isExitApp();
void test();
private:
static void HGAPI PdtToolDbUserEventFunc(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param);
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
std::vector<std::string> get_devices();
std::vector<std::string> getDevices();
signals:
void sane_dev_arrive(QString devName);
void sane_dev_remove(QString devName);
void user_event(int event);
private slots:
void on_sane_dev_arrive(QString devName);
void on_sane_dev_remove(QString devName);
void on_user_event(int event);
private slots:
void on_act_newDevice_triggered();
@ -44,6 +61,7 @@ private slots:
private:
QSplitter *m_top_splitter;
QSplitter *m_bot_splitter;
SANE_Handle m_handle;
int m_splitterCount;
bool m_isLogOut;

View File

@ -2,8 +2,8 @@
#include "HGPdtToolDbImpl.hpp"
#include "base/HGInc.h"
HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar* host, HGUShort port,
const HGChar* userName, const HGChar* pwd, HGPdtToolDbUserMgr* userMgr)
HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar* host, HGUShort port, const HGChar* userName, const HGChar* pwd,
HGPdtToolDbUserEventFunc func, HGPointer param, HGPdtToolDbUserMgr* userMgr)
{
if (NULL == userMgr)
{
@ -11,7 +11,7 @@ HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar* host, HGUShort port,
}
HGPdtToolDbUserMgrImpl* userMgrImpl = new HGPdtToolDbUserMgrImpl;
HGResult ret = userMgrImpl->Create(host, port, userName, pwd);
HGResult ret = userMgrImpl->Create(host, port, userName, pwd, func, param);
if (HGBASE_ERR_OK != ret)
{
delete userMgrImpl;
@ -62,6 +62,17 @@ HGResult HGAPI HGPdtToolDb_GetUserName(HGPdtToolDbUserMgr userMgr, HGChar* userN
return userMgrImpl->GetUserName(userName, maxLen);
}
HGResult HGAPI HGPdtToolDb_RefuseUser(HGPdtToolDbUserMgr userMgr, HGChar* userName)
{
if (NULL == userMgr)
{
return HGBASE_ERR_INVALIDARG;
}
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
return userMgrImpl->RefuseUser(userName);
}
HGResult HGAPI HGPdtToolDb_GetUserList(HGPdtToolDbUserMgr userMgr, HGChar** userNameList, HGUInt maxLen, HGUInt* count)
{
if (NULL == userMgr)

View File

@ -6,6 +6,7 @@ HGPdtToolDb_CreateUserMgr
HGPdtToolDb_DestroyUserMgr
HGPdtToolDb_GetUserType
HGPdtToolDb_GetUserName
HGPdtToolDb_RefuseUser
HGPdtToolDb_GetUserList
HGPdtToolDb_ReleaseUserList
HGPdtToolDb_CreateUser

View File

@ -5,6 +5,15 @@
#include "base/HGBaseErr.h"
#include "HGPdtToolDbErr.h"
/* 账户在其他地方登录 */
#define HGPDTTOOLDB_USEREVENT_CONFLICT 1L
/* 网络错误 */
#define HGPDTTOOLDB_USEREVENT_NETERROR 2L
/* 被管理员账户强制下线 */
#define HGPDTTOOLDB_USEREVENT_REFUSE 3L
/* 数据库异常 */
#define HGPDTTOOLDB_USEREVENT_DBERROR 4L
/* 管理员账户 */
#define HGPDTTOOLDB_USERTYPE_ROOT 1L
/* 普通账户 */
@ -95,9 +104,12 @@
HG_DECLARE_HANDLE(HGPdtToolDbUserMgr);
HG_DECLARE_HANDLE(HGPdtToolDbDevice);
/* 用户事件 */
typedef void (HGAPI* HGPdtToolDbUserEventFunc)(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param);
/* 登录 */
HGEXPORT HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar *host, HGUShort port,
const HGChar *userName, const HGChar *pwd, HGPdtToolDbUserMgr *userMgr);
HGEXPORT HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar *host, HGUShort port, const HGChar *userName, const HGChar *pwd,
HGPdtToolDbUserEventFunc func, HGPointer param, HGPdtToolDbUserMgr *userMgr);
/* 登出 */
HGEXPORT HGResult HGAPI HGPdtToolDb_DestroyUserMgr(HGPdtToolDbUserMgr userMgr);
@ -108,6 +120,9 @@ HGEXPORT HGResult HGAPI HGPdtToolDb_GetUserType(HGPdtToolDbUserMgr userMgr, HGUI
/* 获取当前账户名称 */
HGEXPORT HGResult HGAPI HGPdtToolDb_GetUserName(HGPdtToolDbUserMgr userMgr, HGChar *userName, HGUInt maxLen);
/* 强制某个账户下线,需要管理员账户才能调用 */
HGEXPORT HGResult HGAPI HGPdtToolDb_RefuseUser(HGPdtToolDbUserMgr userMgr, HGChar* userName);
/* 获取账户列表,需要管理员账户才能调用 */
HGEXPORT HGResult HGAPI HGPdtToolDb_GetUserList(HGPdtToolDbUserMgr userMgr, HGChar **userNameList, HGUInt maxLen, HGUInt* count);

View File

@ -111,8 +111,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;HGBase.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../lib/x86;../../../sdk/lib/win/x86/Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -135,8 +135,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>../lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../lib/x86;../../../sdk/lib/win/x86/Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;HGBase.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)HGPdtToolDb.dll $(SolutionDir)..\..\release\win\x86\Release\</Command>
@ -157,8 +157,8 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>../lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../lib/x64;../../../sdk/lib/win/x64/Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;HGBase.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
@ -182,8 +182,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>../lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../lib/x64;../../../sdk/lib/win/x64/Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libmysql.lib;HGBase.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)HGPdtToolDb.dll $(SolutionDir)..\..\release\win\x64\Release\</Command>

View File

@ -1,6 +1,7 @@
#include "HGPdtToolDbImpl.hpp"
#include "HGPdtToolDb.h"
#include "base/HGInc.h"
#include "base/HGInfo.h"
#include "HGString.h"
const HGChar* INITTIAL_INSPECTION[] =
@ -102,6 +103,16 @@ HGPdtToolDbUserMgrImpl::HGPdtToolDbUserMgrImpl()
{
m_sql = NULL;
m_userName.clear();
m_connectId = -1;
m_func = NULL;
m_param = NULL;
m_valid = HGFALSE;
m_lock = NULL;
m_event = NULL;
m_stopThread = HGFALSE;
m_thread = NULL;
m_deviceList.clear();
}
@ -110,7 +121,8 @@ HGPdtToolDbUserMgrImpl::~HGPdtToolDbUserMgrImpl()
}
HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const HGChar* userName, const HGChar* pwd)
HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const HGChar* userName, const HGChar* pwd,
HGPdtToolDbUserEventFunc func, HGPointer param)
{
if (NULL != m_sql)
{
@ -160,8 +172,30 @@ HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const
return HGBASE_ERR_FAIL;
}
int connectId = GetConnectId(sql);
if (-1 == connectId)
{
mysql_close(sql);
return HGBASE_ERR_FAIL;
}
if (0 != SetUserLoginInfo(sql, userName, connectId, userName))
{
mysql_close(sql);
return HGBASE_ERR_FAIL;
}
m_sql = sql;
m_userName = userName;
m_connectId = connectId;
m_func = func;
m_param = param;
m_valid = HGTRUE;
HGBase_CreateLock(&m_lock);
HGBase_CreateEvent(HGTRUE, HGFALSE, &m_event);
m_stopThread = HGFALSE;
HGBase_OpenThread(ThreadFunc, this, &m_thread);
return HGBASE_ERR_OK;
}
@ -172,9 +206,22 @@ HGResult HGPdtToolDbUserMgrImpl::Destroy()
return HGBASE_ERR_FAIL;
}
m_stopThread = HGTRUE;
HGBase_SetEvent(m_event);
HGBase_CloseThread(m_thread);
m_thread = NULL;
HGBase_DestroyEvent(m_event);
m_event = NULL;
HGBase_DestroyLock(m_lock);
m_lock = NULL;
mysql_close(m_sql);
m_sql = NULL;
m_userName.clear();
m_connectId = -1;
m_func = NULL;
m_param = NULL;
m_valid = HGFALSE;
return HGBASE_ERR_OK;
}
@ -217,9 +264,47 @@ HGResult HGPdtToolDbUserMgrImpl::GetUserName(HGChar* userName, HGUInt maxLen)
return HGBASE_ERR_OK;
}
HGResult HGPdtToolDbUserMgrImpl::RefuseUser(HGChar* userName)
{
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (NULL == userName || 0 == *userName)
{
return HGBASE_ERR_INVALIDARG;
}
HGUInt userType = 0;
GetUserType(&userType);
if (HGPDTTOOLDB_USERTYPE_ROOT != userType)
{
return HGBASE_ERR_ACCESSDENIED;
}
if (0 == strcmp(userName, "root"))
{
return HGBASE_ERR_FAIL;
}
if (0 != SetUserLoginInfo(m_sql, userName, m_connectId, m_userName))
{
return HGBASE_ERR_FAIL;
}
return HGBASE_ERR_OK;
}
HGResult HGPdtToolDbUserMgrImpl::GetUserList(HGChar** userNameList, HGUInt maxLen, HGUInt* count)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -287,7 +372,10 @@ HGResult HGPdtToolDbUserMgrImpl::ReleaseUserList(HGChar** userNameList, HGUInt c
HGResult HGPdtToolDbUserMgrImpl::CreateUser(const HGChar* userName, const HGChar* defPwd)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -341,7 +429,10 @@ HGResult HGPdtToolDbUserMgrImpl::CreateUser(const HGChar* userName, const HGChar
HGResult HGPdtToolDbUserMgrImpl::DestroyUser(const HGChar* userName)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -395,7 +486,10 @@ HGResult HGPdtToolDbUserMgrImpl::DestroyUser(const HGChar* userName)
HGResult HGPdtToolDbUserMgrImpl::SetPassword(const HGChar* userName, const HGChar* pwd)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -420,7 +514,10 @@ HGResult HGPdtToolDbUserMgrImpl::SetPassword(const HGChar* userName, const HGCha
HGResult HGPdtToolDbUserMgrImpl::ModifyPassword(const HGChar* oldPwd, const HGChar* newPwd)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -448,7 +545,10 @@ HGResult HGPdtToolDbUserMgrImpl::ModifyPassword(const HGChar* oldPwd, const HGCh
HGResult HGPdtToolDbUserMgrImpl::UploadFile(const HGChar* tag, const HGChar* fileName)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -500,7 +600,7 @@ HGResult HGPdtToolDbUserMgrImpl::UploadFile(const HGChar* tag, const HGChar* fil
char sqlCmd[1024] = {0};
sprintf(sqlCmd, "insert into file_list (tag, file_data) values ('%s', ?);", tag);
int ret = mysql_stmt_prepare(stmt, sqlCmd, strlen(sqlCmd));
int ret = mysql_stmt_prepare(stmt, sqlCmd, (unsigned long)strlen(sqlCmd));
assert(0 == ret);
MYSQL_BIND bnd = {0};
@ -520,7 +620,7 @@ HGResult HGPdtToolDbUserMgrImpl::UploadFile(const HGChar* tag, const HGChar* fil
if (1062 == mysql_stmt_errno(stmt))
{
sprintf(sqlCmd, "update file_list set file_data = ? where tag = '%s';", tag);
ret = mysql_stmt_prepare(stmt, sqlCmd, strlen(sqlCmd));
ret = mysql_stmt_prepare(stmt, sqlCmd, (unsigned long)strlen(sqlCmd));
assert(0 == ret);
MYSQL_BIND bnd = {0};
@ -546,7 +646,10 @@ HGResult HGPdtToolDbUserMgrImpl::UploadFile(const HGChar* tag, const HGChar* fil
HGResult HGPdtToolDbUserMgrImpl::DownloadFile(const HGChar* tag, const HGChar* fileName)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -562,7 +665,7 @@ HGResult HGPdtToolDbUserMgrImpl::DownloadFile(const HGChar* tag, const HGChar* f
char sqlCmd[1024] = {0};
sprintf(sqlCmd, "select file_data from file_list where tag = '%s';", tag);
int ret = mysql_stmt_prepare(stmt, sqlCmd, strlen(sqlCmd));
int ret = mysql_stmt_prepare(stmt, sqlCmd, (unsigned long)strlen(sqlCmd));
assert(0 == ret);
unsigned long readLength = 0;
@ -614,7 +717,10 @@ HGResult HGPdtToolDbUserMgrImpl::DownloadFile(const HGChar* tag, const HGChar* f
HGResult HGPdtToolDbUserMgrImpl::Export(const HGChar* xlsPath)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -759,7 +865,10 @@ HGResult HGPdtToolDbUserMgrImpl::Export(const HGChar* xlsPath)
HGResult HGPdtToolDbUserMgrImpl::GetConfig(const HGChar* key, HGChar* value, HGUInt maxLen)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -810,7 +919,10 @@ HGResult HGPdtToolDbUserMgrImpl::GetConfig(const HGChar* key, HGChar* value, HGU
HGResult HGPdtToolDbUserMgrImpl::SetConfig(const HGChar* key, const HGChar* value)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -842,7 +954,10 @@ HGResult HGPdtToolDbUserMgrImpl::SetConfig(const HGChar* key, const HGChar* valu
HGResult HGPdtToolDbUserMgrImpl::OpenDevice(const HGChar* sn, class HGPdtToolDbDeviceImpl** deviceImpl)
{
if (NULL == m_sql)
HGBase_EnterLock(m_lock);
HGBool valid = m_valid;
HGBase_LeaveLock(m_lock);
if (NULL == m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
@ -877,6 +992,46 @@ HGResult HGPdtToolDbUserMgrImpl::OpenDevice(const HGChar* sn, class HGPdtToolDbD
return HGBASE_ERR_OK;
}
void HGAPI HGPdtToolDbUserMgrImpl::ThreadFunc(HGThread thread, HGPointer param)
{
HGPdtToolDbUserMgrImpl* p = (HGPdtToolDbUserMgrImpl*)param;
while (!p->m_stopThread)
{
HGUInt event = 0;
int connectId = -1;
std::string takeUserName;
int ret = GetUserLoginInfo(p->m_sql, p->m_userName.c_str(), connectId, takeUserName);
if (0 != ret)
{
int errNo = mysql_errno(p->m_sql);
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "HGPdtToolDbUserMgrImpl::ThreadFunc mysql error=%d", errNo);
event = (errNo >= 1158 && errNo <= 1161) ? HGPDTTOOLDB_USEREVENT_NETERROR : HGPDTTOOLDB_USEREVENT_DBERROR;
}
else if (takeUserName == "root" && takeUserName != p->m_userName)
{
event = HGPDTTOOLDB_USEREVENT_REFUSE;
}
else if (connectId != -1 && connectId != p->m_connectId)
{
event = HGPDTTOOLDB_USEREVENT_CONFLICT;
}
if (0 != event)
{
HGBase_EnterLock(p->m_lock);
p->m_valid = HGFALSE;
HGBase_LeaveLock(p->m_lock);
if (NULL != p->m_func)
p->m_func((HGPdtToolDbUserMgr)p, event, p->m_param);
break;
}
HGBase_WaitEventTimeout(p->m_event, 1000);
}
}
void HGPdtToolDbUserMgrImpl::RemoveDevice(class HGPdtToolDbDeviceImpl* deviceImpl)
{
std::list<class HGPdtToolDbDeviceImpl*>::iterator iter;
@ -953,6 +1108,74 @@ std::string HGPdtToolDbUserMgrImpl::GetAuthString(MYSQL* sql, const HGChar* pwd)
return authString;
}
int HGPdtToolDbUserMgrImpl::GetConnectId(MYSQL* sql)
{
assert(NULL != sql);
int connId = -1;
char sqlCmd[1024];
sprintf(sqlCmd, "select connection_id();");
int ret = mysql_query(sql, sqlCmd);
if (0 == ret)
{
MYSQL_RES* sqlRes = mysql_use_result(sql);
if (NULL != sqlRes)
{
MYSQL_ROW row = mysql_fetch_row(sqlRes);
if (NULL != row && NULL != row[0])
connId = atoi(row[0]);
mysql_free_result(sqlRes);
}
}
return connId;
}
int HGPdtToolDbUserMgrImpl::SetUserLoginInfo(MYSQL* sql, const HGChar* userName, int connectId, const std::string& takeUserName)
{
assert(NULL != sql);
assert(NULL != userName && 0 != *userName);
assert(-1 != connectId);
assert(!takeUserName.empty());
char sqlCmd[1024];
sprintf(sqlCmd, "update user_list set connect_id = %d, take_user = '%s' where user = '%s';",
connectId, takeUserName.c_str(), userName);
return mysql_query(sql, sqlCmd);
}
int HGPdtToolDbUserMgrImpl::GetUserLoginInfo(MYSQL* sql, const HGChar* userName, int& connectId, std::string& takeUserName)
{
assert(NULL != sql);
assert(NULL != userName && 0 != *userName);
connectId = -1;
takeUserName.clear();
char sqlCmd[1024];
sprintf(sqlCmd, "select connect_id, take_user from user_list where user = '%s';", userName);
int ret = mysql_query(sql, sqlCmd);
if (0 != ret)
{
return ret;
}
MYSQL_RES* sqlRes = mysql_use_result(sql);
if (NULL != sqlRes)
{
MYSQL_ROW row = mysql_fetch_row(sqlRes);
if (NULL != row)
{
assert(NULL != row[0] && NULL != row[1]);
connectId = atoi(row[0]);
takeUserName = row[1];
}
mysql_free_result(sqlRes);
}
return 0;
}
int HGPdtToolDbUserMgrImpl::CreateFileTable(MYSQL* sql)
{
assert(NULL != sql);
@ -1109,6 +1332,14 @@ HGPdtToolDbDeviceImpl::~HGPdtToolDbDeviceImpl()
HGResult HGPdtToolDbDeviceImpl::GetCurrEntry(HGUInt* entryName)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (NULL == entryName)
{
return HGBASE_ERR_INVALIDARG;
@ -1143,6 +1374,14 @@ HGResult HGPdtToolDbDeviceImpl::GetCurrEntry(HGUInt* entryName)
HGResult HGPdtToolDbDeviceImpl::SetCurrEntry(HGUInt entryName)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (0 != entryName && 0xFFFFFFFF != entryName)
{
const HGChar* entryNameStr = GetEntryNameStr(entryName);
@ -1161,6 +1400,14 @@ HGResult HGPdtToolDbDeviceImpl::SetCurrEntry(HGUInt entryName)
HGResult HGPdtToolDbDeviceImpl::GetEntryStatus(HGUInt entryName, HGUInt* entryStatus)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (NULL == entryStatus)
{
return HGBASE_ERR_INVALIDARG;
@ -1202,6 +1449,14 @@ HGResult HGPdtToolDbDeviceImpl::GetEntryStatus(HGUInt entryName, HGUInt* entrySt
HGResult HGPdtToolDbDeviceImpl::SetEntryStatus(HGUInt entryName, HGUInt entryStatus)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (entryStatus > HGPDTTOOLDB_ENTRYSTATUS_PASS)
{
return HGBASE_ERR_INVALIDARG;
@ -1248,6 +1503,14 @@ HGResult HGPdtToolDbDeviceImpl::SetEntryStatus(HGUInt entryName, HGUInt entrySta
HGResult HGPdtToolDbDeviceImpl::GetEntryExcepDesc(HGUInt entryName, HGChar* excepDesc, HGUInt maxLen)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
if (NULL == excepDesc || 0 == maxLen)
{
return HGBASE_ERR_INVALIDARG;
@ -1301,6 +1564,14 @@ HGResult HGPdtToolDbDeviceImpl::GetEntryExcepDesc(HGUInt entryName, HGChar* exce
HGResult HGPdtToolDbDeviceImpl::SetEntryExcepDesc(HGUInt entryName, const HGChar* excepDesc)
{
HGBase_EnterLock(m_userMgr->m_lock);
HGBool valid = m_userMgr->m_valid;
HGBase_LeaveLock(m_userMgr->m_lock);
if (NULL == m_userMgr->m_sql || !valid)
{
return HGBASE_ERR_FAIL;
}
const HGChar* entryNameStr = GetEntryNameStr(entryName);
const HGChar* tableName = GetDescTableName(entryName);
if (NULL == entryNameStr || NULL == tableName)

View File

@ -3,6 +3,10 @@
#include "base/HGDef.h"
#include "base/HGBaseErr.h"
#include "base/HGLock.h"
#include "base/HGEvent.h"
#include "base/HGThread.h"
#include "HGPdtToolDb.h"
#include "mysql.h"
#include <string>
#include <list>
@ -14,10 +18,12 @@ public:
HGPdtToolDbUserMgrImpl();
~HGPdtToolDbUserMgrImpl();
HGResult Create(const HGChar* host, HGUShort port, const HGChar* userName, const HGChar* pwd);
HGResult Create(const HGChar* host, HGUShort port, const HGChar* userName, const HGChar* pwd,
HGPdtToolDbUserEventFunc func, HGPointer param);
HGResult Destroy();
HGResult GetUserType(HGUInt* userType);
HGResult GetUserName(HGChar* userName, HGUInt maxLen);
HGResult RefuseUser(HGChar* userName);
HGResult GetUserList(HGChar** userNameList, HGUInt maxLen, HGUInt *count);
static HGResult ReleaseUserList(HGChar** userNameList, HGUInt count);
HGResult CreateUser(const HGChar* userName, const HGChar* defPwd);
@ -32,11 +38,15 @@ public:
HGResult OpenDevice(const HGChar* sn, class HGPdtToolDbDeviceImpl **deviceImpl);
private:
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
void RemoveDevice(class HGPdtToolDbDeviceImpl* deviceImpl);
static const HGChar* GetEntryNameCnStr(HGUInt entryName);
static std::string GetPassword(MYSQL* sql, const HGChar* userName);
static std::string GetAuthString(MYSQL* sql, const HGChar* pwd);
static int GetConnectId(MYSQL* sql);
static int SetUserLoginInfo(MYSQL* sql, const HGChar* userName, int connectId, const std::string& takeUserName);
static int GetUserLoginInfo(MYSQL* sql, const HGChar* userName, int &connectId, std::string &takeUserName);
int CreateFileTable(MYSQL* sql);
int CreateMainTestTable(MYSQL *sql);
@ -53,6 +63,16 @@ private:
private:
MYSQL* m_sql;
std::string m_userName;
int m_connectId;
HGPdtToolDbUserEventFunc m_func;
HGPointer m_param;
HGBool m_valid;
HGLock m_lock;
HGEvent m_event;
HGBool m_stopThread;
HGThread m_thread;
std::list<class HGPdtToolDbDeviceImpl*> m_deviceList;
};

View File

@ -5,12 +5,14 @@
int main()
{
HGPdtToolDbUserMgr userMgr = NULL;
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "root", "123456", &userMgr);
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "root", "123456", NULL, NULL, &userMgr);
if (NULL != userMgr)
{
HGPdtToolDb_UploadFile(userMgr, "G100", "D:\\config.json");
Sleep(30 * 1000);
HGPdtToolDb_DownloadFile(userMgr, "G100", "D:\\123.txt");
//HGPdtToolDb_UploadFile(userMgr, "G100", "D:\\config.json");
//HGPdtToolDb_DownloadFile(userMgr, "G100", "D:\\123.txt");
HGPdtToolDbDevice device = NULL;
HGPdtToolDb_OpenDevice(userMgr, "G123456", &device);

View File

@ -3,6 +3,6 @@
3.create user 'huago'@'%' identified by 'huago';
4.grant all privileges on huago_production_tool.* to 'huago'@'%';
5.use huago_production_tool;
6.create table user_list (user varchar(20) not null primary key, password text);
6.create table user_list (user varchar(20) not null primary key, password text, connect_id int, take_user text);
7.insert into user_list (user, password) values ('root', password('123456'));
8.create table root_config (config_key varchar(40) not null primary key, config_value text);