升龙物业 老版本 ocx IPO, 加密狗 转值班电话

ViewMgr.cpp 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #include "StdAfx.h"
  2. #include "ViewMgr.h"
  3. #include "resource.h"
  4. #include "DisplayWnd.h"
  5. #include "Config.h"
  6. #include "MsgCenter.h"
  7. SINGLETON_IMPLEMENT(CViewMgr)
  8. CViewMgr::CViewMgr(void)
  9. {
  10. }
  11. CViewMgr::~CViewMgr(void)
  12. {
  13. }
  14. /*****************************************************************
  15. **【函数名称】 __getView
  16. **【函数功能】 查找指定资源的视图
  17. **【参数】
  18. **【返回值】
  19. ****************************************************************/
  20. CViewResBase* CViewMgr::__getView( UINT ResType )
  21. {
  22. switch(ResType)
  23. {
  24. case DEV_RES_TYPE_TRUNK: return &m_ViewDti;
  25. case DEV_RES_TYPE_VOIP: return &m_ViewVoip;
  26. case DEV_RES_TYPE_IPM: return &m_ViewIpm;
  27. case DEV_RES_TYPE_DSP: return &m_ViewDsp;
  28. }
  29. return NULL;
  30. }
  31. /*****************************************************************
  32. **【函数名称】 setup
  33. **【函数功能】 视图管理器创建
  34. **【参数】
  35. **【返回值】
  36. ****************************************************************/
  37. bool CViewMgr::setup( CDisplayWnd* pWnd )
  38. {
  39. ASSERT(pWnd != NULL);
  40. m_pWnd = pWnd;
  41. if(!m_ViewLog.create(pWnd))
  42. {
  43. AfxMessageBox(_T("日志视图创建失败!"));
  44. return false;
  45. }
  46. if(!m_ViewDti.create(m_pWnd, IDS_STR_VIEW_DTI))
  47. {
  48. AfxMessageBox(_T("DTI视图创建失败!"));
  49. return false;
  50. }
  51. if(!m_ViewVoip.create(m_pWnd, IDS_STR_VIEW_VOIP))
  52. {
  53. AfxMessageBox(_T("VOIP视图创建失败!"));
  54. return false;
  55. }
  56. if(!m_ViewIpm.create(m_pWnd, IDS_STR_VIEW_IPM))
  57. {
  58. AfxMessageBox(_T("IPM视图创建失败!"));
  59. return false;
  60. }
  61. if(!m_ViewDsp.create(m_pWnd, IDS_STR_VIEW_DSP))
  62. {
  63. AfxMessageBox(_T("DSP视图创建失败!"));
  64. return false;
  65. }
  66. ILogger::getInstance().init(&m_ViewLog, LOG_DEV_SC, CConfig::logFilePath());
  67. ILogger::getInstance().start();
  68. CMsgCenter& MsgCenter = CMsgCenter::GetInstance();
  69. MsgCenter.regist(SYS_MSG_RES_NEW, this);
  70. MsgCenter.regist(SYS_MSG_RES_DEL, this);
  71. MsgCenter.regist(SYS_MSG_RES_STATE, this);
  72. return true;
  73. }
  74. /*****************************************************************
  75. **【函数名称】 showResView
  76. **【函数功能】 显示指定资源视图
  77. **【参数】
  78. **【返回值】
  79. ****************************************************************/
  80. void CViewMgr::showResView( UINT ResType )
  81. {
  82. CViewResBase* pView = __getView(ResType);
  83. ASSERT(pView != NULL);
  84. if(pView != NULL)
  85. pView->show();
  86. }
  87. /*****************************************************************
  88. **【函数名称】 onMessage
  89. **【函数功能】 消息事件处理函数
  90. **【参数】 MsgType: 消息事件类型
  91. lpContent: 消息内容
  92. **【返回值】
  93. ****************************************************************/
  94. void CViewMgr::onMessage( UINT MsgType, PARAM lpContent )
  95. {
  96. ASSERT(lpContent != NULL);
  97. DEV_RES_ID* pResId = new DEV_RES_ID(*(DEV_RES_ID*)lpContent);
  98. ASSERT(pResId != NULL);
  99. switch(MsgType)
  100. {
  101. case SYS_MSG_RES_NEW:
  102. AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_NEW, (LPARAM)pResId);
  103. break;
  104. case SYS_MSG_RES_DEL:
  105. AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_DEL, (LPARAM)pResId);
  106. break;
  107. case SYS_MSG_RES_STATE:
  108. AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_STATE, (LPARAM)pResId);
  109. break;
  110. }
  111. }
  112. /*****************************************************************
  113. **【函数名称】 onResNew
  114. **【函数功能】 添加资源处理函数
  115. **【参数】
  116. **【返回值】
  117. ****************************************************************/
  118. void CViewMgr::onResNew( DEV_RES_ID*& pResId )
  119. {
  120. CViewResBase* pView = __getView(pResId->ResType);
  121. ASSERT(pView != NULL);
  122. if(pView != NULL)
  123. pView->onResNew(*pResId);
  124. delete pResId;
  125. pResId = NULL;
  126. }
  127. /*****************************************************************
  128. **【函数名称】 onResDel
  129. **【函数功能】 删除资源处理函数
  130. **【参数】
  131. **【返回值】
  132. ****************************************************************/
  133. void CViewMgr::onResDel( DEV_RES_ID*& pResId )
  134. {
  135. CViewResBase* pView = __getView(pResId->ResType);
  136. ASSERT(pView != NULL);
  137. if(pView != NULL)
  138. pView->onResDel(*pResId);
  139. delete pResId;
  140. pResId = NULL;
  141. }
  142. /*****************************************************************
  143. **【函数名称】 onResState
  144. **【函数功能】 资源状态更新处理函数
  145. **【参数】
  146. **【返回值】
  147. ****************************************************************/
  148. void CViewMgr::onResState( DEV_RES_ID*& pResId )
  149. {
  150. CViewResBase* pView = __getView(pResId->ResType);
  151. ASSERT(pView != NULL);
  152. if(pView != NULL)
  153. pView->onResState(*pResId);
  154. delete pResId;
  155. pResId = NULL;
  156. }