AUDataManage.h 1.76 KB
#pragma once
#include "stdafx.h"
//#include "afxinet.h" 


#define WM_UPDATEPROCESS WM_USER + 1
#define WM_CRASH_CLOSE	 WM_USER + 2

#define PROCESS_KILLCLIENT		1
#define PROCESS_DOWNLOADFILE	2
#define PROCESS_DELETEOLDFILE	3
#define PROCESS_UNZIP			4
#define PROCESS_COMPLETE		5

typedef struct STU_CONFIG 
{
	CString sAppName;
	CString sSelfName;
	CString sVersion;
	CString sTempDir;
	CString sZipName;
	CString sAppDir;

	STU_CONFIG operator= (STU_CONFIG& stuConfig)
	{
		sAppName = stuConfig.sAppName;
		sSelfName = stuConfig.sSelfName;
		sVersion = stuConfig.sVersion;
		sTempDir = stuConfig.sTempDir;
		sZipName = stuConfig.sZipName;
		sAppDir = stuConfig.sAppDir;
		return *this;
	}
}APPConfig;

enum ClientType
{
	CRAD_CLIENT = 0,
	SHOP_CLIENT,
	CENTRAL_CLIENT
};

extern void Log(CString sLog);

class CAUDataManage
{
public:
	static CAUDataManage *Instantialize();
	static void DestoryInstance();
	~CAUDataManage();

public:
	BOOL CheckVersion();
	void Update();
	void RestartClient();

private:
	CAUDataManage();
	CAUDataManage(const CAUDataManage &);
	CAUDataManage& operator = (const CAUDataManage &);

	BOOL KillCilent(CString sName);
	BOOL DownloadClientFile();
	void CreateTempFolder();
	void DeleteDirectory(CString sDirectory);
	CString GetModulePath();
	void ReplaceClientFile(CString sAppDir);
	APPConfig ReadConfig(CString sConfigName);
	void CopyClientFile(CString sSrcFile, CString sDstFile);
	//void DownloadFile(CString sSrcFile, CString sDstFile, CFtpConnection *pFtpConnection);

private:
	static CAUDataManage *m_pInstance;
	static CCriticalSection m_csLocker;

	CString m_sConfigFilePath;
	CString m_sConfigFileName;
	BOOL Unzip(CString sSrcDir, CString sDstDir);

public:
	APPConfig m_stuLocalConfigData;
	APPConfig m_stuRemoteConfigData;
	ClientType m_ClientType;
};