فهرست منبع

remove useless code

lihz 7 سال پیش
والد
کامیت
0c9822f191
23فایلهای تغییر یافته به همراه8 افزوده شده و 2250 حذف شده
  1. 0 262
      Card.cpp
  2. 0 45
      Card.h
  3. 0 137
      ClientSocket.cpp
  4. 0 46
      ClientSocket.h
  5. 0 468
      DBConnPool.cpp
  6. 0 134
      DBConnPool.h
  7. 0 62
      DownloadManager.h
  8. 0 244
      DownloadManagerImpl.cpp
  9. 0 72
      DownloadManagerImpl.h
  10. 0 28
      Log.cpp
  11. 0 61
      ProcessRemodule.cpp
  12. 0 10
      ProcessRemodule.h
  13. 0 28
      ServerSockert.cpp
  14. 0 24
      ServerSockert.h
  15. 7 154
      YAServerDlg.cpp
  16. 0 5
      YAServerDlg.h
  17. 0 207
      client_thread.cpp
  18. 0 92
      listening_thread.cpp
  19. 1 1
      mylog/MyLog.cpp
  20. 0 0
      pingme.txt
  21. 0 31
      send_content.cpp
  22. 0 54
      send_head.cpp
  23. 0 85
      sever_thread.cpp

+ 0 - 262
Card.cpp

@@ -1,262 +0,0 @@
-#include "StdAfx.h"
-#include "Card.h"
-
-
-CCard::CCard(void)
-{
-}
-
-
-CCard::~CCard(void)
-{
-}
-
-void CCard::getCordinate()
-{
-	//#include "stdio.h" 
-#include "stdlib.h" 
-#include <math.h> 
-	//坐标 
-	double ax,ay,bx,by,cx,cy,zx,zy; 
-	//距离 
-	double la,lb,lc; 
-	double cx1,cy1,cx2,cy2,cx3,cy3,cx4,cy4; 
-	int main(void) 
-	{ 
-		int i = 0,j = 0,n = 0; 
-		int okflag = 0; 
-		int err = 0; 
-		int aberr = 0; 
-		int acerr = 0; 
-		int abcerr = 0; 
-		int len; 
-		int abrequery = 0; 
-		int acrequery = 0; 
-		int requery1 = 0; 
-		int loopnum = 1; 
-		int option = 0; 
-		double cax,cay,cbx,cby,ccx,ccy; 
-		double cax_abeyance1[6000],cay_abeyance1[6000]; 
-		double cbx_abeyance1[6000],cby_abeyance1[6000]; 
-		double ccx_abeyance1[6000],ccy_abeyance1[6000]; 
-		double cabx_abeyance1[10],caby_abeyance1[10],cabx_abeyance2[10],caby_abeyance2[10]; 
-		double cacx_abeyance1[10],cacy_abeyance1[10],cacx_abeyance2[10],cacy_abeyance2[10]; 
-		//遍历圆周上所有点 
-		printf("use 'Enter' to divide x y\n"); 
-		printf("input A coordinate:\n"); 
-		scanf("%lf%lf",&ax,&ay); 
-		if((ax > 1000)||(bx > 1000)) 
-		{ 
-			printf("figure is too big! input A coordinate again:\n"); 
-			scanf("%lf%lf",&ax,&ay); 
-		} 
-		printf("input B coordinate:\n"); 
-		scanf("%lf%lf",&bx,&by); 
-		if((bx > 1000)||(bx > 1000)) 
-		{ 
-			printf("figure is too big! input B coordinate again:\n"); 
-			scanf("%lf,%lf",&bx,&by);   
-		} 
-		printf("input C coordinate:\n"); 
-		scanf("%lf%lf",&cx,&cy); 
-		if((cx > 1000)||(cx > 1000)) 
-		{ 
-			printf("figure is too big! input C coordinate again:\n"); 
-			scanf("%lf%lf",&cx,&cy); 
-		} 
-		printf("input distance from A to Z:\n"); 
-		scanf("%lf",&la); 
-		if(la > 1000) 
-		{ 
-			printf("figure is too big! inputdistance from A to Z again:\n"); 
-			scanf("%lf",&la); 
-		} 
-		printf("input distance from B to Z:\n"); 
-		scanf("%lf",&lb); 
-		if(lb > 1000) 
-		{ 
-			printf("figure is too big! inputdistance from B to Z again:\n"); 
-			scanf("%lf",&lb); 
-		} 
-		printf("input distance from C to Z:\n"); 
-		scanf("%lf",&lc); 
-		if(lc > 1000) 
-		{ 
-			printf("figure is too big! inputdistance from C to Z again:\n"); 
-			scanf("%lf",&lc); 
-		} 
-		printf("\n"); 
-		printf("A(%lf,%lf)\n",ax,ay); 
-		printf("B(%lf,%lf)\n",bx,by); 
-		printf("C(%lf,%lf)\n",cx,cy); 
-		printf("AZ = %lf\n",la); 
-		printf("BZ = %lf\n",lb); 
-		printf("CZ = %lf\n",lc); 
-		//INPUT: 
-		for(zx = ax -la;zx <= ax + la;zx++) 
-		{ 
-			do 
-			{ 
-				for(zy = ay -la;zy <= ay + la;zy++) 
-				{ 
-					cax = zx - ax; 
-					cax = fabs(cax); 
-					cax = pow(cax,2); 
-					cay = zy - ay; 
-					cay = fabs(cay); 
-					cay = pow(cay,2); 
-					if(((cax + cay) > (la*la - err))&&((cax + cay) < (la*la + err))) 
-					{ 
-						okflag = 1; 
-						cax_abeyance1[i] = zx; 
-						cay_abeyance1[i] = zy; 
-						n++; 
-					} 
-				} 
-				if(!okflag)err++; 
-			} while (okflag == 0); 
-			i++; 
-			err = 0; 
-			okflag = 0; 
-		} 
-		printf("query...\n"); 
-		i = 0; 
-		for(zx = bx -lb;zx <= bx + lb;zx++) 
-		{ 
-			do 
-			{ 
-				for(zy = by -lb;zy <= by + lb;zy++) 
-				{ 
-					cbx = zx - bx; 
-					cbx = fabs(cbx); 
-					cbx = pow(cbx,2); 
-					cby = zy - by; 
-					cby = fabs(cby); 
-					cby = pow(cby,2); 
-					if(((cbx + cby) > (lb*lb - err))&&((cbx + cby) < (lb*lb + err))) 
-					{ 
-						okflag = 1; 
-						cbx_abeyance1[i] = zx; 
-						cby_abeyance1[i] = zy; 
-					} 
-				} 
-				if(!okflag)err++;       
-			} while (okflag == 0); 
-			i++; 
-			err = 0; 
-			okflag = 0; 
-		} 
-		printf("query...\n"); 
-		getchar(); 
-		i = 0; 
-		for(zx = cx -lc;zx <= cx + lc;zx++) 
-		{ 
-			do 
-			{ 
-				for(zy = cy -lc;zy <= cy + lc;zy++) 
-				{ 
-					ccx = zx - cx; 
-					ccx = fabs(ccx); 
-					ccx = pow(ccx,2); 
-					ccy = zy - cy; 
-					ccy = fabs(ccy); 
-					ccy = pow(ccy,2); 
-					if(((ccx + ccy) > (lc*lc - err))&&((ccx + ccy) < (lc*lc + err))) 
-					{ 
-						okflag = 1; 
-
-						ccx_abeyance1[i] = zx; 
-						ccy_abeyance1[i] = zy; 
-						n++; 
-					} 
-				} 
-				if(!okflag)err++; 
-			} while (okflag == 0); 
-			i++; 
-			err = 0; 
-			okflag = 0; 
-		} 
-		printf("query a b c over!\n"); 
-		printf("press Enter to continue!\n"); 
-		//必须加不然运行出错,但不会停止 
-		getchar(); 
-		do 
-		{ 
-			//找ab 交点,因为距离的偏差,所以坐标会有偏差 
-			aberr =0; 
-			do 
-			{ 
-				for(i = 0;i <= 2*la;i++) 
-				{ 
-					for(j = 0;j <= 2*lb;j++) 
-					{ 
-						if(cax_abeyance1[i] == cbx_abeyance1[j]) 
-						{ 
-
-							if((cay_abeyance1[i]  >  (cby_abeyance1[j]  -  aberr  - abcerr))&&(cay_abeyance1[i] < (cby_abeyance1[j] + aberr + abcerr))) 
-							{ 
-								cabx_abeyance1[abrequery] = cax_abeyance1[i]; 
-								caby_abeyance1[abrequery] = cay_abeyance1[i]; 
-								printf("cabx_abeyance1[%d]=%f",abrequery,cabx_abeyance1[abrequery]); 
-								printf("caby_abeyance1[%d]=%f\n\n",abrequery,caby_abeyance1[abrequery]); 
-								abrequery++; 
-							} 
-						} 
-					} 
-				}   
-				if(abrequery < loopnum)aberr++; 
-			}while(abrequery < loopnum); 
-			acerr =0; 
-			//找ac 交点 
-			do 
-			{ 
-				for(i = 0;i <= 2*la;i++) 
-				{ 
-					for(j = 0;j <= 2*lc;j++) 
-					{ 
-						if(cax_abeyance1[i] == ccx_abeyance1[j]) 
-						{ 
-							if((cay_abeyance1[i]  >  (ccy_abeyance1[j]  -  acerr  - abcerr))&&(cay_abeyance1[i] < (ccy_abeyance1[j] + acerr + abcerr))) 
-							{ 
-								cacx_abeyance1[acrequery] = cax_abeyance1[i]; 
-								cacy_abeyance1[acrequery] = cay_abeyance1[i]; 
-								acrequery++; 
-							} 
-						} 
-					} 
-				} 
-				if(acrequery < loopnum)acerr++; 
-			}while(acrequery < loopnum); 
-			//找交点的交点 
-			for(i = 0;i < abrequery;i++) 
-			{ 
-				for(j = 0;j < acrequery;j++) 
-				{ 
-					if(cabx_abeyance1[i] == cacx_abeyance1[j]) 
-					{ 
-						requery1 = 1; 
-						printf("final result is (%f,%f)\n",cabx_abeyance1[i],caby_abeyance1[i]); 
-					} 
-				} 
-			} 
-			if(requery1 == 0) 
-			{ 
-				loopnum++; 
-				abcerr++; 
-			} 
-			if(loopnum == 10) 
-			{ 
-				printf("chech input figure is right\n"); 
-			} 
-		}while(requery1 ==0); 
-		printf("finish!\n"); 
-		getchar(); 
-		return 0; 
-	}  
-
-}
-
-int CCard::addReader( READERINFO* pReader )
-{
-
-}

