⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsacd_ivrview.cpp

📁 dsacd_ivr 的实现
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		|| csItemName.Left(8) == _T("缺省匹配"))
	{
		 popMenu.EnableMenuItem(IDR_POP_DELETE, MF_GRAYED );
		 popMenu.EnableMenuItem(IDR_POP_PROPERTY, MF_GRAYED );
	}
	else if (csItemName.Left(8) == _T("开始流程") || csItemName.Left(8) == _T("结束流程")
		|| csItemName.Left(4) == _T("应答"))
	{
		 popMenu.EnableMenuItem(IDR_POP_PROPERTY, MF_GRAYED );
	}
	// show the menu (returns, when menu is closed again!)
	pMenu = popMenu.GetSubMenu (0);	
	pMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,	pt.x, pt.y, this);
	
//	CTreeView::OnRButtonDown(nFlags, point); //必须去掉这句语句
}

void CDsACD_IVRView::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	OnPopProperty();
	CTreeView::OnLButtonDblClk(nFlags, point);
}

void CDsACD_IVRView::OnPopProperty() 
{
	HTREEITEM	hSelectedItem = m_TreeCtrl->GetSelectedItem();
	CString		csItemText = m_TreeCtrl->GetItemText(hSelectedItem);
	dsACDObjectBase * pObj = g_MapObj.FindObj(hSelectedItem);
	CString csNewItemText;

	if (csItemText.Left(8) == _T("变量定义"))
	{	
		CVariableDefine variabledefine;
		variabledefine.DisplayDlg(pObj);
		dsVD_INFO * pVDInfo = (dsVD_INFO*) pObj->Read();

		if ((pVDInfo->Value == "")&&(pVDInfo->Comment == ""))
			csNewItemText = "变量定义:" + pVDInfo->Name ;
		else if (pVDInfo->Value == "")
			csNewItemText = "变量定义:" + pVDInfo->Name  + " {" + pVDInfo->Comment + "}";
		else if (pVDInfo->Comment == "")
			csNewItemText = "变量定义:" + pVDInfo->Name  + " 初值 " +pVDInfo->Value;
		else
			csNewItemText = "变量定义:" + pVDInfo->Name  + " 初值 " +pVDInfo->Value + " {" + pVDInfo->Comment + "}";
	}	

	else if (csItemText.Left(8) == _T("数据分类"))
	{	
		CDataSort datasort;
		datasort.DisplayDlg(pObj);
		dsDS_INFO * pDSInfo = (dsDS_INFO*) pObj->Read();
		
		if (pDSInfo->Comment == "")
			csNewItemText = "数据分类";
		else
			csNewItemText = "数据分类 {" + pDSInfo->Comment + "}";
	}	

	else if (csItemText.Left(10) == _T("数据库连接"))
	{	
		CDBConnection dbconnection;
		dbconnection.DisplayDlg(pObj);
		dsDBConn_INFO * pInfo = (dsDBConn_INFO*) pObj->Read();
		
		if (pInfo->Comment != "")
			csNewItemText = "数据库连接:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "数据库连接:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content;
	}

	else if (csItemText.Left(8) == _T("条件控制"))
	{	
		CConControl concontrol;
		concontrol.m_pDsACD_IVRView = this;
		concontrol.DisplayDlg(pObj);
		dsCC_INFO * pCCInfo = (dsCC_INFO*) pObj->Read();

		if ((pCCInfo->Condition == "")&&(pCCInfo->Comment == ""))
			csNewItemText = "条件控制: 空" ;
		else if (pCCInfo->Condition == "")
			csNewItemText = "条件控制: 空 {" + pCCInfo->Comment + "}";
		else if (pCCInfo->Comment == "")
			csNewItemText = "条件控制: " + pCCInfo->Condition;
		else
			csNewItemText = "条件控制: " + pCCInfo->Condition + " {" + pCCInfo->Comment + "}";
	}	

	else if (csItemText.Left(8) == _T("多路分支"))
	{	
		CSwitch switchobj;
		switchobj.m_pDsACD_IVRView = this;
		switchobj.DisplayDlg(pObj);
		dsSM_INFO * pSMInfo = (dsSM_INFO*) pObj->Read();

		if ((pSMInfo->Condition == "")&&(pSMInfo->Comment == ""))
			csNewItemText = "多路分支: 空" ;
		else if (pSMInfo->Condition == "")
			csNewItemText = "多路分支: 空 {" + pSMInfo->Comment + "}";
		else if (pSMInfo->Comment == "")
			csNewItemText = "多路分支: " + pSMInfo->Condition;
		else
			csNewItemText = "多路分支: " + pSMInfo->Condition + " {" + pSMInfo->Comment + "}";
	}	

	else if (csItemText.Left(8) == _T("分支匹配"))
	{	
		CMatch match;
		match.m_pDsACD_IVRView = this;
		match.DisplayDlg(pObj);
		dsMM_INFO * pMMInfo = (dsMM_INFO*) pObj->Read();

		if ((pMMInfo->Condition == "")&&(pMMInfo->Comment == ""))
			csNewItemText = "分支匹配: 空" ;
		else if (pMMInfo->Condition == "")
			csNewItemText = "分支匹配: 空 {" + pMMInfo->Comment + "}";
		else if (pMMInfo->Comment == "")
			csNewItemText = "分支匹配: " + pMMInfo->Condition;
		else
			csNewItemText = "分支匹配: " + pMMInfo->Condition + " {" + pMMInfo->Comment + "}";
	}	

	else if (csItemText.Left(8) == _T("循环控制"))
	{	
		CCirculate circulate;
		circulate.m_pDsACD_IVRView = this;
		circulate.DisplayDlg(pObj);
		dsCir_INFO * pCirInfo = (dsCir_INFO*) pObj->Read();

		if ((pCirInfo->Condition == "")&&(pCirInfo->Comment == ""))
			csNewItemText = "循环控制: 空" ;
		else if (pCirInfo->Condition == "")
			csNewItemText = "循环控制: 空 {" + pCirInfo->Comment + "}";
		else if (pCirInfo->Comment == "")
			csNewItemText = "循环控制: " + pCirInfo->Condition;
		else
			csNewItemText = "循环控制: " + pCirInfo->Condition + " {" + pCirInfo->Comment + "}";
	}
	
	else if (csItemText.Left(6) == _T("程序块"))
	{	
		CFunction function;
		function.DisplayDlg(pObj);
		dsFun_INFO * pFunInfo = (dsFun_INFO*) pObj->Read();
		
		if (pFunInfo->Comment == "")
			csNewItemText = "程序块";
		else
			csNewItemText = "程序块 {" + pFunInfo->Comment + "}";
	}
	
	else if (csItemText.Left(8) == _T("标号位置"))
	{	
		CSign sign;
		sign.DisplayDlg(pObj);
		dsSig_INFO * pSigInfo = (dsSig_INFO*) pObj->Read();

		if (pSigInfo->Comment == "")
			csNewItemText = "标号位置:" + pSigInfo->Name ;
		else
			csNewItemText = "标号位置:" + pSigInfo->Name + " {" + pSigInfo->Comment + "}";
	}	

	else if (csItemText.Left(8) == _T("跳转语句"))
	{	
		CJump jump;
		jump.m_pDsACD_IVRView = this;
		jump.DisplayDlg(pObj);
		dsJmp_INFO * pJmpInfo = (dsJmp_INFO*) pObj->Read();

		if (pJmpInfo->Comment == "")
			csNewItemText = "跳转语句:" + pJmpInfo->SignPos ;
		else
			csNewItemText = "跳转语句:" + pJmpInfo->SignPos + " {" + pJmpInfo->Comment + "}";
	}
	
	else if (csItemText.Left(8) == _T("变量运算"))
	{	
		CVarOperate varoperate;
		varoperate.m_pDsACD_IVRView = this;
		varoperate.DisplayDlg(pObj);
		dsVO_INFO * pVOInfo = (dsVO_INFO*) pObj->Read();
	
		if (pVOInfo->Comment != "")
			csNewItemText = "变量运算:" + pVOInfo->Result + " = " + pVOInfo->DestVar + " " + pVOInfo->OpeType + " " + pVOInfo->SrcVar + " {" + pVOInfo->Comment + "}";
		else 
			csNewItemText = "变量运算:" + pVOInfo->Result + " = " + pVOInfo->DestVar + " " + pVOInfo->OpeType + " " + pVOInfo->SrcVar;
	}

	else if (csItemText.Left(8) == _T("文字转换"))
	{	
		CConvert convert;
		convert.m_pDsACD_IVRView = this;
		convert.DisplayDlg(pObj);
		dsChar_INFO * pInfo = (dsChar_INFO*) pObj->Read();
	
		CString str1, str2;
		if (pInfo->Type != "取子串(部分文字)")
		{
			str1 = "";	str2 = "";
		}
		else
		{
			str1.Format("%d",pInfo->SubstrPlace);
			str2.Format("%d",pInfo->SubstrLength);
		}
		
		if (pInfo->Comment != "")
			csNewItemText = "文字转换:" + pInfo->Variable + " " + pInfo->Type + " " + str1 + " " + str2 + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "文字转换:" + pInfo->Variable + " " + pInfo->Type + " " + str1 + " " + str2;
	}

	else if (csItemText.Left(8) == _T("日期时间"))
	{	
		CDateTime datetime;
		datetime.m_pDsACD_IVRView = this;
		datetime.DisplayDlg(pObj);
		dsDT_INFO * pInfo = (dsDT_INFO*) pObj->Read();
		if (pInfo->Comment != "")
			csNewItemText = "日期时间:" + pInfo->Variable + " " + pInfo->Style + " " + pInfo->Type + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "日期时间:" + pInfo->Variable + " " + pInfo->Style + " " + pInfo->Type ;
	}

	else if (csItemText.Left(10) == _T("数据库操作"))
	{	
		CDBOperate dboperate;
		dboperate.m_pDsACD_IVRView = this;
		dboperate.DisplayDlg(pObj);
		dsDBOpe_INFO * pInfo = (dsDBOpe_INFO*) pObj->Read();
		
		if (pInfo->Comment != "")
			csNewItemText = "数据库操作:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Variable + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "数据库操作:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Variable ;
	}

	else if (csItemText.Left(8) == _T("取字段值"))
	{	
		CGetField getfield;
		getfield.m_pDsACD_IVRView = this;
		getfield.DisplayDlg(pObj);
		dsField_INFO * pInfo = (dsField_INFO*) pObj->Read();
		
		if (pInfo->Comment != "")
			csNewItemText = "取字段值:" + pInfo->Name + " " + pInfo->Field + " " + pInfo->Variable + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "取字段值:" + pInfo->Name + " " + pInfo->Field + " " + pInfo->Variable ;
	}

	else if (csItemText.Left(12) == _T("设置查询命令"))
	{	
		CQueryCommand querycommand;
		querycommand.m_pDsACD_IVRView = this;
		querycommand.DisplayDlg(pObj);
		dsQC_INFO * pInfo = (dsQC_INFO*) pObj->Read();
		
		if (pInfo->Comment != "")
			csNewItemText = "设置查询命令:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "设置查询命令:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content ;
	}

	else if (csItemText.Left(12) == _T("设置查询参数"))
	{	
		CQueryParameter queryparameter;
		queryparameter.m_pDsACD_IVRView = this;
		queryparameter.DisplayDlg(pObj);
		dsQP_INFO * pInfo = (dsQP_INFO*) pObj->Read();
		
		if (pInfo->Comment != "")
			csNewItemText = "设置查询参数:" + pInfo->Name + " " + pInfo->Parameter + " " + pInfo->Value + " {" + pInfo->Comment + "}";
		else 
			csNewItemText = "设置查询参数:" + pInfo->Name + " " + pInfo->Parameter + " " + pInfo->Value ;
	}

	else 
		return;

	m_TreeCtrl->SetItemText(hSelectedItem, csNewItemText);
	m_bModified=TRUE;
	UpdateData(FALSE);
}

