Просмотр исходного кода

1、完成下载接口对接;

Jeff 5 лет назад
Родитель
Сommit
b724fa71ee

+ 1 - 0
scbc.tools/scbc.tools/CurlClient.cpp

@@ -12,6 +12,7 @@ CCurlClient::CCurlClient(void)
 CCurlClient::~CCurlClient(void)
 {
 	// ÊÍ·ÅcurlµÄÈ«¾Ö¶ÔÏó;
+	ClearHeaders();
 	curl_global_cleanup(); 
 }
 

+ 2 - 1
scbc.tools/scbc.tools/CurlClient.h

@@ -75,7 +75,8 @@ public:
 	void SetHeaders(const std::string headers);
 	void ClearHeaders()
 	{
-		curl_slist_free_all(m_headers);
+		if (m_headers)
+			curl_slist_free_all(m_headers);
 		m_headers = NULL;
 	}
 

+ 8 - 8
scbc.tools/scbc.tools/DataImpl.cpp

@@ -26,14 +26,14 @@ PRIMARY KEY (bid ASC));"
 // KeyCopy表;
 #define _CREATE_KEYS_TABLE_ \
 	"CREATE TABLE keys \
-(bid  TEXT(16) NOT NULL,\
+(pid  INTEGER NOT NULL,\
 sn  TEXT(32) PRIMARY KEY NOT NULL,\
 keys  TEXT NOT NULL,\
 copy_date  DATETIME DEFAULT '',\
 report_date  DATETIME DEFAULT '',\
 copy_status  INTEGER NOT NULL DEFAULT 0,\
 report_status  INTEGER NOT NULL DEFAULT 0);"
-#define _SELECT_KEYS_TABLE_ "SELECT bid, sn, keys, copy_date, report_date, copy_status, report_status FROM keys"
+#define _SELECT_KEYS_TABLE_ "SELECT pid, sn, keys, copy_date, report_date, copy_status, report_status FROM keys"
 
 // Log表;
 #define _CREATE_LOG_TABLE_ \
@@ -249,7 +249,7 @@ INT CDataImpl::QueryKeyInfo(std::string sn, STKeys &data)
 	if ( nRow == 1)
 	{
 #ifndef USE_UTF8
-		data.order = pazResult[nCol+0];
+		data.pid = pazResult[nCol+0];
 		data.sn = pazResult[nCol+1];
 		data.keys = pazResult[nCol+2];
 		data.copy_date = pazResult[nCol+3];
@@ -258,7 +258,7 @@ INT CDataImpl::QueryKeyInfo(std::string sn, STKeys &data)
 		data.report_status = pazResult[nCol+6];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
-		data.order = pazResult[nCol+0];
+		data.pid = pazResult[nCol+0];
 		data.sn = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
 		data.keys = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
 		data.copy_date = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
@@ -420,8 +420,8 @@ INT CDataImpl::InsertKeyInfo(STKeys &data)
 	if(m_psqlite3 == NULL)
 		return -1;
 
-	std::string strInsert = "INSERT INTO keys(bid, sn, keys) VALUES ('";
-	strInsert.append(data.order);
+	std::string strInsert = "INSERT INTO keys(pid, sn, keys) VALUES ('";
+	strInsert.append(data.pid);
 	strInsert.append("','");
 	strInsert.append(data.sn);
 	strInsert.append("','");
@@ -479,14 +479,14 @@ INT CDataImpl::BatchInsertKeyInfo(std::vector<STKeys> &vtdata)
 	}
 
 	sqlite3_stmt *stmt;