+ 0 - 45
Card.h

@@ -1,45 +0,0 @@
-#pragma once
-
-#include <list>
-
-using namespace std;
-
-struct READERINFO{
-	double x;
-	double y;
-	double dist;
-};
-
-class CCard
-{
-public:
-	CCard(void);
-	virtual ~CCard(void);
-
-	LONG64 CardId;
-	int CardType;
-
-	LONG64 lTime;
-	int Power;
-	int RangingType;
-	int Acceleration;
-	double Distance;
-	WORD Timestamp;
-
-	WORD ReaderId;
-	WORD ReaderTimestamp;
-	int Antenna;
-
-	CString strRecTime; // ½ÓÊÕʱ¼ä
-	int X;
-	int Y;
-	int lastX;
-	int lastY;
-
-	STAFFER * pStaffer;
-	VEHICLE * pVehicle;
-
-public:
-	void getCordinate();
-};
-

+ 0 - 137
ClientSocket.cpp

@@ -1,137 +0,0 @@
-// ClientSocket.cpp : 实现文件
-//
-
-#include "stdafx.h"
-#include "YAServer.h"
-#include "ClientSocket.h"
-#include "YAServerDlg.h"
-#include "Functions/Functions.h"
-#include "socketdef.h"
-#include "socketdef.h"
-
-// CClientSocket
-
-CClientSocket::CClientSocket(CYAServerDlg* pDlg)
-{
-	m_pDlg = pDlg;
-	m_bClosed = FALSE;
-	bError = false;
-
-	m_wReadLength = 0;
-	m_wDataLength = 0;
-	m_wCharacterWord = 0;
-	reader_id = 0;
-	m_ReceiveBuffer = (BYTE*)malloc(LENGTH_MSG_4K);
-}
-
-CClientSocket::~CClientSocket()
-{
-	free(m_ReceiveBuffer);
-	//delete UserCallInfo;
-}
-
-void CClientSocket::Init()
-{
-
-}
-
-void CClientSocket::Abort()
-{
-
-}
-
-BOOL CClientSocket::SendData( WORD wCharacterWord, int wLength, BYTE* DataBuffer )
-{
-	BYTE SendBuffer[LENGTH_MSG_4K];
-	WORD nlength = wLength + sizeof(WORD) + sizeof(WORD); //socket的数据长度 数据的长度(n) + 特征字(2) + 校验码(2)
-	memset(SendBuffer, 0, LENGTH_MSG_4K);
-
-	int nPos = 0;
-	CFunctions::memcpyWord(SendBuffer, nlength, nPos);//长度
-	nPos += sizeof(WORD);
-	CFunctions::memcpyWord(SendBuffer, wCharacterWord, nPos);
-	nPos += sizeof(WORD);
-	memcpy(&SendBuffer[nPos], &DataBuffer[0], wLength);
-	nPos += wLength;
-
-	WORD wCrc = CFunctions::getCRC(&SendBuffer[sizeof(WORD)], wLength + sizeof(WORD)); // 数据长度 + 特征字
-	CFunctions::memcpyWord(SendBuffer, wCrc, nPos);
-	nPos += sizeof(WORD);
-
-	int sRet = Send(SendBuffer, nPos);
-	Sleep(20);
-
-	if(sRet == SOCKET_ERROR)
-	{
-		return FALSE;
-	}
-	return TRUE;
-}
-
-void CClientSocket::OnSend(int nErrorCode)
-{
-	switch(nErrorCode)
-	{
-		case 0:
-			break;
-		case WSAENETDOWN:
-			bError = true;			
-			//m_pDlg->showerr();
-			break;
-		default:
-			break;
-	}
-	CAsyncSocket::OnSend(nErrorCode);
-}
-void CClientSocket::OnReceive(int nErrorCode)
-{
-	if( nErrorCode != 0 )
-	{
-		bError = true;
-		return;
-	}
-	bError = false;
-	m_bClosed = FALSE;
-	m_pDlg->receive_data(this);
-	
-	CAsyncSocket::OnReceive(nErrorCode);
-}
-void CClientSocket::OnConnect(int nErrorCode)
-{
-	if(0 != nErrorCode){
-		m_pDlg->remove_socket(this);
-	}
-}
-void CClientSocket::OnClose(int nErrorCode)
-{
-	bError = true;
-	CAsyncSocket::OnClose(nErrorCode);
-	//CString sMsg;
-	//switch(nErrorCode)
-	//{
-	//	case WSAENETDOWN://套接字操作遇到一个不活动的网络
-	//		sMsg="网络不可用:";
-	//		break;
-	//	case WSAECONNRESET://远程主机强制关闭
-	//		sMsg="客户端强制关闭:";
-	//		break;
-	//	case WSAECONNABORTED://一个已建立的连接被你的主机上的软件终止,可能是因为一次数据传输超时或是协议错误。
-	//		sMsg="关闭客户端:";
-	//		break;
-	//	case 0://正常退出
-	//		sMsg="正常退出:";
-	//		break;
-	//	default:
-	//		sMsg="退出:";
-	//		break;
-	//}
-	if(m_bClosed){
-		return;
-	}
-	m_pDlg->remove_socket(this);
-	m_bClosed = TRUE;
-	ShutDown();
-	//delete this;
-}
-
-IMPLEMENT_DYNAMIC(CClientSocket, CAsyncSocket)

+ 0 - 46
ClientSocket.h

@@ -1,46 +0,0 @@
-#ifndef YASERVER_CLIENTSOCKET_H_
-#define YASERVER_CLIENTSOCKET_H_
-
-// CClientSocket 命令目标
-
-class CYAServerDlg;
-
-class CClientSocket : public CAsyncSocket
-{
-	DECLARE_DYNAMIC(CClientSocket);
-private:
-	CClientSocket(const CClientSocket& rSrc);
-	void operator=(const CClientSocket& rSrc);
-public:
-	CClientSocket(CYAServerDlg* pDlg);
-	virtual ~CClientSocket();
-
-	virtual void OnClose(int nErrorCode);
-	virtual void OnConnect(int nErrorCode);
-public:
-	CYAServerDlg* m_pDlg;
-	CString rAddress;//IP
-	//BOOL bCollServer;//是否采集服务器
-	//DATE mReceiveDateTimeSock;
-	//int RetryTimes; //重试次数,如果失去连接3次,则认为已经关断。
-	//BOOL ReceiveData;//是否接收采集的数据
-	DWORD m_wReadLength;
-	WORD m_wDataLength;
-	WORD m_wCharacterWord;
-
-	BYTE* m_ReceiveBuffer;
-	bool bError; //是否出错
-	BOOL m_bClosed;
-	//BOOL m_bNeedRemallocMem;
-	DWORD reader_id;
-public:
-	void Init();
-	void Abort();
-	BOOL SendData(WORD wCharacterWord,int wLength,BYTE* DataBuffer);
-protected:
-	virtual void OnReceive(int nErrorCode);
-	virtual void OnSend(int nErrorCode);
-};
-
-#endif // YASERVER_CLIENTSOCKET_H_
-

+ 0 - 468
DBConnPool.cpp