void CDsACD_IVRView::OnPopDelete() 
{
	HTREEITEM hSelectedItem = m_TreeCtrl->GetSelectedItem();
	g_MapObj.RemoveMapItem(hSelectedItem);
	m_TreeCtrl->DeleteItem( hSelectedItem);
	m_bModified=TRUE;
}

void CDsACD_IVRView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if (nChar == 46 || nChar == 110)
	{
		HTREEITEM hSelectedItem = m_TreeCtrl->GetSelectedItem();
		CString csItemName = m_TreeCtrl->GetItemText(hSelectedItem);
		if (csItemName.Left(8) == _T("数据定义") || csItemName.Left(6) == _T("返回值")
			|| csItemName.Left(8) == _T("流程开始") || csItemName.Left(8) == _T("流程结束")
			|| csItemName.Left(8) == _T("条件为真") || csItemName.Left(8) == _T("条件为假")
			|| csItemName.Left(8) == _T("缺省匹配"))
		{
			 return;
		}
		else
			OnPopDelete();			
	}

	CTreeView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CDsACD_IVRView::OnPopExtendAll() 
{	
	HTREEITEM hExpandItem=m_TreeCtrl->GetRootItem();
	m_TreeCtrl->SelectItem(hExpandItem);
	do{
		m_TreeCtrl->Expand(hExpandItem, TVE_EXPAND);

	}while(hExpandItem=GetNextItem(hExpandItem));
}