-	const char* sql = "INSERT INTO keys(bid, sn, keys) VALUES (?,?,?)";
+	const char* sql = "INSERT INTO keys(pid, sn, keys) VALUES (?,?,?)";
 	sqlite3_prepare_v2(m_psqlite3, sql, strlen(sql), &stmt, 0);
 
 	std::vector<STKeys>::iterator it = vtdata.begin();
 	for ( int i = 0; it != vtdata.end(); it++, i++ )
 	{
 		sqlite3_reset(stmt);  
-		sqlite3_bind_text(stmt, 1, it->order.c_str(), it->order.size(), SQLITE_STATIC);  
+		sqlite3_bind_text(stmt, 1, it->pid.c_str(), it->pid.size(), SQLITE_STATIC);  
 		sqlite3_bind_text(stmt, 2, it->sn.c_str(), it->sn.size(), SQLITE_STATIC);  
 		sqlite3_bind_text(stmt, 3, it->keys.c_str(), it->keys.size(), SQLITE_STATIC);   
 		sqlite3_step(stmt);  

+ 140 - 41
scbc.tools/scbc.tools/SDK.cpp

@@ -3,6 +3,7 @@
 #include "CritSection.h"
 #include "Global.h"
 #include "DataImpl.h"
+#include <sys/stat.h>
 
 ThreadSection g_csTask;
 std::list<STMid> CSDK::m_vtMidTask;
@@ -14,10 +15,12 @@ m_hReportEvent(NULL),
 m_hThreadReport(NULL)
 {
 	Global::Init();
+	m_curl.Initialize();
 }
 
 CSDK::~CSDK(void)
 {
+	
 }
 
 int CSDK::QueryMidInfo(std::string order)
@@ -60,7 +63,7 @@ int CSDK::DownloadMidData(std::string order)
 			return -1;
 		}
 
-		m_hThreadDownload = CreateThread(NULL, 0, ThreadDownload, NULL, 0, NULL);
+		m_hThreadDownload = CreateThread(NULL, 0, ThreadDownload, this, 0, NULL);
 		if ( m_hThreadDownload == NULL )
 		{
 			CloseHandle(m_hDownloadEvent);
@@ -69,13 +72,15 @@ int CSDK::DownloadMidData(std::string order)
 		}
 	}
 
+	int nRet = 0;
 	STMid host_mid;
 	STMid local_mid;
 	// https请求;
-	/*
-	if ( https:// == false)
+	nRet = GetMidInfo(order, host_mid);
+	if ( nRet == -1)
 		return -5;
-	*/
+	else if ( nRet != 0 ) 
+		return 0;
 
 	// 判断该订单是否存在;
 	CDataImpl db;
@@ -83,27 +88,31 @@ int CSDK::DownloadMidData(std::string order)
 		return -2;
 
 	// 查询mid;
-	int nRow = db.QueryMidInfo(order, local_mid);
-	if ( nRow == -1)
+	nRet = db.QueryMidInfo(order, local_mid);
+	if ( nRet == -1)
 		return -3;
 
-	if ( nRow == 0 )
+	if ( nRet == 0 )
 	{
 		// 新增mid;
 		db.InsertMidInfo(host_mid);
 	}
-	else if ( nRow == 1 )
+	else if ( nRet == 1 )
 	{
+		// 是否已下载过,已下载过的不允许重新下载;
+		if ( local_mid.status == "1" && local_mid.finish_date.size() )
+			return 2;
+
 		// 更新Mid;
 		db.UpdateMidInfo(host_mid);
 	}
-	else if ( nRow > 1 )
+	else if ( nRet > 1 )
 		return -4;
 	
 	// 加入任务中;
 	CSDK::AddDownloadTask(host_mid);
 
-	return 0;
+	return 1;
 }
 
 int CSDK::QueryKeyInfo(std::string sn, STKeys &keys)
@@ -199,7 +208,90 @@ BOOL CSDK::PopDownloadTask(STMid &mid)
 	return FALSE;
 }
 
