|
@@ -139,119 +139,6 @@ BOOL CDatabase::ExcuteSQL(std::string sql)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-#if DEPRECATED
|
|
|
-BOOL CDatabase::InserProvider(const STProvider& provider)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- TCHAR szSql[MAX_PATH] = {0};
|
|
|
- _stprintf_s(szSql, INSER_PROVIDER, provider.name.c_str(), provider.note.c_str());
|
|
|
- if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("InserProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::InserProvider(std::string name, std::string note)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, INSER_PROVIDER, name.c_str(), note.c_str());
|
|
|
- if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("InserProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::DeleteProvider(std::string name)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, DEL_PROVIDER, name.c_str());
|
|
|
- if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("DeleteProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::UpdateProvider(std::string name, const STProvider& provider)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, MOD_PROVIDER, provider.name.c_str(), provider.note.c_str(), name.c_str());
|
|
|
- if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("DeleteProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::QueryProvider(std::vector<STProvider>& vtProvider)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- if (0 != mysql_query(m_pConn, QUERY_PROVIDER)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取表数据;
|
|
|
- MYSQL_RES* pData = mysql_store_result(m_pConn);
|
|
|
- if ( pData == NULL ) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryProvider error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
-#ifdef _DEBUG
|
|
|
- // 统计表字段;
|
|
|
- unsigned int nLen = mysql_num_fields(pData);
|
|
|
- // 字段长度是否一致;
|
|
|
- if (nLen != 2) {
|
|
|
- mysql_free_result(pData);
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- // 打印出字段名称;
|
|
|
- TCHAR szLog[MAX_PATH] = {0};
|
|
|
- for ( int i = 0; i < nLen; i++ ) {
|
|
|
- _stprintf_s(szLog, _T("字段名称:%s\n"), mysql_fetch_field(pData)->name);
|
|
|
- OutputDebugString(szLog);
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- // 遍历数据;
|
|
|
- MYSQL_ROW row;
|
|
|
- while ( (row = mysql_fetch_row(pData)) != NULL ) {
|
|
|
- STProvider provider;
|
|
|
- provider.name = row[0];
|
|
|
- provider.note = row[1];
|
|
|
- vtProvider.push_back(provider);
|
|
|
- }
|
|
|
-
|
|
|
- // 释放内存;
|
|
|
- mysql_free_result(pData);
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
BOOL CDatabase::InserSoc(const STSOC& soc)
|
|
|
{
|
|
|
CHECKDB;
|
|
@@ -476,7 +363,6 @@ BOOL CDatabase::QuerySoc(std::vector<STSOC>& vtSoc)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
BOOL CDatabase::InsertBrand(const STBrand& brand)
|
|
|
{
|
|
|
CHECKDB;
|
|
@@ -745,7 +631,7 @@ BOOL CDatabase::QueryQuarter(std::vector<STQuarter>& vtQuarter)
|
|
|
STQuarter quarter;
|
|
|
quarter.name = row[0];
|
|
|
quarter.scp = row[1] == NULL ? _T("") : row[1];
|
|
|
- quarter.note = row[2] == NULL ? _T("") : row[1];
|
|
|
+ quarter.note = row[2] == NULL ? _T("") : row[2];
|
|
|
vtQuarter.push_back(quarter);
|
|
|
}
|
|
|
|
|
@@ -755,14 +641,20 @@ BOOL CDatabase::QueryQuarter(std::vector<STQuarter>& vtQuarter)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::InsertServer(const STServer& Server)
|
|
|
+BOOL CDatabase::InsertQBrand(const STQbrand& QBrand)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, INSER_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(),Server.note.c_str());
|
|
|
+ _stprintf_s(szSql, INSER_QBRAND, QBrand.soc.c_str(), QBrand.brand.c_str(), QBrand.quarter.c_str(),
|
|
|
+ QBrand.whitelist.c_str(), QBrand.version.c_str(),
|
|
|
+ QBrand.oemkey.c_str(), QBrand.approved.c_str(),
|
|
|
+ QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
|
|
|
+ QBrand.builddate.c_str(), QBrand.gtvs.c_str(),
|
|
|
+ QBrand.ftpdir.c_str(), QBrand.codedir.c_str(),
|
|
|
+ QBrand.note.c_str(), QBrand.status.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("InsertQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -770,14 +662,14 @@ BOOL CDatabase::InsertServer(const STServer& Server)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note)
|
|
|
+BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string brand)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, INSER_SERVER, name.c_str(), ip.c_str(), type.c_str(), user.c_str(), password.c_str(), note.c_str());
|
|
|
+ _stprintf_s(szSql, DEL_QBRAND, soc.c_str(), brand.c_str(), quarter.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("DeleteQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -785,14 +677,23 @@ BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type,
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::DeleteServer(std::string name)
|
|
|
+BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, DEL_SERVER, name.c_str());
|
|
|
+ _stprintf_s(szSql, MOD_QBRAND, QBrand.soc.c_str(), QBrand.quarter.c_str(),
|
|
|
+ QBrand.brand.c_str(), QBrand.whitelist.c_str(),
|
|
|
+ QBrand.version.c_str(), QBrand.approved.c_str(),
|
|
|
+ QBrand.oemkey.c_str(), QBrand.approveddate.c_str(),
|
|
|
+ QBrand.fingerprint.c_str(), QBrand.builddate.c_str(),
|
|
|
+ QBrand.gtvs.c_str(), QBrand.note.c_str(),
|
|
|
+ QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(),
|
|
|
+ QBrand.local_cfg.c_str(), QBrand.ftpdir.c_str(),
|
|
|
+ QBrand.codedir.c_str(), QBrand.status.c_str(),
|
|
|
+ brand.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("DeleteServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -800,14 +701,21 @@ BOOL CDatabase::DeleteServer(std::string name)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
|
|
|
+BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand& QBrand)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, MOD_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(), Server.note.c_str(), name.c_str());
|
|
|
+ _stprintf_s(szSql, MOD_QBRAND,
|
|
|
+ QBrand.soc.c_str(), QBrand.quarter.c_str(), QBrand.brand.c_str(),
|
|
|
+ QBrand.whitelist.c_str(), QBrand.version.c_str(), QBrand.approved.c_str(),
|
|
|
+ QBrand.oemkey.c_str(), QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
|
|
|
+ QBrand.builddate.c_str(), QBrand.gtvs.c_str(), QBrand.note.c_str(),
|
|
|
+ QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(), QBrand.local_cfg.c_str(),
|
|
|
+ QBrand.ftpdir.c_str(), QBrand.codedir.c_str(), QBrand.status.c_str(),
|
|
|
+ brand.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("UpdateServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -815,10 +723,10 @@ BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
|
|
|
+BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
- if (0 != mysql_query(m_pConn, QUERY_SERVER)) {
|
|
|
+ if (0 != mysql_query(m_pConn, QUERY_QBRAND)) {
|
|
|
#ifdef _DEBUG
|
|
|
_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
@@ -838,7 +746,7 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
|
|
|
// 统计表字段;
|
|
|
unsigned int nLen = mysql_num_fields(pData);
|
|
|
// 字段长度是否一致;
|
|
|
- if (nLen != 6) {
|
|
|
+ if (nLen != 19) {
|
|
|
mysql_free_result(pData);
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -854,14 +762,26 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
|
|
|
// 遍历数据;
|
|
|
MYSQL_ROW row;
|
|
|
while ((row = mysql_fetch_row(pData)) != NULL) {
|
|
|
- STServer server;
|
|
|
- server.name = row[0];
|
|
|
- server.ip = row[1];
|
|
|
- server.type = row[2];
|
|
|
- server.user = row[3];
|
|
|
- server.password = row[4];
|
|
|
- server.note = row[5];
|
|
|
- vtServer.push_back(server);
|
|
|
+ STQbrand QBrand;
|
|
|
+ QBrand.soc = row[0];
|
|
|
+ QBrand.quarter = row[1];
|
|
|
+ QBrand.brand = row[2];
|
|
|
+ QBrand.whitelist = row[3];
|
|
|
+ QBrand.version = row[4];
|
|
|
+ QBrand.oemkey = row[5];
|
|
|
+ QBrand.approved = row[6];
|
|
|
+ QBrand.approveddate = row[7];
|
|
|
+ QBrand.fingerprint = row[8];
|
|
|
+ QBrand.builddate = row[9];
|
|
|
+ QBrand.gtvs = row[10];
|
|
|
+ QBrand.note = row[11];
|
|
|
+ QBrand.apps_cfg = row[12];
|
|
|
+ QBrand.fav_cfg = row[13];
|
|
|
+ QBrand.local_cfg = row[14];
|
|
|
+ QBrand.ftpdir = row[15];
|
|
|
+ QBrand.codedir = row[16];
|
|
|
+ QBrand.status = row[17];
|
|
|
+ vtQBrand.push_back(QBrand);
|
|
|
}
|
|
|
|
|
|
// 释放内存;
|
|
@@ -870,6 +790,55 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
+BOOL CDatabase::ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
|
|
|
+{
|
|
|
+ if (!PathFileExists(file.c_str()))
|
|
|
+ return FALSE;
|
|
|
+
|
|
|
+ // 读出图片;
|
|
|
+ CFile cfile;
|
|
|
+ if (!cfile.Open(file.c_str(), CFile::modeRead, NULL))
|
|
|
+ return FALSE;
|
|
|
+
|
|
|
+ ULONGLONG ulLength = cfile.GetLength();
|
|
|
+ char* pData = new char[ulLength];
|
|
|
+ cfile.Read(pData, ulLength);
|
|
|
+ cfile.Close();
|
|
|
+
|
|
|
+ TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
+ _stprintf_s(szSql, _T("update qbrand set logo = ? where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
|
|
|
+
|
|
|
+ BOOL bResult = SetBinaryField(szSql, pData, ulLength);
|
|
|
+ if (pData)
|
|
|
+ delete[]pData;
|
|
|
+ pData = NULL;
|
|
|
+
|
|
|
+ return bResult;
|
|
|
+}
|
|
|
+
|
|
|
+BOOL CDatabase::ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
|
|
|
+{
|
|
|
+ char* pData = NULL;
|
|
|
+ unsigned long ulLength = 0;
|
|
|
+ TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
+ _stprintf_s(szSql, _T("select logo from qbrand where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
|
|
|
+ BOOL bResult = GetBinaryField(szSql, (void**)&pData, ulLength);
|
|
|
+ if (bResult && pData)
|
|
|
+ {
|
|
|
+ CFile cfile;
|
|
|
+ if (cfile.Open(file.c_str(), CFile::modeCreate | CFile::modeWrite))
|
|
|
+ {
|
|
|
+ cfile.Write(pData, ulLength);
|
|
|
+ cfile.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ delete[]pData;
|
|
|
+ pData = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return bResult;
|
|
|
+}
|
|
|
+
|
|
|
BOOL CDatabase::InsertUser(const STUser& user)
|
|
|
{
|
|
|
CHECKDB;
|
|
@@ -982,16 +951,14 @@ BOOL CDatabase::QueryUser(std::vector<STUser>& vtUser)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::InsertBranch(const STBranch& branch)
|
|
|
+BOOL CDatabase::InsertServer(const STServer& Server)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, INSER_BRANCH, branch.name.c_str(), branch.quarter.c_str(),
|
|
|
- branch.address.c_str(), branch.provider.c_str(), branch.chip.c_str(),
|
|
|
- branch.type.c_str(), branch.status.c_str(), branch.note.c_str());
|
|
|
+ _stprintf_s(szSql, INSER_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(),Server.note.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("InsertBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -999,14 +966,14 @@ BOOL CDatabase::InsertBranch(const STBranch& branch)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::DeleteBranch(std::string branch)
|
|
|
+BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, DEL_BRANCH, branch.c_str());
|
|
|
+ _stprintf_s(szSql, INSER_SERVER, name.c_str(), ip.c_str(), type.c_str(), user.c_str(), password.c_str(), note.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("DeleteBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1014,16 +981,14 @@ BOOL CDatabase::DeleteBranch(std::string branch)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
|
|
|
+BOOL CDatabase::DeleteServer(std::string name)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, MOD_BRANCH, stBranch.quarter.c_str(), stBranch.address.c_str(),
|
|
|
- stBranch.provider.c_str(), stBranch.chip.c_str(), stBranch.type.c_str(),
|
|
|
- stBranch.status.c_str(), stBranch.note.c_str(),branch.c_str());
|
|
|
+ _stprintf_s(szSql, DEL_SERVER, name.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("UpdateBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("DeleteServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1031,12 +996,27 @@ BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
+BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
- if (0 != mysql_query(m_pConn, QUERY_BRANCH)) {
|
|
|
+ TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
+ _stprintf_s(szSql, MOD_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(), Server.note.c_str(), name.c_str());
|
|
|
+ if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("UpdateServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+#endif
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
|
|
|
+{
|
|
|
+ CHECKDB;
|
|
|
+ if (0 != mysql_query(m_pConn, QUERY_SERVER)) {
|
|
|
+#ifdef _DEBUG
|
|
|
+ _dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1045,7 +1025,7 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
MYSQL_RES* pData = mysql_store_result(m_pConn);
|
|
|
if (pData == NULL) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1054,7 +1034,7 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
// 统计表字段;
|
|
|
unsigned int nLen = mysql_num_fields(pData);
|
|
|
// 字段长度是否一致;
|
|
|
- if (nLen != 8) {
|
|
|
+ if (nLen != 6) {
|
|
|
mysql_free_result(pData);
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1070,16 +1050,14 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
// 遍历数据;
|
|
|
MYSQL_ROW row;
|
|
|
while ((row = mysql_fetch_row(pData)) != NULL) {
|
|
|
- STBranch stBranch;
|
|
|
- stBranch.name = row[0];
|
|
|
- stBranch.quarter = row[1];
|
|
|
- stBranch.address = row[2];
|
|
|
- stBranch.provider = row[3];
|
|
|
- stBranch.chip = row[4];
|
|
|
- stBranch.type = row[5];
|
|
|
- stBranch.status = row[6];
|
|
|
- stBranch.note = row[7];
|
|
|
- vtBranch.push_back(stBranch);
|
|
|
+ STServer server;
|
|
|
+ server.name = row[0];
|
|
|
+ server.ip = row[1];
|
|
|
+ server.type = row[2];
|
|
|
+ server.user = row[3];
|
|
|
+ server.password = row[4];
|
|
|
+ server.note = row[5];
|
|
|
+ vtServer.push_back(server);
|
|
|
}
|
|
|
|
|
|
// 释放内存;
|
|
@@ -1088,35 +1066,16 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::InsertQBrand(const STQbrand& QBrand)
|
|
|
-{
|
|
|
- CHECKDB;
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, INSER_QBRAND, QBrand.soc.c_str(), QBrand.brand.c_str(), QBrand.quarter.c_str(),
|
|
|
- QBrand.whitelist.c_str(), QBrand.version.c_str(),
|
|
|
- QBrand.oemkey.c_str(), QBrand.approved.c_str(),
|
|
|
- QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
|
|
|
- QBrand.builddate.c_str(), QBrand.gtvs.c_str(),
|
|
|
- QBrand.ftpdir.c_str(), QBrand.codedir.c_str(),
|
|
|
- QBrand.note.c_str(), QBrand.status.c_str());
|
|
|
- if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
-#ifdef _DEBUG
|
|
|
- _dprintf(_T("InsertQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
-#endif
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string brand)
|
|
|
+BOOL CDatabase::InsertBranch(const STBranch& branch)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, DEL_QBRAND, soc.c_str(), brand.c_str(), quarter.c_str());
|
|
|
+ _stprintf_s(szSql, INSER_BRANCH, branch.name.c_str(), branch.quarter.c_str(),
|
|
|
+ branch.address.c_str(), branch.provider.c_str(), branch.chip.c_str(),
|
|
|
+ branch.type.c_str(), branch.status.c_str(), branch.note.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("DeleteQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("InsertBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1124,23 +1083,14 @@ BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string b
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
|
|
|
+BOOL CDatabase::DeleteBranch(std::string branch)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, MOD_QBRAND, QBrand.soc.c_str(), QBrand.quarter.c_str(),
|
|
|
- QBrand.brand.c_str(), QBrand.whitelist.c_str(),
|
|
|
- QBrand.version.c_str(), QBrand.approved.c_str(),
|
|
|
- QBrand.oemkey.c_str(), QBrand.approveddate.c_str(),
|
|
|
- QBrand.fingerprint.c_str(), QBrand.builddate.c_str(),
|
|
|
- QBrand.gtvs.c_str(), QBrand.note.c_str(),
|
|
|
- QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(),
|
|
|
- QBrand.local_cfg.c_str(), QBrand.ftpdir.c_str(),
|
|
|
- QBrand.codedir.c_str(), QBrand.status.c_str(),
|
|
|
- brand.c_str());
|
|
|
+ _stprintf_s(szSql, DEL_BRANCH, branch.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("DeleteBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1148,21 +1098,16 @@ BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand& QBrand)
|
|
|
+BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, MOD_QBRAND,
|
|
|
- QBrand.soc.c_str(), QBrand.quarter.c_str(), QBrand.brand.c_str(),
|
|
|
- QBrand.whitelist.c_str(), QBrand.version.c_str(), QBrand.approved.c_str(),
|
|
|
- QBrand.oemkey.c_str(), QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
|
|
|
- QBrand.builddate.c_str(), QBrand.gtvs.c_str(), QBrand.note.c_str(),
|
|
|
- QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(), QBrand.local_cfg.c_str(),
|
|
|
- QBrand.ftpdir.c_str(), QBrand.codedir.c_str(), QBrand.status.c_str(),
|
|
|
- brand.c_str());
|
|
|
+ _stprintf_s(szSql, MOD_BRANCH, stBranch.quarter.c_str(), stBranch.address.c_str(),
|
|
|
+ stBranch.provider.c_str(), stBranch.chip.c_str(), stBranch.type.c_str(),
|
|
|
+ stBranch.status.c_str(), stBranch.note.c_str(),branch.c_str());
|
|
|
if (0 != mysql_query(m_pConn, szSql)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("UpdateBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1170,12 +1115,12 @@ BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string b
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
+BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
|
|
|
{
|
|
|
CHECKDB;
|
|
|
- if (0 != mysql_query(m_pConn, QUERY_QBRAND)) {
|
|
|
+ if (0 != mysql_query(m_pConn, QUERY_BRANCH)) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1184,7 +1129,7 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
MYSQL_RES* pData = mysql_store_result(m_pConn);
|
|
|
if (pData == NULL) {
|
|
|
#ifdef _DEBUG
|
|
|
- _dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
|
|
|
+ _dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
|
|
|
#endif
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1193,7 +1138,7 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
// 统计表字段;
|
|
|
unsigned int nLen = mysql_num_fields(pData);
|
|
|
// 字段长度是否一致;
|
|
|
- if (nLen != 19) {
|
|
|
+ if (nLen != 8) {
|
|
|
mysql_free_result(pData);
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1209,26 +1154,16 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
// 遍历数据;
|
|
|
MYSQL_ROW row;
|
|
|
while ((row = mysql_fetch_row(pData)) != NULL) {
|
|
|
- STQbrand QBrand;
|
|
|
- QBrand.soc = row[0];
|
|
|
- QBrand.quarter = row[1];
|
|
|
- QBrand.brand = row[2];
|
|
|
- QBrand.whitelist = row[3];
|
|
|
- QBrand.version = row[4];
|
|
|
- QBrand.oemkey = row[5];
|
|
|
- QBrand.approved = row[6];
|
|
|
- QBrand.approveddate = row[7];
|
|
|
- QBrand.fingerprint = row[8];
|
|
|
- QBrand.builddate = row[9];
|
|
|
- QBrand.gtvs = row[10];
|
|
|
- QBrand.note = row[11];
|
|
|
- QBrand.apps_cfg = row[12];
|
|
|
- QBrand.fav_cfg = row[13];
|
|
|
- QBrand.local_cfg = row[14];
|
|
|
- QBrand.ftpdir = row[15];
|
|
|
- QBrand.codedir = row[16];
|
|
|
- QBrand.status = row[17];
|
|
|
- vtQBrand.push_back(QBrand);
|
|
|
+ STBranch stBranch;
|
|
|
+ stBranch.name = row[0];
|
|
|
+ stBranch.quarter = row[1];
|
|
|
+ stBranch.address = row[2];
|
|
|
+ stBranch.provider = row[3];
|
|
|
+ stBranch.chip = row[4];
|
|
|
+ stBranch.type = row[5];
|
|
|
+ stBranch.status = row[6];
|
|
|
+ stBranch.note = row[7];
|
|
|
+ vtBranch.push_back(stBranch);
|
|
|
}
|
|
|
|
|
|
// 释放内存;
|
|
@@ -1237,55 +1172,6 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-BOOL CDatabase::ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
|
|
|
-{
|
|
|
- if (!PathFileExists(file.c_str()))
|
|
|
- return FALSE;
|
|
|
-
|
|
|
- // 读出图片;
|
|
|
- CFile cfile;
|
|
|
- if (!cfile.Open(file.c_str(), CFile::modeRead, NULL))
|
|
|
- return FALSE;
|
|
|
-
|
|
|
- ULONGLONG ulLength = cfile.GetLength();
|
|
|
- char* pData = new char[ulLength];
|
|
|
- cfile.Read(pData, ulLength);
|
|
|
- cfile.Close();
|
|
|
-
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, _T("update qbrand set logo = ? where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
|
|
|
-
|
|
|
- BOOL bResult = SetBinaryField(szSql, pData, ulLength);
|
|
|
- if (pData)
|
|
|
- delete[]pData;
|
|
|
- pData = NULL;
|
|
|
-
|
|
|
- return bResult;
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CDatabase::ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
|
|
|
-{
|
|
|
- char* pData = NULL;
|
|
|
- unsigned long ulLength = 0;
|
|
|
- TCHAR szSql[MAX_PATH] = { 0 };
|
|
|
- _stprintf_s(szSql, _T("select logo from qbrand where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
|
|
|
- BOOL bResult = GetBinaryField(szSql, (void**)&pData, ulLength);
|
|
|
- if (bResult && pData)
|
|
|
- {
|
|
|
- CFile cfile;
|
|
|
- if (cfile.Open(file.c_str(), CFile::modeCreate | CFile::modeWrite))
|
|
|
- {
|
|
|
- cfile.Write(pData, ulLength);
|
|
|
- cfile.Close();
|
|
|
- }
|
|
|
-
|
|
|
- delete[]pData;
|
|
|
- pData = NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return bResult;
|
|
|
-}
|
|
|
-
|
|
|
// 示例;
|
|
|
void test(MYSQL* mysql)
|
|
|
{
|