@@ -1,468 +0,0 @@
-// DBConnPool.cpp: implementation of the DBConnPool class.
-//
-//////////////////////////////////////////////////////////////////////
-#include "stdafx.h"
-#include "DBConnPool.h"
-DBConnect * pDBConn = NULL;
-void InitDBIterface(LPCSTR strDstAddress, LPCSTR strUsername, LPCSTR strPassword, LPCSTR strDBName,int minConn,int maxConn)
-{
-	DBConnPool::Instanse()->SetDBInfo(strDstAddress,strUsername,strPassword,strDBName,minConn,maxConn);
-	int cout = DBConnPool::Instanse()->InitializeAllDBConnections();
-}
-DBConnect * GetAConnect()
-{
-	DBConnGuard oConnGuard(pDBConn);
-	return pDBConn;
-}
-//////////////////////////////////////DBConnect/////////////////////////
-DBConnect::DBConnect(LPCTSTR strDstAddress, LPCTSTR strUsername, LPCTSTR strPassword, LPCTSTR strDBName,BOOL &state)
-{
-	m_bDBOpen = false;
-	if (0 == Open(strDstAddress,strUsername,strPassword,strDBName))
-	{
-		state =true;
-	}
-	else
-	{
-		state = false;
-	}
-}
-DBConnect::~DBConnect()
-{
-	Close();
-}
-int DBConnect::Open(LPCTSTR strDstAddress, LPCTSTR strUsername, LPCTSTR strPassword, LPCTSTR strDBName)
-{
-	_strDstAddress = strDstAddress;
-	_strDBName       = strDBName;
-	_strUsername     = strUsername;
-	_strPassword     = strPassword;
-
-	HRESULT comhr = ::CoInitialize(NULL);
-	if (FAILED(comhr))
-
-	{
-		return -1;
-	}
-	HRESULT hr = _connection_ptr.CreateInstance(__uuidof(Connection));
-
-	if (FAILED(hr))
-	{
-		return -1;
-	}
-
-	char szSQL[SQL_BUFFER_LEN] = {0};
-	memset(szSQL, 0, SQL_BUFFER_LEN);
-	sprintf(szSQL, "Driver=SQL Server;Server=%s;DATABASE=%s", strDstAddress, strDBName);
-
-	try
-	{
-		// 连接到服务器上数据库
-		_connection_ptr->Open(szSQL, strUsername, strPassword,adModeUnknown) ;
-		if (FAILED(hr))
-			return -1;
-	}
-	catch (_com_error &err)
-	{
-		TRACE(_T("数据库操作失败! 错误信息:%s, 文件:%s, 行:%d./n"), err.ErrorMessage(), __FILE__, __LINE__);
-
-		return -1;
-	}
-
-	m_bDBOpen = TRUE;
-
-	return 0;
-}
-int DBConnect::Close()
-{
-	if (m_bDBOpen)
-	{
-		HRESULT hr =_connection_ptr->Close();
-
-		if (FAILED(hr))
-		{
-			return -1;
-		}
-		::CoUninitialize();
-		m_bDBOpen = FALSE;
-	}
-
-	return 0;
-}
-int DBConnect::UserLogin(LPCSTR name,LPCSTR password)
-{
-	if (!m_bDBOpen)
-	{
-		return -1;
-	}
-	// 创建Command对象
-	_CommandPtr cmd;
-	HRESULT hr = cmd.CreateInstance(__uuidof(Command));
-	if (FAILED(hr))
-	{
-		return -1;
-	}
-
-	char szSQL[SQL_BUFFER_LEN] = {0};
-	sprintf(szSQL, "select count(*) as count from t_user where name =/'%s/' and password =/'%s/'",
-		name,password);
-	cmd->ActiveConnection = _connection_ptr;
-	cmd->CommandText = _bstr_t(szSQL);
-	cmd->CommandType = adCmdText;
-	try 
-	{
-		_RecordsetPtr rs = cmd->Execute(NULL, NULL, adCmdUnknown);
-
-		if (FAILED(hr)) 
-		{
-			return -1;
-		}
-		_variant_t count;
-		while (!rs->ADOEOF)
-		{     
-			count = rs->GetCollect("count");
-			rs->MoveNext() ;
-		}
-		if(count.intVal == 0)
-			return -1;
-	}
-	catch (_com_error &err)
-	{
-		TRACE(_T("数据库操作失败! 错误信息:%s, 文件:%s, 行:%d./n"), err.ErrorMessage(), __FILE__, __LINE__);
-
-		return -1;
-	}
-	return 0;
-}
-int DBConnect::GetSubmitInfo(vector<SOAP_SUBMIT_SMS> &vecsoapSms)
-{
-	if (!m_bDBOpen)
-	{
-		return -1;
-	}
-	// 创建Command对象
-	_CommandPtr cmd;
-	HRESULT hr = cmd.CreateInstance(__uuidof(Command));
-	if (FAILED(hr))
-	{
-		return -1;
-	}
-	string strSql = "exec SP_SMS_GETSUBMIT";
-	cmd->ActiveConnection = _connection_ptr;
-	cmd->CommandText = _bstr_t(strSql.c_str());
-	cmd->CommandType = adCmdText;
-	try 
-	{
-		_RecordsetPtr rs = cmd->Execute(NULL, NULL, adCmdUnknown);
-
-		if (FAILED(hr)) 
-		{
-			return -1;
-		}
-		while (!rs->ADOEOF)
-		{     
-			_variant_t  id;
-			_variant_t  recverid;
-			_variant_t  recvertel;
-			_variant_t  messagecontent;
-			_variant_t  recverphonetype;
-			_variant_t  inout;
-			_variant_t  sendtime;
-			_variant_t  cardtime;
-			_variant_t  schoolid;
-			_variant_t  classid;
-			_variant_t  rfidno;
-
-			id = rs->GetCollect("id");
-			recverid = rs->GetCollect("recverid");
-			recvertel = rs->GetCollect("recvertel");
-			messagecontent = rs->GetCollect("messagecontent");
-			recverphonetype = rs->GetCollect("recverphonetype");
-			inout = rs->GetCollect("inout");
-			sendtime = rs->GetCollect("sendtime");
-			cardtime = rs->GetCollect("cardtime");
-			schoolid = rs->GetCollect("schoolid");
-			classid = rs->GetCollect("classid");
-			rfidno = rs->GetCollect("rfidno");
-			SOAP_SUBMIT_SMS submitsms;
-			submitsms.id = (int)(long)id;
-			VarientToString(recverid, submitsms.recverid);
-			VarientToString(recvertel, submitsms.recvertel);
-			VarientToString(messagecontent, submitsms.messagecontent);
-			VarientToString(recverphonetype, submitsms.recverphonetype);
-			submitsms.inout = (int)(long)inout;
-			VarientToString(sendtime, submitsms.sendtime);
-			VarientToString(cardtime, submitsms.cardtime);
-			VarientToString(rfidno, submitsms.rfidno);
-			submitsms.schoolid = (int)(long)schoolid;
-			submitsms.classid = (int)(long)classid;
-			vecsoapSms.push_back(submitsms);
-			rs->MoveNext() ;
-		}
-	}
-	catch (_com_error &err)
-	{
-		TRACE(_T("数据库操作失败! 错误信息:%s, 文件:%s, 行:%d./n"), err.ErrorMessage(), __FILE__, __LINE__);
-
-		return -1;
-	}
-	return 0;
-}
-int DBConnect::InsertHistory(int id)
-{
-	if (!m_bDBOpen)
-	{
-		return -1;
-	}
-	// 创建Command对象
-	_CommandPtr cmd;
-	HRESULT hr = cmd.CreateInstance(__uuidof(Command));
-	if (FAILED(hr))
-	{
-		return -1;
-	}
-	char szSQL[SQL_BUFFER_LEN] = {0};
-	sprintf(szSQL, "exec SP_SMS_SUBMITRESULT %d", id);
-	try
-	{
-		cmd->ActiveConnection = _connection_ptr;
-		cmd->CommandText = _bstr_t(szSQL);
-		cmd->CommandType = adCmdText;
-		cmd->Execute(NULL, NULL, adCmdUnknown);
-	}
-	catch (_com_error &err)
-	{
-		TRACE(_T("数据库操作失败! 错误信息:%s, 文件:%s, 行:%d./n"), err.ErrorMessage(), __FILE__, __LINE__);
-
-		return -1;
-	}
-	return 0;
-}
-void DBConnect::VarientToString(_variant_t var, string& str)
-{
-	if (VT_NULL == var.vt)
-	{
-		str = "";
-	}
-	else
-	{
-		str = (char*)_bstr_t(var);
-	}
-}
-//////////////////////////////////////End//////////////////////////////
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-DBConnPool* DBConnPool::m_pInstanse = NULL;
-DBConnPool::DBConnPool()
-{
-	m_bNeedStop = FALSE;
-	m_bNeedConnection = FALSE;
-	m_hMaintanceThread = INVALID_HANDLE_VALUE;
-
-	// 线程控制
-	m_hHaveData = CreateEvent (NULL, TRUE, FALSE, _T("DataConnPool"));
-
-	InitializeCriticalSection(&m_csIdleConnList);
-	InitializeCriticalSection(&m_csBusyConnList);
-}
-void DBConnPool::SetDBInfo(LPCSTR strDstAddress, LPCSTR strUsername, LPCSTR strPassword, LPCSTR strDBName,int minConn,int maxConn)
-{
-	_strDBName = strDBName;
-	_strDstAddress = strDstAddress;
-	_strPassword = strPassword;
-	_strUsername = strUsername;
-	m_nMaxCount = maxConn;
-	m_nMinCount = minConn;
-}
-DBConnPool::~DBConnPool()
-{
-	m_hMaintanceThread = INVALID_HANDLE_VALUE;
-	m_bNeedStop = TRUE;
-	CloseHandle(m_hHaveData);
-	CloseHandle(m_hMaintanceThread);
-
-	DeleteCriticalSection(&m_csIdleConnList);
-	DeleteCriticalSection(&m_csBusyConnList);
-}
-DBConnPool *DBConnPool::Instanse()
-{
-	if (NULL == m_pInstanse)
-	{
-		m_pInstanse = new DBConnPool();
-	}
-	return m_pInstanse;
-}
-int DBConnPool::InitializeAllDBConnections()
-{
-	// 先清除现有的数据
-	DestroyAllDBConnections();
-	// 开始按照最小数量开始创建
-	DBConnect * pDBConnect = NULL;
-	int nCount = 0;
-	for (int i = 0; i < m_nMinCount; i++)
-	{
-		nCount = InitializeAConnection();
-	}
-	// 创建一个工作线程,用来进行一些后台维护工作
-	if (INVALID_HANDLE_VALUE == m_hMaintanceThread)
-	{
-		m_hMaintanceThread = CreateThread(NULL, NULL, thread_run, (LPVOID)this, 0, NULL);
-	}
-	return nCount;
-}
-void DBConnPool::DestroyAllDBConnections()
-{
-	// 销毁数据库连接可以使用大锁
-	EnterCriticalSection(&m_csIdleConnList);
-	DBConnectList::iterator itIdle = m_listIdleConnection.begin();
-	DBConnectList::iterator itIdleEnd = m_listIdleConnection.end();
-	while (itIdle != itIdleEnd)
-	{
-		if (NULL != (*itIdle))
-		{
-			(*itIdle)->Close();
-			delete (*itIdle);
-		}
-		// erase本身就会把跌代器指向下一个
-		itIdle = m_listIdleConnection.erase(itIdle);
-	}
-	LeaveCriticalSection(&m_csIdleConnList);
-	// 还有使用中的连接
-	EnterCriticalSection(&m_csBusyConnList);
-	DBConnectList::iterator itBusy = m_listBusyConnection.begin();
-	DBConnectList::iterator itBusyEnd = m_listBusyConnection.end();
-	while (itBusy != itBusyEnd)
-	{
-		if (NULL != (*itBusy))
-		{
-			(*itBusy)->Close();
-			delete (*itBusy);
-		}
-		// erase本身就会把跌代器指向下一个
-		itBusy = m_listBusyConnection.erase(itBusy);
-	}
-	LeaveCriticalSection(&m_csBusyConnList);
-}
-int DBConnPool::InitializeAConnection()
-{
-	BOOL bSuccess = FALSE;
-	DBConnect * pDBEngine = new DBConnect(_strDstAddress, _strUsername, _strPassword, _strDBName, bSuccess);
-	if (bSuccess)
-	{
-		m_bNeedConnection = FALSE;
-		return RestoreAConnection(pDBEngine);
-	}
-	else
-	{
-		delete pDBEngine;
-		return m_listIdleConnection.size();
-	}
-}
-void DBConnPool::CloseAConnection(DBConnect* pDBEngine)
-{
-	pDBEngine->Close();
-	// 从空闲队列将其删除
-	EnterCriticalSection(&m_csIdleConnList);
-	m_listIdleConnection.remove(pDBEngine);
-	LeaveCriticalSection(&m_csIdleConnList);
-}
-DBConnect * DBConnPool::GetAConnection()
-{
-	DBConnect * pDBEngine = NULL;
-	// 做一个循环,反复尝试五次取连接,每次间隔1秒钟
-	int nTimes = 0;
-	while ((m_listIdleConnection.size() <= 0) && (nTimes < 5))
-	{
-		Sleep(1000);
-		nTimes++;
-	}
-	if (5 == nTimes)
-	{
-		// 这样狼狈的进来肯定是没有可用连接了,记录日志退出
-		// g_pSvrLog->AddRunLog(LL_ERROR, _T("Waiting for a connection for a long time, but failed."));
-		return pDBEngine;
-	}
-	// 从空闲队列中取出,并且加入到使用队列中
-	EnterCriticalSection(&m_csIdleConnList);
-	if (m_listIdleConnection.size() > 0)
-	{
-		pDBEngine = m_listIdleConnection.front();
-		m_listIdleConnection.pop_front();
-		// 加入使用的连接队列
-		EnterCriticalSection(&m_csBusyConnList);
-		m_listBusyConnection.push_back(pDBEngine);
-		LeaveCriticalSection(&m_csBusyConnList);
-	}
-	LeaveCriticalSection(&m_csIdleConnList);
-	if (m_listIdleConnection.size() <= 1)
-	{
-		// 剩余空闲连接的数目小于等于1个时候需要检查开始创建
-		if ((m_listIdleConnection.size() + m_listBusyConnection.size()) < m_nMaxCount)
-		{
-			// 还小于最大限制,可以创建
-			SetEvent(m_hHaveData);
-			m_bNeedConnection = TRUE;
-		}
-		else
-		{
-			// 超出限制了,做个记录吧
-			//g_pSvrLog->AddRunLog(LL_ERROR, _T("Database connection reached max count."));
-		}
-	}
-	return pDBEngine;
-}
-int DBConnPool::RestoreAConnection(DBConnect* pDBEngine)
-{
-	if (NULL != pDBEngine)
-	{
-		// 从使用中的队列取出
-		EnterCriticalSection(&m_csBusyConnList);
-		m_listBusyConnection.remove(pDBEngine);
-		LeaveCriticalSection(&m_csBusyConnList);
-		// 加入到空闲队列中
-		EnterCriticalSection(&m_csIdleConnList);
-		m_listIdleConnection.push_back(pDBEngine);
-		LeaveCriticalSection(&m_csIdleConnList);
-	}
-	EnterCriticalSection(&m_csIdleConnList);
-	int nCount = m_listIdleConnection.size();
-	LeaveCriticalSection(&m_csIdleConnList);
-	return nCount;
-}
-void DBConnPool::StopThread()
-{
-	m_bNeedStop = TRUE;
-	// 因为线程是无限制等待信号的,所以这里先把标志位置为停止,然后发信号让线程检测
-	SetEvent(m_hHaveData);
-	// 等待退出
-	WaitForSingleObject(m_hMaintanceThread, INFINITE);
-	CloseHandle(m_hMaintanceThread);
-}
-BOOL DBConnPool::IsNeedStop()
-{
-	return m_bNeedStop;
-}
-BOOL DBConnPool::IsNeedConnection()
-{
-	return m_bNeedConnection;
-}
-/************************************************************************/
-/* 维护线程                                                             */
-/************************************************************************/
-DWORD WINAPI DBConnPool::thread_run( LPVOID pdata)
-{
-	DBConnPool * pConPool = (DBConnPool *) pdata;
-	while (!pConPool->IsNeedStop())
-	{
-		// 设置事件为无信号, 并且无限制等待
-		ResetEvent(pConPool->m_hHaveData);  
-		WaitForSingleObject(pConPool->m_hHaveData, INFINITE);
-		if (pConPool->IsNeedConnection())
-		{
-			// g_pSvrLog->AddRunLog(LL_DEBUG, _T("Create a new DB connection."));
-			pConPool->InitializeAConnection();
-		}
-	}
-	return 0;
-}

