中间件底层,websocket

CellSubFlow.cpp 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #include "StdAfx.h"
  2. #include "CellSubFlow.h"
  3. #include "IvrFlow.h"
  4. #include "FlowDataProvider.h"
  5. #include "IvrCore.h"
  6. #include "FlowTemplate.h"
  7. IMPLEMENT_CELL_AUTOCREATE(CCellSubFlow, CELL_NAME_SUB_FLOW)
  8. CCellSubFlow::CCellSubFlow(void) : m_pInnerFlow(NULL), m_NextPos(0), m_BeginPos(0)
  9. {
  10. }
  11. CCellSubFlow::CCellSubFlow( CCellSubFlow& CellSubFlow ) : CCellBase(CellSubFlow)
  12. {
  13. m_NextPos = CellSubFlow.m_NextPos;
  14. m_BeginPos = CellSubFlow.m_BeginPos;
  15. m_FLowName = CellSubFlow.m_FLowName;
  16. }
  17. CCellSubFlow::~CCellSubFlow(void)
  18. {
  19. if(m_pInnerFlow != NULL)
  20. delete m_pInnerFlow;
  21. m_pInnerFlow = NULL;
  22. }
  23. /*****************************************************************
  24. **【函数名称】 operate
  25. **【函数功能】 节点执行函数
  26. **【参数】
  27. **【返回值】 下一个节点编号
  28. ****************************************************************/
  29. int CCellSubFlow::operate( void )
  30. {
  31. if(m_pIvrFlow == NULL)
  32. return CELL_OP_ERROR;
  33. CString Info;
  34. _getCellInfo(Info);
  35. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Cell}: 开始执行[%s]"), Info);
  36. CFlowTemplate* pTemplate = CIvrCore::GetInstance().flowTemplateMgr().findTemplate(m_FLowName);
  37. ASSERT(pTemplate != NULL);
  38. if(pTemplate == NULL)
  39. {
  40. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Cell}: 执行[%s]出错, 未找到子流程模板[%s]"), Info, m_FLowName);
  41. return CELL_OP_ERROR;
  42. }
  43. m_pInnerFlow = new CIvrFlow(m_pIvrFlow->id());
  44. ASSERT(m_pInnerFlow != NULL);
  45. if(m_pInnerFlow == NULL)
  46. {
  47. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Cell}: 执行[%s]出错, 创建子流程执行体失败"), Info);
  48. return CELL_OP_ERROR;
  49. }
  50. m_pInnerFlow->copyVar(*m_pIvrFlow);
  51. int Res = m_pInnerFlow->start(pTemplate, m_BeginPos);
  52. switch(Res)
  53. {
  54. case CELL_OP_END:
  55. case CELL_OP_ERROR:
  56. case CELL_OP_SEND_ERROR:
  57. return m_NextPos;
  58. break;
  59. case CELL_OP_WAIT_FOR:
  60. return CELL_OP_WAIT_FOR;
  61. break;
  62. default:
  63. ASSERT(FALSE);
  64. }
  65. return m_NextPos;
  66. }
  67. /*****************************************************************
  68. **【函数名称】 copy
  69. **【函数功能】 拷贝自身
  70. **【参数】
  71. **【返回值】 拷贝副本
  72. ****************************************************************/
  73. CCellBase * CCellSubFlow::copy( void )
  74. {
  75. CCellBase * pCellBase = new CCellSubFlow(*this);
  76. return pCellBase;
  77. }
  78. /*****************************************************************
  79. **【函数名称】 fillData
  80. **【函数功能】 节点解析,填充数据
  81. **【参数】 Provider:数据提供器
  82. **【返回值】 成功true,失败false
  83. ****************************************************************/
  84. bool CCellSubFlow::fillData( IFlowDataProvider& Provider )
  85. {
  86. CString Data;
  87. do
  88. {
  89. if(!Provider.getData(CELL_ATTRIBUTE_POS, Data))
  90. {
  91. Data = _T("节点号");
  92. break;
  93. }
  94. else
  95. {
  96. sscanf_s(Data, _T("%d"), &m_Pos);
  97. if(m_Pos < 1)
  98. {
  99. Data = _T("节点号");
  100. break;
  101. }
  102. }
  103. if(!Provider.getData(CELL_ATTRIBUTE_FLOW_NAME, m_FLowName))
  104. {
  105. Data = _T("子流程名");
  106. break;
  107. }
  108. if(!Provider.getData(CELL_ATTRIBUTE_BEGIN_POS, Data))
  109. {
  110. Data = _T("起始节点");
  111. break;
  112. }
  113. else
  114. {
  115. sscanf_s(Data, _T("%d"), &m_BeginPos);
  116. if(m_BeginPos < 1)
  117. {
  118. Data = _T("起始节点");
  119. break;
  120. }
  121. }
  122. if(!Provider.getData(CELL_ATTRIBUTE_NEXT, Data))
  123. {
  124. Data = _T("跳转节点");
  125. break;
  126. }
  127. else
  128. {
  129. sscanf_s(Data, _T("%d"), &m_NextPos);
  130. if(m_NextPos < 1)
  131. {
  132. Data = _T("跳转节点");
  133. break;
  134. }
  135. }
  136. Provider.getData(CELL_ATTRIBUTE_NOTE, m_Note);
  137. return true;
  138. } while (false);
  139. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("{Cell}: 节点[%s]解析失败, '%s'错误"), CELL_NAME_SUB_FLOW, Data);
  140. return false;
  141. }
  142. /*****************************************************************
  143. **【函数名称】 onOpResultReturn
  144. **【函数功能】 处理PDU命令
  145. **【参数】 a_pPduEntity:PDU命令
  146. **【返回值】 下一个节点编号
  147. ****************************************************************/
  148. int CCellSubFlow::onOpResultReturn( CPduEntity *a_pPduEntity )
  149. {
  150. int Res = m_pInnerFlow->procPdu(a_pPduEntity);
  151. switch(Res)
  152. {
  153. case CELL_OP_END:
  154. case CELL_OP_ERROR:
  155. case CELL_OP_SEND_ERROR:
  156. return m_NextPos;
  157. break;
  158. case CELL_OP_WAIT_FOR:
  159. return CELL_OP_WAIT_FOR;
  160. break;
  161. default:
  162. ASSERT(FALSE);
  163. }
  164. return m_NextPos;
  165. }