123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- #define PHMS_DLL_EXPORTS
- #include "CommonNetInterface.h"
- #include "Poco/UUIDGenerator.h"
- #include "Poco/UUID.h"
- #include "Poco/Exception.h"
- #include "Poco/Thread.h"
- #include "Util.h"
- #include "PhmsLogger.h"
- #include "ExternalNetInterface.h"
- #include "ErrorCode.h"
- #include <map>
- #include "NetThreadManager.h"
- #include "SessionIdManager.h"
- #include "HandleMutexManager.h"
- #include "PushObjectManager.h"
- #include "AllObjectManagerUtil.h"
- #include "GlobalTerminalLogoString.h"
- using Poco::UUID;
- using Poco::UUIDGenerator;
- using Poco::Thread;
- using namespace std;
- string g_stringTerminalType;
- string g_stringContecServerAddr;
- string g_stringContecServerPort;
- string g_stringUsername;
- string g_stringPassword;
- void SetContecServerInfo(const char* stringContecServerAddr, const char* stringContecServerPort)
- {
- g_stringContecServerAddr = stringContecServerAddr;
- g_stringContecServerPort = stringContecServerPort;
- }
- void SetAppDir(const char* stringWorkDir)
- {
- return CUtil::SetAppDir(stringWorkDir);
- }
- int SetTerminalType(const char* stringTerminalType)
- {
- if(stringTerminalType == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- g_stringTerminalType = stringTerminalType;
- return PHMS_SUCCESSFUL_RESULT;
- }
- NET_HANDLE InitializeNetLibObject()
- {
- CAllObjectManagerUtil::InitializeSSL();
- CAllObjectManagerUtil::InitializeLocale();
- //初始化日志对象Logger
- NET_HANDLE handle = new char[128];
- memset(handle, 0, 128);
- string stringUuid;
- stringUuid = CNetThreadManager::GetHandleByThreadId(Thread::currentTid());
- if(stringUuid.size() != 0)
- {
- strcpy(handle, stringUuid.c_str());
- return handle;
- }
- try
- {
- CPhmsLogger::GetPhmsLogger();
- }
- catch(Exception& error)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(error.what(), __FUNCTION__, __FILE__, __LINE__);
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_GENERATE_LOG_FILE_ERROR), __FUNCTION__, __FILE__, __LINE__);
- delete handle;
- return NULL;
- }
- if(g_stringTerminalType.size() == 0)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_NO_SET_TERMINAL_TYPE), __FUNCTION__, __FILE__, __LINE__);
- delete handle;
- return NULL;
- }
- stringUuid = UUIDGenerator::defaultGenerator().createOne().toString();
- int nRet = PHMS_SUCCESSFUL_RESULT;
- nRet = CNetThreadManager::InsertNetThread(stringUuid);
- if(nRet != PHMS_SUCCESSFUL_RESULT)
- {
- delete handle;
- return NULL;
- }
- nRet = CHandleMutexManager::InsertHandleMutex(stringUuid);
- if(nRet != PHMS_SUCCESSFUL_RESULT)
- {
- delete handle;
- return NULL;
- }
- strcpy(handle, stringUuid.c_str());
- return handle;
- }
- int DeleteNetLibObject(NET_HANDLE handle)
- {
- if(handle == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- int nRet = PHMS_SUCCESSFUL_RESULT;
- //DeleteNetLibObject接口也不允许handle跨线程
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- Thread::yield();
- Mutex* pMutex = CHandleMutexManager::GetHandleMutex(handle);
- if(pMutex == NULL)
- {
- return COMMON_INVALID_HANDLE;
- }
- Thread::yield();
- pMutex->lock();
- nRet = CNetThreadManager::DeleteNetThread(stringUuid);
- if(nRet == PHMS_SUCCESSFUL_RESULT)
- {
- CAllObjectManagerUtil::UnInitializeSSL();
- CAllObjectManagerUtil::UnInitializeLocale();
- delete handle;
- }
- pMutex->unlock();
- nRet = CHandleMutexManager::DeleteHandleMutex(stringUuid);
- CAllObjectManagerUtil::ReleasePhmsLogger();
- return nRet;
- }
- int SetSessionId(const char* stringSessionId)
- {
- if(stringSessionId == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringTempSessionId = stringSessionId;
- int nRet = PHMS_SUCCESSFUL_RESULT;
- nRet = CSessionIdManager::SetSessionId(stringTempSessionId);
- return nRet;
- }
- int GetSessionId(char* bufSessionId, unsigned int nBufMaxLen)
- {
- if(bufSessionId == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringSessionId;
- int nRet = PHMS_SUCCESSFUL_RESULT;
- nRet = CSessionIdManager::GetSessionId(stringSessionId);
- if(nRet != PHMS_SUCCESSFUL_RESULT)
- {
- return nRet;
- }
- if(stringSessionId.size() <= nBufMaxLen)
- {
- strcpy(bufSessionId, stringSessionId.c_str());
- }
- else
- {
- return COMMON_BUF_SMALL;
- }
- return PHMS_SUCCESSFUL_RESULT;
- }
- int SetUsernameAndPassword(const char* stringUsername, const char* stringPassword)
- {
- if(stringUsername==NULL || stringPassword==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- g_stringUsername = stringUsername;
- g_stringPassword = stringPassword;
- return PHMS_SUCCESSFUL_RESULT;
- }
- int KeepSession(NET_HANDLE handle)
- {
- if(handle == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->KeepSession();
- }
- int Logout(NET_HANDLE handle)
- {
- if(handle == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->Logout();
- }
- int UploadIm(NET_HANDLE handle, const char* stringSenderId, const char* stringSenderName, const char* stringReceiverId, const char* stringMsgDirection, const char* stringMsgType,
- const char* stringMsgContent, const char* stringAudioFilePath, const char* stringCaseId, const char* stringCaseType)
- {
- if(handle==NULL || stringSenderId==NULL || stringSenderName==NULL || stringReceiverId==NULL || stringMsgDirection==NULL || stringMsgType==NULL ||
- stringMsgContent==NULL || stringAudioFilePath==NULL || stringCaseId==NULL || stringCaseType==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->UploadIm(stringSenderId, stringSenderName, stringReceiverId, stringMsgDirection, stringMsgType, stringMsgContent, stringAudioFilePath, stringCaseId, stringCaseType);
- }
- int GetImList(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringSenderId, const char* stringCaseId, const char* stringCaseType, const char* stringMsgDirection, const char* stringMsgType)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringSenderId==NULL || stringCaseId==NULL || stringCaseType==NULL || stringMsgDirection==NULL || stringMsgType==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetImList(stringLocalFilePath, stringSenderId, stringCaseId, stringCaseType, stringMsgDirection, stringMsgType);
- }
- int GetImList2(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringNextId)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringNextId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetImList2(stringLocalFilePath, stringNextId);
- }
- int DownloadIm(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringMsgId, const char* stringUri, unsigned long nFileSize)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringMsgId==NULL || stringUri==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->DownloadIm(stringLocalFilePath, stringMsgId, stringUri, nFileSize);
- }
- int DownloadImComplete(NET_HANDLE handle, const char* stringMsgId)
- {
- if(handle==NULL || stringMsgId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->DownloadImComplete(stringMsgId);
- }
- int ChangePwd(NET_HANDLE handle, const char* stringOldPwd, const char* stringNewPwd)
- {
- if(handle==NULL || stringOldPwd==NULL || stringNewPwd==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->ChangePwd(stringOldPwd, stringNewPwd);
- }
- int Feedback(NET_HANDLE handle, const char* stringTitle, const char* stringNotes, const char* stringPhone, const char* stringPicPath)
- {
- if(handle==NULL || stringTitle==NULL || stringNotes==NULL || stringPhone==NULL || stringPicPath==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->Feedback(stringTitle, stringNotes, stringPhone, stringPicPath);
- }
- int GetReportListOfCase(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringCaseId)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringCaseId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetReportListOfCase(stringLocalFilePath, stringCaseId);
- }
- int GetHospitalListOfGroup(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringGroupId, const char* stringType, const char* stringCaseType, unsigned int nPageTo, unsigned int nPageSize)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringGroupId==NULL || stringType==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetHospitalListOfGroup(stringLocalFilePath, stringGroupId, stringType, stringCaseType, nPageTo, nPageSize);
- }
- int GetDoctorListOfHospital(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringHospitalId, const char* stringDoctorId, const char* stringCaseType, const char* stringDoctorType, unsigned int nPageTo, unsigned int nPageSize)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringHospitalId==NULL || stringDoctorId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetDoctorListOfHospital(stringLocalFilePath, stringHospitalId, stringDoctorId, stringCaseType, stringDoctorType, nPageTo, nPageSize);
- }
- int AbortSession(NET_HANDLE handle)
- {
- if(handle==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- Mutex* pMutex = CHandleMutexManager::GetHandleMutex(handle);
- if(pMutex == NULL)
- {
- return COMMON_INVALID_HANDLE;
- }
- Mutex::ScopedLock lock(*pMutex);
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid, true);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->AbortSession();
- }
- int GetEventStream(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringCaseId, const char* stringOriginalHospital)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringCaseId==NULL || stringOriginalHospital==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetEventStream(stringLocalFilePath, stringCaseId, stringOriginalHospital);
- }
- int GetCaseTypeList(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringLanguage)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringLanguage==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetCaseTypeList(stringLocalFilePath, stringLanguage);
- }
- int DownloadPhoto(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringUri, unsigned long nFileSize, pProgressAndSpeedCallback pCallback)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringUri==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->DownloadPhoto(stringLocalFilePath, stringUri, nFileSize, pCallback);
- }
- int GetServerFileSize(NET_HANDLE handle, const char* stringUri, int& nFileSize)
- {
- if(handle==NULL || stringUri==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetAlreadyUploadFileSize(stringUri, nFileSize);
- }
- int SendPhoneMsg(NET_HANDLE handle, const char* stringCardId, const char* stringPhone, const char* stringMsg)
- {
- if(handle==NULL || stringCardId==NULL || stringPhone==NULL || stringMsg==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->SendPhoneMsg(stringCardId, stringPhone, stringMsg);
- }
- int GetFileWithHttp(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringUrl, int bContinue)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringUrl==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetFileWithHttp(stringLocalFilePath, stringUrl, bContinue);
- }
- int PostForm(NET_HANDLE handle, char* stringResponse, unsigned int nResponseSize, const char* stringHost, const char* stringUrl, const char* stringKey[], const char* stringValue[], int nSize)
- {
- if(handle==NULL || stringResponse==NULL || stringHost==NULL || stringUrl==NULL || stringKey==NULL || stringValue==NULL || nSize==0 || nResponseSize==0)
- {
- return COMMON_PARAMETER_NULL;
- }
- map<string, string> mapParams;
- for(int i=0; i<nSize; i++)
- {
- mapParams[stringKey[i]] = stringValue[i];
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- int nRet = PHMS_SUCCESSFUL_RESULT;
- string stringTempResponse;
- nRet = pNetInterface->PostForm(stringTempResponse, stringHost, stringUrl, mapParams);
- if(nRet != PHMS_SUCCESSFUL_RESULT)
- {
- return nRet;
- }
- if(stringTempResponse.size() != 0)
- {
- if(stringTempResponse.size() > nResponseSize)
- {
- strncpy(stringResponse, stringTempResponse.c_str(), nResponseSize);
- }
- else
- {
- strcpy(stringResponse, stringTempResponse.c_str());
- }
- }
- return nRet;
- }
- int GetVerificationCode(NET_HANDLE handle, const char* stringType, const char* stringPhone)
- {
- if(handle==NULL || stringType==NULL || stringPhone==NULL)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(handle, __FUNCTION__, __FILE__, __LINE__);
- CPhmsLogger::GetPhmsLogger()->WriteLog(stringType, __FUNCTION__, __FILE__, __LINE__);
- CPhmsLogger::GetPhmsLogger()->WriteLog(stringPhone, __FUNCTION__, __FILE__, __LINE__);
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetVerificationCode(stringType, stringPhone);
- }
- int ApplyQRCode(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringType, const char* stringScene)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringType==NULL || stringScene==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->ApplyQRCode(stringLocalFilePath, stringType, stringScene);
- }
- int ValidateUserAccount(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringLoginId, const char* stringPassword, const char* stringRole)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringLoginId==NULL || stringPassword==NULL || stringRole==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->ValidateUserAccount(stringLocalFilePath, stringLoginId, stringPassword, stringRole);
- }
- int UploadCommonFile(NET_HANDLE handle, char* stringUri, const char* stringType, const char* stringExtra, const char* stringLocalFilePath, const char* stringFileType, pProgressAndSpeedCallback pCallbcak)
- {
- if(handle==NULL || stringType==NULL || stringExtra==NULL || stringLocalFilePath==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- string stringTempUri;
- int nRet = pNetInterface->UploadCommonFile(stringTempUri, stringType, stringExtra, stringLocalFilePath, stringFileType, pCallbcak);
- if(stringTempUri.size() != 0)
- {
- strcpy(stringUri, stringTempUri.c_str());
- }
- return nRet;
- }
- int GetListOfHealthyKnowledge(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringSenderId, const char* stringNextId, const char* stringIds, const char* stringPageSize, const char* stringOrderBy)
- {
- if(handle==NULL || stringSenderId==NULL || stringNextId==NULL || stringIds==NULL || stringLocalFilePath==NULL || stringPageSize==NULL || stringOrderBy==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetListOfHealthyKnowledge(stringLocalFilePath, stringSenderId, stringNextId, stringIds, stringPageSize, stringOrderBy);
- }
- int GetCardUserReportList(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringReportId, const char* stringReportStartDate, const char* stringReportEndDate, const char* stringCaseType, const char* stringState, const char* stringOrderBy,
- const char* stringThirdIdType, const char* stringThirdId, const char* stringNextId, const char* stringPageSize)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringReportId==NULL || stringReportStartDate==NULL || stringReportEndDate==NULL || stringCaseType==NULL || stringState==NULL || stringOrderBy==NULL ||
- stringThirdIdType==NULL || stringThirdId==NULL || stringNextId==NULL || stringPageSize==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetCardUserReportList(stringLocalFilePath, stringReportId, stringReportStartDate, stringReportEndDate, stringCaseType, stringState, stringOrderBy, stringThirdIdType, stringThirdId, stringNextId, stringPageSize);
- }
- int MyFans(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringUserId, const char* stringNextId)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringUserId==NULL || stringNextId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->MyFans(stringLocalFilePath, stringUserId, stringNextId);
- }
- int GetPayCode(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringType, const char* stringCaseId)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringType==NULL || stringCaseId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetPayCode(stringLocalFilePath, stringType, stringCaseId);
- }
- int GetOrderInfo(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringType, const char* stringCaseId)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringType==NULL || stringCaseId==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->GetOrderInfo(stringLocalFilePath, stringType, stringCaseId);
- }
- int AbortSessionByThreadId(THREAD_ID threadId)
- {
- #if(POCO_OS == POCO_OS_MAC_OS_X)
- return PHMS_SUCCESSFUL_RESULT;
- #else
- string handle = CNetThreadManager::GetHandleByThreadId(threadId);
- if(handle.size() == 0)
- {
- return COMMON_INVALID_THREAD_ID;
- }
- return AbortSession((char*)handle.c_str());
- #endif
- }
- NET_HANDLE NET_API BeginMsgListPush(const char* stringSenderId, const char* stringCaseId, const char* stringCaseType, const char* stringMsgType, const char* stringMsgDirection, const char* stringVersion,
- pHttpPushCallback pCallback, pHttpPushFailCallback pFailCallback)
- {
- CAllObjectManagerUtil::InitializeSSL();
- CAllObjectManagerUtil::InitializeLocale();
- //初始化日志对象Logger
- string stringUuid;
- try
- {
- CPhmsLogger::GetPhmsLogger();
- }
- catch(Exception& error)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(error.what(), __FUNCTION__, __FILE__, __LINE__);
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_GENERATE_LOG_FILE_ERROR), __FUNCTION__, __FILE__, __LINE__);
- return NULL;
- }
- if(stringSenderId==NULL || stringCaseId==NULL || stringCaseType==NULL || stringMsgType==NULL ||stringMsgDirection==NULL ||
- pCallback==NULL || pFailCallback==NULL)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_PARAMETER_NULL), __FUNCTION__, __FILE__, __LINE__);
- return NULL;
- }
- if(g_stringTerminalType.size() == 0)
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_NO_SET_TERMINAL_TYPE), __FUNCTION__, __FILE__, __LINE__);
- return NULL;
- }
- if(CPushObjectManager::SomeTypePushIsRun(MSG_LIST_PUSH))
- {
- CPhmsLogger::GetPhmsLogger()->WriteLog(CUtil::GetErrorMsg(COMMON_SAME_PUSH_IS_RUN), __FUNCTION__, __FILE__, __LINE__);
- return NULL;
- }
- stringUuid = UUIDGenerator::defaultGenerator().createOne().toString();
- int nRet = PHMS_SUCCESSFUL_RESULT;
- nRet = CPushObjectManager::InsertPushMsgListObject(stringUuid, stringSenderId, stringCaseId, stringCaseType, stringMsgType, stringMsgDirection, stringVersion, pCallback, pFailCallback);
- if(nRet != PHMS_SUCCESSFUL_RESULT)
- {
- return NULL;
- }
- NET_HANDLE handle = new char[128];
- memset(handle, 0, 128);
- strcpy(handle, stringUuid.c_str());
- return handle;
- }
- int NET_API EndPush(NET_HANDLE handle)
- {
- if(handle == NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- int nRet = PHMS_SUCCESSFUL_RESULT;
- nRet = CPushObjectManager::DeletePushObject(stringUuid);
- if(nRet == PHMS_SUCCESSFUL_RESULT)
- {
- CAllObjectManagerUtil::UnInitializeSSL();
- CAllObjectManagerUtil::UnInitializeLocale();
- delete handle;
- }
- CAllObjectManagerUtil::ReleasePhmsLogger();
- return nRet;
- }
- int ExecuteGWService(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringLastPath, const char* stringJson, const char* stringUploadFilePath)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringLastPath==NULL || stringJson==NULL || stringUploadFilePath==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->ExecuteGWService(stringLocalFilePath, stringLastPath, stringJson, stringUploadFilePath);
- }
- int ExecuteCommonRESTful(NET_HANDLE handle, const char* stringLocalFilePath, const char* stringIp, const char* stringPort, const char* stringUrl, const char* stringContentType, const char* stringPayload)
- {
- if(handle==NULL || stringLocalFilePath==NULL || stringIp==NULL || stringPort==NULL || stringUrl==NULL || stringContentType==NULL || stringPayload==NULL)
- {
- return COMMON_PARAMETER_NULL;
- }
- string stringUuid = handle;
- CExternalNetInterface* pNetInterface = NULL;
- pNetInterface = CNetThreadManager::GetNetThread(stringUuid);
- if(pNetInterface == NULL)
- {
- //写日志
- return COMMON_INVALID_HANDLE;
- }
- return pNetInterface->ExecuteCommonRESTful(stringLocalFilePath, stringIp, stringPort, stringUrl, stringContentType, stringPayload);
- }
|