HTREEITEM CDsACD_IVRView::GetNextItem(HTREEITEM hItem)
{
	if(m_TreeCtrl->ItemHasChildren(hItem))	//有子节点
		return m_TreeCtrl->GetChildItem(hItem);

	HTREEITEM hSibItem=m_TreeCtrl->GetNextSiblingItem(hItem);
	if(hSibItem)	// 无子节点,但有兄弟节点,则返回兄弟节点
		return hSibItem;

	else //既无子节点,也无兄弟节点,则寻找上级节点的兄弟节点
	{    //flag表示上溯的级数
		hSibItem=NULL;
		do{
			hItem=m_TreeCtrl->GetParentItem(hItem);
			hSibItem=m_TreeCtrl->GetNextSiblingItem(hItem);
		}while(hSibItem==NULL&&hItem);
		if(!hItem)
			return NULL;
		else
			return hSibItem;
	}
}

void CDsACD_IVRView::OnPopCloseAll() 
{
	m_TreeCtrl->Expand(m_hParent1, TVE_COLLAPSE);
	m_TreeCtrl->Expand(m_hParent2, TVE_COLLAPSE);
	m_TreeCtrl->Expand(m_hParent3, TVE_COLLAPSE);		
}

void CDsACD_IVRView::OnPopExtendCurrent() 
{
	HTREEITEM hSelectedItem = m_TreeCtrl->GetSelectedItem();
	if (m_TreeCtrl->ItemHasChildren(hSelectedItem))
		m_TreeCtrl->Expand(hSelectedItem, TVE_EXPAND);
}

