Kaynağa Gözat

添加微信ado数据库连接库。

Jeff 6 yıl önce
ebeveyn
işleme
fc948acd67

+ 84 - 0
source/hook/WxAdoInterface/CritSection.h

@@ -0,0 +1,84 @@
+#ifndef __CRITSECTION_20160221__
+#define __CRITSECTION_20160221__
+
+// ÁÙ½çÖµ;
+class ThreadSection
+{
+public:
+	ThreadSection(){
+		HRESULT hr = Init();
+		(hr);
+	}
+
+	~ThreadSection(){
+		DeleteCriticalSection(&_CriticalSection);
+	}
+
+	bool Lock()
+	{
+		bool result = false;
+		__try
+		{
+			EnterCriticalSection(&_CriticalSection);
+			result = true;
+		}
+		__except (STATUS_NO_MEMORY == GetExceptionCode())
+		{
+		}
+		return result;
+	}
+
+	bool Unlock()
+	{
+		bool result = false;
+		__try
+		{
+			LeaveCriticalSection(&_CriticalSection);
+			result = true;
+		}
+		__except (STATUS_NO_MEMORY == GetExceptionCode())
+		{
+		}
+		return result;
+	}
+
+private:
+	HRESULT Init() throw()
+	{
+		HRESULT hRes = E_FAIL;
+		__try
+		{
+			InitializeCriticalSection(&_CriticalSection);
+			hRes = S_OK;
+		}
+		__except (STATUS_NO_MEMORY == GetExceptionCode())
+		{
+			hRes = E_OUTOFMEMORY;
+		}
+		return hRes;
+	}
+
+	ThreadSection(const ThreadSection & tSection);
+	ThreadSection &operator=(const ThreadSection & tSection);
+	CRITICAL_SECTION _CriticalSection;
+};
+
+
+class AutoThreadSection
+{
+public:
+	AutoThreadSection(IN ThreadSection* pSection){
+		_pSection = pSection;
+		_pSection->Lock();
+	}
+
+	~AutoThreadSection(){
+		_pSection->Unlock();
+	}
+private:
+	AutoThreadSection(const AutoThreadSection & tSection);
+	AutoThreadSection &operator=(const AutoThreadSection & tSection);
+	ThreadSection * _pSection;
+};
+
+#endif //__CRITSECTION_20160221__

+ 184 - 0
source/hook/WxAdoInterface/Global.cpp

