| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #include "StdAfx.h"
- #include "CellSubFlow.h"
- #include "IvrFlow.h"
- #include "FlowDataProvider.h"
- #include "IvrCore.h"
- #include "FlowTemplate.h"
- IMPLEMENT_CELL_AUTOCREATE(CCellSubFlow, CELL_NAME_SUB_FLOW)
- CCellSubFlow::CCellSubFlow(void) : m_pInnerFlow(NULL), m_NextPos(0), m_BeginPos(0)
- {
- }
- CCellSubFlow::CCellSubFlow( CCellSubFlow& CellSubFlow ) : CCellBase(CellSubFlow)
- {
- m_NextPos = CellSubFlow.m_NextPos;
- m_BeginPos = CellSubFlow.m_BeginPos;
- m_FLowName = CellSubFlow.m_FLowName;
- }
- CCellSubFlow::~CCellSubFlow(void)
- {
- if(m_pInnerFlow != NULL)
- delete m_pInnerFlow;
- }
- /*****************************************************************
- **【函数名称】 operate
- **【函数功能】 节点执行函数
- **【参数】
- **【返回值】 下一个节点编号
- ****************************************************************/
- int CCellSubFlow::operate( void )
- {
- if(m_pIvrFlow == NULL)
- return CELL_OP_ERROR;
- CString Info;
- _getCellInfo(Info);
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Cell}: 开始执行[%s]"), Info);
- CFlowTemplate* pTemplate = CIvrCore::GetInstance().flowTemplateMgr().findTemplate(m_FLowName);
- ASSERT(pTemplate != NULL);
- if(pTemplate == NULL)
- {
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Cell}: 执行[%s]出错, 未找到子流程模板[%s]"), Info, m_FLowName);
- return CELL_OP_ERROR;
- }
- m_pInnerFlow = new CIvrFlow(m_pIvrFlow->id());
- ASSERT(m_pInnerFlow != NULL);
- if(m_pInnerFlow == NULL)
- {
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Cell}: 执行[%s]出错, 创建子流程执行体失败"), Info);
- return CELL_OP_ERROR;
- }
- m_pInnerFlow->copyVar(*m_pIvrFlow);
- int Res = m_pInnerFlow->start(pTemplate, m_BeginPos);
- switch(Res)
- {
- case CELL_OP_END:
- case CELL_OP_ERROR:
- case CELL_OP_SEND_ERROR:
- return m_NextPos;
- break;
- case CELL_OP_WAIT_FOR:
- return CELL_OP_WAIT_FOR;
- break;
- default:
- ASSERT(FALSE);
- }
-
- return m_NextPos;
- }
- /*****************************************************************
- **【函数名称】 copy
- **【函数功能】 拷贝自身
- **【参数】
- **【返回值】 拷贝副本
- ****************************************************************/
- CCellBase * CCellSubFlow::copy( void )
- {
- CCellBase * pCellBase = new CCellSubFlow(*this);
- return pCellBase;
- }
- /*****************************************************************
- **【函数名称】 fillData
- **【函数功能】 节点解析,填充数据
- **【参数】 Provider:数据提供器
- **【返回值】 成功true,失败false
- ****************************************************************/
- bool CCellSubFlow::fillData( IFlowDataProvider& Provider )
- {
- CString Data;
- do
- {
- if(!Provider.getData(CELL_ATTRIBUTE_POS, Data))
- {
- Data = _T("节点号");
- break;
- }
- else
- {
- sscanf_s(Data, _T("%d"), &m_Pos);
- if(m_Pos < 1)
- {
- Data = _T("节点号");
- break;
- }
- }
- if(!Provider.getData(CELL_ATTRIBUTE_FLOW_NAME, m_FLowName))
- {
- Data = _T("子流程名");
- break;
- }
- if(!Provider.getData(CELL_ATTRIBUTE_BEGIN_POS, Data))
- {
- Data = _T("起始节点");
- break;
- }
- else
- {
- sscanf_s(Data, _T("%d"), &m_BeginPos);
- if(m_BeginPos < 1)
- {
- Data = _T("起始节点");
- break;
- }
- }
- if(!Provider.getData(CELL_ATTRIBUTE_NEXT, Data))
- {
- Data = _T("跳转节点");
- break;
- }
- else
- {
- sscanf_s(Data, _T("%d"), &m_NextPos);
- if(m_NextPos < 1)
- {
- Data = _T("跳转节点");
- break;
- }
- }
- Provider.getData(CELL_ATTRIBUTE_NOTE, m_Note);
- return true;
- } while (false);
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("{Cell}: 节点[%s]解析失败, '%s'错误"), CELL_NAME_SUB_FLOW, Data);
- return false;
- }
- /*****************************************************************
- **【函数名称】 onOpResultReturn
- **【函数功能】 处理PDU命令
- **【参数】 a_pPduEntity:PDU命令
- **【返回值】 下一个节点编号
- ****************************************************************/
- int CCellSubFlow::onOpResultReturn( CPduEntity *a_pPduEntity )
- {
- int Res = m_pInnerFlow->procPdu(a_pPduEntity);
- switch(Res)
- {
- case CELL_OP_END:
- case CELL_OP_ERROR:
- case CELL_OP_SEND_ERROR:
- return m_NextPos;
- break;
- case CELL_OP_WAIT_FOR:
- return CELL_OP_WAIT_FOR;
- break;
- default:
- ASSERT(FALSE);
- }
- return m_NextPos;
- }
|