-void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes)
+bool CSDK::CheckDownload(std::string file, STMid& mid)
+{
+	// 校验文件md5值;
+	std::string fileMd5 = GetFileMD5(file.c_str());
+	if ( _tcsicmp(fileMd5.c_str(), mid.pmd5.c_str()) == 0 )
+	{
+		// 文件下载成功,批量插入数据库;
+		std::vector<STKeys> vtKeys;
+		ParserKey(file, vtKeys, mid.pid);
+		if ( vtKeys.size() )
+		{
+			CDataImpl db;
+			if ( db.Open() )
+			{
+				if ( db.BatchInsertKeyInfo(vtKeys) == 0 )
+				{
+					// 更新任务状态;
+					db.UpdateDownloadStatus(mid.order, 1);
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
+int CSDK::GetMidInfo(std::string order, STMid &mid)
+{
+	// http获取mid;
+	std::string result;
+	std::string url = "http://test.admin.ota.qhmoka.com/IDManage/getofflinelist.do?";
+	std::string content = "orderNumber=";
+	content.append(order);
+	if ( m_curl.Posts(url, content, result) == CURLE_OK)
+	{
+		// 解析json字符串;
+		cJSON *pJson = cJSON_Parse(result.c_str());
+		if ( !pJson )
+		{
+			return -2;
+		}
+
+		std::string code, des;
+		code = cJSON_GetObjectItem(pJson, _T("code")) ? cJSON_GetObjectItem(pJson, _T("code"))->valuestring : "";
+		des = cJSON_GetObjectItem(pJson, _T("des")) ? cJSON_GetObjectItem(pJson, _T("des"))->valuestring : "";
+		cJSON *pData = cJSON_GetObjectItem(pJson, _T("data"));
+		if ( _tcsicmp(code.c_str(), "1000") )
+		{
+			cJSON_Delete(pJson);
+			return -3;
+		}
+		
+		if ( !pData )
+		{
+			cJSON_Delete(pJson);
+			return -4;
+		}
+
+		TCHAR szData[10] = {0};
+		mid.order = cJSON_GetObjectItem(pData, _T("order_number")) ? cJSON_GetObjectItem(pData, _T("order_number"))->valuestring : "";
+		mid.version = cJSON_GetObjectItem(pData, _T("soft_version")) ? cJSON_GetObjectItem(pData, _T("soft_version"))->valuestring : "";
+		//mid.number = cJSON_GetObjectItem(pData, _T("order_quantity")) ? cJSON_GetObjectItem(pData, _T("order_quantity"))->valuestring : "";
+		_itoa_s(cJSON_GetObjectItem(pData, _T("order_quantity")) ? cJSON_GetObjectItem(pData, _T("order_quantity"))->valueint : 0, szData, 10);
+		mid.number = szData;
+		mid.pmd5 = cJSON_GetObjectItem(pData, _T("packet_md5")) ? cJSON_GetObjectItem(pData, _T("packet_md5"))->valuestring : "";
+		mid.ctype = cJSON_GetObjectItem(pData, _T("client_type")) ? cJSON_GetObjectItem(pData, _T("client_type"))->valuestring : "";
+		mid.pid = cJSON_GetObjectItem(pData, _T("project_id")) ? cJSON_GetObjectItem(pData, _T("project_id"))->valuestring : "";
+		mid.purl = cJSON_GetObjectItem(pData, _T("packet_url")) ? cJSON_GetObjectItem(pData, _T("packet_url"))->valuestring : "";
+		//mid.psize = cJSON_GetObjectItem(pData, _T("packet_size")) ? cJSON_GetObjectItem(pData, _T("packet_size"))->valuestring : "";
+		memset(szData, 0, 10);
+		_itoa_s(cJSON_GetObjectItem(pData, _T("packet_size")) ? cJSON_GetObjectItem(pData, _T("packet_size"))->valueint : 0, szData, 10);
+		mid.psize = szData;
+
+		cJSON_Delete(pJson);
+		pJson = NULL;
+
+		return 0;
+	}
+
+	// http请求异常;
+	return -1;
+}
+void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes, std::string pid)
 {
 	// 读取文件;
 	FILE* pf = NULL;
@@ -225,21 +317,27 @@ void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes)
 	//////////////////////////////////////////////////////////////////////////
 	// 解析Json;
 	cJSON *pItem = NULL;
-	cJSON *pKeys = cJSON_GetObjectItem(pJson, "");
-	if ( pKeys )
+	int nCount = cJSON_GetArraySize(pJson);
+	for ( int i = 0; i < nCount; i++ )
 	{
-		int nCount = cJSON_GetArraySize(pKeys);
-		for ( int i = 0; i < nCount; i++ )
+		pItem = cJSON_GetArrayItem(pJson, i);
+		if ( pItem )
 		{
-			pItem = cJSON_GetArrayItem(pKeys, i);
-			if ( pItem )
+			STKeys key;
+			key.pid = pid;
+			// 序列号;
+			key.sn = cJSON_GetObjectItem(pItem, _T("sn")) ? cJSON_GetObjectItem(pItem, _T("sn"))->valuestring : "";
+			cJSON *pJsonKeys = cJSON_GetObjectItem(pItem, _T("key"));
+			if ( pJsonKeys )
 			{
-				STKeys key;
-				// 序列号;
-				key.sn = cJSON_GetObjectItem(pItem, _T("sn")) ? cJSON_GetObjectItem(pItem, _T("sn"))->valuestring : "";
-				key.keys = cJSON_GetObjectItem(pItem, _T("keys")) ? cJSON_GetObjectItem(pItem, _T("keys"))->valuestring : "";
-				vtKyes.push_back(key);
+				char *lpszKeys = cJSON_Print(pJsonKeys);
+				if ( lpszKeys)
+				{
+					key.keys = lpszKeys;
+					free(lpszKeys);
+				}
 			}
+			vtKyes.push_back(key);
 		}
 	}
 
@@ -277,7 +375,6 @@ bool CSDK::ParserSNKey(std::string json, SNKeys &snKey)
 	return bRet;
 }
 
-
 DWORD CSDK::ThreadDownload(LPVOID lpParam)
 {
 	CSDK *that = (CSDK*)lpParam;
@@ -292,32 +389,34 @@ DWORD CSDK::ThreadDownload(LPVOID lpParam)
 
 			// 判断文件是否存在,并检验md5值;
 			_stprintf_s(szKeyPacket, _T("%scache\\%s.json"), Global::g_szCurModuleDir, mid.order.c_str());
-			if ( _taccess(szKeyPacket, 0) != -1 )
+ 			if ( _taccess(szKeyPacket, 0) != -1 )
 			{
-				// 校验文件md5值;
-				std::string fileMd5 = GetFileMD5(szKeyPacket);
-				if ( _tcsicmp(fileMd5.c_str(), mid.pmd5.c_str()) == 0 )
+				if ( CheckDownload(szKeyPacket, mid) )
 				{
-					// 文件下载成功,批量插入数据库;
-					std::vector<STKeys> vtKeys;
-					ParserKey(szKeyPacket, vtKeys);
-					if ( vtKeys.size() )
+					// 弹出任务;
+					AutoThreadSection ats(&g_csTask);
+					if ( m_vtMidTask.size() )
 					{
-						CDataImpl db;
-						if ( db.Open() )
-						{
-							db.BatchInsertKeyInfo(vtKeys);
-						}
+						m_vtMidTask.pop_front();
 					}
 					continue;
 				}
+
+				// 文件大小相同,删除文件;
+				struct stat fst;
+				if ( stat(szKeyPacket, &fst) == 0 )
+				{
+					if ( atoi(mid.psize.c_str()) == fst.st_size )
+						DeleteFile(szKeyPacket);
+				}
 			}
-			else
-			{
-				// 文件不存在,开始下载;
-			}
+
+			// 文件不存在,开始下载;
+			CCurlClient curl;
+			curl.Initialize();
+			curl.DownloadEx(mid.purl, szKeyPacket);
 		}
-	} while (WaitForSingleObject(that->m_hDownloadEvent, 3000) == WAIT_TIMEOUT );
+	} while (WaitForSingleObject(that->m_hDownloadEvent, 5000) == WAIT_TIMEOUT );
 
 	return 0L;
 }

