Selaa lähdekoodia

完善接口;

Jeff 5 vuotta sitten
vanhempi
commit
9fbf6d842e
2 muutettua tiedostoa jossa 65 lisäystä ja 45 poistoa
  1. 42 45
      scbc.tools/scbc.tools/scbc.tools.cpp
  2. 23 0
      scbc.tools/scbc.tools/scbc.tools.h

+ 42 - 45
scbc.tools/scbc.tools/scbc.tools.cpp

@@ -83,6 +83,7 @@ void TEST_InertKeys()
 		for ( int i = 0; i < 50000; i++ )
 		{
 			_itoa_s(i, szdata, 10);
+			keys.bid = "1";
 			keys.pid = "102";
 			keys.sn = szdata;
 			keys.keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
@@ -106,6 +107,7 @@ void TEST_InertKeys2()
 		for ( int i = 0; it != vtKeys.end(); it++, i++ )
 		{
 			_itoa_s(i, szdata, 10);
+			it->bid = "1";
 			it->pid = "102";
 			it->sn = szdata;
 			it->keys = "{\"did\":\"did\",\"mac\":\"mac\",\"cikey\":\"cikey\",\"hdcp\":\"hdcp\",\"hdcp22\":\"hdcp22\",\"widi\":\"widi\",\"esn\":\"esn\",\"widevine\":\"widevine\"}";
@@ -128,6 +130,7 @@ void TEST_InertLog()
 		for ( int i = 0; i < 200; i++ )
 		{
 			_itoa_s(i, szdata, 10);
+			log.bid = "1";
 			log.sn = szdata;
 			log.type = "1";
 			log.content = "测试内容:东方丽景散热地觚单位 加菲软糖加工厂饮用水";
@@ -184,7 +187,7 @@ void TEST_QueryKeyInfo()
 	{
 		STKeys key;
 		db.QueryKeyInfo("1", key);
-		printf("查询SNKey=>sn=%s,pid=%s,keys=%s, copy_date=%s, report_date=%s \n", 
+		printf("查询SNKey=>bid=%s, sn=%s,pid=%s,keys=%s, copy_date=%s, report_date=%s \n", key.bid.c_str(),
 			key.sn.c_str(), key.pid.c_str(), key.keys.c_str(), key.copy_date.c_str(), key.report_date.c_str());
 	}
 }
@@ -196,7 +199,7 @@ void TEST_QueryLogInfo()
 	{
 		STLog log;
 		db.QueryLogInfo("1", log);
-		printf("查询Log=>sn=%s,type=%s, content=%s, gdate=%s, report_date=%s \n", 
+		printf("查询Log=>bid=%s, sn=%s,type=%s, content=%s, gdate=%s, report_date=%s \n", log.bid.c_str(),
 			log.sn.c_str(), log.type.c_str(), log.content.c_str(), log.gdate.c_str(), log.report_date.c_str());
 
 	}
@@ -212,7 +215,7 @@ void TEST_QueryUnReportLogInfo()
 		std::vector<STLog>::iterator it = vtlog.begin();
 		for (; it != vtlog.end(); it++)
 		{
-			printf("查询Log=>sn=%s,type=%s, content=%s, gdate=%s, report_date=%s \n", 
+			printf("查询Log=>bid=%s, sn=%s,type=%s, content=%s, gdate=%s, report_date=%s \n", it->bid.c_str(),
 				it->sn.c_str(), it->type.c_str(), it->content.c_str(), it->gdate.c_str(), it->report_date.c_str());
 		}
 	}
@@ -236,8 +239,8 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 		// TODO: 在此处为应用程序的行为编写代码。
 		//Sleep(10000);
 		//TEST_Download();
-		TEST_GetMidInfo();
-		/*
+		//TEST_GetMidInfo();
+		
 		TEST_InsertMidInfo();
 		TEST_QueryMidInfo();
 		TEST_InertKeys();
@@ -247,7 +250,7 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 		TEST_QueryUnReportKey();
 		TEST_QueryLogInfo();
 		TEST_QueryUnReportLogInfo();
-		*/
+	
 	}
 
 	system("pause");
@@ -272,43 +275,7 @@ int DownloadMidData(const char* lpOrder)
 	if ( lpOrder == NULL || lpOrder[0] == '\0' )
 		return -1;
 	
-	STMid host_mid;
-	// 1、直接http请求数据mid data;
-	// ...
-
-	// 2、查询数据库是否有该批次,有则更新,无则插入;
-	CDataImpl db;
-	if ( !db.Open() )
-		return -2;
-
-	STMid local_mid;
-	int nRow = db.QueryMidInfo(lpOrder, local_mid);
-	if ( nRow == -1)
-		return -3;
-
-	if ( nRow == 0 )
-	{
-		// 新增;
-		db.InsertMidInfo(host_mid);
-	}
-	else if ( nRow == 1 )
-	{
-		// 已下载完成,退出;
-		if ( _tcsicmp(local_mid.status.c_str(), "1") == 0 )
-			return 0;
-
-		// 更新;
-		db.UpdateMidInfo(host_mid);
-	}
-
-	// 3、key文件包是否存在,存在判断md5值,相同则下载成功;否则启动后台线程开始下载;
-	if ( _tcsicmp(host_mid.pmd5.c_str(), local_mid.pmd5.c_str()) != 0 )
-	{
-		// 线程是否正在下载,如果是删除该任务;同时删除文件;
-		
-	}
-
-	return 0;
+	return g_sdk.DownloadMidData(lpOrder);
 }
 
 int QueryKeyInfo(const char* lpSN, SNKeys &snKeys)
@@ -320,6 +287,7 @@ int QueryKeyInfo(const char* lpSN, SNKeys &snKeys)
 	int nRet = g_sdk.QueryKeyInfo(lpSN, keys);
 	if ( nRet == 1 )
 	{
+		snKeys.pid = atoi(keys.pid.c_str());
 		nRet = CSDK::ParserSNKey(keys.keys, snKeys);
 	}
 
@@ -331,7 +299,7 @@ int UpdateKeyCopyStatus(const char* lpSN)
 	if ( lpSN == NULL || lpSN[0] == '\0' )
 		return -1;
 
-	return g_sdk.UpdateKeyCopyStatus(lpSN, 1);
+	return g_sdk.UpdateKeyCopyStatus(lpSN);
 }
 
 int UpdateKeyReportStatus(const char* lpSN)
@@ -339,12 +307,41 @@ int UpdateKeyReportStatus(const char* lpSN)
 	if ( lpSN == NULL || lpSN[0] == '\0' )
 		return -1;
 
-	return g_sdk.UpdateKeyReportStatus(lpSN, 1);
+	return g_sdk.UpdateKeyReportStatus(lpSN);
 }
 
 int ReportKeyCopyResults(const char* lpSN)
 {
+	if ( lpSN == NULL || lpSN[0] == '\0' )
+		return -1;
+
 	return 0;
 }
 