+ 0 - 134
DBConnPool.h

@@ -1,134 +0,0 @@
-// !defined(AFX_DBCONNPOOL_H__42089E9A_FD85_4DD4_A973_64A4980332A5__INCLUDED_)  
-// DBConnPool.h: interface for the DBConnPool class.
-//
-//////////////////////////////////////////////////////////////////////
-#if !defined(AFX_DBCONNPOOL_H__42089E9A_FD85_4DD4_A973_64A4980332A5__INCLUDED_)
-#define AFX_DBCONNPOOL_H__42089E9A_FD85_4DD4_A973_64A4980332A5__INCLUDED_
-#define  SQL_BUFFER_LEN 1024
-#import "C:/Program Files/Common Files/System/ado/msado15.dll" rename("EOF","ADOEOF")
-#include <list>
-#include <windows.h>
-#include <string>
-#include <vector>
-//#include  "DBDefine.h"
-using namespace ADODB;
-using namespace std;
-
-class RFIDAPI DBConnect
-{
-public:
-	DBConnect(LPCSTR strDstAddress, 
-		LPCSTR strUsername, 
-		LPCSTR strPassword, 
-		LPCSTR strDBName,
-		BOOL &state);
-	~DBConnect();
-public:
-	// 连接到数据库
-
-	int Open(LPCTSTR strDstAddress, LPCTSTR strUsername, LPCTSTR strPassword, LPCTSTR strDBName);
-	// 关闭数据库
-
-	int Close();
-	// 数据库是否已连接
-
-	BOOL IsOpen() const;
-public:
-private:
-	ADODB::_ConnectionPtr           _connection_ptr;   //ADO的数据库连接智能指针
-	bool                            _isAdoValid;       //ADO环境是否已经初化成功标志量
-	bool       m_bDBOpen;
-
-	LPCSTR       _strDstAddress;    //数据源地址或服务名
-	LPCSTR       _strUsername;      //数据库用户名
-	LPCSTR       _strPassword;      //数据库密码
-	LPCSTR       _strDBName;        //数据库名称
-	void         VarientToString(_variant_t var, string& str);
-	//对外公共接口
-public:
-	int          GetSubmitInfo(vector<SOAP_SUBMIT_SMS> &vecsoapSms);    
-
-	int          InsertHistory(int id);
-	int          UserLogin(LPCSTR name,LPCSTR password);
-}; 
-typedef std::list<DBConnect*> DBConnectList;
-class  DBConnPool  
-{
-public:
-	DBConnPool();
-	virtual ~DBConnPool();
-	// 获取实例指针
-	static DBConnPool * Instanse();
-	// 初始化所有连接
-	int InitializeAllDBConnections();
-
-	// 关闭所有连接
-	void DestroyAllDBConnections();
-	// 获取一个空闲连接
-	DBConnect* GetAConnection();
-	// 交还连接给空闲队列
-	int RestoreAConnection(DBConnect* pDBEngine);
-	void SetDBInfo(LPCSTR strDstAddress, LPCSTR strUsername, LPCSTR strPassword, LPCSTR strDBName,int minConn,int maxConn);
-private:
-
-	// 创建一个连接
-	int InitializeAConnection();
-	// 关闭一个连接
-	void CloseAConnection(DBConnect* pDBEngine);
-	// 停止工作线程
-	void StopThread();
-
-	// 判断是否需要停止
-	BOOL IsNeedStop();
-	BOOL IsNeedConnection();
-	// 将守卫类作为连接池类的友元类
-	friend class ConnGuard;
-	// 唯一实例
-	static DBConnPool *m_pInstanse;
-
-	// 空闲数据库连接队列
-	DBConnectList m_listIdleConnection;
-	// 在使用的数据库连接
-	DBConnectList m_listBusyConnection;
-
-	// 队列保护的临界区
-	CRITICAL_SECTION m_csIdleConnList;
-	CRITICAL_SECTION m_csBusyConnList;
-
-	// 可用连接总数的三个指标:最大、最小
-	int m_nMaxCount;
-	int m_nMinCount;
-
-	//  // 数据库信息
-	LPCSTR       _strDstAddress;    //数据源地址或服务名
-	LPCSTR       _strUsername;      //数据库用户名
-	LPCSTR       _strPassword;      //数据库密码
-	LPCSTR       _strDBName;        //数据库名称
-
-	// 维护线程
-	HANDLE m_hMaintanceThread; // 线程句柄
-	HANDLE m_hHaveData; // 信号
-
-	BOOL m_bNeedStop; // 管理线程起停的标志位
-	BOOL m_bNeedConnection; // 需要创建连接的标志
-	static DWORD WINAPI thread_run( LPVOID pdata);
-};
-// 守卫类,利用构造和析构函数保证连接取出和归还必须成对,防止资源泄露
-class  DBConnGuard
-{
-public:
-	DBConnGuard(DBConnect*& DBConn)
-	{
-		DBConn = DBConnPool::Instanse()->GetAConnection();
-		m_pDBConn = DBConn;
-	}
-	virtual ~DBConnGuard()
-	{
-		DBConnPool::Instanse()->RestoreAConnection(m_pDBConn);
-	}
-private:
-	DBConnect *m_pDBConn;
-};
-RFIDAPI void  InitDBIterface(LPCSTR strDstAddress, LPCSTR strUsername, LPCSTR strPassword, LPCSTR strDBName,int minConn,int maxConn);
-RFIDAPI DBConnect * GetAConnect();
-#endif // !defined(AFX_DBCONNPOOL_H__42089E9A_FD85_4DD4_A973_64A4980332A5__INCLUDED_)

+ 0 - 62
DownloadManager.h

@@ -1,62 +0,0 @@
-#ifndef COMMON_DOWNLOADMANAGER_H_
-#define COMMON_DOWNLOADMANAGER_H_
-
-#include <list>
-
-typedef void* TaskID;
-
-#define  TaskIDNULL NULL
-
-enum HttpMethod
-{
-	HM_GET = 0,
-	HM_POST,
-	HM_END,
-};
-
-struct DownloadProgress
-{
-	double fNow;
-	double fTotal;
-};
-
-struct DownloadData{
-	void* ptr;
-	unsigned int nLen;
-};
-
-struct TaskInitData
-{
-	typedef std::list<std::pair<std::string, std::string>> ParamList;
-	std::string strRequestURL;
-	std::string strFilename;
-	HttpMethod hm;
-	std::string strParam;
-	//ParamList lsParams;
-};
-
-struct DownloadManager
-{
-	virtual TaskID CreateTask(TaskInitData* pInit) = 0;
-	virtual bool StartTask(TaskID taskID) = 0;
-	virtual bool StopTask(TaskID taskID) = 0;
-};
-
-struct ParamConstructor 
-{
-	virtual void ParamAlloc(
-		unsigned int nEvent,
-		unsigned int nSubEvent,
-		void** param1,
-		void** param2
-		) = 0;
-
-	virtual void ParamFree(
-		unsigned int nEvent,
-		unsigned int nSubEvent,
-		void* param1,
-		void* param2
-		) = 0;
-};
-
-#endif // COMMON_DOWNLOADMANAGER_H_