@@ -0,0 +1,184 @@
+#include "StdAfx.h"
+#include "Global.h"
+#include "CritSection.h"
+#include <locale.h>
+
+namespace Global
+{
+
+	TCHAR g_szModulePath[MAX_PATH] = _T("");			// 软件目录;
+	TCHAR g_szModuleFileName[MAX_PATH] = _T("");		// 软件名称;
+	TCHAR g_szConnectString[MAX_PATH] = _T("");			// DB连接串;
+	// 服务器信息;
+	TCHAR g_szDBSource[MAX_PATH] = _T("");				// 数据库源(服务所在IP或计算机名);
+	TCHAR g_szDBSourcePort[MAX_PATH] = _T("");			// 数据库源端口;
+	DWORD g_dwDBServerPort = 0;							// 数据库源端口;
+	TCHAR g_szDBAccount[MAX_PATH] = _T("");				// 数据库登录用户;
+	TCHAR g_szDBPassWord[MAX_PATH] = _T("");			// 数据库登录密码;
+	TCHAR g_szDBName[MAX_PATH] = _T("");				// 数据库名称;	
+	DWORD g_dwDBPoolMaxCount = 1;						// 数据库连接池最大对象数;
+	DWORD g_dwDBPoolDef = 1;							// 数据库连接池默认对象数;
+
+	/************************************************************************/
+	/*  函数:[5/20/2016 IT];
+	/*  描述:;
+	/*  参数:;
+	/*  	[IN] :;
+	/*  	[OUT] :;
+	/*  	[IN/OUT] :;
+	/*  返回:void;
+	/*  注意:;
+	/*  示例:;
+	/*
+	/*  修改:;
+	/*  日期:;
+	/*  内容:;
+	/************************************************************************/
+	int GetIniInfo(const TCHAR *szPath, const TCHAR *szIniName)
+	{
+		TCHAR szDrive[_MAX_DRIVE] = {0};
+		TCHAR szDir[_MAX_DIR] = {0};
+		TCHAR szFName[_MAX_FNAME] = {0};
+		TCHAR szExt[_MAX_EXT] = {0};
+		::GetModuleFileName(NULL, g_szModulePath, sizeof(g_szModulePath) / sizeof(TCHAR));
+		_stprintf_s(g_szModulePath, MAX_PATH, _T("%s"), g_szModulePath);
+
+		_tsplitpath_s(g_szModulePath, szDrive, szDir, szFName, szExt);
+		_tcscpy_s(g_szModulePath, szDrive);
+		_tcscat_s(g_szModulePath, szDir);
+
+		// -----------------------------------------------------//
+		TCHAR szIniPath[MAX_PATH] = {0};
+		if (szPath != NULL && szIniName != NULL)
+			_stprintf_s(szIniPath, _T("%s%s"), szPath, szIniName);
+		else
+			_stprintf_s(szIniPath, _T("%sServiceInfo.ini"), g_szModulePath);
+
+		HANDLE hFile = CreateFile(szIniPath, 0/*GENERIC_READ*/, 0, NULL, OPEN_EXISTING, 0, NULL);
+		if (ERROR_FILE_NOT_FOUND == GetLastError())
+		{
+			return -1;
+		}
+		CloseHandle(hFile);
+
+		// 获取服务器端信息;
+		GetPrivateProfileString(_T("DatabaseInfo"), _T("dbSource"), _T(""), g_szDBSource, MAX_PATH, szIniPath);
+		g_dwDBServerPort = GetPrivateProfileInt(_T("DatabaseInfo"), _T("dbServerPort"), 0, szIniPath);
+		GetPrivateProfileString(_T("DatabaseInfo"), _T("dbAccount"), _T(""), g_szDBAccount, MAX_PATH, szIniPath);
+		GetPrivateProfileString(_T("DatabaseInfo"), _T("dbPassWord"), _T(""), g_szDBPassWord, MAX_PATH, szIniPath);
+		GetPrivateProfileString(_T("DatabaseInfo"), _T("dbName"), _T(""), g_szDBName, MAX_PATH, szIniPath);
+
+		g_dwDBPoolMaxCount = GetPrivateProfileInt(_T("DatabaseInfo"), _T("dbpoolMaxObj"), 1, szIniPath);
+		g_dwDBPoolDef = GetPrivateProfileInt(_T("DatabaseInfo"), _T("dbpoolDef"), 1, szIniPath);
+
+		if (g_dwDBServerPort != 0)
+		{
+			if ( _tcscmp(g_szDBAccount, _T("")) == 0 )
+				_stprintf_s(g_szConnectString, DB_SW_CONN_WITH_PORT, g_szDBSource, g_dwDBServerPort,g_szDBName);
+			else
+				_stprintf_s(g_szConnectString, DB_SS_CONN_WITH_PORT,g_szDBSource, g_dwDBServerPort, g_szDBName, g_szDBAccount, g_szDBPassWord);
+		}
+		else
+		{
+			if ( _tcscmp(g_szDBAccount, _T("")) == 0 )
+				_stprintf_s(g_szConnectString, DB_SW_CONN_WITHOUT_PORT, g_szDBSource, g_szDBName);
+			else
+				_stprintf_s(g_szConnectString, DB_SS_CONN_WITHOUT_PORT,g_szDBSource, g_szDBName, g_szDBAccount, g_szDBPassWord);
+		}
+
+		return 0;
+	}
+
+	/************************************************************************/
+	/*  函数:WriteTextLog[7/28/2016 IT];
+	/*  描述:写文本日志;
+	/*  参数:;
+	/*  	[IN] :;
+	/*  返回:void;
+	/*  注意:;
+	/*  示例:;
+	/*
+	/*  修改:;
+	/*  日期:;
+	/*  内容:;
+	/************************************************************************/
+	void WriteTextLog(const TCHAR *format, ...)
+	{
+		try
+		{
+			static ThreadSection _critSection;
+			AutoThreadSection aSection(&_critSection);
+			// 解析出日志路径;
+			TCHAR szlogpath[MAX_PATH] = {0};
+			static TCHAR szModulePath[MAX_PATH] = {0};
+			static TCHAR szFna[_MAX_DIR] = { 0 };
+			if ( szModulePath[0] == _T('\0') )
+			{
+				TCHAR szDrive[_MAX_DRIVE] = { 0 };
+				TCHAR szDir[_MAX_DIR] = { 0 };
+				TCHAR szExt[_MAX_DIR] = { 0 };
+				::GetModuleFileName(NULL, szModulePath, sizeof(szModulePath) / sizeof(TCHAR));
+				_tsplitpath_s(szModulePath, szDrive, szDir, szFna, szExt);
+				_tcscpy_s(szModulePath, szDrive);
+				_tcscat_s(szModulePath, szDir);
+			}
+
+			_stprintf_s(szlogpath, _T("%s%s.txt"), szModulePath, szFna);
+
+			// 打开或创建文件;
+			CStdioFile fp;
+			if (PathFileExists(szlogpath))
+			{
+				if (fp.Open(szlogpath, CFile::modeWrite) == FALSE)
+				{
+					return;
+				}
+				fp.SeekToEnd();
+			}
+			else
+			{
+				if ( !fp.Open(szlogpath, CFile::modeCreate | CFile::modeWrite) )
+					return;
+			}
+
+			// 格式化前设置语言区域;
+			TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+			_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+			// 格式化日志内容;
+			va_list		args = NULL;
+			int			len = 0;
+			TCHAR		*buffer = NULL;
+			va_start( args, format );
+			// _vscprintf doesn't count. terminating '\0'
+			len = _vsctprintf_p( format, args );
+			if ( len == -1 )
+			{
+				goto clear;
+			}
+
+			len++;
+			buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+			_vstprintf_s( buffer, len, format, args ); // C4996
+			// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+			// 将日志内容输入到文件中;
+			fp.WriteString( CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S ")) );
+			fp.WriteString(buffer);
+			fp.WriteString(_T("\n"));
+
+			// 关闭文件,释放资源并设置回原语言区域;
+			free( buffer );
+clear:
+			_tsetlocale(LC_CTYPE, old_locale);
+			free(old_locale);//还原区域设定;
+			fp.Close();
+		}
+		catch (CException *e)
+		{
+			e->ReportError();
+			e->Delete();
+		}
+	}
+
+};

+ 39 - 0
source/hook/WxAdoInterface/Global.h

@@ -0,0 +1,39 @@
+#ifndef __GLOBAL_20160918__
+#define __GLOBAL_20160918__
+
+#pragma once
+
+#ifdef USE_ODBC
+#define DB_SS_CONN_WITH_PORT		_T("driver={SQL Server};Server=%s,%d;database=%s;uid=%s;pwd=%s")
+#define DB_SS_CONN_WITHOUT_PORT		_T("driver={SQL Server};Server=%s;database=%s;uid=%s;pwd=%s")
+#define DB_SS_CONN_WITHOUT_PORT2	_T("driver={SQL Server};Server=%s;database=%d;uid=%s;pwd=%s")
+#define DB_SW_CONN_WITH_PORT		_T("Driver={SQL Server};Server=%s,%d;Database=%s;Trusted_Connection=yes;")
+#define DB_SW_CONN_WITHOUT_PORT		_T("Driver={SQL Server};Server=%s;Database=%s;Trusted_Connection=yes;")
+#define DB_SW_CONN_WITHOUT_PORT2	_T("Driver={SQL Server};Server=%s;Database=%d;Trusted_Connection=yes;")
+#else
+#define DB_SS_CONN_WITH_PORT		_T("Provider=sqloledb;Data Source=%s,%ld;Initial Catalog=%s;User Id=%s;Password=%s; ")
+#define DB_SS_CONN_WITHOUT_PORT		_T("Provider=sqloledb;Data Source=%s;Initial Catalog=%s;User Id=%s;Password=%s; ")
+#define DB_SS_CONN_WITHOUT_PORT2	_T("Provider=sqloledb;Data Source=%s,%ld;Initial Catalog=%s;User Id=%s;Password=%s; ")
+#define DB_SW_CONN_WITH_PORT		_T("Provider=sqloledb;Data Source=%s;Initial Catalog=%s;User Id=%s;Password=%s; ")
+#define DB_SW_CONN_WITHOUT_PORT		_T("Provider=sqloledb;Data Source=%s;Initial Catalog=%s;Trusted_Connection=yes;")
+#define DB_SW_CONN_WITHOUT_PORT2	_T("Provider=sqloledb;Data Source=%s;Initial Catalog=%d;Trusted_Connection=yes;")
+#endif
+namespace Global
+{
+	extern TCHAR g_szModulePath[MAX_PATH];			// 软件目录;
+	extern TCHAR g_szModuleFileName[MAX_PATH];		// 软件名称;
+	extern TCHAR g_szConnectString[MAX_PATH];		// DB连接串;
+	// 服务器信息;
+	extern TCHAR g_szDBSource[MAX_PATH];			// 数据库源(服务所在IP或计算机名);
+	extern TCHAR g_szDBSourcePort[MAX_PATH];		// 数据库源端口;
+	extern DWORD g_dwDBServerPort;					// 数据库源端口;
+	extern TCHAR g_szDBAccount[MAX_PATH];			// 数据库登录用户;
+	extern TCHAR g_szDBPassWord[MAX_PATH];			// 数据库登录密码;
+	extern TCHAR g_szDBName[MAX_PATH];				// 数据库名称;	
+	extern DWORD g_dwDBPoolMaxCount;				// 数据库连接池最大对象数;
+	extern DWORD g_dwDBPoolDef;						// 数据库连接池默认对象数;
+	extern int GetIniInfo(const TCHAR *szPath = NULL, const TCHAR *szIniName = NULL);
+	extern void WriteTextLog(const TCHAR *format, ...);
+};
+
+#endif

+ 83 - 0
source/hook/WxAdoInterface/IWxAdoInterface.h

@@ -0,0 +1,83 @@
+/************************************************************************/
+/*  Copyright (C), 2016-2020, [IT], 保留所有权利;
+/*  模 块 名:;
+/*  描    述:;
+/*
+/*  版    本:[V];	
+/*  作    者:[IT];
+/*  日    期:[9/20/2016];
+/*
+/*
+/*  注    意:;
+/*
+/*  修改记录:[IT];
+/*  修改日期:;
+/*  修改版本:;
+/*  修改内容:;
+/************************************************************************/
+#ifndef __WXADO_INTERFACE__
+#define __WXADO_INTERFACE__
+
+#pragma once
+
+// <string>和<vector>命名空间最好放在stdafx.h头文件中,不然可能产生编译错误;
+#include <string>
+#include <vector>
+using namespace std;
+
+#ifndef _UNICODE
+	typedef string TString;
+#else
+	typedef wstring TString;
+#endif
+
+// {FD137BAF-FE58-42ba-95E8-0BA64DCEA1D0}
+static const GUID IID_IWxAdoInterface =
+{ 0xfd137baf, 0xfe58, 0x42ba, { 0x95, 0xe8, 0xb, 0xa6, 0x4d, 0xce, 0xa1, 0xd0 } };
+
+
+interface IWxAdoInterface:public IUnknown
+{
+public:
+	virtual DWORD InitializePool( 
+		IN LPCTSTR lpDBSource, 
+		IN CONST DWORD &dwDBPort, 
+		IN LPCTSTR lpDBAccount, 
+		IN LPCTSTR lpPassWord, 
+		IN LPCTSTR lpDBName, 
+		IN CONST INT &nMinConn = 1, 
+		IN CONST INT &nMaxConn = 5) = 0;
+	virtual void ReleasePool() = 0;
+	virtual BOOL ExecuteSQL( IN LPCTSTR lpExcuteSQL, IN CONST DWORD &dwTimeOut = 30000 ) = 0;
+	virtual BOOL IsUserExist( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut = 3000 ) = 0;
+	virtual INT QueryUserDetail(IN LPCTSTR lpStudioID, IN LPVOID lpUserDetail, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryUserDetail( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut = 3000 ) = 0;
+	virtual INT QueryDepartmentInfo( IN LPCTSTR lpStudioID, OUT LPVOID lpOutDepartmentInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryStaffInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStaffInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryUserInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutUserInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryProductType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductType, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryProductInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QuerySceneryInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSceneryInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryPackageType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageType, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryPackageInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryPackageItemsView(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryPackageItemsDetail(IN LPCTSTR lpStudioID, IN LPCTSTR lpPackageSN, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryCustomerType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerFrom, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryCustomerInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryOrderType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderType, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryOrderInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryOrderScenery(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderScenery, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryOrderPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderPackageItems, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QuerySysConfig(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSysConfig, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryLog(IN LPCTSTR lpStudioID, OUT LPVOID lpOutLog, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT QueryStudioInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStudioInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual INT SupQueryStudioInfo(OUT LPVOID lpOutStudioInfo, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryMaxOrderId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	virtual INT QueryMaxPrintId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut = 3000) = 0;
+	//////////////////////////////////////////////////////////////////////////
+	virtual BOOL InsertStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD& dwTimeOut = 3000 ) = 0;
+	virtual BOOL UpdateStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD& dwTimeOut = 3000) = 0;
+};
+
+#endif

+ 16 - 0
source/hook/WxAdoInterface/Resource.h

@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// 供 WxAdoInterface.rc 使用
+//
+
+// 新对象的下一组默认值
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE	1000
+#define _APS_NEXT_CONTROL_VALUE		1000
+#define _APS_NEXT_SYMED_VALUE		1000
+#define _APS_NEXT_COMMAND_VALUE		32771
+#endif
+#endif

+ 92 - 0
source/hook/WxAdoInterface/SafeList.h

@@ -0,0 +1,92 @@
+#ifndef __SAFE_LIST__
+#define __SAFE_LIST__
+
+#include <list>
+#include <locale.h>
+#include "CritSection.h"
+
+class CDatabase;
+using namespace std;
+
+template <class _Ty,class _Ax = allocator<_Ty>>
+class SafeList: public std::list<_Ty, _Ax>
+{
+public:
+	ThreadSection _critSection;
+	void _push_back(const _Ty& _Val)
+	{
+		AutoThreadSection aSection(&_critSection);
+		push_back(_Val);
+	}
+
+	void _push_front(const _Ty& _Val)
+	{
+		AutoThreadSection aSection(&_critSection);
+		push_front(_Val);
+	}
+
+	void _pop_front()
+	{
+		AutoThreadSection aSection(&_critSection);
+		pop_front();
+	}
+
+	_Ty _pop_front_()
+	{
+		AutoThreadSection aSection(&_critSection);
+		if (size())
+		{
+			_Ty it = front();
+			pop_front();
+			return it;
+		}
+
+		return NULL;
+	}
+
+	void _pop_back()
+	{
+		AutoThreadSection aSection(&_critSection);
+		pop_back();
+	}
+
+	void _remove(const _Ty& _Val_arg)
+	{
+		AutoThreadSection aSection(&_critSection);
+		remove(_Val_arg);
+	}
+
+	reference _front()
+	{
+		AutoThreadSection aSection(&_critSection);
+		return (*begin());
+	}
+
+	const_reference _front() const
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*begin());
+	}
+
+	reference _back()
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*(--end()));
+	}
+
+	const_reference _back() const
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*(--end()));
+	}
+
+	size_type _size()
+	{	
+		//AutoThreadSection aSection(&_critSection);
+		return size();
+	}
+};
+
+typedef SafeList<CDatabase*> ODBCConnectList;
+
+#endif // __SAFE_LIST__

