MiddleWares_YiHe 郑州颐和医院随访系统中间件

InfoList.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // TaskList.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "IVR.h"
  5. #include "InfoList.h"
  6. #include "IvrCore.h"
  7. #include "IvrFlowMgr.h"
  8. #include "NetworkIvr.h"
  9. // CTaskList
  10. IMPLEMENT_DYNAMIC(CInfoList, CListCtrl)
  11. CInfoList::CInfoList()
  12. {
  13. }
  14. CInfoList::~CInfoList()
  15. {
  16. }
  17. BEGIN_MESSAGE_MAP(CInfoList, CListCtrl)
  18. END_MESSAGE_MAP()
  19. /*****************************************************************
  20. **【函数名称】 __indexItem
  21. **【函数功能】 索引任务
  22. **【参数】
  23. **【返回值】
  24. *****************************************************************/
  25. int CInfoList::__indexItem( int id )
  26. {
  27. for (int i=0; i < GetItemCount(); i++)
  28. {
  29. if (GetItemData(i) == id)
  30. return i;
  31. }
  32. return -1;
  33. }
  34. /*****************************************************************
  35. **【函数名称】 __transState
  36. **【函数功能】 翻译状态
  37. **【参数】
  38. **【返回值】
  39. *****************************************************************/
  40. void CInfoList::__transState( IVR_FLOW_STATE State, CString& Data )
  41. {
  42. switch(State)
  43. {
  44. case IVR_FLOW_STATE_FREE:
  45. Data = _T("空闲");
  46. break;
  47. case IVR_FLOW_STATE_RUN:
  48. Data = _T("正在运行");
  49. break;
  50. default:
  51. ASSERT(FALSE);
  52. Data = _T("未知状态");
  53. break;
  54. }
  55. }
  56. /*****************************************************************
  57. **【函数名称】 __showTask
  58. **【函数功能】 显示任务
  59. **【参数】
  60. **【返回值】
  61. *****************************************************************/
  62. void CInfoList::__showInfo( Flow2Show& Info )
  63. {
  64. int Item = GetItemCount();
  65. CString Data;
  66. Data.Format(_T("%d"), Info.Id);
  67. InsertItem(Item, Data);
  68. __transState(Info.State, Data);
  69. SetItemText(Item, 1, Data);
  70. SetItemText(Item, 2, Info.NodeNote);
  71. SetItemData(Item, Info.Id);
  72. }
  73. /*****************************************************************
  74. **【函数名称】 __updateTaskState
  75. **【函数功能】 更新任务
  76. **【参数】
  77. **【返回值】
  78. *****************************************************************/
  79. void CInfoList::__updateState( int Item, Flow2Show& Info )
  80. {
  81. CString Data;
  82. __transState(Info.State, Data);
  83. SetItemText(Item, 1, Data);
  84. SetItemText(Item, 2, Info.NodeNote);
  85. /*if(State == IVR_FLOW_STATE_FREE)
  86. DeleteItem(Item);*/
  87. }
  88. /*****************************************************************
  89. **【函数名称】 format
  90. **【函数功能】 格式化控件
  91. **【参数】
  92. **【返回值】
  93. *****************************************************************/
  94. void CInfoList::format( void )
  95. {
  96. CRect mRect;
  97. GetClientRect(&mRect);
  98. int length = mRect.right - mRect.left - 150;
  99. //加载日志列表
  100. SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
  101. InsertColumn(1, (LPCTSTR)_T("流程ID"), LVCFMT_CENTER, 50, -1);
  102. InsertColumn(1, (LPCTSTR)_T("流程状态"), LVCFMT_CENTER, 100, -1);
  103. InsertColumn(2, (LPCTSTR)_T("节点名称"), LVCFMT_CENTER, length, -1);
  104. }
  105. /*****************************************************************
  106. **【函数名称】 onTaskStateUpdated
  107. **【函数功能】 任务状态变化处理函数
  108. **【参数】
  109. **【返回值】
  110. *****************************************************************/
  111. void CInfoList::onStateUpdated(int id)
  112. {
  113. Flow2Show Info;
  114. Info.Id = id;
  115. int Item = __indexItem(id);
  116. if(CIvrCore::GetInstance().ivrFLowMgr().getFlowInfo(Info))
  117. {
  118. if(Item != -1)
  119. __updateState(Item, Info);
  120. else
  121. __showInfo(Info);
  122. }
  123. else
  124. {
  125. if(Item != -1)
  126. DeleteItem(Item);
  127. }
  128. }
  129. // CTaskList 消息处理程序