#ifndef _SMS_HANDLE_HEADER_ #define _SMS_HANDLE_HEADER_ #include "DBInterface.h" #include "HttpTransByGet.h" typedef struct _SEND_RESPONEINFO_ { CString strSendStatus; CString strSendCount; CString strBalance; CString strErPhone; CString strSid; }ResponebySend, *pResponebySend; typedef struct _QUERYACCOUNTINFO_ { CString strSendStatus; CString strAccount; CString strBalance; CString strSMSCharacterCount; CString strSignatures; CString strOwnedOperators; }QuerAccountInfo, *pQuerAccountInfo; #define VERIFYDATA(name,sex,birthday,today,lastfewdate,phone,check) \ if(birthday.IsEmpty()) continue;\ int nMonth = _ttoi(birthday.Mid(5,2));\ int nDay = _ttoi(birthday.Mid(8,2));\ if ( (nMonth >> 2) > 3 || (nDay >> 5) > 0 ) continue;\ if(check == _T("1") )\ birthday = LuanrToSolarDate(CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\ else\ birthday.Format(_T("%04d-%02d-%02d"),CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\ COleDateTime Solar;\ Solar.SetDateTime(_ttoi(birthday.Left(4)),_ttoi(birthday.Mid(5,2)),_ttoi(birthday.Mid(8,2)),0,0,0);\ Solar -= Span;\ lastfewdate.Format(_T("%04d-%02d-%02d"),Solar.GetYear(),Solar.GetMonth(),Solar.GetDay());\ if ( today >= lastfewdate && today < birthday)\ GenerateToSendreg(name,sex,phone,s_SMSInfo.msgContent1); #define VERIFYHOSPITALCHECK1(strArray,strChildMsgArray,a,b,c,d,e,f) VerifyHospitalCheck1(strArray.ElementAt(a),strChildMsgArray.ElementAt(b),strArray.ElementAt(c),strChildMsgArray.ElementAt(d),strArray.ElementAt(e),strArray.ElementAt(f)); #pragma once class CSMSHandle { public: CSMSHandle(); ~CSMSHandle(); public: static SMSInfo s_SMSInfo; // 该成员应该受保存,防止意外修改; TCHAR m_szAccount[MAX_NAME_LEN]; // 短信账号; TCHAR m_szPassWord[MAX_NAME_LEN]; // 账号密码; DWORD m_dwblance; // 短信余额; ULONGLONG m_ulCountOfSended; // 已发送的短信条数; std::vector m_vtSMSTypeOfChild; std::vector m_vtSMSTypeOfWedding; CString CalculateFilter_Child(); CString CalculateFilter_Wedding(); CString GetHTTPErrorInf() { return m_httpGet.GetErrorInfo(); } private: ThreadSection s_critSection; ThreadSection *ReturnSection() { return &s_critSection; } CHttpTransByGet m_httpGet; INT_PTR SendSMS(LPCTSTR lpStringToSend, CONST INT &nIndex, CONST INT &nGroup, LPCTSTR lpAutoId); VOID QuerySMSStatus(LPCTSTR lpSid, LPCTSTR lpAutoId); void UTF8ToWideChar(LPBYTE lpRespone, CString &strRespone); void UrlUTF8Decode(LPBYTE lpRespone, CString &strRespone); void AnalyzeAccoutStatus(CString &strRespone); // 解析账号的返回状态值; INT AnalyzeSendStatus(LPBYTE lpRespone, ResponebySend &lRespone); // 解析发送的返回状态值; void AnalyzeQueryStatus(CString &strRespone); // 解析查询的返回状态值; // 应该非静态+const比较好,防止s_SMSInfo被意外修改; static void GenerateToSendreg( IN CONST CString &strName, IN CONST CString &strSex, IN CONST CString &strPhone, IN CString &strContent, IN CONST CString &strMsgtype); static BOOL IsValidDate(CONST CString &strDate, BOOL bThisyear = TRUE); public: void GetMainInfo(); // 获取主要信息; INT_PTR ReadySendSMS(CString& strPhones, CString& strContent, CString& strTime, CString& strAutoId); HANDLE m_hSendSMSThread; HANDLE m_hGenerateSMSThread; HANDLE m_hSendEvent; HANDLE m_hGenerateEvent; HANDLE m_hWaitableTime; static BOOL m_bGenerateEndof; static DWORD WINAPI SendSMSThread(LPVOID lpParam); // 发送短信的线程; static DWORD WINAPI GenerateSMSThread(LPVOID lpParam); // 生成短信线程; int StartThread(); int EndofThread(); BOOL GetSMSBlance(QuerAccountInfo &tAccountInfo); protected: // --------------------------------------------------------------------------------------------------------------------------------------- // 客户端有选择"一周"、"两周"、"三周"、"满月"至"十一月"、"一岁"至"三岁"。要在客户里自动将这些中文转为天数。 // 短信类型msgtyped: // ==0,没有归类的短信; // == 1,生日短信; // == 2,百天或结婚纪念日短信; // == 15,结婚当天; // == 10000,儿童满n天; // == 20000,怀孕满n天; static BOOL VerifyCheck1(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck); static BOOL VerifyCheck2(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck); static BOOL VerifyCheck15(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strWiddingDay, CONST CString &strCheck); static BOOL VerifyHospitalCheck1( CONST CString &strMsgtype, CONST CString &strName, CONST CString &strDays, // 出生满_ttoi(strDays)天; CONST CString &strPhone, CString strContent, CString strBirthday, CONST CString &strCheck); static BOOL VerifyHospitalCheck2( CONST CString &strMsgtype, CONST CString &strName, CONST CString &strDays, CONST CString &strPhone, CString strContent, CString strOrderDate, // 订单日期; CString strPregnancyDate // 已怀孕天数; ); public: // 儿童版本; static VOID CHandleDindanClient(CArray *pArrayOfDindanClient, CArray *pArrayOfChildMsg = NULL); static VOID CHandleClient2(CArray *pArrayOfClien2, CArray *pArrayOfChildMsg = NULL); static VOID CHandleClient3(CArray *pArrayOfClien3, CArray *pArrayOfChildMsg = NULL); static VOID CHandleHospitalClient(CArray *pArrayOfHospitalClient, CArray *pArrayOfChildMsg); // 婚纱版本; static VOID WHandleDindanClient(CArray *pArrayOfDindanClient, CArray *pArrayOfChildMsg = NULL); static VOID WHandleClient2(CArray *pArrayOfClien2, CArray *pArrayOfChildMsg = NULL); static VOID WHandleClient3(CArray *pArrayOfClien3, CArray *pArrayOfChildMsg = NULL); static VOID WHandleHospitalClient(CArray *pArrayOfHospitalClient, CArray *pArrayOfChildMsg); }; #endif