+ 774 - 0
source/hook/WxAdoInterface/WxAdoImpl.cpp

@@ -0,0 +1,774 @@
+#include "StdAfx.h"
+#include "WxAdoImpl.h"
+#include "Global.h"
+#include "WxAdoPool.h"
+
+
+#define GETDBPTR(dwTimeOut) \
+pAdoObj pObj = NULL;\
+CAdoConnGuard tagConnGuard(pObj, dwTimeOut);\
+if ( pObj == NULL)\
+	return FALSE\
+
+enum UserLogInStatus
+{
+	USER_LOGIN		= 1,				// 登录成功;
+	USER_PW_MISTAKE = 2,				// 密码错误;
+	USER_NULL		= 0					// 没有用户;
+};
+
+CWxAdoImpl* CWxAdoImpl::m_pInstance = NULL;
+CWxAdoImpl::CWxAdoImpl(void):m_nRef(0),m_nObjRef(0)
+{
+
+}
+
+CWxAdoImpl::~CWxAdoImpl(void)
+{
+}
+
+ULONG CWxAdoImpl::AddRef()
+{
+	InterlockedIncrement( &m_nRef ); //增加引用计数;
+	return m_nRef;
+}
+
+ULONG CWxAdoImpl::Release()
+{
+	InterlockedDecrement( &m_nRef ); //减少引用计数;
+	//如果为0,删除对象
+	if( m_nRef == 0 )
+	{
+		delete this;
+	}
+	return m_nRef;
+}
+
+HRESULT CWxAdoImpl::QueryInterface(REFIID refiid, void **ppvObject)
+{
+	if (IID_IUnknown == refiid)
+	{
+		*ppvObject = this;
+	}
+	else if (IID_IWxAdoInterface == refiid)
+	{
+		*ppvObject = (IWxAdoInterface*)this;
+	}
+	else 
+	{
+		*ppvObject = NULL;
+		return E_NOINTERFACE;
+	}
+	((IUnknown*)(*ppvObject))->AddRef();
+
+	return NOERROR;
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void CWxAdoImpl::SolveDBError( IN CONST DWORD &dwError, IN LPVOID pDBConn)
+{
+	switch(dwError)
+	{
+	//case SQL_ERROR://这个错误比较难精确判断问题;
+	case ERROR_PIPE_NOT_CONNECTED:
+	case WSAECONNRESET:
+	case WSAECONNABORTED:
+	{
+		pAdoObj pObj = (pAdoObj)pDBConn;
+		CWxAdoPool::GetInstance()->CloseBusyConnection(pObj);
+#if _DEBUG
+		OutputDebugString(_T("关闭数据库连接\n"));
+#endif
+	}
+		break;
+	default:
+		break;
+	}
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+DWORD CWxAdoImpl::InitializePool( IN LPCTSTR lpDBSource, IN CONST DWORD &dwDBPort, IN LPCTSTR lpDBAccount, IN LPCTSTR lpPassWord, IN LPCTSTR lpDBName, IN CONST INT &nMinConn /* = 1 */, IN CONST INT &nMaxConn /* = 5 */ )
+{
+	return CWxAdoPool::GetInstance()->InitializePool(lpDBSource, dwDBPort, lpDBAccount, lpPassWord, lpDBName, nMinConn, nMaxConn);
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void CWxAdoImpl::ReleasePool()
+{
+	CWxAdoPool::GetInstance()->ReleasePool();
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL CWxAdoImpl::ExecuteSQL( IN LPCTSTR lpExcuteSQL, IN CONST DWORD &dwTimeOut /* = 30000 */ )
+{
+	GETDBPTR(dwTimeOut);
+
+	try
+	{
+		if ( lpExcuteSQL == NULL )
+			return FALSE;
+
+		pObj->pCommand->CommandText = _bstr_t(lpExcuteSQL);
+		// 执行SQL语句,返回记录集
+		pObj->pCommand->Execute(NULL, NULL, adCmdText);
+	}
+	catch (CDBException* e)
+	{
+		//Global::WriteTextLog(_T("%s,%d,%s:%s"), __FILE__, __LINE__, __FUNCTION__, e->m_strError);
+		Global::WriteTextLog(_T("%s\n%s"), lpExcuteSQL, e->m_strError);
+		SolveDBError(e->m_nRetCode, pObj);
+		e->Delete();
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL CWxAdoImpl::IsUserExist( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut /* = 3000 */ )
+{
+	
+
+	return TRUE;
+}
+
+INT CWxAdoImpl::QueryUserDetail(IN LPCTSTR lpStudioID, IN LPVOID lpUserDetail, IN CONST DWORD & dwTimeOut)
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryUserDetail( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut /* = 3000 */ )
+{
+	
+
+	return USER_NULL;
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryDepartmentInfo( IN LPCTSTR lpStudioID, OUT LPVOID lpOutDepartmentInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/25/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryStaffInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStaffInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/28/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryUserInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutUserInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryProductType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductType, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryProductInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QuerySceneryInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSceneryInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryPackageType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageType, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryPackageInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageInfo, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[9/30/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/5/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryPackageItemsView(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD & dwTimeOut)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/5/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryPackageItemsDetail(IN LPCTSTR lpStudioID, IN LPCTSTR lpPackageSN, OUT LPVOID lpOutPackageItems, IN CONST DWORD & dwTimeOut)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/5/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryCustomerType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerFrom, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/5/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryCustomerInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut /* = 3000 */)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/5/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryOrderType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderType, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/16/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryOrderInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/16/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryOrderScenery(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderScenery, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut /* = 3000 */)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/16/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryOrderPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderPackageItems, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut /* = 3000 */)
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/16/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QuerySysConfig(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSysConfig, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/16/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryLog(IN LPCTSTR lpStudioID, OUT LPVOID lpOutLog, IN CONST DWORD& dwTimeOut /* = 3000 */ )
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/27/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryStudioInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStudioInfo, IN CONST DWORD & dwTimeOut)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/27/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::SupQueryStudioInfo(OUT LPVOID lpOutStudioInfo, IN CONST DWORD & dwTimeOut)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[2/26/2017 Jeff];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryMaxOrderId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut /* = 3000 */)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[2/26/2017 Jeff];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+INT CWxAdoImpl::QueryMaxPrintId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut /* = 3000 */)
+{
+	
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[10/27/2016 IT];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL CWxAdoImpl::InsertStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD & dwTimeOut)
+{
+	
+	
+	return FALSE;
+}
+
+BOOL CWxAdoImpl::UpdateStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD & dwTimeOut)
+{
+	
+	return FALSE;
+}
+
+/*
+GETDBPTR(dwTimeOut);
+try
+{
+
+}
+catch (CDBException* e)
+{
+e->ReportError();
+SolveDBError(e->m_nRetCode, pDatabase);
+e->Delete();
+return FALSE;
+}
+return TRUE;
+*/

+ 96 - 0
source/hook/WxAdoInterface/WxAdoImpl.h

@@ -0,0 +1,96 @@
+/************************************************************************/
+/*  Copyright (C), 2016-2020, [IT], 保留所有权利;
+/*  模 块 名:;
+/*  描    述:;
+/*
+/*  版    本:[V];	
+/*  作    者:[IT];
+/*  日    期:[9/20/2016];
+/*
+/*
+/*  注    意:;
+/*
+/*  修改记录:[IT];
+/*  修改日期:;
+/*  修改版本:;
+/*  修改内容:;
+/************************************************************************/
+#ifndef __ODBCPTR_20160920__
+#define __ODBCPTR_20160920__
+
+//class CDatabase;
+#include "IWxAdoInterface.h"
+
+#pragma once
+
+
+class AFX_EXT_CLASS CWxAdoImpl:public IWxAdoInterface
+{
+	CWxAdoImpl(void);
+public:
+	~CWxAdoImpl(void);
+	ULONG	STDMETHODCALLTYPE AddRef( );
+	ULONG	STDMETHODCALLTYPE Release( );
+	HRESULT STDMETHODCALLTYPE QueryInterface(REFIID refiid, void **ppvObject);
+
+	// 获取实例指针;
+	static CWxAdoImpl* GetInstance(){
+		if ( m_pInstance == NULL )
+			m_pInstance = new CWxAdoImpl;
+		return m_pInstance;
+	}
+
+private:
+	volatile LONG m_nRef;
+	volatile LONG m_nObjRef;
+	// 单例实例;
+	static CWxAdoImpl* m_pInstance;
+
+	void SolveDBError( IN CONST DWORD &dwError, IN LPVOID pDBConn);
+public:
+	// 初始化所有连接;
+	DWORD InitializePool( 
+		IN LPCTSTR lpDBSource, 
+		IN CONST DWORD &dwDBPort, 
+		IN LPCTSTR lpDBAccount, 
+		IN LPCTSTR lpPassWord, 
+		IN LPCTSTR lpDBName, 
+		IN CONST INT &nMinConn = 1, 
+		IN CONST INT &nMaxConn = 5
+		);
+	// 关闭所有连接;
+	void ReleasePool();
+
+	BOOL ExecuteSQL( IN LPCTSTR lpExcuteSQL, IN CONST DWORD &dwTimeOut = 30000 );
+	BOOL IsUserExist( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut = 3000 );
+	INT QueryUserDetail(IN LPCTSTR lpStudioID, IN LPVOID lpUserDetail, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryUserDetail( IN LPCTSTR lpStudioID, IN LPCTSTR lpAccount, IN LPCTSTR lpPassword, OUT LPVOID lpOutUserInfo,IN CONST DWORD &dwTimeOut = 3000 );
+	INT QueryDepartmentInfo( IN LPCTSTR lpStudioID, OUT LPVOID lpOutDepartmentInfo, IN CONST DWORD& dwTimeOut = 3000  );
+	INT QueryStaffInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStaffInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryUserInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutUserInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryProductType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductType, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryProductInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutProductInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QuerySceneryInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSceneryInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryPackageType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageType, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryPackageInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryPackageItemsView(IN LPCTSTR lpStudioID, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryPackageItemsDetail(IN LPCTSTR lpStudioID, IN LPCTSTR lpPackageSN, OUT LPVOID lpOutPackageItems, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryCustomerType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerFrom, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryCustomerInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutCustomerInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryOrderType(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderType, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryOrderInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderInfo, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryOrderScenery(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderScenery, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryOrderPackageItems(IN LPCTSTR lpStudioID, OUT LPVOID lpOutOrderPackageItems, IN LPCTSTR lpFilter, IN CONST DWORD& dwTimeOut = 3000);
+	INT QuerySysConfig(IN LPCTSTR lpStudioID, OUT LPVOID lpOutSysConfig, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryLog(IN LPCTSTR lpStudioID, OUT LPVOID lpOutLog, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryStudioInfo(IN LPCTSTR lpStudioID, OUT LPVOID lpOutStudioInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT SupQueryStudioInfo(OUT LPVOID lpOutStudioInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	INT QueryMaxOrderId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut = 3000);
+	INT QueryMaxPrintId(IN LPCTSTR lpStudioID, IN CONST DWORD& dwTimeOut = 3000);
+	//////////////////////////////////////////////////////////////////////////
+	BOOL InsertStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD& dwTimeOut = 3000 );
+	BOOL UpdateStudioInfo(IN LPVOID lpStudioInfo, IN CONST DWORD& dwTimeOut = 3000);
+};
+
+#endif

+ 86 - 0
source/hook/WxAdoInterface/WxAdoInterface.cpp

@@ -0,0 +1,86 @@
+// WxAdoInterface.cpp: 定义 DLL 的初始化例程。
+//
+
+#include "stdafx.h"
+#include "WxAdoInterface.h"
+#include "IWxAdoInterface.h"
+#include "WxAdoImpl.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+//
+//TODO:  如果此 DLL 相对于 MFC DLL 是动态链接的,
+//		则从此 DLL 导出的任何调入
+//		MFC 的函数必须将 AFX_MANAGE_STATE 宏添加到
+//		该函数的最前面。
+//
+//		例如: 
+//
+//		extern "C" BOOL PASCAL EXPORT ExportedFunction()
+//		{
+//			AFX_MANAGE_STATE(AfxGetStaticModuleState());
+//			// 此处为普通函数体
+//		}
+//
+//		此宏先于任何 MFC 调用
+//		出现在每个函数中十分重要。  这意味着
+//		它必须作为以下项中的第一个语句:
+//		出现,甚至先于所有对象变量声明,
+//		这是因为它们的构造函数可能生成 MFC
+//		DLL 调用。
+//
+//		有关其他详细信息,
+//		请参阅 MFC 技术说明 33 和 58。
+//
+
+// CWxAdoInterfaceApp
+
+BEGIN_MESSAGE_MAP(CWxAdoInterfaceApp, CWinApp)
+END_MESSAGE_MAP()
+
+
+// CWxAdoInterfaceApp 构造
+
+CWxAdoInterfaceApp::CWxAdoInterfaceApp()
+{
+	// TODO:  在此处添加构造代码,
+	// 将所有重要的初始化放置在 InitInstance 中
+}
+
+
+// 唯一的 CWxAdoInterfaceApp 对象
+
+CWxAdoInterfaceApp theApp;
+
+
+// CWxAdoInterfaceApp 初始化
+
+BOOL CWxAdoInterfaceApp::InitInstance()
+{
+	CWinApp::InitInstance();
+
+	::CoInitialize(NULL);//初始化COM环境  
+
+	return TRUE;
+}
+
+extern "C" IWxAdoInterface* PASCAL EXPORT CreateWxAdoPoolInstance()
+{
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
+	// 此处为普通函数体
+ 	IWxAdoInterface *pInstance = CWxAdoImpl::GetInstance();
+ 	if (pInstance != NULL)
+ 		pInstance->AddRef();
+ 
+ 	return pInstance;
+	return NULL;
+}
+
+int CWxAdoInterfaceApp::ExitInstance()
+{
+	// TODO: 在此添加专用代码和/或调用基类
+	::CoUninitialize();
+	return CWinApp::ExitInstance();
+}

+ 7 - 0
source/hook/WxAdoInterface/WxAdoInterface.def

@@ -0,0 +1,7 @@
+; WxAdoInterface.def: 声明 DLL 的模块参数。
+
+LIBRARY
+
+EXPORTS
+    ; 此处可以是显式导出
+	CreateWxAdoPoolInstance

+ 28 - 0
source/hook/WxAdoInterface/WxAdoInterface.h

@@ -0,0 +1,28 @@
+// WxAdoInterface.h: WxAdoInterface DLL 的主标头文件
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+	#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
+#endif
+
+#include "resource.h"		// 主符号
+
+
+// CWxAdoInterfaceApp
+// 有关此类实现的信息,请参阅 WxAdoInterface.cpp
+//
+
+class CWxAdoInterfaceApp : public CWinApp
+{
+public:
+	CWxAdoInterfaceApp();
+
+// 重写
+public:
+	virtual BOOL InitInstance();
+
+	DECLARE_MESSAGE_MAP()
+	virtual int ExitInstance();
+};

BIN
source/hook/WxAdoInterface/WxAdoInterface.rc


+ 229 - 0
source/hook/WxAdoInterface/WxAdoInterface.vcxproj

@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>15.0</VCProjectVersion>
+    <ProjectGuid>{B3C0BF00-C99D-4CC1-BABE-842914F0D9D6}</ProjectGuid>
+    <Keyword>MFCDLLProj</Keyword>
+    <RootNamespace>WxAdoInterface</RootNamespace>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+    <UseOfMfc>Dynamic</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+    <UseOfMfc>Dynamic</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <UseOfMfc>Dynamic</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+    <UseOfMfc>Dynamic</UseOfMfc>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>..\..\..\..\bin\$(SolutionName)\</OutDir>
+    <IntDir>$(OutDir)$(ProjectName)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>..\..\..\..\bin\$(SolutionName)\</OutDir>
+    <IntDir>$(OutDir)$(ProjectName)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_AFXEXT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <ModuleDefinitionFile>.\WxAdoInterface.def</ModuleDefinitionFile>
+    </Link>
+    <Midl>
+      <MkTypLibCompatible>false</MkTypLibCompatible>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </Midl>
+    <ResourceCompile>
+      <Culture>0x0804</Culture>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ResourceCompile>
+    <PostBuildEvent>
+      <Command>xcopy $(TargetDir)$(ProjectName).lib $(SolutionDir)WxService\ /Y /A</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <ModuleDefinitionFile>.\WxAdoInterface.def</ModuleDefinitionFile>
+    </Link>
+    <Midl>
+      <MkTypLibCompatible>false</MkTypLibCompatible>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </Midl>
+    <ResourceCompile>
+      <Culture>0x0804</Culture>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ResourceCompile>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_AFXEXT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <ModuleDefinitionFile>.\WxAdoInterface.def</ModuleDefinitionFile>
+    </Link>
+    <Midl>
+      <MkTypLibCompatible>false</MkTypLibCompatible>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </Midl>
+    <ResourceCompile>
+      <Culture>0x0804</Culture>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ResourceCompile>
+    <PostBuildEvent>
+      <Command>xcopy $(TargetDir)$(ProjectName).lib $(SolutionDir)WxService\ /Y /A</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <ModuleDefinitionFile>.\WxAdoInterface.def</ModuleDefinitionFile>
+    </Link>
+    <Midl>
+      <MkTypLibCompatible>false</MkTypLibCompatible>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </Midl>
+    <ResourceCompile>
+      <Culture>0x0804</Culture>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ResourceCompile>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="WxAdoImpl.cpp" />
+    <ClCompile Include="WxAdoPool.cpp" />
+    <ClCompile Include="Global.cpp" />
+    <ClCompile Include="stdafx.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="WxAdoInterface.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="res\WxAdoInterface.rc2" />
+    <None Include="WxAdoInterface.def" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="CritSection.h" />
+    <ClInclude Include="WxAdoImpl.h" />
+    <ClInclude Include="WxAdoPool.h" />
+    <ClInclude Include="Global.h" />
+    <ClInclude Include="IWxAdoInterface.h" />
+    <ClInclude Include="Resource.h" />
+    <ClInclude Include="SafeList.h" />
+    <ClInclude Include="stdafx.h" />
+    <ClInclude Include="targetver.h" />
+    <ClInclude Include="WxAdoInterface.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="WxAdoInterface.rc" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 79 - 0
source/hook/WxAdoInterface/WxAdoInterface.vcxproj.filters

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="源文件">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="头文件">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
+    </Filter>
+    <Filter Include="资源文件">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="WxAdoInterface.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="stdafx.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="Global.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="WxAdoPool.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="WxAdoImpl.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="WxAdoInterface.def">
+      <Filter>源文件</Filter>
+    </None>
+    <None Include="res\WxAdoInterface.rc2">
+      <Filter>资源文件</Filter>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="stdafx.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="Resource.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="WxAdoInterface.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="CritSection.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="Global.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="SafeList.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="IWxAdoInterface.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="WxAdoPool.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="WxAdoImpl.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="WxAdoInterface.rc">
+      <Filter>资源文件</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+</Project>

+ 241 - 0
source/hook/WxAdoInterface/WxAdoPool.cpp

@@ -0,0 +1,241 @@
+#include "StdAfx.h"
+#include "WxAdoPool.h"
+#include "Global.h"
+
+//////////////////////////////////////////////////////////////////////////
+CWxAdoPool::CWxAdoPool()
+{
+	m_nRef = 0;
+	m_nObjRef = 0;
+
+	m_nMaxCount = 0;
+	m_nMinCount = 0;
+
+	m_bNeedExit = FALSE;
+	m_bNeedStop = FALSE;
+	m_bNeedConnection = FALSE;
+}
+
+CWxAdoPool::~CWxAdoPool()
+{
+	DestroyAllDBConnections();
+}
+
+DWORD CWxAdoPool::InitializePool(IN LPCTSTR lpDBSource, IN CONST DWORD &dwDBPort, IN LPCTSTR lpDBAccount, IN LPCTSTR lpPassWord, IN LPCTSTR lpDBName, IN CONST INT &nMinConn /* = 1 */, IN CONST INT &nMaxConn /* = 5 */)
+{
+	if ( !lpDBSource || lpDBSource[0] == _T('\0') || !lpDBName || lpDBName[0] == _T('\0') )
+	{
+		return 0;
+	}
+
+	m_strDBSource = lpDBSource;
+	m_dwDBPort = dwDBPort;
+	m_strDBAccount = lpDBAccount;
+	m_strPassWord = lpPassWord;
+	m_strDBName = lpDBName;
+
+	m_nMinCount = nMinConn;
+	m_nMaxCount = nMaxConn;
+
+	return IntiAllConnections();
+}
+
+void CWxAdoPool::ReleasePool()
+{
+	DestroyAllDBConnections();
+}
+
+INT CWxAdoPool::IntiAllConnections()
+{
+	DestroyAllDBConnections();
+
+#if USE_ODBC
+	// 开始按照最小数量开始创建;
+	int nCount = 0;
+	CDatabase *pDatabase = NULL;
+	for (int i = 0; i < m_nMinCount; i++)
+	{
+		pDatabase = InitAConnection();
+		if ( pDatabase )
+		{
+			nCount++;
+			m_listIdleConnections._push_back(pDatabase);
+			InterlockedIncrement(&m_nObjRef);	//增加引用计数;
+			pDatabase = NULL;
+		}
+	}
+#else
+	int nCount = 0;
+	pAdoObj pDatabase = NULL;
+	for ( int i = 0; i < m_nMinCount; i++)
+	{
+		pDatabase = InitAConnection();
+		if (pDatabase)
+		{
+			nCount++;
+			m_listIdleConnections._push_back(pDatabase);
+			InterlockedIncrement(&m_nObjRef);
+			pDatabase = NULL;
+		}
+	}
+#endif
+
+	return nCount;
+}
+
+void CWxAdoPool::DestroyAllDBConnections()
+{
+	m_bNeedExit = TRUE;
+	// 首先等待m_listBusyConnections.size() == 0;
+	while(1)
+	{
+		if ( m_listBusyConnections.size() == 0 )
+			break;
+		Sleep(1000);
+	}
+	
+	AdoConnList::iterator itIdle = m_listIdleConnections.begin();
+	while (itIdle != m_listIdleConnections.end())
+	{
+		if (NULL != (*itIdle))
+		{
+			(*itIdle)->pConnection->Close();
+			delete (*itIdle);
+		}
+		itIdle = m_listIdleConnections.erase(itIdle);
+	}
+	
+	m_bNeedExit = FALSE;
+}
+
+pAdoObj CWxAdoPool::GetAConnection( IN CONST DWORD &dwTimeOut /* = 1000 */ )
+{
+	if ( m_bNeedExit )// 停止获取;
+		return NULL;
+
+	// 1.首先到池中查找有无空闲对象;
+	BOOL bGetIdl = FALSE;
+	DWORD dwTime = GetTickCount();
+	pAdoObj pConnection = NULL;
+	do 
+	{
+		if ( m_listIdleConnections._size() > 0){
+			//AutoThreadSection aSection(&m_critSection);
+			pConnection = m_listIdleConnections._pop_front_();
+			if (pConnection)
+			{
+				m_listBusyConnections._push_back(pConnection);
+				bGetIdl = TRUE;
+			}
+		}
+		else 
+		{
+			if (m_nObjRef < m_nMaxCount)
+			{
+				//AutoThreadSection aSection(&m_critSection);
+				pConnection = InitAConnection();
+				if (pConnection){
+					//bGetIdl = TRUE;
+					m_listBusyConnections._push_back(pConnection);
+					InterlockedIncrement(&m_nObjRef);	//增加引用计数;
+					Global::WriteTextLog(_T("创建连接对象:共有 %d 个"), m_nObjRef);
+					break;
+				}
+			}
+		}
+
+		if ( !bGetIdl )	{
+			// 未找到,小憩一会,防止CPU爆满;
+			Sleep(0);
+			// 超时,则结束返回NULL;
+			if ( (GetTickCount() - dwTime) >= dwTimeOut){
+				Global::WriteTextLog(_T("获取连接对象超时"));
+				break;
+			}
+		}
+	} while ( !bGetIdl );
+	
+	return pConnection;
+}
+
+void CWxAdoPool::RestoreAConnection(IN pAdoObj pObj)
+{
+	if (pObj != NULL ){
+		m_listBusyConnections._remove(pObj);
+		if (pObj->pConnection->GetState() != adStateClosed)
+			m_listIdleConnections._push_back(pObj);
+		else
+			delete pObj;
+	}
+}
+
+pAdoObj CWxAdoPool::InitAConnection()
+{
+	if ( m_nObjRef == m_nMaxCount )
+		return NULL;
+
+	pAdoObj pObj = new AdoObj;
+	pObj->pConnection.CreateInstance(__uuidof(Connection));
+
+	TCHAR szConnString[MAX_PATH] = {0};
+	if (m_dwDBPort != 0)
+	{
+		if ( m_strDBAccount.IsEmpty() )
+			_stprintf_s(szConnString, MAX_PATH, DB_SW_CONN_WITH_PORT, m_strDBSource, m_dwDBPort,m_strDBName);
+		else
+			_stprintf_s(szConnString, MAX_PATH, DB_SS_CONN_WITH_PORT,m_strDBSource, m_dwDBPort, m_strDBName, m_strDBAccount, m_strPassWord);
+	}
+	else
+	{
+		if ( m_strDBAccount.IsEmpty() )
+			_stprintf_s(szConnString, MAX_PATH, DB_SW_CONN_WITHOUT_PORT, m_strDBSource, m_strDBName);
+		else
+			_stprintf_s(szConnString, MAX_PATH, DB_SS_CONN_WITHOUT_PORT, m_strDBSource, m_strDBName, m_strDBAccount, m_strPassWord);
+	}
+
+	try
+	{
+		HRESULT hr = pObj->pConnection->Open(_bstr_t(szConnString), "", "", adModeUnknown);
+
+		if (FAILED(hr))
+		{
+			if (pObj)
+				delete pObj;
+			pObj = NULL;
+			return NULL;
+		}
+
+		pObj->pCommand.CreateInstance(__uuidof(Command));
+		// 将库连接赋于它;
+		pObj->pCommand->ActiveConnection = pObj->pConnection;
+	}
+	catch (_com_error &e)
+	{
+		_bstr_t bstrSource(e.Source());
+		_bstr_t bstrDescription(e.Description());
+		if (pObj)
+			delete pObj;
+		pObj = NULL;
+		Global::WriteTextLog(_T("SQL连接串:%08lx,%s,%s,%s"), e.Error(), e.ErrorMessage(), (TCHAR*)bstrSource, (TCHAR*)bstrDescription);
+	}
+
+	return pObj;
+}
+
+void CWxAdoPool::CloseAConnection(pAdoObj &pDataBase)
+{
+	m_listIdleConnections._remove(pDataBase);
+	InterlockedDecrement(&m_nObjRef);	// 减少计数;
+	if ( pDataBase )
+		delete pDataBase;
+
+	pDataBase = NULL;
+}
+
+void CWxAdoPool::CloseBusyConnection(IN pAdoObj &pDataBase)
+{
+	m_listBusyConnections._remove(pDataBase);
+	InterlockedDecrement(&m_nObjRef);	// 减少计数;
+	if ( pDataBase )
+		pDataBase->pConnection->Close();
+}

+ 104 - 0
source/hook/WxAdoInterface/WxAdoPool.h

@@ -0,0 +1,104 @@
+#ifndef __ODBC_POOL__
+#define __ODBC_POOL__
+
+#pragma once
+
+#include "SafeList.h"
+//#include <afxdb.h>
+
+typedef SafeList<AdoObj*> AdoConnList;
+
+class CWxAdoPool
+{
+	ThreadSection m_critSection;
+	// 空闲数据库连接池;
+	AdoConnList m_listIdleConnections;
+	// 在使用的数据库连接池;
+	AdoConnList m_listBusyConnections;
+
+	// 可用的指标:最大、最小;
+	INT m_nMaxCount;
+	INT m_nMinCount;
+
+	// 引入的指针变量;
+	DWORD m_dwDBPort;
+	CString m_strDBSource;
+	CString m_strDBAccount;
+	CString m_strPassWord;
+	CString m_strDBName;
+
+	BOOL m_bNeedExit;	// 退出数据池;
+	BOOL m_bNeedStop;
+	BOOL m_bNeedConnection;
+public:
+	CWxAdoPool(void) ;
+	~CWxAdoPool(void);
+
+	// 获取实例指针;
+	static CWxAdoPool* GetInstance()
+	{
+		static CWxAdoPool* pInstance = NULL;
+		if ( pInstance == NULL )
+			pInstance = new CWxAdoPool;
+
+		return pInstance;
+	}
+
+	// 初始化所有连接;
+	DWORD InitializePool( 
+		IN LPCTSTR lpDBSource, 
+		IN CONST DWORD &dwDBPort, 
+		IN LPCTSTR lpDBAccount, 
+		IN LPCTSTR lpPassWord, 
+		IN LPCTSTR lpDBName, 
+		IN CONST INT &nMinConn = 1, 
+		IN CONST INT &nMaxConn = 5
+		);
+
+	// 关闭所有连接;
+	void ReleasePool();
+
+	// 设置数据库信息;
+	void SetDBConnectionInfo(IN LPCTSTR lpDBSource, IN CONST DWORD &dwDBPort, IN LPCTSTR lpDBAccount, IN LPCTSTR lpPassWord, IN LPCTSTR lpDBName);
+	// 初始化所有连接;
+	INT IntiAllConnections();
+	// 断开所有连接;
+	void DestroyAllDBConnections();
+
+	// 获取一个空闲连接;
+	pAdoObj GetAConnection( IN CONST DWORD &dwTimeOut = 1000 );
+	// 交还连接给空闲队列;
+	void RestoreAConnection(IN pAdoObj pDBEngine);
+	// 关闭一个连接;
+	void CloseAConnection(pAdoObj &pDBEngine);
+	// 关闭使用的连接;
+	void CloseBusyConnection(IN pAdoObj &pDataBase);
+private:
+	volatile LONG m_nRef;
+	volatile LONG m_nObjRef;
+	// 创建一个连接;
+	pAdoObj InitAConnection();
+	// 将守卫类友元化;
+	friend class CAdoConnGuard;
+};
+
+// ODBC守卫垫片类;
+class CAdoConnGuard
+{
+	pAdoObj m_pAdoConn;
+public:
+	CAdoConnGuard(pAdoObj &pDBConn, CONST DWORD &dwTimeOut = 30000 ):m_pAdoConn(NULL)
+	{
+		pDBConn = CWxAdoPool::GetInstance()->GetAConnection( dwTimeOut );
+		m_pAdoConn = pDBConn;
+	}
+
+	virtual ~CAdoConnGuard()
+	{
+		CWxAdoPool::GetInstance()->RestoreAConnection(m_pAdoConn);
+	}
+};
+
+
+
+#endif // __SAFE_LIST__

BIN
source/hook/WxAdoInterface/res/WxAdoInterface.rc2


+ 7 - 0
source/hook/WxAdoInterface/stdafx.cpp

@@ -0,0 +1,7 @@
+// stdafx.cpp : 只包括标准包含文件的源文件
+// WxAdoInterface.pch 将作为预编译标头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+
+

+ 51 - 0
source/hook/WxAdoInterface/stdafx.h

@@ -0,0 +1,51 @@
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN            // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // 某些 CString 构造函数将是显式的
+
+#include <afxwin.h>         // MFC 核心组件和标准组件
+#include <afxext.h>         // MFC 扩展
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxole.h>         // MFC OLE 类
+#include <afxodlgs.h>       // MFC OLE 对话框类
+#include <afxdisp.h>        // MFC 自动化类
+#endif // _AFX_NO_OLE_SUPPORT
+
+#ifndef _AFX_NO_DB_SUPPORT
+#include <afxdb.h>                      // MFC ODBC 数据库类
+#endif // _AFX_NO_DB_SUPPORT
+
+#ifndef _AFX_NO_DAO_SUPPORT
+#include <afxdao.h>                     // MFC DAO 数据库类
+#endif // _AFX_NO_DAO_SUPPORT
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h>           // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                     // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+// Ado//由于MFC封装的ODBC不太好用;
+#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename_namespace("ADOCG") rename("EOF", "adoEOF")
+//#import "..\ado\msado15.dll" rename_namespace("ADOCG") rename("EOF", "adoEOF")
+#pragma warning (default: 4146)  // 微软建议不要理会这个错误;
+using namespace ADOCG;
+
+typedef struct __ADO__
+{
+	_ConnectionPtr pConnection;
+	_RecordsetPtr pRecordSet;
+	_CommandPtr pCommand;
+}AdoObj, *pAdoObj;

+ 8 - 0
source/hook/WxAdoInterface/targetver.h

@@ -0,0 +1,8 @@
+#pragma once
+
+// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
+
+// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
+// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
+
+#include <SDKDDKVer.h>