+ 0 - 244
DownloadManagerImpl.cpp

@@ -1,244 +0,0 @@
-#include "StdAfx.h"
-#include "DownloadManagerImpl.h"
-#include <boost/make_shared.hpp>
-
-#define BUFFER_STEP_SIZE 1024
-#define	MSG_COMPLETE_FILE	WM_USER + 100
-#define MSG_COMPLETE_BUFFER	WM_USER + 101
-#define MSG_ERROR			WM_USER + 102
-
-
-DownloadManagerImpl::~DownloadManagerImpl(void)
-{
-}
-
-void DownloadManagerImpl::init(HWND hWnd)
-{
-	m_hParent = hWnd;
-	mspTaskManager = UEFactory::getTaskManager(emProtocol_Http);
-	mspTaskManager->initTaskManager();
-}
-
-void DownloadManagerImpl::uninit( void )
-{
-	mspTaskManager->uninitTaskManager();
-	mspTaskManager.reset();
-
-	m_hParent = NULL;
-}
-
-TaskID DownloadManagerImpl::CreateTask( TaskInitData* pInit )
-{
-	if (!mspTaskManager)
-	{
-		return NULL;
-	}
-
-	nsURLEngine::IUETaskPtr spNewTask = mspTaskManager->getNewTask();
-	TaskID taskID = reinterpret_cast<TaskID>(spNewTask.get());
-	TaskDataPtr spTaskData = boost::make_shared<TaskData>(); 
-
-	spNewTask->setCallback(static_cast<IUETaskCallback*>(this));
-	spNewTask->setURL(pInit->strRequestURL.c_str());
-	spNewTask->setMethod(pInit->hm == HM_POST ? emMethod_Post : emMethod_Get);
-	spNewTask->setParam(pInit->strParam.c_str());
-
-	//TaskInitData::ParamList::iterator itParam = pInit->lsParams.begin();
-	//while (itParam != pInit->lsParams.end())
-	//{
-	//	spNewTask->addParam(itParam->first.c_str(),itParam->second.c_str());
-	//	itParam++;
-	//}
-
-	if (!pInit->strFilename.empty())
-	{
-		spNewTask->setLocalFile(pInit->strFilename.c_str());
-		spTaskData->strFile = pInit->strFilename;
-	}
-	else
-	{
-		spTaskData->vecData.reserve(BUFFER_STEP_SIZE);
-	}
-
-	spTaskData->spTask = spNewTask;
-
-	TaskDataMap::iterator it = mmTasks.find(taskID);
-
-	if (it != mmTasks.end())
-	{
-		mmTasks.erase(it);
-	}
-
-	mmTasks.insert(std::make_pair(taskID,spTaskData));
-
-	return taskID;
-}
-
-bool DownloadManagerImpl::StartTask( TaskID taskID )
-{
-	TaskDataMap::iterator it = mmTasks.find(taskID);
-
-	if (it != mmTasks.end())
-	{
-		mspTaskManager->startTask(it->second->spTask);
-
-		return true;
-	}
-
-	return false;
-}
-
-void* DownloadManagerImpl::AllocCompleteBuffer( TaskID taskID )
-{
-	TaskDataMap::iterator it = mmTasks.find(taskID);
-
-	if (it == mmTasks.end())
-	{
-		return NULL;
-	}
-
-	DownloadData* pData = new DownloadData();
-
-	if (it->second->strFile.empty())
-	{
-		pData->nLen = it->second->vecData.size();
-		pData->ptr = new char[pData->nLen];
-		memcpy(pData->ptr,&(it->second->vecData[0]),pData->nLen);
-	}
-	else
-	{
-		pData->nLen = it->second->strFile.size() + 1;
-		pData->ptr = new char[pData->nLen];
-		memcpy(pData->ptr,it->second->strFile.c_str(),pData->nLen);
-	}
-
-	return reinterpret_cast<void*>(pData);
-}
-
-void DownloadManagerImpl::OnTaskProgress( double fNow,double fTotal,UETaskID taskid )
-{
-
-}
-
-void DownloadManagerImpl::OnTaskEvent( emTaskEvent event,emEngineErrCode errCode,UETaskID taskid )
-{
-	if (event == emEvent_Complete)
-	{
-		TaskDataMap::iterator it = mmTasks.find(taskid);
-		if (it != mmTasks.end())
-		{
-			try{
-				ParamConstructor* pConstructor = static_cast<ParamConstructor*>(this);
-				DownloadData* pData = NULL;
-				pConstructor->ParamAlloc(it->second->strFile.empty() ? MSG_COMPLETE_BUFFER : MSG_COMPLETE_FILE,0,&taskid,reinterpret_cast<void**>(&pData));
-
-				PostMessage(m_hParent, it->second->strFile.empty() ? MSG_COMPLETE_BUFFER : MSG_COMPLETE_FILE,
-					(WPARAM)taskid, (LPARAM)pData);
-/*				eventMgr->postEvent(
-					EVENT_DOWNLOADMANAGER_COMPLETE,
-					it->second->strFile.empty() ? DOWNLOADCOMPLETE_BUFFER : DOWNLOADCOMPLETE_FILE,
-					taskid,
-					pData,
-					pConstructor
-					);*/	
-			}
-			catch(...)
-			{
-				PostMessage(m_hParent, MSG_ERROR, (WPARAM)&taskid, NULL);
-				//eventMgr->postEvent(EVENT_DOWNLOADMANAGER_ERROR,0,taskid,NULL);
-			}
-		}
-
-		mmTasks.erase(taskid);
-	}
-	else if (event == emEvent_Error)
-	{
-		//eventMgr->postEvent(EVENT_DOWNLOADMANAGER_ERROR,0,taskid,NULL);
-		mmTasks.erase(taskid);
-	}
-}
-
-void DownloadManagerImpl::OnTaskData( UEVoidPtr ptr,unsigned int nLen,UETaskID taskid )
-{
-	TaskDataMap::iterator it = mmTasks.find(taskid);
-
-	if (it != mmTasks.end())
-	{
-		if (it->second->strFile.empty())
-		{
-			std::vector<unsigned char>::size_type nSize = it->second->vecData.size();
-			std::vector<unsigned char>::size_type nCaps = it->second->vecData.capacity();
-			if (nSize + nLen > nCaps)
-			{
-				it->second->vecData.reserve(nSize + nLen + BUFFER_STEP_SIZE);
-			}
-
-			it->second->vecData.resize(nSize + nLen);
-			memcpy(&(it->second->vecData[nSize]),ptr,nLen);
-		}
-	}
-}
-
-bool DownloadManagerImpl::StopTask( TaskID taskID )
-{
-	TaskDataMap::iterator it = mmTasks.find(taskID);
-
-	if (it != mmTasks.end())
-	{
-		if (it->second->spTask)
-		{
-			it->second->spTask->cancel();
-			return true;
-		}
-	}	
-
-	return false;
-}
-
-void DownloadManagerImpl::ParamAlloc( unsigned int nEvent, unsigned int nSubEvent, void** param1, void** param2 )
-{
-	switch (nEvent)
-	{
-	//case EVENT_DOWNLOADMANAGER_PROGRESS:
-	//	*param2 = reinterpret_cast<void*>(new DownloadProgress());
-	//	break;
-	case MSG_COMPLETE_BUFFER:
-		*param2 = AllocCompleteBuffer(*param1);
-		break;
-	case MSG_COMPLETE_FILE:
-		*param2 = AllocCompleteBuffer(*param1);
-		break;
-	}
-}
-
-void DownloadManagerImpl::ParamFree( unsigned int nEvent, unsigned int nSubEvent, void* param1, void* param2 )
-{
-	switch (nEvent)
-	{
-	//case EVENT_DOWNLOADMANAGER_PROGRESS:
-	//	if (param2)
-	//	{
-	//		delete param2;
-	//	}	
-	//	break;
-	case MSG_COMPLETE_BUFFER || MSG_COMPLETE_FILE:
-		{
-			DownloadData* pData = reinterpret_cast<DownloadData*>(param2);
-			if (pData)
-			{
-				if (pData->ptr)
-				{
-					delete []pData;
-				}
-
-				delete pData;
-			}
-		}
-		break;
-	}
-}
-
-DownloadManagerImpl::DownloadManagerImpl( void )
-{
-
-}

+ 0 - 72
DownloadManagerImpl.h

@@ -1,72 +0,0 @@
-#ifndef COMMON_DOWNLOADMANAGERIMPL_H_
-#define COMMON_DOWNLOADMANAGERIMPL_H_
-
-#include "DownloadManager.h"
-#include "../common/URLEngine/UEFactory.h"
-#include <vector>
-#include <map>
-#include <Windows.h>
-
-using namespace nsURLEngine;
-
-class DownloadManagerImpl : 
-	public DownloadManager,
-	public nsURLEngine::IUETaskCallback,
-	public ParamConstructor
-{
-	struct TaskData{
-		IUETaskPtr spTask;
-		std::string strFile;
-		std::vector<unsigned char> vecData;
-	};
-
-	typedef boost::shared_ptr<TaskData> TaskDataPtr;
-	typedef std::map<TaskID, TaskDataPtr> TaskDataMap;
-public:
-	~DownloadManagerImpl(void);
-	static DownloadManagerImpl& getInstance(void)
-	{
-		static DownloadManagerImpl s_instance;
-		return s_instance;
-	}
-
-	virtual TaskID CreateTask(TaskInitData* pInit);
-	virtual bool StartTask(TaskID taskID);
-	virtual bool StopTask(TaskID taskID);
-
-	void init(HWND hWnd);
-	void uninit(void);
-
-	//任务进度回调
-	virtual void OnTaskProgress(double fNow,double fTotal,UETaskID taskid);
-	//任务事件回调
-	virtual void OnTaskEvent(emTaskEvent event,emEngineErrCode errCode,UETaskID taskid);
-	//任务数据回调
-	virtual void OnTaskData(UEVoidPtr ptr,unsigned int nLen,UETaskID taskid);
-
-	virtual void ParamAlloc(
-		unsigned int nEvent,
-		unsigned int nSubEvent,
-		void** param1,
-		void** param2
-		);
-	virtual void ParamFree(
-		unsigned int nEvent,
-		unsigned int nSubEvent,
-		void* param1,
-		void* param2
-		);
-
-protected:
-	void* AllocCompleteBuffer(TaskID taskID);
-
-private:
-	TaskDataMap mmTasks;
-	IUETaskManagerPtr mspTaskManager;
-	HWND m_hParent;
-	DownloadManagerImpl(void);
-};
-
-#define GetDownloadManager() DownloadManagerImpl::getInstance()
-
-#endif //COMMON_DOWNLOADMANAGERIMPL_H_