void CDsACD_IVRView::OnPopCloseCurrent() 
{
	HTREEITEM hSelectedItem = m_TreeCtrl->GetSelectedItem();
	if (m_TreeCtrl->ItemHasChildren(hSelectedItem))
		m_TreeCtrl->Expand(hSelectedItem, TVE_COLLAPSE);	
}

//保存界面上树中的内容到文件
BOOL CDsACD_IVRView::SaveTree(CString csFileName)
{	
	HTREEITEM hWriteItem=m_TreeCtrl->GetRootItem();
	if(!hWriteItem)
		return FALSE;

	m_IOFile.Open(csFileName,CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite);
	m_IOFile.WriteString("[StrategyInfo]\n");

	int flag=-1;
	do{
		dsACDObjectBase * pObj = g_MapObj.FindObj(hWriteItem);

		pObj->WritetoFile(m_IOFile, flag);

	}while(hWriteItem=GetNextWriteItem(hWriteItem,flag));

	m_IOFile.Flush();
//	m_IOFile.SeekToBegin();
	m_IOFile.Close();
	return TRUE;
}

//辅助函数,用于保存文件时获取下一个要保存的项,采用深度优先遍历
HTREEITEM CDsACD_IVRView::GetNextWriteItem(HTREEITEM hItem, int &flag)
{
	if(m_TreeCtrl->ItemHasChildren(hItem)) //有子节点
	{
		flag=-1;
		return m_TreeCtrl->GetChildItem(hItem);
	}

	HTREEITEM hSibItem=m_TreeCtrl->GetNextSiblingItem(hItem);
	if(hSibItem)// 无子节点,但有兄弟节点,则返回兄弟节点
	{
		flag=0;
		return hSibItem;
	}

	else //既无子节点,也无兄弟节点,则寻找上级节点的兄弟节点
	{    //flag表示上溯的级数
		flag=0;
		hSibItem=NULL;
		do{
			flag++;
			hItem=m_TreeCtrl->GetParentItem(hItem);
			hSibItem=m_TreeCtrl->GetNextSiblingItem(hItem);
		}while(hSibItem==NULL&&hItem);
		if(!hItem)
			return NULL;
		else
			return hSibItem;
	}
}

//构造树
BOOL CDsACD_IVRView::OpenTree(CString csFileName)
{
	//把原文件csFileName复制另一份用于填充树以及操作中的读写
	Reset();
//	CString csNewTitle;
//	csNewTitle += m_csTitle + " - " + csFileName;
//	SetWindowText(csNewTitle);
	m_csOpenFileName=csFileName; //设置打开文件为csFileName  
	m_csCurFileName=CreateTempFileName();
	CopyFile(m_csOpenFileName,m_csCurFileName,FALSE);//复制文件
	m_IOFile.Open(m_csCurFileName, CFile::modeRead); 	
	HTREEITEM hItem=TVI_ROOT;

	CString buf, csItemText;
	BOOL bResult=m_IOFile.ReadString(buf);

	while(bResult)
	{
		if (buf.Find(":") != -1)
		{
//			int nID = atoi(buf.Left(buf.Find(":")));
			int nID;
			sscanf( buf.Left(buf.Find(":")), "%x", &nID);
			int nFlag = atoi(buf.Mid(buf.Find("Flag")+5, buf.Find(";")));

			if(nFlag==-1) //表示要插入的节点是前一插入节点的子项
			{
				hItem = InsertItemFromFile(buf, nID, hItem);		
			}
			else if(nFlag==0)//表示要插入的节点时前一插入节点的兄弟项
			{   
				hItem = m_TreeCtrl->GetParentItem(hItem);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -