app_mgr.cpp
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "stdafx.h"
#include "etradeclient/utility/app_mgr.h"
#include "etradeclient/utility/logon_mgr.h"
#include "etradeclient/utility/session.h"
#include "etradeclient/utility/logging.h"
AppMgr::AppMgr() :m_is_need_relauch(false)
{}
AppMgr& AppMgr::Instance()
{
static AppMgr instance;
return instance;
}
bool AppMgr::IsNeedRelauch()
{
return m_is_need_relauch||LogonMgr::Instance().IsFirstLogin();
}
void AppMgr::Exit(bool is_need_user_confirm /*= true*/)
{
if (!is_need_user_confirm)
{
if (!LogonMgr::Instance().DoLogout())
LOG_ERROR(L"创建商户操作完成后,服务端退出请求处理失败。");
else
LOG_TRACE(L"退出系统成功。");
/*不让主窗口关闭的时候,再去提示用户是否退出以及做退出后台系统处理!!! */
Session::Instance().OnExpired();
}
// AfxGetMainWnd() will return NULL if called from an other thread (has to do with thread local storage).
// That's why we use AfxGetApp()->GetMainWnd() instead of AfxGetMainWnd().
HWND hwnd = AfxGetApp()->GetMainWnd()->GetSafeHwnd();
::PostMessage(hwnd, WM_CLOSE, NULL, NULL);
}
void AppMgr::Relauch()
{
m_is_need_relauch = true;
Exit(false);
}