+ 0 - 28
Log.cpp

@@ -1,28 +0,0 @@
-#include "stdafx.h"
-#include "Log.h"
-
-
-CLog::CLog(void)
-{
-}
-
-
-CLog::~CLog(void)
-{
-}
-
-DWORD WINAPI CLog::WriteLog()
-{
-	if(m_logMsgQueue.size()>0){
-	
-	}
-	while(m_logMsgQueue.size()>0){
-	}
-	return 0;
-}
-
-afx_msg LRESULT ReceiveLogMessage(WPARAM wParam,LPARAM lParam);
-{
-
-	return 0;
-}

+ 0 - 61
ProcessRemodule.cpp

@@ -25,9 +25,6 @@ unsigned nThreadID[MSG_PROCESS_THREAD_NUM];
 HANDLE hSqlThread[SQL_PROCESS_THREAD_NUM];
 unsigned nSqlThreadID[SQL_PROCESS_THREAD_NUM];
 
-HANDLE hErrLogThread[ERR_LOG_PROCESS_THREAD_NUM];
-unsigned nErrLogThreadID[ERR_LOG_PROCESS_THREAD_NUM];
-
 HANDLE hSysLogThread[SYS_LOG_PROCESS_THREAD_NUM];
 unsigned nSysLogThreadID[SYS_LOG_PROCESS_THREAD_NUM];
 
@@ -244,63 +241,6 @@ int send_sql_message(char* pchr)
 	return 0;
 }
 
-int err_log_process_thread_init()
-{
-	int i = 0;
-	for(i=0; i<ERR_LOG_PROCESS_THREAD_NUM; i++)
-	{
-		hErrLogThread[i] = (HANDLE)_beginthreadex( NULL, 0, &err_log_process_entry, NULL, 0, &(nErrLogThreadID[i]) );
-		if(hErrLogThread[i] == 0)
-		{
-			printf("start thread failed,errno:%d\n",::GetLastError());
-			return 1;
-		}
-	}
-	return 0;
-}
-
-// thread function
-unsigned __stdcall err_log_process_entry(void *param)
-{
-	//printf("thread err log_process_entry start\n");
-
-	MSG msg;
-	//check for msg quene isExist or not
-	PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
-	while(true)
-	{
-		if(GetMessage(&msg,0,0,0)) //get msg from message queue
-		{
-			switch(msg.message)
-			{
-			case ERR_LOG_MSG:
-				char * pInfo = (char *)msg.wParam;
-
-#ifndef  UT_TEST
-				_write_error_log(pInfo);
-#else
-				delete[] pInfo;
-#endif
-				break;
-			}
-		}
-	};
-	return 0;
-}
-int send_err_log_message(char* pchr)
-{
-	//send thread message
-	unsigned thread_id = rand() % ERR_LOG_PROCESS_THREAD_NUM;
-	if(!PostThreadMessage(nErrLogThreadID[thread_id], ERR_LOG_MSG, (WPARAM)pchr, 0))//post thread msg
-	{
-		LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_33);
-		debug_print_syslog(0, "post err log message failed,errno:%d\n",::GetLastError());
-		delete[] pchr;
-		return 1;
-	}
-	return 0;
-}
-
 int sys_log_process_thread_init()
 {
 	int i = 0;
@@ -353,7 +293,6 @@ int service_task_init()
 	bufPtr->init();
 	message_process_thread_init();
 	sql_process_thread_init();
-	err_log_process_thread_init();
 	sys_log_process_thread_init();
 	::Sleep(1000);
 	return 0;

+ 0 - 10
ProcessRemodule.h

@@ -29,16 +29,6 @@ extern int sql_process_thread_init();
 extern unsigned __stdcall sql_process_entry(void *param);
 extern int send_sql_message(char* pchr);
 
-//err log thread function
-#define ERR_LOG_MSG WM_USER+300
-#define    ERR_LOG_PROCESS_THREAD_NUM    1
-extern HANDLE hErrLogThread[ERR_LOG_PROCESS_THREAD_NUM];
-extern unsigned nErrLogThreadID[ERR_LOG_PROCESS_THREAD_NUM];
-extern int err_log_process_thread_init();
-extern unsigned __stdcall err_log_process_entry(void *param);
-extern int send_err_log_message(char* pchr);
-
-
 //sys log thread function
 #define SYS_LOG_MSG WM_USER+400
 #define    SYS_LOG_PROCESS_THREAD_NUM    1

+ 0 - 28
ServerSockert.cpp

@@ -1,28 +0,0 @@
-// ServerSockert.cpp : ʵÏÖÎļþ
-//
-
-#include "stdafx.h"
-#include "YAServer.h"
-#include "ServerSockert.h"
-#include "YAServerDlg.h"
-
-// CServerSockert
-
-CServerSockert::CServerSockert( CYAServerDlg* pDlg )
-{
-	m_pDlg = pDlg;
-}
-
-CServerSockert::~CServerSockert()
-{
-}
-
-void CServerSockert::OnAccept( int nErrorCode )
-{
-	CAsyncSocket::OnAccept(nErrorCode);
-	m_pDlg->parse_accept();
-}
-
-// CServerSockert ³ÉÔ±º¯Êý
-
-IMPLEMENT_DYNAMIC(CServerSockert, CAsyncSocket);

+ 0 - 24
ServerSockert.h

@@ -1,24 +0,0 @@
-#ifndef YASERVER_SERVERSOCKET_H_
-#define YASERVER_SERVERSOCKET_H_
-
-class CYAServerDlg;
-// CServerSockert ÃüÁîÄ¿±ê
-
-class CServerSockert : public CAsyncSocket
-{
-	DECLARE_DYNAMIC(CServerSockert);
-private:
-	CServerSockert(const CServerSockert& rSrc);
-	void operator=(const CServerSockert& rSrc);
-
-public:
-	CServerSockert(CYAServerDlg* pDlg);
-	virtual ~CServerSockert();
-
-	CYAServerDlg* m_pDlg;
-protected:
-	virtual void OnAccept(int nErrorCode);
-
-};
-
-#endif //YASERVER_SERVERSOCKET_H_

+ 7 - 154
YAServerDlg.cpp

@@ -305,29 +305,6 @@ DWORD WINAPI _exec_sql(const char * lparam)
 	return 0;
 }
 
-DWORD WINAPI _write_error_log(LPVOID lparam)
-{
-	::InterlockedIncrement(&g_QueueItemCount);
-	LogInfo* err =  (LogInfo*)lparam;
-	CYAServerDlg* dlg = reinterpret_cast<CYAServerDlg*>(err->handle);
-#ifdef TRACE_MEMORY_WRITELOG
-	dlg->writeErrorLogEx(err->path, err->strLog, err->useTime);
-#endif // TRACE_MEMORY_WRITELOG
-
-	if(err){
-		free(err->path);
-		err->path = NULL;
-		free(err->strLog);
-		err->strLog = NULL;
-
-		delete err;
-		err = NULL;
-	}
-	//Sleep(1);
-	::InterlockedDecrement(&g_QueueItemCount);
-	return 0;
-}
-
 DWORD WINAPI _parse_package_data(LPVOID lparam)
 {
 	::InterlockedIncrement(&g_QueueItemCount);
@@ -6471,23 +6448,6 @@ void CYAServerDlg::formatByteArray( std::string &strBuf, BYTE * buf, int nLen )
 	}
 }
 
-void CYAServerDlg::writeErrorLog( const CString strFile, const CString strErr, bool bTime /*= true*/  )
-{
-	LogInfo* err = new LogInfo;
-	err->handle = NULL;
-	err->useTime = false;
-	err->path = NULL;
-	err->strLog = NULL;
-
-	err->handle = this;
-	err->useTime = bTime;
-
-	err->path = CFunctions::wc2c(strFile);
-	err->strLog  = CFunctions::wc2c(strErr);
-
-	send_err_log_message((char *)err);
-}
-
 BOOL CYAServerDlg::openLogFile(CString strFile)
 {
 	TCHAR lpstrCurDir[MAX_PATH] = _T("");
@@ -6803,17 +6763,8 @@ void CYAServerDlg::store_data_card(std::shared_ptr<Card> card /*Card* card*/, in
 	default:
 		return;
 	}
-	try
-	{
-		if(b_exec){
-			execute_sql(sql);
-			std::string strSqlLog = sql;
-			//Log::write_log(FILE_TYPE::SQL_S,strSqlLog,true);
-		}
-	}
-	catch (...)
-	{
-
+	if(b_exec){
+		execute_sql(sql);
 	}
 }
 
@@ -9767,8 +9718,6 @@ int CYAServerDlg::store_data_section(std::shared_ptr<Section> section,time_t cur
 
 void CYAServerDlg::execute_sql( const char* sql )
 {
-
-
 	m_qsmSQL->AddString(sql);
 	Log::write_log(FILE_TYPE::SQL_S, sql, true);
 }
@@ -12347,19 +12296,6 @@ int CYAServerDlg::TestGenerateAllDataJson()
 	return 0;
 }
 
-afx_msg LRESULT CYAServerDlg::OnWriteErrorLog(WPARAM wParam, LPARAM lParam)
-{
-	LogMsg* pMsg = (LogMsg*)wParam;
-	CString strFile = pMsg->strFile;
-	bool bTime = pMsg->isNeedTime;
-	CString strErr = pMsg->strLog;
-	writeErrorLogEx(strFile, strErr, bTime);
-	strErr.Empty();
-	strFile.Empty();
-	delete pMsg;
-	return 0;
-}
-
 void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConnId )
 {
 	LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_92);
@@ -12527,7 +12463,6 @@ void CYAServerDlg::deal_card_msg( std::shared_ptr<Card> card/*Card* card*/, bool
 		return ;
 	}
 
