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

ViewMgr.cpp 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. #include "ViewExten.h"
  8. #include "ViewTrunk.h"
  9. #include "ViewVoip.h"
  10. #include "ViewIvr.h"
  11. #include "ViewFax.h"
  12. SINGLETON_IMPLEMENT(CViewMgr)
  13. CViewMgr::CViewMgr(void)
  14. {
  15. }
  16. CViewMgr::~CViewMgr(void)
  17. {
  18. __free();
  19. }
  20. /*****************************************************************
  21. **【函数名称】 __free
  22. **【函数功能】 释放资源
  23. **【参数】
  24. **【返回值】
  25. ****************************************************************/
  26. void CViewMgr::__free( void )
  27. {
  28. UINT Key = 0;
  29. CViewResBase *pView = NULL;
  30. POSITION pos = m_ViewMap.GetStartPosition();
  31. while(pos != NULL)
  32. {
  33. m_ViewMap.GetNextAssoc(pos, Key, pView);
  34. if(pView != NULL)
  35. delete pView;
  36. } // end while
  37. m_ViewMap.RemoveAll();
  38. }
  39. /*****************************************************************
  40. **【函数名称】 __showResView
  41. **【函数功能】 显示资源视图
  42. **【参数】
  43. **【返回值】
  44. ****************************************************************/
  45. void CViewMgr::__showResView( CViewResBase* pView )
  46. {
  47. if(m_ViewMap.IsEmpty())
  48. return;
  49. ViewMap ::CPair* pPair = m_ViewMap.PGetFirstAssoc();
  50. ASSERT(pPair != NULL);
  51. pView->showTogether(pPair->value);
  52. }
  53. /*****************************************************************
  54. **【函数名称】 __procResType
  55. **【函数功能】 设备资源类型初始化函数
  56. **【参数】 Type 设备资源类型
  57. **【返回值】
  58. ****************************************************************/
  59. void CViewMgr::procResType(UINT Type)
  60. {
  61. CViewResBase* pView = NULL;
  62. UINT NameId;
  63. UINT ListId;
  64. switch(Type)
  65. {
  66. case DEV_RES_TYPE_EXT: // 内线
  67. {
  68. pView = new CViewExten();
  69. m_ViewRes.newRes(DEV_RES_TYPE_EXT);
  70. NameId = IDS_STR_VIEW_EXT;
  71. ListId = IDC_LIST_EXT;
  72. m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_EXT, IDS_STR_VIEW_EXT);
  73. }
  74. break;
  75. case DEV_RES_TYPE_TRUNK: // 外线
  76. {
  77. pView = new CViewTrunk();
  78. m_ViewRes.newRes(DEV_RES_TYPE_TRUNK);
  79. NameId = IDS_STR_VIEW_TRUNK;
  80. ListId = IDC_LIST_TRUNK;
  81. m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_TRUNK, IDS_STR_VIEW_TRUNK);
  82. }
  83. break;
  84. case DEV_RES_TYPE_VOIP: // VoIP
  85. {
  86. pView = new CViewVoip();
  87. m_ViewRes.newRes(DEV_RES_TYPE_VOIP);
  88. NameId = IDS_STR_VIEW_VOIP;
  89. ListId = IDC_LIST_VOIP;
  90. m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_VOIP, IDS_STR_VIEW_VOIP);
  91. }
  92. break;
  93. case DEV_RES_TYPE_IVR: // IVR线路
  94. {
  95. pView = new CViewIvr();
  96. m_ViewRes.newRes(DEV_RES_TYPE_IVR);
  97. NameId = IDS_STR_VIEW_IVR;
  98. ListId = IDC_LIST_IVR;
  99. m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_IVR, IDS_STR_VIEW_IVR);
  100. }
  101. break;
  102. case DEV_RES_TYPE_FAX: // 传真
  103. {
  104. pView = new CViewFax();
  105. m_ViewRes.newRes(DEV_RES_TYPE_FAX);
  106. NameId = IDS_STR_VIEW_FAX;
  107. ListId = IDC_LIST_FAX;
  108. m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_FAX, IDS_STR_VIEW_FAX);
  109. }
  110. break;
  111. //case DEV_RES_TYPE_CONFERENCE: // 会议
  112. // {
  113. // pView = new CViewMeeting();
  114. // m_ViewRes.newRes(DEV_RES_TYPE_CONFERENCE);
  115. // NameId = IDS_STR_VIEW_MEETING;
  116. // ListId = IDC_LIST_MEETING;
  117. // m_pWnd->InsertMenuItem(ID_MENU_LOG, ID_MENU_VIEW_MEETING, IDS_STR_VIEW_MEETING);
  118. // }
  119. // break;
  120. default:
  121. break;
  122. } // end switch
  123. // 生成并存储设备资源类型节点
  124. if(pView != NULL)
  125. {
  126. pView->create(m_pWnd, NameId, ListId);
  127. __showResView(pView);
  128. m_ViewMap.SetAt(Type, pView);
  129. }
  130. }
  131. /*****************************************************************
  132. **【函数名称】 __procResDetail
  133. **【函数功能】 资源明细处理函数
  134. **【参数】 pResDetail 资源明细
  135. **【返回值】
  136. ****************************************************************/
  137. void CViewMgr::__procResDetail(EventResDetail *pResDetail)
  138. {
  139. ASSERT(pResDetail != NULL);
  140. CViewResBase* pView = NULL;
  141. if(m_ViewMap.Lookup(pResDetail->nResType, pView))
  142. {
  143. ASSERT(pView != NULL);
  144. pView->onResDetail(pResDetail);
  145. }
  146. }
  147. /*****************************************************************
  148. **【函数名称】 __procResState
  149. **【函数功能】 资源状态变化处理函数
  150. **【参数】 pResStatus 资源状态
  151. **【返回值】
  152. ****************************************************************/
  153. void CViewMgr::__procResState(EventResStatus *pResStatus)
  154. {
  155. ASSERT(pResStatus != NULL);
  156. CViewResBase* pView = NULL;
  157. if(m_ViewMap.Lookup(pResStatus->nResType, pView))
  158. {
  159. ASSERT(pView != NULL);
  160. pView->onResState(pResStatus);
  161. }
  162. }
  163. /*****************************************************************
  164. **【函数名称】 setup
  165. **【函数功能】 视图管理器创建
  166. **【参数】
  167. **【返回值】
  168. ****************************************************************/
  169. bool CViewMgr::setup( CDisplayWnd* pWnd )
  170. {
  171. ASSERT(pWnd != NULL);
  172. m_pWnd = pWnd;
  173. if(!m_ViewLog.create(pWnd))
  174. {
  175. AfxMessageBox(_T("日志视图创建失败!"));
  176. return false;
  177. }
  178. ILogger::getInstance().init(&m_ViewLog, LOG_DEV_CTI, CConfig::GetInstance().logFilePath());
  179. ILogger::getInstance().start();
  180. if(!m_ViewRes.create(pWnd))
  181. {
  182. AfxMessageBox(_T("设备资源视图创建失败!"));
  183. return false;
  184. }
  185. CMsgCenter& MsgCenter = CMsgCenter::GetInstance();
  186. MsgCenter.regist(DEV_EVENT_RES_TYPE, this);
  187. MsgCenter.regist(DEV_EVENT_RES_DETAIL, this);
  188. MsgCenter.regist(DEV_EVENT_RES_STATUS, this);
  189. return true;
  190. }
  191. /*****************************************************************
  192. **【函数名称】 showResView
  193. **【函数功能】 显示指定资源视图
  194. **【参数】
  195. **【返回值】
  196. ****************************************************************/
  197. bool CViewMgr::showResView( UINT ResType )
  198. {
  199. CViewResBase* pView = NULL;
  200. if(m_ViewMap.Lookup(ResType, pView))
  201. {
  202. ASSERT(pView != NULL);
  203. pView->show();
  204. return true;
  205. }
  206. else
  207. return false;
  208. }
  209. /*****************************************************************
  210. **【函数名称】 onMessage
  211. **【函数功能】 消息事件处理函数
  212. **【参数】 MsgType: 消息事件类型
  213. lpContent: 消息内容
  214. **【返回值】
  215. ****************************************************************/
  216. void CViewMgr::onMessage( UINT MsgType, const PARAM lpContent )
  217. {
  218. if(lpContent == NULL) return;
  219. switch(MsgType)
  220. {
  221. case DEV_EVENT_RES_TYPE: // 设备资源类型
  222. {
  223. EventResType* pResType = (EventResType*)lpContent;
  224. #ifdef _USE_EHANGCOM
  225. AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_TYPE, pResType->nResType);
  226. #else
  227. AfxGetMainWnd()->SendMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_TYPE, pResType->nResType);
  228. #endif
  229. }
  230. break;
  231. case DEV_EVENT_RES_DETAIL: // 设备资源明细
  232. {
  233. EventResDetail* pResDetail = (EventResDetail*)lpContent;
  234. __procResDetail(pResDetail);
  235. }
  236. break;
  237. case DEV_EVENT_RES_STATUS: // 设备资源状态变化
  238. {
  239. EventResStatus* pResStatus = (EventResStatus*)lpContent;
  240. __procResState(pResStatus);
  241. }
  242. break;
  243. default:
  244. break;
  245. }
  246. }