+int QueryBidInfo(const char* lpOrder, BidInfo& binfo)
+{
+	if ( lpOrder == NULL || lpOrder[0] == '\0' )
+		return -1;
+
+	CDataImpl db;
+	if ( db.Open() )
+	{
+		int nRet = db.QueryBidInfo(lpOrder, binfo);
+		if ( nRet == 0 )
+			return 0;
+		else if ( nRet == -1 )
+			return -3;
+		else if ( nRet == 1 )
+			return 1;
+		else if ( nRet > 1 )
+			return -4;
+	}
+
+	return -2;
+}
+
+int RemoveBidData(const char* lpOrder)
+{
+	return 0;
+}
 #endif

+ 23 - 0
scbc.tools/scbc.tools/scbc.tools.h

@@ -90,3 +90,26 @@ extern SCBCTOOLS_API int UpdateKeyReportStatus(const char* lpSN);
 	上报成功后,需调用UpdateKeyReportStatus更新上报状态;
 */
 extern SCBCTOOLS_API int ReportKeyCopyResults(const char* lpSN);
+
+/*
+描述:查询批次信息:总sn数、实际sn数、抄写成功数量、上报成功数量;
+参数:lpOrder 批次号; binfo 返回的bid信息;
+返回:
+	0=表示订单不存在数据库中;
+	1=表示获取bid信息成功;
+	-1=表示lpOrder参数空;
+	-2=表示打开数据库失败;
+	-3=表示查询订单出错;
+	-4=表示数据异常;
+*/
+extern SCBCTOOLS_API int QueryBidInfo(const char* lpOrder, BidInfo& binfo);
+
+/*
+描述:删除批次相关的所有表数量;
+参数:lpOrder 批次号;
+返回:
+	0=表示上报抄写结果失败
+	1=表示上报抄写结果成功;
+	上报成功后,需调用UpdateKeyReportStatus更新上报状态;
+*/
+extern SCBCTOOLS_API int RemoveBidData(const char* lpOrder);