-	int aa = card->card_type;
 	//判断井下和区域是否超时
 	if(card->b_pos_change || PDT_UP == card->p_reader->pos_state) // 坐标不变化,不走业务
 	{ 
@@ -12562,71 +12497,6 @@ afx_msg LRESULT CYAServerDlg::OnRemoveSocket(WPARAM wParam, LPARAM lParam)
 	return 0;
 }
 
-void CYAServerDlg::writeErrorLogEx( const CString strFile, const CString strErr ,bool bTime /*= true*/ )
-{
-	EnterCriticalSection(&m_csWriteLog);
-	if(openLogFile(strFile)){
-		CString strTempInfo;
-		if(bTime){
-			COleDateTime t = COleDateTime::GetCurrentTime(); 
-			strTempInfo.Format(_T("%s\r\n%s\r\n"), t.Format(_T("%H:%M:%S")), strErr);
-		}else{
-			strTempInfo.Format(_T("%s\r\n"), strErr);
-		}
-		TRY{
-			cfErrorLog.SeekToEnd();
-			char* old_locale = _strdup(setlocale(LC_CTYPE,NULL));
-			setlocale( LC_CTYPE, "chs" );//设定
-
-			cfErrorLog.WriteString(strTempInfo);
-
-			setlocale( LC_CTYPE, old_locale );
-			free( old_locale );//还原区域设定
-		}
-		CATCH(CFileException, e){
-			if(cfErrorLog.m_pStream)
-				cfErrorLog.Close();
-		}
-		END_CATCH
-	}
-	LeaveCriticalSection(&m_csWriteLog);
-}
-
-void CYAServerDlg::writeErrorLogEx( const char* strFile, const char* strErr ,bool bTime /*= true*/ )
-{
-	EnterCriticalSection(&m_csWriteLog);
-	if(openLogFile(strFile)){
-		CString strTempInfo;
-		if(bTime){
-			COleDateTime t = COleDateTime::GetCurrentTime(); 
-			strTempInfo.Format(_T("%s\r\n"), t.Format(_T("%H:%M:%S")));
-			USES_CONVERSION;
-			CString tmp = A2T(strErr);
-			strTempInfo += tmp + _T("\r\n");
-		}else{
-			USES_CONVERSION;
-			strTempInfo = CFunctions::c2wc(strErr);
-			strTempInfo += _T("\r\n");
-		}
-		TRY{
-			cfErrorLog.SeekToEnd();
-			char* old_locale = _strdup(setlocale(LC_CTYPE,NULL));
-			setlocale( LC_CTYPE, "chs" );//设定
-
-			cfErrorLog.WriteString(strTempInfo);
-
-			setlocale( LC_CTYPE, old_locale );
-			free( old_locale );//还原区域设定
-		}
-		CATCH(CFileException, e){
-			if(cfErrorLog.m_pStream)
-				cfErrorLog.Close();
-		}
-		END_CATCH
-	}
-	LeaveCriticalSection(&m_csWriteLog);
-}
-
 void CYAServerDlg::init_queuestring()
 {
 	m_qsmSQL = new QueueStrManager(SQL_EXECUTE_SENTENCE_COUNT_MAX,
@@ -12856,14 +12726,9 @@ void CYAServerDlg::parse_data_locate_card_his_tof_card( BYTE* DataBuffer, int nL
 		}						
 	}
 
-	try
-	{
-		if(b_exec){
-			execute_sql(sql);
-		}
-	}
-	catch (...)
+	if (b_exec)
 	{
+		execute_sql(sql);
 	}
 }
 
@@ -12957,14 +12822,9 @@ void CYAServerDlg::parse_data_locate_card_his_tdoa_card( BYTE* DataBuffer, int n
 		}						
 	}
 
-	try
-	{
-		if(b_exec){
-			execute_sql(sql);
-		}
-	}
-	catch (...)
+	if (b_exec)
 	{
+		execute_sql(sql);
 	}
 }
 
@@ -14381,14 +14241,7 @@ void CYAServerDlg::save_raw_data_card_tof( std::shared_ptr<Card> card )
 	sprintf_s(sql, LENGTH_SQL, 
 		"INSERT INTO his_raw_data_card_tof(card_id, ct, ft, power_state, acc_state, reader_id, antenna_id, distance) VALUES(%s, %d, %I64u, %d, %d, %d, %d, %.3f);",  
 		card->card_id.c_str(), card->time_stamp, card->flying_time, card->power_state, card->accelerate_state, card->reader_id, card->antenna_id, card->distance);
-	try
-	{
-		execute_sql(sql);
-	}
-	catch (...)
-	{
-
-	}
+	execute_sql(sql);
 }
 
 int CYAServerDlg::init_shift()

+ 0 - 5
YAServerDlg.h

@@ -73,7 +73,6 @@ struct _SOCKET_BUFFER
 
 //extern DWORD WINAPI _exec_sql(LPVOID lparam);
 extern DWORD WINAPI _exec_sql(const char* lparam);
-extern DWORD WINAPI _write_error_log(LPVOID lparam);
 
 // CYAServerDlg ¶Ô»°¿ò
 class CYAServerDlg : public CDialogEx, public CTcpServerListener
@@ -505,9 +504,6 @@ public:
 	int API_StringToTime(const string &strDateStr,time_t &timeData);
 	//void formatByteArray(CString &strBuf, BYTE * buf, int nLen);
 	void formatByteArray(std::string &strBuf, BYTE * buf, int nLen);
-	void writeErrorLog(const CString strFile, const CString strErr ,bool bTime = true);
-	void writeErrorLogEx(const CString strFile, const CString strErr ,bool bTime = true);
-	void writeErrorLogEx(const char* strFile, const char* strErr ,bool bTime = true);
 	BOOL openLogFile(const CString strFile);
 	BOOL openLogFile(const char* strFile);
 	void show_log( LPCTSTR szlog, BOOL bSave = true);
