Commit 11216891 authored by captainwong's avatar captainwong

update

parent 0bc24748
...@@ -55,13 +55,8 @@ inline void init_logger(const std::wstring& file_name = L"") ...@@ -55,13 +55,8 @@ inline void init_logger(const std::wstring& file_name = L"")
sinks.push_back(std::make_shared<spdlog::sinks::msvc_sink_mt>()); sinks.push_back(std::make_shared<spdlog::sinks::msvc_sink_mt>());
#endif #endif
sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>()); sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>( sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(file_name + L".log", 23, 59));
#ifdef WIN32
file_name + L".log"
#else
file_name + ".log"
#endif
, 23, 59));
auto combined_logger = std::make_shared<spdlog::logger>(g_logger_name, begin(sinks), end(sinks)); auto combined_logger = std::make_shared<spdlog::logger>(g_logger_name, begin(sinks), end(sinks));
combined_logger->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [tid %t] [%L] %v"); combined_logger->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [tid %t] [%L] %v");
spdlog::register_logger(combined_logger); spdlog::register_logger(combined_logger);
......
...@@ -441,11 +441,32 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -441,11 +441,32 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
{ {
bool ok = false; bool ok = false;
// 初始化COM // 初始化COM COINIT_APARTMENTTHREADED
HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); HRESULT hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hres)) { if (FAILED(hres)) {
#ifndef __AFXWIN_H__
_com_error ce(hres);
qDebug() << "CoInitializeEx with COINIT_MULTITHREADED failed:\n" << ce.Error() << QString::fromWCharArray(ce.ErrorMessage()); //
#endif
if (hres == 0x80010106) {
#ifndef __AFXWIN_H__
qDebug() << "already initilized, pass"; //
#endif
} else {
#ifndef __AFXWIN_H__
qDebug() << "trying CoInitializeEx with COINIT_APARTMENTTHREADED"; //
#endif
hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoInitializeEx with COINIT_APARTMENTTHREADED failed, exit";
#endif
return false; return false;
} }
}
}
// 设置COM的安全认证级别 // 设置COM的安全认证级别
hres = CoInitializeSecurity( hres = CoInitializeSecurity(
...@@ -460,6 +481,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -460,6 +481,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
NULL NULL
); );
if (FAILED(hres)) { if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoInitializeSecurity:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
CoUninitialize(); CoUninitialize();
return false; return false;
} }
...@@ -474,6 +498,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -474,6 +498,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
reinterpret_cast<LPVOID*>(&pLoc) reinterpret_cast<LPVOID*>(&pLoc)
); );
if (FAILED(hres)) { if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoCreateInstance:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
CoUninitialize(); CoUninitialize();
return false; return false;
} }
...@@ -491,8 +518,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -491,8 +518,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
&pSvc &pSvc
); );
if (FAILED(hres)) { if (FAILED(hres)) {
_com_error e(hres); #ifndef __AFXWIN_H__
e.ErrorMessage(); qDebug() << "ConnectServer:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
pLoc->Release(); pLoc->Release();
CoUninitialize(); CoUninitialize();
return false; return false;
...@@ -510,6 +538,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -510,6 +538,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
EOAC_NONE EOAC_NONE
); );
if (FAILED(hres)) { if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoSetProxyBlanket:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
pSvc->Release(); pSvc->Release();
pLoc->Release(); pLoc->Release();
CoUninitialize(); CoUninitialize();
...@@ -537,6 +568,10 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q ...@@ -537,6 +568,10 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
//pSvc->Release(); //pSvc->Release();
//pLoc->Release(); //pLoc->Release();
//CoUninitialize(); //CoUninitialize();
#ifndef __AFXWIN_H__
qDebug() << "ExecQuery:\n" << QString::fromWCharArray(query.szSelect) << '\n' << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
results[queryType] = _com_error(hres).ErrorMessage();
continue; continue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment