1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456 |
- #include "StdAfx.h"
- #include "ClientProcess.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- CRITICAL_SECTION CClientProcess::m_csMsgInfo;
- list<MsgInfo> CClientProcess::m_listMsgInfo;
- CString GetAuthCode(CString requestcode, long newsecond)
- {
- try
- {
- UINT m_year;
- UINT m_month;
- UINT m_day;
- UINT m_hour;
- UINT m_minute;
- {
- TCHAR year[10],month[10],day[10],hour[10],minute[10], second[10];
- ConvertTimerToStringReal(newsecond, year, month, day, hour, minute, second);
- m_year=_ttoi(year);
- m_month=_ttoi(month);
- m_day=_ttoi(day);
- m_hour=_ttoi(hour);
- m_minute=_ttoi(minute);
- if(newsecond==60)
- {
- m_year=60;
- m_month=0;
- m_day=0;
- m_hour=0;
- m_minute=0;
- }
- }
- if(m_year<0 || m_month<0 || m_day<0 || m_hour<0 || m_minute<0)
- {
- return _T("");
- }
- requestcode.TrimLeft();
- requestcode.TrimRight();
- requestcode.Replace("\n", "");
- requestcode.Replace("\r", "");
- if(requestcode.IsEmpty())
- {
- return "";
- }
- TString str,temp,temp2;
- int id,time1,time2,idtemp;
- int leng;
- str=requestcode;
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0, leng);
- str=str.substr(leng);
- id=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() -1)=="1")id=-id;
- //////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0, leng);
- str=str.substr(leng);
- time1=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() -1)=="1")time1=-time1;
- //////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0, leng);
- str=str.substr(leng);
- time2=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() -1)=="1")time2=-time2;
- //////////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0, leng);
- str=str.substr(leng);
- idtemp=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() -1)=="1")idtemp=-idtemp;
- //////////////////////////////////////////////////////
- // SoftKey ytSoftKey;
- int ret=0;//ytSoftKey.Ini();
- if (ret!=0 )
- {
- return "";
- }
- int d[8];double f[8];
- char s0[50]="",s1[50]="",s2[50]="",s3[50]="",s4[50]="",s5[50]="",s6[50]="",s7[50]="";
- // 运行自定义函数;
- ret=ytSoftKey.code2(&id,&idtemp,&time1,&time2,&d[4],&d[5],&d[6],&d[7],
- &f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],
- s0,s1,s2,s3,s4,s5,s6,s7);
- if(ret!=0 && ret!=-43)
- {
- return "";
- }
- ////////////////////////////////////////////////////////////////////////
- TCHAR DevicePath[ 260];
- if(FindPort(0,DevicePath)!=0)
- return "";
- DWORD OutID;
- int version;
- GetIDVersion(&OutID, &version, DevicePath);
- TCHAR year[10],month[10],day[10],hour[10],minute[10], OutString[100];
- _stprintf_s(year, _T("%d"), m_year);
- _stprintf_s(month, _T("%d"), m_month);
- _stprintf_s(day, _T("%d"), m_day);
- _stprintf_s(hour, _T("%d"), m_hour);
- _stprintf_s(minute, _T("%d"), m_minute);
- MakeTimerAuth("20D30D15FFB7F6AF9EAB30FD229F797B", id, year, month, day, hour, minute, OutString,DevicePath);
- CString authcode=OutString;
- TCHAR szTemp[50] = {0};
- //str.Format ("%04d", m_year);
- _stprintf_s(szTemp, _T("%04d"), m_year);
- authcode += szTemp;
- //str.Format ("%02d", m_month);
- _stprintf_s(szTemp, _T("%02d"), m_month);
- authcode += szTemp;
- //str.Format ("%02d", m_day);
- _stprintf_s(szTemp, _T("%02d"), m_day);
- authcode+=szTemp;
- _stprintf_s(szTemp, _T("%02d"), m_hour);
- //str.Format ("%02d", m_hour);
- authcode+=szTemp;
- _stprintf_s(szTemp, _T("%02d"), m_minute);
- //str.Format ("%02d", m_minute);
- authcode+=szTemp;
- //str.Format ("%08d", id);
- _stprintf_s(szTemp, _T("%08d"), id);
- authcode+=szTemp;
- TString str1,str2,str3,str4,str5;
- str1=authcode.Mid (0, 20);
- str2=authcode.Mid (20, 20);
- str3=authcode.Mid (40, 20);
- str4=authcode.Mid (60, 20);
- str5=authcode.Mid (80, 20);
- _stprintf_s(s0, "%s", str1.c_str());
- _stprintf_s(s1, "%s", str2.c_str());
- _stprintf_s(s2, "%s", str3.c_str());
- _stprintf_s(s3, "%s", str4.c_str());
- _stprintf_s(s4, "%s", str5.c_str());
- //运行自定义函数
- {
- SoftKey ytSoftKey2;
- ret=ytSoftKey2.Ini();
- if (ret!=0 )
- {
- return "";
- }
- {
- int d[8];double f[8];
- char s5[50]="",s6[50]="",s7[50]="";
- ret=ytSoftKey2.code1(&d[0],&d[1],&d[2],&d[3],&d[4],&d[5],&d[6],&d[7],
- &f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],
- s0,s1,s2,s3,s4,s5,s6,s7);
- }
- if(ret!=0 && ret!=-43)
- {
- return "";
- }
- str1=s0;
- str2=s1;
- str3=s2;
- str4=s3;
- str5=s4;
- }
- authcode=str1.c_str();
- authcode+=str2.c_str();
- authcode+=str3.c_str();
- authcode+=str4.c_str();
- authcode+=str5.c_str();
- return authcode;
- }
- catch(...)
- {
- }
- return _T("");
- }
- CString GetUseDays(CString requestcode)
- {
- try
- {
- CString sRet;
- requestcode.TrimLeft();
- requestcode.TrimRight();
- requestcode.Replace("\n", "");
- requestcode.Replace("\r", "");
- if(requestcode.IsEmpty())
- {
- return "";
- }
- TString str,temp,temp2;
- int id,time1,time2,idtemp;
- int leng;
- str=requestcode;
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0,leng);
- str=str.substr(leng);
- id=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() - 1)=="1")id=-id;
- //////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0,leng);
- str=str.substr(leng);
- time1=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() - 1)=="1")time1=-time1;
- //////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0,leng);
- str=str.substr(leng);
- time2=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() - 1)=="1")time2=-time2;
- //////////////////////////////////////////////////////
- temp=str.substr(0,3);
- str=str.substr(3);
- leng=_ttoi(temp.substr(0,2).c_str());
- temp2=str.substr(0,leng);
- str=str.substr(leng);
- idtemp=_ttoi(temp2.c_str());
- if(temp.substr(temp.length() - 1)=="1")idtemp=-idtemp;
- //////////////////////////////////////////////////////
- // SoftKey ytSoftKey;
- int ret=0;//ytSoftKey.Ini();
- if (ret!=0 )
- {
- return "";
- }
- int d[8];double f[8];
- char s0[50]="",s1[50]="",s2[50]="",s3[50]="",s4[50]="",s5[50]="",s6[50]="",s7[50]="";
- //运行自定义函数
- ret=ytSoftKey.code2(&id,&idtemp,&time1,&time2,&d[4],&d[5],&d[6],&d[7],
- &f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],
- s0,s1,s2,s3,s4,s5,s6,s7);
- if(ret!=0 && ret!=-43)
- {
- return "";
- }
- // TODO: Add your control notification handler code here
- TCHAR year[10],month[10],day[10],hour[10],minute[10], second[10];
- ConvertTimerToStringReal(time2, year, month, day, hour, minute, second);
- TCHAR szTemp[MAX_PATH];
- _stprintf_s(szTemp, _T("已运行:%d年%d月%d日 "), _ttoi(year), _ttoi(month), _ttoi(day));
- sRet+=szTemp;
- if(time1>0)
- ConvertTimerToStringReal(time1, year, month, day, hour, minute, second);
- else
- {
- _stprintf_s(year, "%s", "0");
- _stprintf_s(month, "%s", "0");
- _stprintf_s(day, "%s", "0");
- _stprintf_s(hour, "%s", "0");
- _stprintf_s(minute, "%s", "0");
- }
- _stprintf_s(szTemp, _T("能运行:%d年%d月%d日---%d"), _ttoi(year), _ttoi(month), _ttoi(day), time2);
- sRet+=szTemp;
- return sRet;
- }
- catch(...)
- {
- }
- return "";
- }
- CClientProcess::CClientProcess(void)
- {
- m_hEvent = NULL;
- m_hThread = NULL;
- m_hEvent2 = NULL;
- m_hThread2 = NULL;
- InitializeCriticalSection(&m_csMsgInfo);
- }
- CClientProcess::~CClientProcess(void)
- {
- DeleteCriticalSection(&m_csMsgInfo);
- m_listMsgInfo.clear();
- }
- void CClientProcess::StartMsgWork()
- {
- m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- if ( m_hEvent == NULL )
- {
- // 创建事件失败;
- return;
- }
- m_hThread = CreateThread(NULL, 0, MsgThread, this, 0, NULL);
- if ( m_hThread == NULL )
- {
- CloseHandle(m_hEvent);
- m_hEvent = NULL;
- }
- //////////////////////////////////////////////////////////////////////////
- m_hEvent2 = CreateEvent(NULL, TRUE, FALSE, NULL);
- if ( m_hEvent2 == NULL )
- {
- // 创建事件失败;
- return;
- }
- m_hThread2 = CreateThread(NULL, 0, MsgThread, this, 0, NULL);
- if ( m_hThread2 == NULL )
- {
- CloseHandle(m_hEvent2);
- m_hEvent2 = NULL;
- }
- }
- void CClientProcess::EndOfMsgWork()
- {
- if ( m_hEvent )
- {
- SetEvent(m_hEvent);
- }
- if ( m_hThread )
- {
- WaitForSingleObject(m_hThread, INFINITE);
- CloseHandle(m_hThread);
- m_hThread = NULL;
- }
- if (m_hEvent)
- CloseHandle(m_hEvent);
- m_hEvent = NULL;
- //////////////////////////////////////////////////////////////////////////
- if ( m_hEvent2 )
- {
- SetEvent(m_hEvent2);
- }
- if ( m_hThread2 )
- {
- WaitForSingleObject(m_hThread2, INFINITE);
- CloseHandle(m_hThread2);
- m_hThread2 = NULL;
- }
- if (m_hEvent2)
- CloseHandle(m_hEvent2);
- m_hEvent2 = NULL;
- }
- void CClientProcess::InsertMsgInfo(IN MsgInfo& msgInfo)
- {
- EnterCriticalSection(&m_csMsgInfo);
- m_listMsgInfo.push_back(msgInfo);
- LeaveCriticalSection(&m_csMsgInfo);
- }
- BOOL CClientProcess::PopMsgInfo(IN MsgInfo& msgInfo)
- {
- BOOL bRet = FALSE;
- EnterCriticalSection(&m_csMsgInfo);
- if ( m_listMsgInfo.size())
- {
- msgInfo = m_listMsgInfo.front();
- m_listMsgInfo.pop_front();
- bRet = TRUE;
- }
- LeaveCriticalSection(&m_csMsgInfo);
- return bRet;
- }
- void CClientProcess::WorkSendInfo(IN CONST SOCKET& nSock, IN CONST INT& wMessageLen, IN TString &strInfo, OUT INT& ArySize, OUT BYTE** pAryData, OUT DWORD& dwAryDataSize)
- {
- //////////////////////////////////////////////////////////////////////////
- DWORD dwFromUserID = wMessageLen;
- WORD wMessageId = MSG_CHATMESSAGE_RESP;
- DWORD dwDataLen;
- BYTE *pSendData;
- TCHAT_MESSAGE_STRU *pChatMessage;
- TMessageHeader tHeader = {0};
- tHeader.wMessageId = wMessageId;
- SENDHEAD tSendhead;
- ZeroMemory(&tSendhead,sizeof(SENDHEAD));
- if ( strInfo.empty() )
- strInfo = _T("OK");
- int nDataLen = strInfo.length();
- if(dwAryDataSize)
- {
- nDataLen = dwAryDataSize;
- tSendhead.count[0] = ArySize;
- }
- dwDataLen = sizeof(TCHAT_MESSAGE_STRU) + nDataLen ;
- pSendData = new BYTE[dwDataLen];
- pChatMessage=(TCHAT_MESSAGE_STRU*)pSendData;
- memset(pChatMessage, 0x00, dwDataLen);
- memcpy(pSendData, &tSendhead, sizeof(SENDHEAD));
- pChatMessage->tCommonMsg.dwConnectionID = dwFromUserID;
- pChatMessage->tCommonMsg.wMessageId = wMessageId;
- pChatMessage->dwFromUserID = dwFromUserID;
- pChatMessage->dwToUserID = pChatMessage->wMessageLen;
- pChatMessage->wMessageLen = nDataLen;
- if(dwAryDataSize)
- {
- memcpy(pChatMessage->byFileContent, *pAryData, nDataLen);
- //delete []*pAryData;
- }
- else
- {
- memcpy(pChatMessage->byFileContent, strInfo.c_str(), nDataLen);
- }
- CSocketHandle tClientSo;
- tClientSo.Attach(nSock);
- net_Send(&tClientSo, &tHeader, (void *)pChatMessage, dwDataLen);
- tClientSo.Detach();
- delete [] pSendData;
- }
- DWORD CClientProcess::MsgThread(LPVOID lpParam)
- {
- MsgInfo tagMsgInfo;
- BOOL bSend = FALSE;
- INT nArySize = 0;
- DWORD dwAryDataSize = 0;
- BYTE *pAryData = NULL;
- CClientProcess *pInstance = (CClientProcess*)lpParam;
- do
- {
- if ( PopMsgInfo(tagMsgInfo) )
- {
- bSend = FALSE;
- switch( tagMsgInfo.dwUserId )
- {
- case 6:
- bSend = Work_No6(tagMsgInfo.strMessage, tagMsgInfo.strIPAddress.c_str());
- break;
- case 7:
- bSend = Work_No7(tagMsgInfo.strMessage);
- break;
- case 8:
- bSend = Work_No8(tagMsgInfo.strMessage, nArySize, &pAryData, dwAryDataSize);
- break;
- case 9:
- bSend = Work_No9(tagMsgInfo.strMessage, tagMsgInfo.pData, tagMsgInfo.wMessageLen);
- break;
- case 10:
- bSend = Work_No10(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.strMessage);
- break;
- case 11:
- bSend = Work_No11(tagMsgInfo.strMessage);
- break;
- case 12:
- bSend = Work_No12(tagMsgInfo.strMessage);
- break;
- case 13:
- bSend = Work_No13(tagMsgInfo.strMessage);
- break;
- case 14:
- bSend = Work_No14(tagMsgInfo.strMessage);
- break;
- case 15:
- bSend = Work_No15(tagMsgInfo.strMessage);
- break;
- case 16:
- bSend = Work_No16(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.strMessage);
- break;
- default:
- break;
- }
-
- if ( bSend )
- {
- WorkSendInfo(tagMsgInfo.nSocket, tagMsgInfo.wMessageLen, tagMsgInfo.strMessage, nArySize, &pAryData, dwAryDataSize);
- if ( pAryData )
- {
- delete []pAryData;
- pAryData = NULL;
- }
- nArySize = 0;
- dwAryDataSize = 0;
- }
- }
- } while (WaitForSingleObject(pInstance->m_hEvent, 10) == WAIT_TIMEOUT );
- return 0;
- }
- DWORD CClientProcess::net_Send(CSocketHandle* pSH, IN void *pHeader, IN void *pMessage, IN unsigned long ulDataLen)
- {
- unsigned long ulSendLen = 0;
- unsigned long ulBufLen = 0;
- TMessageHeader *pSendHeader = (TMessageHeader *)pHeader;
- ulBufLen = MESSAGE_HEADER_LEN + ulDataLen;
- BYTE *pSendBuf = new BYTE[ulBufLen];
- memset(pSendBuf, 0, ulBufLen);
- TMessageHeader *pMessageHeader = (TMessageHeader *)pSendBuf;
- pMessageHeader->byVersion = 101;
- pMessageHeader->wHeaderFlag = MESSAGE_HEADER_FLAG;
- pMessageHeader->wMessageId = pSendHeader->wMessageId;
- pMessageHeader->wMessageSubId = pSendHeader->wMessageSubId;
- pMessageHeader->dwDataLen = ulDataLen;
- pMessageHeader->wReserve = 0;
- memcpy((void *)(pSendBuf+MESSAGE_HEADER_LEN), pMessage, ulDataLen);
- // convert network word
- htons(pMessageHeader->wHeaderFlag);
- htons(pMessageHeader->wMessageId);
- htons(pMessageHeader->wMessageSubId);
- htonl(pMessageHeader->dwDataLen);
- htons(pMessageHeader->wCheckSum);
- htonl(pMessageHeader->wReserve);
- INT nBytes = pSH->Write(pSendBuf, ulBufLen, NULL, 1000);
- DWORD dwError = WSAGetLastError();
- if ( dwError != 0 )
- {
- printf("\t发送给客户端信息失败:%d\n", dwError);
- }
- delete []pSendBuf;
- pSendBuf = NULL;
- return nBytes;
- }
- void CClientProcess::ClientProcess(IN const SOCKET sClient, IN const BYTE* pbData, IN DWORD dwCount, IN LPCTSTR lpaddr, IN BYTE** PendingBuf, IN UINT &nPendingSize, IN UINT &nCurSize)
- {
- try
- {
- TMessageHeader *pMessageHeader = (TMessageHeader *)pbData;
- if(pMessageHeader->wMessageId == MSG_LOGIN_REQ)
- {
- WORD wMessageId = MSG_LOGIN_RESP;
- LOGIN_RESULT_STRU tLoginResult = {0};
- tLoginResult.tCommonMsg.dwConnectionID = 0;
- tLoginResult.tCommonMsg.wMessageId = wMessageId;
- tLoginResult.byResult = LOGIN_RESULT_SUC;
- tLoginResult.dwUserID = 0;
- tLoginResult.byStatus = USER_STATUS_ONLINE ;
- DWORD dwDataLen = sizeof(LOGIN_RESULT_STRU);
- TMessageHeader tHeader = {0};
- tHeader.wMessageId = wMessageId;
- tHeader.dwDataLen = dwDataLen;
- if ( (pMessageHeader->dwDataLen + sizeof(LOGIN_RESULT_STRU)) != dwCount )
- {
- return;
- }
- CSocketHandle hClient;
- hClient.Attach(sClient);
- net_Send(&hClient, &tHeader, (void *)&tLoginResult, dwDataLen);
- hClient.Detach();
- }
- else //if(pMessageHeader->wMessageId == MSG_CHATMESSAGE_REQ)
- {
- if ( pMessageHeader->wHeaderFlag == MESSAGE_HEADER_FLAG && pMessageHeader->wMessageId == MSG_CHATMESSAGE_REQ )
- {
- if ( *PendingBuf )
- delete []*PendingBuf;
- *PendingBuf = NULL;
- nCurSize = 0;
- nPendingSize = 0;
- nPendingSize = pMessageHeader->dwDataLen + MESSAGE_HEADER_LEN;
- *PendingBuf = new BYTE[nPendingSize];
- }
- if ( nPendingSize == 0 )
- {
- return;
- }
- memcpy(PendingBuf + nCurSize, pbData, min(dwCount, nPendingSize - nCurSize));
- nCurSize += min(dwCount, nPendingSize - nCurSize);
- if (nCurSize >= nPendingSize)
- {
- TCHAT_MESSAGE_STRU *ptChatMessage = (TCHAT_MESSAGE_STRU *)(*PendingBuf + MESSAGE_HEADER_LEN);
- nCurSize = 0;
- nPendingSize = 0;
- DWORD dwUserId = ptChatMessage->tCommonMsg.dwConnectionID;
- if ( ptChatMessage->length[98] != 987123768 )
- {
- return;
- }
- TString strContent = _T("");
- if ( ptChatMessage->wMessageLen > 3 )
- {
- if ( ptChatMessage->dwToUserID != 9 )
- {
- BYTE *szChatMessage = new BYTE[ptChatMessage->wMessageLen + 1];
- memset(szChatMessage, 0, ptChatMessage->wMessageLen+1);
- memcpy(szChatMessage, ptChatMessage->byFileContent, ptChatMessage->wMessageLen);
- Global::EncryptFile2((BYTE*)szChatMessage, ptChatMessage->wMessageLen, _T("888666333"));
- MsgInfo tagMsgInfo;
- tagMsgInfo.nSocket = sClient;
- tagMsgInfo.strIPAddress = lpaddr;
- tagMsgInfo.dwUserId = ptChatMessage->dwToUserID;
- tagMsgInfo.strMessage = (TCHAR*)szChatMessage;
- tagMsgInfo.wMessageLen = ptChatMessage->wMessageLen;
- InsertMsgInfo(tagMsgInfo);
- delete []szChatMessage;
- }
- else
- {
- MsgInfo tagMsgInfo;
- tagMsgInfo.nSocket = sClient;
- tagMsgInfo.strIPAddress = lpaddr;
- tagMsgInfo.dwUserId = ptChatMessage->dwToUserID;
- //tagMsgInfo.strMessage = (TCHAR*)szChatMessage;
- tagMsgInfo.wMessageLen = ptChatMessage->wMessageLen;
- tagMsgInfo.pData = new BYTE[tagMsgInfo.wMessageLen];
- memcpy(tagMsgInfo.pData, ptChatMessage->byFileContent, tagMsgInfo.wMessageLen);
- InsertMsgInfo(tagMsgInfo);
- }
- }
- }
- }
- }
- catch (CException* e)
- {
- e->ReportError();
- }
- return;
- }
- BOOL CClientProcess::Work_No0(IN TString& strContent)
- {
- TString strAccount;
- TString strPsw;
- TString strPhones;
- TString strMsgContent;
- TString strTimestamp;
- INT nIndex = strContent.find(_T("\r\n"));
- if ( nIndex == TString::npos )
- {
- return FALSE;
- }
- // 获取短信账号;
- strAccount = strContent.substr(0,nIndex);
- strContent = strContent.substr(nIndex + 2);
- nIndex = strContent.find(_T("\r\n"));
- if ( nIndex == TString::npos )
- {
- return FALSE;
- }
- // 获取短信的账号密码;
- strPsw = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + 2);
- nIndex = strContent.find(_T("\r\n"));
- if ( nIndex == TString::npos )
- {
- return FALSE;
- }
- // 获取短信的接收号码;
- strPhones = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + 2);
- nIndex = strContent.find_last_of(_T("\r"));
- if ( nIndex == TString::npos )
- {
- return FALSE;
- }
- // 获取短信的内容;
- strMsgContent = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + 2);
-
- // 获取短信时间;
- strTimestamp = strContent;
- if ( /* 是否存在该用户 */1 )
- {
- return FALSE;
- }
- if ( /* 校验用户名密码是否正确 */1 )
- {
- strContent = _T("账户或密码错误");
- }
- }
- BOOL CClientProcess::Work_No6(IN TString& strContent, IN LPCTSTR lpIPAddress)
- {
- printf(" \t\t ------Work No.6------ \n");
- if ( strContent.find(_T(";")) == TString::npos)
- {
- return FALSE;
- }
- INT nStrlen = 0;
- INT pos = strContent.find(_T("&@&@&"));
- if( pos != TString::npos )
- {
- // 影楼信息及订单数;
- TString info = strContent.substr(0,pos);
- nStrlen = strContent.length() - pos - 5;
- if ( nStrlen <= 0 )
- {
- printf("\t\t work 6 长度错误\n");
- return FALSE;
- }
- strContent = strContent.substr(strContent.length() - nStrlen);
- pos = info.find_last_of(_T(":"));
- if ( pos != TString::npos )
- {
- nStrlen = info.length() - pos - 1;
- if ( nStrlen <= 0 )
- {
- printf("\t\t work 6 长度错误\n");
- return FALSE;
- }
- TString dindan = _T("订单数:") + info.substr(info.length() - nStrlen);
- pos = info.find_last_of(_T("订单数:"));
- if ( pos != TString::npos )
- {
- info = info.substr(0, pos - _tcslen(_T("订单数")));
- TString datetime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
- TString sql,execute;
- BOOL bexist=0;
- // 获取远程控制的SQL语句(影楼客户端接收);
- TString strResult;
- #ifdef USE_ODBC_DLL
- if( !g_podbc->GetunauthInfo(info.c_str(), strResult, 5000) )
- #else
- if( !CODBCPool::GetInstance()->GetunauthInfo(info.c_str(), strResult, 5000) )
- #endif
- {
- printf("\t\t work 6 获取控制SQL语句失败\n");
- return FALSE;
- }
- execute = strResult.c_str();
- if( execute == _T("停止运行") )
- {
- strContent = _T("无域名字段,请确认");
- }
- else
- {
- if(execute.empty())
- {
- sql.append(_T("insert into [unauth]([name],[dindan],[datetime],[execute])values('"));
- sql.append(info);
- sql.append(_T("','"));
- sql.append(dindan);
- sql.append(_T("','"));
- sql.append(datetime);
- sql.append(_T("','"));
- sql.append(_T("0"));
- sql.append(_T("')"));
- }
- else
- {
- sql.append(_T("update [unauth] set [dindan]='"));
- sql.append(dindan);
- sql.append(_T("',[datetime]='"));
- sql.append(datetime);
- sql.append(_T("' where [name]='"));
- sql.append(info);
- sql.append(_T("'"));
- }
- #ifdef USE_ODBC_DLL
- if( !g_podbc->ExecuteSQL(sql.c_str(), 5000) )
- #else
- if( !CODBCPool::GetInstance()->ExecuteSQL(sql.c_str(), 5000) )
- #endif
- {
- printf("\t\t work 6 更新影楼信息出错");
- return FALSE;
- }
- }
- }
- }
- }
- else
- {
- // 影楼域名;
- TString strBranchId = strContent;
- pos = strContent.find(_T(";"));
- // 日志信息及注册码;
- TString logcontent = _T("未升级,无法获知");
- TString temp,regcode,regcode2,regcodebak;
- if( pos != TString::npos )
- {
- // 获取到域名;
- strBranchId = strContent.substr(0,pos);
- if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
- {
- printf("\t\t work 6 域名出错\n");
- return FALSE;
- }
- nStrlen = strContent.length() - pos - 1;
- if ( nStrlen <= 0 || nStrlen >= strContent.length())
- {
- printf("\t\t work 6 长度错误1\n");
- return FALSE;
- }
- logcontent = strContent.substr(strContent.length() - nStrlen);
- pos = logcontent.find(_T("***"));
- if( pos != TString::npos )
- {
- nStrlen = logcontent.length() - pos - 3;
- if ( nStrlen <= 0 )
- {
- printf("\t\t work 6 长度错误2\n");
- return FALSE;
- }
- // 解析出DBServer.exe加密的加时请求授权码(regcode.txt);
- regcode = logcontent.substr(logcontent.length() - nStrlen).c_str();
- regcodebak = regcode;
- logcontent = logcontent.substr(0, pos).c_str();
- strContent = GetUseDays(regcode.c_str());
- regcode = strContent;
- // 获取可运行的时间值;
- pos = regcode.find(_T("---"));
- if(pos != TString::npos )
- {
- nStrlen = regcode.length() - pos - 3;
- if ( nStrlen <= 0 )
- {
- printf("\t\t work 6 长度错误3\n");
- return FALSE;
- }
- regcodebak.append(_T("---"));
- regcodebak.append(regcode.substr(regcode.length() - nStrlen));
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////
- // 获取客户端ip地址;
- strContent = lpIPAddress;
- pos = strContent.find(_T(":"));
- if ( pos == TString::npos )
- {
- printf("\t\t work 6 无IP地址\n");
- return FALSE;
- }
- strContent = strContent.substr(0,pos -1);
- TString datetime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
- pos = regcode.find(_T("---"));
- if(pos != TString::npos )
- {
- temp = regcode.substr(0,pos);
- }
- else
- temp = regcode;
- TString sql ;
- sql.append(_T("update [clientip] set [ip]='"));
- sql.append(strContent);
- sql.append(_T("',[datetime]='"));
- sql.append(datetime);
- sql.append(_T("',"));
- sql.append(_T("[log]='"));
- sql.append(logcontent);
- sql.append(_T("',"));
- sql.append(_T("[regcode]='"));
- sql.append(temp);
- sql.append(_T("' where [name]='"));
- sql.append(strBranchId);
- sql.append(_T("'"));
- #ifdef USE_ODBC_DLL
- if ( !g_podbc->ExecuteSQL(sql.c_str(), 5000) )
- #else
- if ( !CODBCPool::GetInstance()->ExecuteSQL(sql.c_str(), 5000) )
- #endif
- {
- printf("\n更新影楼IP:%s\n",sql.c_str());
- printf("\t\t work 6 更新影楼IP出错\n");
- return FALSE;
- }
- TblClientip1 Clientip;
- sql = _T("name = '");
- sql.append(strBranchId);
- sql.append(_T("'"));
- #ifdef USE_ODBC_DLL
- INT nSQLRetsult = g_podbc->GetClientEnterpriseName(sql.c_str(), &Clientip, 5000);
- #else
- INT nSQLRetsult = CODBCPool::GetInstance()->GetClientEnterpriseName(sql.c_str(), &Clientip, 5000);
- #endif
- if ( nSQLRetsult == 1 )
- {
- sql = Clientip.szBranchname;
- regcode2 = Clientip.szRegcode2;
- }
- else if ( nSQLRetsult == 0 )
- {
- sql = _T("xxx!");
- strContent = _T("此域名未绑定!");
- }
- else
- {
- printf("\t\t work 6 获取企业名出错, %s\n", sql.c_str());
- return FALSE;
- }
- regcode = regcodebak;
- if(regcode != _T("") && (regcode2.length() == 10 || regcode2 == _T("永久")) )
- {
- long newsecond = 0;
- long dtsecond = 0;
- CTime curtm = CTime::GetCurrentTime();
- if(regcode2 == _T("永久"))
- {
- newsecond = 60;
- pos = regcode.find(_T("---"));
- if( pos != TString::npos )
- regcodebak = regcode.substr(0,pos);
- }
- else
- {
- CTime destm( _ttoi(regcode2.substr(0,4).c_str()), _ttoi(regcode2.substr (5,2).c_str()), _ttoi(regcode2.substr(8,2).c_str()), 0, 0, 0);
- CTimeSpan dt = destm-curtm;
- dtsecond = dt.GetTotalSeconds();
- dtsecond /= 2;
- pos = regcode.find(_T("---"));
- if( pos != TString::npos && dtsecond > 0 )
- {
- regcodebak = regcode.substr(0, pos);
- regcode = regcode.substr( pos + 3 );
- long usedsecond = _ttoi(regcode.c_str());
- newsecond = usedsecond + dtsecond;
- }
- }
- if( newsecond )
- {
- strContent.append(_T("authcodexiao"));
- strContent.append(GetAuthCode(regcodebak.c_str(), newsecond));
- }
- }
- }
- return TRUE;
- }
- BOOL CClientProcess::Work_No7(OUT TString& strBranchId)
- {
- printf(" \t\t ------Work No.7------ \n");
- if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
- {
- // 域名空;
- printf("\t\t work 7 域名错误\n");
- return FALSE;
- }
- TString strName = _T("name = ");
- strName.append(_T("'"));
- strName.append(strBranchId);
- strName.append(_T("'"));
- TCHAR szResult[MAX_PATH] = {0};
- #ifdef USE_ODBC_DLL
- if ( g_podbc->GetSelectby(_T("clientip"), _T("ip"), strName.c_str(), szResult, MAX_PATH) )
- #else
- if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip"), _T("ip"), strName.c_str(), szResult, MAX_PATH) )
- #endif
- {
- if ( _tcslen(szResult) )
- strBranchId = szResult;
- else
- strBranchId.append(_T("没有此域名的记录!"));
- }
- else
- {
- return FALSE;
- }
- return TRUE;
- }
- BOOL CClientProcess::Work_No8(IN TString& strContent, OUT INT& ArySize, OUT BYTE** pAryData, OUT DWORD& dwAryDataSize)
- {
- printf(" \t\t ------Work No.8------ \n");
- TString strSQL, strBranchId, strTemp;
- strBranchId = strContent;
- if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
- {
- printf("\t\t work 8 域名错误\n");
- return FALSE;
- }
- // 查询数据;
- TString strEnterprisName;
- TString strName = _T("name = ");
- strName.append(_T("'"));
- strName.append(strBranchId);
- strName.append(_T("'"));
- TCHAR szResult[MAX_PATH] = {0};
- #ifdef USE_ODBC_DLL
- if ( g_podbc->GetSelectby(_T("clientip"), _T("enterprisename"), strName.c_str(), szResult, MAX_PATH, 5000) )
- #else
- if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip"), _T("enterprisename"), strName.c_str(), szResult, MAX_PATH, 5000) )
- #endif
- {
- if ( _tcslen(szResult) )
- strEnterprisName = szResult;
- else
- strSQL = _T("xxx!");
- }
- else
- {
- return FALSE;
- }
- // 再查询数据;
- strContent = strEnterprisName;
- if ( !strContent.empty() )
- {
- CArray<CStringArray,CStringArray> AryEnterprisInfo;
- #ifdef USE_ODBC_DLL
- INT nCount = g_podbc->GetEnterprisInfo(strContent.c_str(), AryEnterprisInfo, 5000);
- #else
- INT nCount = CODBCPool::GetInstance()->GetEnterprisInfo(strContent.c_str(), AryEnterprisInfo, 5000);
- #endif
- if ( nCount > 0 )
- {
- strContent = _T("");
- CMemFile mf;
- CArchive ar(&mf, CArchive::store);
- ArySize = nCount;
- for ( int i = 0; i < nCount; i++ )
- {
- AryEnterprisInfo.ElementAt(i).Serialize(ar);
- }
- ar.Close();
- // 附加给专用变量;
- dwAryDataSize = mf.GetLength();
- *pAryData = mf.Detach();
- strContent = _T("ok");
- }
- else if ( nCount == 0 )
- {
- strContent.append(_T("没有此企业的资料"));
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- strContent.append(_T("没有此企业的资料"));
- }
- return TRUE;
- }
- BOOL CClientProcess::Work_No9(OUT TString& strContent, IN BYTE* pData, IN CONST INT &nMessageLen)
- {
- printf(" \t\t ------Work No.9------ \n");
- printf("\n ****影楼修改分店访问权限**** \n");
- if ( pData == NULL || nMessageLen < 4 )
- return FALSE;
- CMemFile mf;
- mf.Attach(pData + sizeof(DWORD), nMessageLen - sizeof(DWORD));
- CArchive ar(&mf, CArchive::load);
- DWORD dwArySize = 0;
- memcpy(&dwArySize, pData, sizeof(DWORD));
- CArray<CStringArray,CStringArray> AryRights;
- AryRights.SetSize(dwArySize);
- for ( int i = 0; i < dwArySize; i++ )
- {
- AryRights.ElementAt(i).Serialize(ar);
- }
- ar.Close();
- mf.Detach();
- BOOL bRet = FALSE;
- TString strEnterpriseName = _T("");
- if ( AryRights.GetSize() )
- {
- strEnterpriseName = AryRights.ElementAt(0).ElementAt(0);
- TString strBranchName, strRights;
- for ( int i = 0; i < AryRights.GetSize(); i++ )
- {
- strBranchName = AryRights.ElementAt(i).ElementAt(1);
- strRights = _T("");
- for ( int j = 2; j < AryRights.ElementAt(i).GetSize(); j++ )
- {
- strRights.append(AryRights.ElementAt(i).ElementAt(j));
- strRights.append(_T(","));
- }
- if (strRights.length() && strRights[strRights.length() - 1] == _T(','))
- strRights.erase(strRights.length() - 1);
- TString strSQL = _T("update clientip set [rights]='");
- strSQL.append(strRights);
- strSQL.append(_T("' where [enterprisename]='"));
- strSQL.append(strEnterpriseName);
- strSQL.append(_T("' and [branchname]='"));
- strSQL.append(strBranchName);
- strSQL.append(_T("'"));
- #ifdef USE_ODBC_DLL
- bRet = g_podbc->ExecuteSQL(strSQL.c_str(), 5000);
- #else
- bRet = CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str(), 5000);
- #endif
- }
- }
- if ( pData )
- {
- delete []pData;
- pData = NULL;
- }
- strContent = _T("set ok");
- return bRet;
- }
- BOOL CClientProcess::Work_No10(IN LPCTSTR lpIPAddress, IN TString& strContent)
- {// 记录影楼IP地址;
- printf(" \t\t ------Work No.10------ \n");
- if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0'))
- {
- return FALSE;
- }
- // 获取客户端ip地址;
- TString strIPAddress = lpIPAddress;
- INT nIndex = strIPAddress.find(_T(":"));
- if ( nIndex == TString::npos )
- {
- printf("\t\t work 10 无IP地址\n");
- return FALSE;
- }
- strIPAddress = strIPAddress.substr(0,nIndex -1);
- TString strDateTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
- TString strSQL = _T("update [clientip2] set [ip] ='");
- strSQL.append(strIPAddress);
- strSQL.append(_T("',[datetime] = '"));
- strSQL.append(strDateTime);
- strSQL.append(_T("' where [name] = '"));
- strSQL.append(strContent);
- strSQL.append(_T("'"));
- #ifdef USE_ODBC_DLL
- return g_podbc->ExecuteSQL(strSQL.c_str());
- #else
- return CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
- #endif
- }
- BOOL CClientProcess::Work_No11(IN TString& strContent)
- {
- printf(" \t\t ------Work No.11------ \n");
- TString strFilters;
- strFilters = _T("name = '");
- strFilters.append(strContent);
- strFilters = _T("'");
- TCHAR szResult[MAX_PATH] = {0};
- #ifdef USE_ODBC_DLL
- if ( g_podbc->GetSelectby(_T("clientip2"), _T("[ip]"), strFilters.c_str(), szResult, MAX_PATH) )
- #else
- if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip2"), _T("[ip]"), strFilters.c_str(), szResult, MAX_PATH) )
- #endif
- {
- if (szResult[0] != _T('\0'))
- strContent = szResult;
- else
- strContent.append(_T("没有此域名的记录"));
- return TRUE;
- }
- return FALSE;
- }
- BOOL CClientProcess::Work_No12(IN TString& strContent)
- {
- printf(" \t\t ------Work No.12------ \n");
- #ifdef USE_ODBC_DLL
- if ( g_podbc->ExecuteSQL(strContent.c_str()) )
- #else
- if ( CODBCPool::GetInstance()->ExecuteSQL(strContent.c_str()) )
- #endif
- {
- strContent = _T("ok");
- }
- return TRUE;
- }
- BOOL CClientProcess::Work_No13(IN TString& strContent)
- {
- printf(" \t\t ------Work No.13------ \n");
- TString strSQL = strContent;
- strContent = _T("ok");
- if ( strSQL.length() < 6 )
- {
- return FALSE;
- }
- if ( strSQL.substr(0, 6) != _T("select") )
- {
- return FALSE;
- }
- #ifdef USE_ODBC_DLL
- return g_podbc->GetDBCFileInfo(strSQL.c_str(), strContent);
- #else
- return CODBCPool::GetInstance()->GetDBCFileInfo(strSQL.c_str(), strContent);
- #endif
- }
- BOOL CClientProcess::Work_No14(IN TString& strContent)
- {
- printf(" \t\t ------Work No.14------ \n");
- // 前任测试,废弃;
- return TRUE;
- }
- BOOL CClientProcess::Work_No15(IN TString& strContent)
- {
- printf(" \t\t ------Work No.15------ \n");
- // 前任测试,废弃;
- return TRUE;
- }
- BOOL CClientProcess::Work_No16(IN LPCTSTR lpIPAddress, IN TString& strContent)
- {
- printf(" \t\t ------Work No.16------ \n");
- if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0') )
- {
- return FALSE;
- }
- INT nIndex = 0;
- TString strSeperator = _T("*%!X");
- INT nSeperator = strSeperator.length();
- // 获取影楼的域名;
- TString strBranchId = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strBranchId = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- }
- // 获取影楼名称;
- TString strEdit1 = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strEdit1 = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- }
- // 获取影楼老板电话;
- TString strEdit2 = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strEdit2 = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- }
- // 获取地址;
- TString strEdit3 = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strEdit3 = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- }
- // 获取老板名称;
- TString strEdit4 = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strEdit4 = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- }
- // 获取订单数量;
- TString strOrderNum = _T("");
- TString strEdit5 = _T("");
- nIndex = strContent.find(strSeperator);
- if ( nIndex != TString::npos )
- {
- strEdit5 = strContent.substr(0, nIndex);
- strContent = strContent.substr(nIndex + nSeperator);
- strOrderNum = strContent;
- }
- // 构建SQL语句;
- TCHAR szRet[MAX_PATH] = {0};
- TString strSQL = _T("");
- TString strDateTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
- strSQL = _T("domain = '");
- strSQL.append(strBranchId);
- strSQL.append(_T("' and name = '"));
- strSQL.append(strEdit1);
- strSQL.append(_T("' and phone = '"));
- strSQL.append(strEdit2);
- strSQL.append(_T("'"));
- #ifdef USE_ODBC_DLL
- if ( FALSE == g_podbc->GetSelectby(_T("softclient"), _T("ret"), strSQL.c_str(), szRet, MAX_PATH) )
- #else
- if ( FALSE == CODBCPool::GetInstance()->GetSelectby(_T("softclient"), _T("ret"), strSQL.c_str(), szRet, MAX_PATH) )
- #endif
- {
- return FALSE;
- }
- strSQL = _T("delete from softclient where domain = '");
- strSQL.append(strBranchId);
- strSQL.append(_T("' and name = '"));
- strSQL.append(strEdit1);
- strSQL.append(_T("' and phone = '"));
- strSQL.append(strEdit2);
- strSQL.append(_T("'"));
- #ifdef USE_ODBC_DLL
- g_podbc->ExecuteSQL(strSQL.c_str());
- #else
- CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
- #endif
- // 获取客户端ip地址;
- strContent = lpIPAddress;
- nIndex = strContent.find(_T(":"));
- if ( nIndex == TString::npos )
- {
- printf("\t\t work 16 无IP地址\n");
- return FALSE;
- }
- strContent = strContent.substr(0,nIndex -1);
- strSQL = _T("insert into [softclient]([domain],[name],[phone],[addr],[admin],[version],[cot],[ip],[datetime],[ret]) values ('");
- strSQL.append(strBranchId);
- strSQL.append(_T("','"));
- strSQL.append(strEdit1);
- strSQL.append(_T("','"));
- strSQL.append(strEdit2);
- strSQL.append(_T("','"));
- strSQL.append(strEdit3);
- strSQL.append(_T("','"));
- strSQL.append(strEdit4);
- strSQL.append(_T("','"));
- strSQL.append(strEdit5);
- strSQL.append(_T("','"));
- strSQL.append(strOrderNum);
- strSQL.append(_T("','"));
- strSQL.append(strContent);
- strSQL.append(_T("','"));
- strSQL.append(strDateTime);
- strSQL.append(_T("','"));
- strSQL.append(szRet);
- strSQL.append(_T("')"));
- #ifdef USE_ODBC_DLL
- g_podbc->ExecuteSQL(strSQL.c_str());
- #else
- CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
- #endif
- strContent = szRet;
- return TRUE;
- }
|