#ifndef __SDK_HEADER__
#define __SDK_HEADER__

#pragma once

#include "TableInfo.h"
#include "CurlClient.h"

class CSDK
{
public:
	CSDK(void);
	~CSDK(void);

public:
	int QueryMidInfo(std::string order);
	int DownloadMidData(std::string order);
	int QueryKeyInfo(std::string sn, STKeys &keys);
	int UpdateKeyCopyStatus(std::string sn );
	int UpdateKeyReportStatus(std::string sn);
	int ReportKeyCopyResults(std::string sn = "");

	int GetMidInfo(std::string order, STMid &mid);
	static int ReportDownloadStatus(std::string order);
	static void ParserKey(std::string file, std::vector<STKeys> &vtKyes, STMid& mid);
	static bool ParserSNKey(std::string json, SNKeys &snKey);
private:
	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);
	void EndDowloadThread();

	HANDLE m_hReportEvent;
	HANDLE m_hThreadReport;
	static DWORD WINAPI ThreadReport(LPVOID lpParam);
	void EndReportThread();
};

#endif