@@ -600,7 +596,6 @@ public:
 protected:
 	afx_msg LRESULT OnRemoveSocket(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnMsgRefreshIpList(WPARAM wParam, LPARAM lParam);
-	afx_msg LRESULT OnWriteErrorLog(WPARAM wParam, LPARAM lParam);
 public:
 	UINT m_reader_id_hist;
 	afx_msg void OnEnUpdateEditReaderid();

+ 0 - 207
client_thread.cpp

@@ -1,207 +0,0 @@
-#include "stdafx.h"
-#include "classdef.h"
-#include "winsock2.h"
-#include "constdef.h"
-#include <sys/stat.h>
-#include <map>
-using namespace std;
-
-void sendHead(SOCKET s, int state, char* fileExtension, char* version);
-bool sendContent(SOCKET s, char* filePath);
-map<string, string> map_param;
-
-char ascii_string[10000];
-char *char_to_ascii(char ch){
-	char *ascii_str;
-	ascii_string[0] = 0;
-	ascii_str = ascii_string;
-	if(isgraph(ch)){
-		*ascii_str++ = ch;
-	}else if(ch == ' '){
-		*ascii_str++ =ch;
-	}else if(ch == '\n' || ch == '\r'){
-		*ascii_str++ =ch;
-	}else{
-		*ascii_str++ ='.';
-	}
-	*ascii_str = 0;
-	return ascii_string;
-}
-
-void parse_interface(){
-	string username, inter_face, json_data, version; 
-	map<string, string>::iterator it_para = map_param.begin();
-	for(; it_para != map_param.end(); ++it_para){
-		if(it_para->first == PARAM_NAME_USERNAME){
-			username = it_para->second;
-		}else if(it_para->first == PARAM_NAME_INTERFACE){
-			inter_face = it_para->second;
-		}else if(it_para->first == PARAM_NAME_DATA){
-			json_data = it_para->second;
-		}else if(it_para->first == PARAM_NAME_VERSION){
-			version = it_para->second;
-		}
-	}
-	//
-	if(version == "1.0"){
-		if(inter_face == INTERFACE_NAME_SETLIMITVALUE){
-
-		}else if(inter_face == INTERFACE_NAME_CALLCARD){
-
-		}else if(inter_face == INTERFACE_NAME_CLEARCARD){
-
-		}else if(inter_face == INTERFACE_NAME_EDITAREA){
-
-		}else if(inter_face == INTERFACE_NAME_EDITSTATION){
-
-		}else if(inter_face == INTERFACE_NAME_EDITPATH){
-
-		}else if(inter_face == INTERFACE_NAME_EDITCARD){
-
-		}else if(inter_face == INTERFACE_NAME_EDITSTAFFER){
-
-		}else if(inter_face == INTERFACE_NAME_EDITVEHICLE){
-
-		}
-	}
-}
-
-void parse_param_data(char content[], int number){
-	//char temp[1000];
-	int i,j = 0;
-	bool bkey = true;
-	string para_key = "", para_value = "";
-
-	for(i = 0; i < number; i++){
-		if(content[i] == '&'){
-			bkey = true;
-			para_value += '\0';
-			i++;
-			map_param.insert(make_pair(para_key, para_value));
-			para_key = "";
-			para_value = "";
-			j = 0;
-		}
-		if(content[i] == '='){
-			bkey = false;
-			para_key += '\0';
-			i++;
-			j = 0;
-		}		
-		if(bkey){
-			para_key += content[i];
-		}else{
-			para_value += content[i];
-		}
-		j++;
-	}
-	para_value += '\0';
-	map_param.insert(make_pair(para_key, para_value));
-}
-
-void parse_server_data(char content[], size_t number){
-	char temp[1024];
-	char str1[1024];
-	char str2[1024];
-	char str3[1024];
-	char paralen[20];
-	size_t i, j, k = 0, m = 0;
-	char entity_content[1024];
-
-	for(i = 0; i < number; i++){
-		if(content[i] != '\n'){
-			k++;
-			continue;
-		}
-		for(j = 0; j < k; j++)
-			temp[j] = content[j + i - k];
-		temp[j] = '\0';
-		if(strstr(temp, "GET") || strstr(temp, "POST")){ // 请求行为
-			sscanf_s(temp, "%s %s %s", str1, str2, str3); // 命令,路径,协议版本
-		}
-		//if(strstr(temp, "Accept:")){ // 数据文件包括(Accept:)
-
-		//}
-		//if(strstr(temp, "Referer")){ // 转移地址(Referer)
-
-		//}
-		//if(strstr(temp, "Accept-Language")){ // 使用的语言 
-
-		//}
-		//if(strstr(temp, "Accept-Encoding")){ // 编码方式
-
-		//}
-		//if(strstr(temp, "If-Modified-Since")){ // 上次修改时间
-
-		//}
-		//if(strstr(temp, "If-Node-Match")){ // 
-
-		//}
-		//if(strstr(temp, "User-Agent")){ // 用户浏览器信息
-
-		//}
-		//if(strstr(temp, "Host")){ // 访问的主机
-
-		//}
-		//if(strstr(temp, "Connection")){ // 连接状态
-
-		//}
-		//if(strstr(temp, "Cookie")){ // cookie
-
-		//}
-		//if(strstr(temp, "Cache-Control:")){ // 
-
-		//}
-		//if(strstr(temp, "Content-Type:")){ // 实体数据格式
-		//
-		//}
-		if(strstr(temp, "Content-Length:")){ // 数据长度
-			//sscanf(temp, "%s%d", temp, paralen);
-			m = 0;
-			for(j = 15; j < strlen(temp); j++){
-				if(temp[j] != ' ' && temp[j] != '\n'){
-					paralen[m] = temp[j];
-					m++;
-				}
-			}
-			paralen[m] = '\0';
-			m = atoi(paralen);
-		}
-		// 实体数据
-		if((content[i]  == '\n') && content[i + 1] == '\r' && content[i + 2] == '\n'){
-			if(i + 3 == strlen(content)){ // 无数据
-				break;
-			}
-			//for (j = 0; j < strlen(content) - i - 3; j++){
-			for(j = 0; j < m; j++){
-				entity_content[j] = content[i + 3 + j];
-			}
-			entity_content[j] = '\0';
-
-			string estr = entity_content;
-			// 解析参数
-			parse_param_data(entity_content, m);
-			break;
-		}
-		k = 0;		
-	}
-}
-
-DWORD WINAPI clientThread(LPVOID lparam)
-{
-	PARA* para = (PARA*)lparam;
-	char buf[MAXSIZE], filePath[200], cmd[50], version[50], fileExtension[50]={'\0'};
-	int recvCount;
-
-	filePath[0]='.';
-	//int aa, bb, cc = 0;
-	//char temp1[200], temp2[200] = {0};
-	recvCount = recv(para->s, buf, MAXSIZE, 0);
-	sscanf_s(buf, "%s %s %s", cmd, filePath + 1, version);
-
-	parse_server_data(buf, recvCount);
-
-	closesocket(para->s);
-	delete para;
-	return 0;
-}

+ 0 - 92
listening_thread.cpp

@@ -1,92 +0,0 @@
-#include "stdafx.h"
-
-#include <stdio.h>
-#include "winsock2.h"
-#include "classdef.h"
-#include "constdef.h"
-#include <process.h>
-
-#pragma comment (lib, "Ws2_32.lib")
-
-DWORD WINAPI clientThread(LPVOID lparam);
-
-unsigned int __stdcall listeningThread(void *param)
-{
-	SOCKET local_socket, client_socket;
-	sockaddr_in service, client_sock_addr;
-	PARA* clientInfo;
-
-	local_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-	if(local_socket == INVALID_SOCKET)
-	{
-		//printf("socket failed\n");
-		exit(0);
-	}
-
-	service.sin_family = AF_INET;
-	service.sin_addr.S_un.S_addr = INADDR_ANY;
-	service.sin_port = htons(int(param));
-
-
-	if(bind(local_socket, (sockaddr*)&service, sizeof(sockaddr)) == SOCKET_ERROR)
-	{
-		//printf("bind failed\n");
-		exit(0);
-	}
-
-	if(listen(local_socket, BACKLOG) == SOCKET_ERROR)
-	{
-		//printf("listen failed\n");
-		exit(0);
-	}
-
-	//printf("****************************Web server start up!****************************\n\n");
-
-	while(1)
-	{
-		int sockaddrLength = sizeof(sockaddr);
-		client_socket = accept(local_socket, (sockaddr*)&client_sock_addr, &sockaddrLength);
-		if(client_socket == INVALID_SOCKET)
-		{
-			//printf("accept failed\n");
-			continue;
-		}
-
-		clientInfo = new PARA;
-		clientInfo->s = client_socket;
-		memcpy((void*)&(clientInfo->addr), &client_sock_addr, sizeof(client_sock_addr));
-		//clientInfo.addr=clientSockaddr;
-
-		clientThread((LPVOID)clientInfo);
-
-		//DWORD lpThreadId;
-		//HANDLE hThread;
-		//hThread = CreateThread(NULL, 0, clientThread, (LPVOID)clientInfo, 0, &lpThreadId);
-		//if(hThread != NULL)
-		//{
-		//	//printf("------------------Start one connect!------------------\n");
-		//}
-		//else
-		//{
-		//	//printf("------------------One client connection failed!\n------------------");
-		//}
-	}
-	//closesocket(local_socket);
-	//WSACleanup();
-}
-
-//void main()
-//{
-//	WORD wVersionRequested;
-//	WSADATA wsaData;
-//	int err;
-//	wVersionRequested = MAKEWORD(2, 2);
-//	err = WSAStartup(wVersionRequested, &wsaData);
-//	if (err != 0) {
-//		return;
-//	}
-//
-//	_beginthreadex(NULL, 0, listeningThread, (void *) 8120, 0, NULL);
-//	_beginthreadex(NULL, 0, listeningThread, (void *) 8121, 0, NULL);
-//	Sleep(INFINITE);
-//}

+ 1 - 1
mylog/MyLog.cpp

@@ -193,7 +193,7 @@ bool MyLog::CreateDir(const char * pDir)
 				iRet = MKDIR(pszDir);  
 				if (iRet != 0)  
 				{  
-					return -1;  
+					return false;  
 				}   
 			}  
 			//Ö§³Ölinux,½«ËùÓÐ\»»³É/  

+ 0 - 0
pingme.txt


+ 0 - 31
send_content.cpp

@@ -1,31 +0,0 @@
-#include "stdafx.h"
-#include <winsock2.h>
-#include "constdef.h"
-
-bool sendContent(SOCKET s, char* filePath)
-{
-	char buf[MAXSIZE] = {'\0'};
-	FILE* filePtr;
-	fopen_s(&filePtr, filePath, "rb");
-	if(filePtr == NULL)
-	{
-		//printf("Failed to open the file\n");
-		return false;
-	}
-	else
-	{
-		int sendCount;
-		while(!feof(filePtr))
-		{
-			sendCount = fread(buf,sizeof(char), MAXSIZE, filePtr);
-			send(s, buf, sendCount, 0);
-			if(ferror(filePtr))
-			{
-				//printf("File read error\n");
-				return false;
-			}
-		}
-	}
-	fclose(filePtr);
-	return true;
-}

+ 0 - 54
send_head.cpp

@@ -1,54 +0,0 @@
-#include "stdafx.h"
-#include <winsock2.h>
-#include "constdef.h"
-
-void sendHead(SOCKET s, int state, char* fileExtension, char* version)
-{
-	char buf[MAXSIZE] = {'\0'}, *content = "text/plain", *stateStr = NULL;
-	switch(state)
-	{
-	case 200:
-		stateStr = "OK";
-		break;
-	case 400:
-		stateStr = "Bad Request";
-		break;
-	case 404:
-		stateStr = "Not Found";
-		break;
-	default:
-		stateStr = "Unknown";
-		break;
-	}
-
-	if(strcmp(fileExtension, "html") == 0 || strcmp(fileExtension, "htm") == 0)
-	{
-		content = "text/html";
-	}
-	else if(strcmp(fileExtension, "css") == 0)
-	{
-		content = "text/css";
-	}
-	else if(strcmp(fileExtension, "gif") == 0)
-	{
-		content = "image/gif";
-	}
-	else if(strcmp(fileExtension, "jpeg") == 0)
-	{
-		content ="image/jpeg";
-	}
-	else if(strcmp(fileExtension, "jpg") == 0)
-	{
-		content = "image/jpg";
-	}
-	else if(strcmp(fileExtension,"png") == 0)
-	{
-		content = "image/png";
-	}
-	sprintf_s(buf, "%s %d %s \r\nContent-Type: %s \r\n\r\n", version, state, stateStr, content);
-
-	int sendCount = strlen(buf);
-	//for(;buf[sendCount]!='\0';sendCount++);
-	send(s, buf, sendCount, 0);
-	return ;
-}

+ 0 - 85
sever_thread.cpp

@@ -1,85 +0,0 @@
-#include <stdio.h> 
-#include <Winsock2.h> 
-#include <process.h> 
-#pragma comment (lib, "Ws2_32.lib") 
-
-unsigned int __stdcall listeningThread(void *param)
-{ 
-	SOCKET sockSrv = socket(AF_INET, SOCK_STREAM, 0); 
-	SOCKADDR_IN addrSrv; 
-
-	addrSrv.sin_addr.S_un.S_addr = htonl(INADDR_ANY); 
-
-	addrSrv.sin_family = AF_INET; 
-
-	addrSrv.sin_port = htons((int)param); 
-
-
-
-	int ret = bind(sockSrv, (SOCKADDR*) &addrSrv, sizeof(SOCKADDR)); 
-
-	ret = listen(sockSrv, 5); 
-
-	SOCKADDR_IN addrClient; 
-
-	int len = sizeof(SOCKADDR); 
-
-	while (1) 
-
-	{ 
-
-		SOCKET sockConn = accept(sockSrv, (SOCKADDR*) &addrClient, &len); 
-
-		char sendBuf [] = "Hello World !"; 
-
-
-
-		send(sockConn, sendBuf, strlen(sendBuf) + 1, 0); 
-
-		char recvBuf[50]; 
-
-		recv(sockConn, recvBuf, 50, 0); 
-
-		printf("%s\n", recvBuf); 
-
-		closesocket(sockConn); 
-
-	} 
-
-	return 0; 
-
-} 
-
-void main() 
-
-{ 
-
-	WORD wVersionRequested; 
-
-	WSADATA wsaData; 
-
-	int err; 
-
-
-
-	wVersionRequested = MAKEWORD(2, 2); 
-
-
-
-	err = WSAStartup(wVersionRequested, &wsaData); 
-
-	if (err != 0) { 
-
-		return; 
-
-	} 
-
-
-
-	_beginthreadex(NULL, 0, listeningThread, (void *) 8120, 0, NULL); 
-
-	_beginthreadex(NULL, 0, listeningThread, (void *) 8121, 0, NULL); 
-
-	Sleep(INFINITE); 
-
-}