|
@@ -48,10 +48,14 @@ PRIMARY KEY (type, sn));"
|
|
|
#define _SELECT_LOG_TABLE_ "SELECT type, sn, content, gdate, report_status FROM log"
|
|
|
|
|
|
|
|
|
-#define FREE_MSG if ( m_pszErrmsg ) { sqlite3_free(m_pszErrmsg); m_pszErrmsg = NULL;}
|
|
|
-#define FREE_MSG2 if ( psqlite_error ) { sqlite3_free(psqlite_error); psqlite_error = NULL;}
|
|
|
+//#define FREE_MSG if ( m_pszErrmsg ) { printf(m_pszErrmsg);sqlite3_free(m_pszErrmsg); m_pszErrmsg = NULL;}
|
|
|
+#define FREE_MSG if ( psqlite_error ) \
|
|
|
+ printf("%s\n",psqlite_error),\
|
|
|
+ sqlite3_free(psqlite_error),\
|
|
|
+ psqlite_error = NULL
|
|
|
|
|
|
-CDataImpl::CDataImpl(void):m_psqlite3(NULL),m_pszErrmsg(NULL)
|
|
|
+
|
|
|
+CDataImpl::CDataImpl(void):m_psqlite3(NULL)
|
|
|
{
|
|
|
//sqlite3_threadsafe();
|
|
|
}
|
|
@@ -65,7 +69,7 @@ BOOL CDataImpl::Open()
|
|
|
{
|
|
|
Close();
|
|
|
CHAR szpath[MAX_PATH] = {0};
|
|
|
- _stprintf_s(szpath, _T("%sscbc.db"), Global::g_szCurModuleDir);
|
|
|
+ _stprintf_s(szpath, _T("%sdb\\scbc.db"), Global::g_szCurModuleDir);
|
|
|
std::string strPath;
|
|
|
if ( !CharEncoding::ASCII2UTF8(szpath,strPath))
|
|
|
{
|
|
@@ -81,19 +85,19 @@ BOOL CDataImpl::Open()
|
|
|
if ( !QueryTable("mid"))
|
|
|
{
|
|
|
sqlite3_exec(m_psqlite3, _CREATE_MID_TABLE_, NULL, NULL, &psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
if ( !QueryTable("keys"))
|
|
|
{
|
|
|
sqlite3_exec(m_psqlite3, _CREATE_KEYS_TABLE_, NULL, NULL, &psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
if ( !QueryTable("log"))
|
|
|
{
|
|
|
sqlite3_exec(m_psqlite3, _CREATE_LOG_TABLE_, NULL, NULL, &psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
return TRUE;
|
|
@@ -105,9 +109,6 @@ void CDataImpl::Close()
|
|
|
sqlite3_close(m_psqlite3);
|
|
|
|
|
|
m_psqlite3 = NULL;
|
|
|
- if ( m_pszErrmsg )
|
|
|
- sqlite3_free(m_pszErrmsg);
|
|
|
- m_pszErrmsg = NULL;
|
|
|
}
|
|
|
|
|
|
BOOL CDataImpl::ExecteSQL(IN LPCSTR lpSQL)
|
|
@@ -126,7 +127,7 @@ BOOL CDataImpl::ExecteSQL(IN LPCSTR lpSQL)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("ExecteSQL:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -155,7 +156,7 @@ BOOL CDataImpl::QueryTable(std::string table)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryContactsType:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -183,7 +184,7 @@ INT CDataImpl::QueryMidInfo(std::string order, STMid &data)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryContactsType:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -242,7 +243,7 @@ INT CDataImpl::QueryKeyInfo(std::string sn, STKeys &data)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -288,7 +289,7 @@ INT CDataImpl::QueryUnReportKeyInfo(std::vector<STKeys> &vtdata)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -319,7 +320,7 @@ INT CDataImpl::QueryLogInfo(std::string sn, STLog &data)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryTaskInfo:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -361,7 +362,7 @@ INT CDataImpl::QueryUnReportLogInfo(std::vector<STLog> &vtdata)
|
|
|
if ( sqlite_error != SQLITE_OK)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -408,7 +409,7 @@ INT CDataImpl::InsertMidInfo(STMid &data)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("InsertContactsType:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
return sqlite_error;
|
|
@@ -432,7 +433,7 @@ INT CDataImpl::InsertKeyInfo(STKeys &data)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("InsertContactsInfo:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
return sqlite_error;
|
|
@@ -459,7 +460,7 @@ INT CDataImpl::InsertLogInfo(STLog &data)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("InsertContactsInfo:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
}
|
|
|
|
|
|
return sqlite_error;
|
|
@@ -474,7 +475,7 @@ INT CDataImpl::BatchInsertKeyInfo(std::vector<STKeys> &vtdata)
|
|
|
INT nRet = sqlite3_exec(m_psqlite3, "begin;", 0, 0, &psqlite_error);
|
|
|
if ( nRet != SQLITE_OK )
|
|
|
{
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return nRet;
|
|
|
}
|
|
|
|
|
@@ -497,14 +498,14 @@ INT CDataImpl::BatchInsertKeyInfo(std::vector<STKeys> &vtdata)
|
|
|
{
|
|
|
// »Ø¹öÊÂÎñ;
|
|
|
nRet = sqlite3_exec(m_psqlite3, "rollback;", 0, 0, &psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return nRet;
|
|
|
}
|
|
|
|
|
|
nRet = sqlite3_exec(m_psqlite3, "commit;", 0, 0, &psqlite_error);
|
|
|
if ( nRet != SQLITE_OK )
|
|
|
{
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return nRet;
|
|
|
}
|
|
|
|
|
@@ -540,7 +541,7 @@ BOOL CDataImpl::UpdateMidInfo(STMid &data)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("UpdateContactsType:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -576,7 +577,7 @@ BOOL CDataImpl::UpdateDownloadStatus(std::string order, int status, std::string
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("UpdateContactsType:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -606,7 +607,7 @@ BOOL CDataImpl::UpdateKeyCopyStatus(std::string sn, int status)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -636,7 +637,7 @@ BOOL CDataImpl::UpdateKeyReportStatus(std::string sn, int status)
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -668,7 +669,7 @@ BOOL CDataImpl::UpdateLogReportStatus(std::string sn, std::string type, int stat
|
|
|
if(SQLITE_OK != sqlite_error)
|
|
|
{
|
|
|
//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
|
|
|
- FREE_MSG2
|
|
|
+ FREE_MSG;
|
|
|
return FALSE;
|
|
|
}
|
|
|
|