+ 6 - 2
scbc.tools/scbc.tools/SDK.h

@@ -4,6 +4,7 @@
 #pragma once
 
 #include "TableInfo.h"
+#include "CurlClient.h"
 
 class CSDK
 {
@@ -19,13 +20,16 @@ public:
 	int UpdateKeyReportStatus(std::string sn, int status = 1);
 	int ReportKeyCopyResults(std::string sn = "");
 
-	static void ParserKey(std::string file, std::vector<STKeys> &vtKyes);
+	int GetMidInfo(std::string order, STMid &mid);
+	static void ParserKey(std::string file, std::vector<STKeys> &vtKyes, std::string pid);
 	static bool ParserSNKey(std::string json, SNKeys &snKey);
 private:
+	CCurlClient m_curl;
 	static std::list<STMid> m_vtMidTask;
 	static void AddDownloadTask(STMid &mid);
 	static BOOL PopDownloadTask(STMid &mid);
-
+	static bool CheckDownload(std::string file, STMid& mid);
+	
 	HANDLE m_hDownloadEvent;
 	HANDLE m_hThreadDownload;
 	static DWORD WINAPI ThreadDownload(LPVOID lpParam);

+ 1 - 1
scbc.tools/scbc.tools/TableInfo.h

@@ -49,7 +49,7 @@ typedef struct __ST_KEYS__
 {
 	std::string		sn;								// sn;
 	std::string		keys;							// key包Json字符串;
-	std::string		order;							// 订单号;
+	std::string		pid;							// project id;
 	std::string		copy_date;						// 抄写成功时间;
 	std::string		report_date;					// 上报时间;
 	std::string		copy_status;					// 抄写状态:0=未抄写、-1=抄写成失败、1=抄写成功;

+ 195 - 113
scbc.tools/scbc.tools/scbc.tools.cpp

@@ -19,6 +19,199 @@ CWinApp theApp;
 
 using namespace std;
 
+void TEST_GetMidInfo()
+{
+	CSDK sdk;
+	STMid mid;
+	if ( sdk.DownloadMidData("IDL144240G") )
+	{
+		
+	}
+
+	system("pause");
+}
+
+void TEST_InsertMidInfo()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STMid mid;
+		char szdata[10] = {0};
+		for ( int i = 0; i < 100; i++ )
+		{
+			_itoa_s(i, szdata, 10);
+			mid.order = szdata;
+			mid.ctype = szdata;
+			mid.version = "V8-SCBC098-LV1096";
+			mid.dsize = "100";
+			mid.number = "1000";
+			mid.pid = "102";
+			mid.pmd5 = "dfeqadfadfer546489er4adf";
+			mid.purl = "https://www.baidu.com";
+			db.InsertMidInfo(mid);
+		}
+
+		for ( int i = 0; i < 100; i++)
+		{
+			_itoa_s(i, szdata, 10);
+			db.UpdateKeyCopyStatus(szdata, 1);
+			if ( i%2 )
+				db.UpdateKeyReportStatus(szdata, 1);
+		}
+	}
+}
+
+void TEST_InertKeys()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STKeys keys;
+		char szdata[10] = {0};
+		db.TransactionBegin();
+		for ( int i = 0; i < 50000; i++ )
+		{
+			_itoa_s(i, szdata, 10);
+			keys.sn = szdata;
+			keys.keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
+			db.InsertKeyInfo(keys);
+		}
+		db.TransactionCommit();
+	}
+}
+
+void TEST_InertKeys2()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		char szdata[10] = {0};
+		OutputDebugString("批量插入数据\n");
+		OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
+		
+		std::vector<STKeys> vtKeys;
+		vtKeys.resize(200);
+		std::vector<STKeys>::iterator it = vtKeys.begin();
+		for ( int i = 0; it != vtKeys.end(); it++, i++ )
+		{
+			_itoa_s(i, szdata, 10);
+			it->pid = "1";
+			it->sn = szdata;
+			it->keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
+		}
+
+		OutputDebugString("开始批量插入数据\n");
+		OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
+		db.BatchInsertKeyInfo(vtKeys);
+		OutputDebugString("完成批量插入数据\n");
+		OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
+	}
+}
+
+void TEST_InertLog()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STLog log;
+		char szdata[10] = {0};
+		db.TransactionBegin();
+		for ( int i = 0; i < 200; i++ )
+		{
+			_itoa_s(i, szdata, 10);
+			log.sn = szdata;
+			log.type = "1";
+			log.content = "测试内容:东方丽景散热地觚单位 加菲软糖加工厂饮用水";
+			if ( i%2 )
+				log.report_status = "1";
+			else
+				log.report_status = "0";
+			log.report_date = "";
+			db.InsertLogInfo(log);
+		}
+		db.TransactionCommit();
+
+		std::vector<STLog> vtLog;
+		db.QueryUnReportLogInfo(vtLog);
+		db.UpdateLogReportStatus("0", "1", 1);
+	}
+}
+
+void TEST_QueryMidInfo()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STMid mid;
+		db.QueryMidInfo("1", mid);
+	}
+}
+
+void TEST_QueryUnReportKey()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		std::vector<STKeys> vtKeys;
+		db.QueryUnReportKeyInfo(vtKeys);
+		std::vector<STKeys>::iterator it = vtKeys.begin();
+		for (; it != vtKeys.end(); it++ )
+		{
+			OutputDebugString("SN:");
+			OutputDebugString(it->sn.c_str());
+			OutputDebugString("\t");
+
+			OutputDebugString("copy_date:");
+			OutputDebugString(it->copy_date.c_str());
+			OutputDebugString("\t");
+
+			OutputDebugString("copy_status:");
+			OutputDebugString(it->copy_status.c_str());
+			OutputDebugString("\t");
+
+			OutputDebugString("report_date:");
+			OutputDebugString(it->report_date.c_str());
+			OutputDebugString("\t");
+
+			OutputDebugString("report_status:");
+			OutputDebugString(it->report_status.c_str());
+			OutputDebugString("\n");
+		}
+	}
+}
+
+void TEST_QueryKeyInfo()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STKeys key;
+		db.QueryKeyInfo("1", key);
+	}
+}
+
+void TEST_QueryLogInfo()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		STKeys log;
+		db.QueryKeyInfo("1", log);
+	}
+}
+
+void TEST_QueryUnReportLogInfo()
+{
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		std::vector<STLog> vtlog;
+		db.QueryUnReportLogInfo(vtlog);
+	}
+}
+
+
 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 {
 	int nRetCode = 0;
@@ -34,120 +227,9 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	{
 		std::string md5 = GetFileMD5("D:\\bin\\scbc.tools\\scbc.tools.pdb");
 		// TODO: 在此处为应用程序的行为编写代码。
-		CDataImpl db;
-		if ( db.Open() )
-		{
-			STMid mid;
-			char szdata[100] = {0};
-			for ( int i = 0; i < 100; i++ )
-			{
-				_itoa_s(i, szdata, 10);
-				mid.order = szdata;
-				mid.ctype = szdata;
-				mid.version = "V8-SCBC098-LV1096";
-				mid.dsize = "100";
-				mid.number = "1000";
-				mid.pid = "102";
-				mid.pmd5 = "dfeqadfadfer546489er4adf";
-				mid.purl = "https://www.baidu.com";
-				db.InsertMidInfo(mid);
-			}
-
-			db.QueryMidInfo("1", mid);
-			OutputDebugString("查询描述:");
-			OutputDebugString(mid.des.c_str());
-			OutputDebugString("\n");
+		TEST_GetMidInfo();
 
-#if 0
-			STKeys keys;
-			db.TransactionBegin();
-			for ( int i = 0; i < 50000; i++ )
-			{
-				_itoa_s(i, szdata, 10);
-				keys.sn = szdata;
-				keys.keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
-				db.InsertKeyInfo(keys);
-			}
-			db.TransactionCommit();
-#else
-			OutputDebugString("批量插入数据\n");
-			OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
-			std::vector<STKeys> vtKeys;
-			vtKeys.resize(200);
-			std::vector<STKeys>::iterator it = vtKeys.begin();
-			for ( int i = 0; it != vtKeys.end(); it++, i++ )
-			{
-				_itoa_s(i, szdata, 10);
-				it->order = "1";
-				it->sn = szdata;
-				it->keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
-			}
-
-			OutputDebugString("开始批量插入数据\n");
-			OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
-			db.BatchInsertKeyInfo(vtKeys);
-			OutputDebugString("完成批量插入数据\n");
-			OutputDebugString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S\n"));
-#endif
-
-			for ( int i = 0; i < 100; i++)
-			{
-				_itoa_s(i, szdata, 10);
-				db.UpdateKeyCopyStatus(szdata, 1);
-				if ( i%2 )
-					db.UpdateKeyReportStatus(szdata, 1);
-			}
-
-			vtKeys.clear();
-			db.QueryUnReportKeyInfo(vtKeys);
-			it = vtKeys.begin();
-			for (; it != vtKeys.end(); it++ )
-			{
-				OutputDebugString("SN:");
-				OutputDebugString(it->sn.c_str());
-				OutputDebugString("\t");
-
-				OutputDebugString("copy_date:");
-				OutputDebugString(it->copy_date.c_str());
-				OutputDebugString("\t");
-
-				OutputDebugString("copy_status:");
-				OutputDebugString(it->copy_status.c_str());
-				OutputDebugString("\t");
-
-				OutputDebugString("report_date:");
-				OutputDebugString(it->report_date.c_str());
-				OutputDebugString("\t");
-
-				OutputDebugString("report_status:");
-				OutputDebugString(it->report_status.c_str());
-				OutputDebugString("\n");
-			}
-
-#if 1
-			STLog log;
-			db.TransactionBegin();
-			for ( int i = 0; i < 200; i++ )
-			{
-				_itoa_s(i, szdata, 10);
-				log.sn = szdata;
-				log.type = "1";
-				log.content = "测试内容:东方丽景散热地觚单位 加菲软糖加工厂饮用水";
-				if ( i%2 )
-					log.report_status = "1";
-				else
-					log.report_status = "0";
-				log.report_date = "";
-				db.InsertLogInfo(log);
-			}
-			db.TransactionCommit();
-
-			std::vector<STLog> vtLog;
-			db.QueryUnReportLogInfo(vtLog);
-
-			db.UpdateLogReportStatus("0", "1", 1);
-#endif
-		}
+		
 	}
 
 	return nRetCode;