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

📄 appserver.cpp

📁 用过恒迅达交换机的人都知道。恒迅达交换机是需要在交换机内部运行中间程序来给脚本提供数据接口并且监控机器运行状态的。本程序即是完成以上功能!用C++开发、调用了数据库(sqlserver2000)存储过
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
}

CString GetTTSDesc(int ttsset)
{
	_RecordsetPtr m_pRecordset; 
	m_pRecordset.CreateInstance(_uuidof(Recordset));
	CAppServerApp *pApp=(CAppServerApp*)AfxGetApp();
	_variant_t TheValue; 
	CString str;
	str.Format ("proc_GetTTSDesc %d",ttsset);

	
	try{
		m_pRecordset->Open(_variant_t(str),(IDispatch*)pApp->m_pConnection, 
			adOpenDynamic,adLockOptimistic,	adCmdText); 
		
		if(!m_pRecordset->EndOfFile) 
		{
			str=m_pRecordset->GetCollect ("desc_txt").bstrVal;

			return str;
		}
		
	}
	catch (_com_error err)
	{
		pApp->EventLog(err.ErrorMessage ());
		return "标准女生";
	}

	return "标准女生";
}

void ProcessMo()
{
	CAppServerApp *pApp=(CAppServerApp*)AfxGetApp();
	CAppServerDlg* pDlg=(CAppServerDlg*)pApp->m_pMainWnd;
	while(1)
	{
		if(pApp->iBegin==0) goto monext;
		MOMSG momsg;
		if(GetMoMsg(&momsg))
		{
			CString strTime;
			CTime time=CTime::GetCurrentTime();
			strTime.Format ("%d-%d-%d %d:%d",time.GetYear(),time.GetMonth(),time.GetDay()
				,time.GetHour(),time.GetMinute ());
			CString str=momsg.spNumber;
			int iOperID=GetOperFromSpnumber(str);
			CString sms=momsg.smsg;
			sms.TrimLeft();
			sms.TrimRight();
			sms.MakeUpper();
			CString strCMD=sms.Left(2);
			//strCMD.MakeUpper();
			if(strCMD=="ZC")  ////注册 
			{
				if(sms.GetLength()==2)   
				{
					char strID[8];
					pDlg->RegisterUser(momsg.userNumber,iOperID,2,strID);
					pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,0,2);
					str.Format("%s %s短信注册%s ",strTime,momsg.userNumber,pApp->operInfo[iOperID-1].name);
					pDlg->AddListMessage(3,str);
				}
				else	////未处理代理商销售的卡片注册方式
				{
					
				}
				goto monext;
			}
			if(strCMD=="ZX")///注销
			{
				CString strid=GetUserID(momsg.userNumber);
				if(strid=="") 
				{
					pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,-1,2);
				}
				else
				{
					pDlg->LogoutOper(strid, iOperID,2);
					pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,1,2);
					str.Format("%s %s短信注消%s ",strTime,momsg.userNumber,pApp->operInfo[iOperID-1].name);
					pDlg->AddListMessage(3,str);

				}
				goto monext;
			}

			int itmp=pApp->strTTSSp.GetLength();
			/////星星点点
			if(str.Left(itmp)==pApp->strTTSSp || str.Left(pApp->strTTSSet.GetLength())==pApp->strTTSSet)///TTS and DG
			{

				if(strCMD=="DG")	////短信点歌
				{
					CString strsong=sms.Mid(2,sms.GetLength()-2);
					char namepath[200];
					char filepath[200];
					strsong.TrimLeft();
					strsong.TrimRight();
					if(!GetSongInfo(strsong,namepath,filepath)) goto monext;
					CString tel;
					itmp=pApp->strTTSSet.GetLength();
					if(str.Left(itmp)==pApp->strTTSSet)///固定电话 
						tel=str.Mid(itmp,str.GetLength());
					else tel=str.Mid(2,str.GetLength());


					pDlg->CastSelectMusic(momsg.userNumber,tel,filepath,namepath,strTime,iOperID);
					str.Format("%s 短信点播 %s %s",strTime,momsg.userNumber,filepath);
					pDlg->AddListMessage(3,str);
				}
				else if((strCMD=="80" || strCMD=="81" || strCMD=="82"
					|| strCMD=="83" || strCMD=="84") && sms.GetAt(2)>='0' && sms.GetAt(2)<'9' )///设置tts参数
				{
					int ttsset=atoi(sms.Left(3));
					str.Format("proc_SetTtsSet '%s',%d",momsg.userNumber,ttsset);
					pApp->SQLEXEC(str);
					CString sss=GetTTSDesc(ttsset);
					str.Format("proc_AddMTMsg '%s',%d,'%s','%s','%s','您已经设置为%s',1"
						,pApp->strTTSSp,pApp->spCode,momsg.userNumber,momsg.userNumber,pApp->sZeroCode,sss);
					pApp->SQLEXEC(str);

				}
				/*
				else		////tts转换
				{
					CString tel;
					itmp=pApp->strTTSSet.GetLength();
					if(str.Left(itmp)==pApp->strTTSSet)///固定电话 
						tel=str.Mid(itmp,str.GetLength());
					else tel=str.Mid(2,str.GetLength());
					/////怎么计费senmtmsg
					CTime time=CTime::GetCurrentTime();
					CString strFile;
					strFile.Format("E:\\HXLT\\TTS\\%s_%d%02d%02d%02d%02d%02d",momsg.userNumber
						,time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());
					
					//BOOL b=TTS2FILE(strFile,momsg.smsg,momsg.userNumber);
					////1--送到order
					////2--mt
					if(b)
					{
						((CAppServerDlg*)pApp->m_pMainWnd)->AddListMessage(4,"TTS: "+strFile+".voc");
						str.Format("proc_addtts '%s','%s','%s'",tel,momsg.userNumber,strFile+".voc");
						pApp->SQLEXEC(str);
						///呼叫成功或3次以后计费
						if(pApp->iTtsMode==1)
						{
							str.Format ("proc_AddMtInfo '%s','%s',%d,%d,%d "
								,momsg.userNumber,"",iOperID,MTINFO_TTSZH,2 );
							pApp->SQLEXEC(str);
						}
					}
				}*/
			}
			if(str.Left(pApp->strCaiHua.GetLength())==pApp->strCaiHua)///彩话
			{
				//RegisterUser(CString strTel, int oper, int type,char *sID)
				CString strSms=sms;
				CString sql;
				if(strSms.Left(3)=="SZK")   ////设置开
				{
					sql.Format("proc_SetKTStatus '%s',%d,1",momsg.userNumber,iOperID);
					pApp->SQLEXEC(sql);
				}
				else if(strSms.Left(3)=="SZT")////设置停
				{
					sql.Format("proc_SetKTStatus '%s',%d,0",momsg.userNumber,iOperID);
					pApp->SQLEXEC(sql);
				}
				else if(strSms.Left(3)=="SZB")///设置默认背景音
				{
					CString strid=GetUserID(momsg.userNumber);
					if(strid=="")
					{
						pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,-1,2);
						goto monext;	
					}
					else
					{
						CString strpos=strSms.Mid(3,1);
						int ipos=atoi(strpos);
						sql.Format("proc_SetOmitBackMusic '%s',%d",strid,ipos);
						pApp->SQLEXEC(sql);
					}
				}
				else if(strSms.Left(3)=="SZD")///设置开通时段
				{
					CString strid=GetUserID(momsg.userNumber);
					if(strid=="")
					{
						pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,-1,2);
						goto monext;	
					}
					else
					{
						CString strB=strSms.Mid(3,4);
						strSms.TrimRight();
						CString strE=strSms.Right(4);

						sql.Format("proc_SetKT '%s',%d,'%s','%s'",strid,iOperID,strB,strE);
						pApp->SQLEXEC(sql);
					}
				}
				else if(strSms.Left(2)=="DX")///彩话短信
				{
					CString strid=GetUserID(momsg.userNumber);
					CString strTel;			///
					if(strid=="") strTel=pApp->strCaiHua+momsg.userNumber;
					else strTel=pApp->strCaiHua+strid;
					///////???????????????
					//////发送MT 非注册用户收费
					sql.Format ("proc_AddMTMsg '%s',%d,'%s','%s','%s','%s',%d"
							,strTel,pApp->spCode,momsg.userNumber,momsg.userNumber,pApp->sZeroCode,momsg.smsg,0);
					pApp->SQLEXEC(sql);
				}
			}
			else if(str.Left(pApp->strLiaotian.GetLength())==pApp->strLiaotian)///聊天
			{
				CString strSms=sms;
				CString sql;
				CString strid=GetUserID(momsg.userNumber);
				if(strSms.Left(3)=="SZD")////设置开通时段
				{
					if(strid=="")
					{
						pDlg->SendMTMsg(momsg.userNumber,momsg.userNumber,iOperID,-1,2);
						goto monext;	
					}
					else
					{
						CString strB=strSms.Mid(3,4);
						strSms.TrimRight();
						CString strE=strSms.Right(4);
						
						sql.Format("proc_SetKT '%s',%d,'%s','%s'",strid,iOperID,strB,strE);
						pApp->SQLEXEC(sql);
					}
				}
				else////短信
				{
					CString strid=GetUserID(momsg.userNumber);
					CString strTel;			///
					if(strid=="") strTel=pApp->strLiaotian+momsg.userNumber;
					else strTel=pApp->strLiaotian+strid;
					///////???????????????strLiaotian
					//////发送MT 非注册用户收费
					sql.Format ("proc_AddMTMsg '%s',%d,'%s','%s','%s','%s',%d"
							,strTel,pApp->spCode,momsg.userNumber,momsg.userNumber,pApp->sZeroCode,momsg.smsg,0);
					pApp->SQLEXEC(sql);
					
				}
			}
		}
monext:
		Sleep(20);
	}

}



BOOL TTSAPI CallBackProc2(WORD wParam, LONG lParam, DWORD dwUserData)
{
	switch(wParam)
	{
	case NOTIFY_BEGIN:
		{
		CString str;
		str.Format("Callback Func - Notify - Begin - %ld, UserData: %lx", lParam, dwUserData);
		AfxMessageBox(str);
		break;
		}
	case NOTIFY_END:
		{
		CString str;
		str.Format("Callback Func - Notify - End - %ld, UserData: %lx", lParam, dwUserData);
		AfxMessageBox(str);
		break;
		}
	case NOTIFY_SENTEND:
		{
		CString str;
		str.Format("Callback Func - Notify - %ld End, UserData: %lx", lParam, dwUserData);
		AfxMessageBox(str);
		break;
		}
	case NOTIFY_SENTBEGIN:
		{
		CString str;
		str.Format("Callback Func - Notify - Will Read To %ld, UserData: %lx", lParam, dwUserData);
		AfxMessageBox(str);
		break;
		}
	default:
		//AfxMessageBox("Callback Func - Notify - Unknow");
		break;
	}
	return TRUE;
}

void GetUserTtsSet(CString strTel,int *is,int *iv,int *ip)
{
	CAppServerApp *pApp=(CAppServerApp*)AfxGetApp();
	_RecordsetPtr m_pRecordset; 
	m_pRecordset.CreateInstance(_uuidof(Recordset));
	_variant_t TheValue; 
	CString str;
	str.Format("proc_GetTtsSet '%s'",strTel);
	*is=5;*iv=9;*ip=5;	///omit value
	try{
		m_pRecordset->Open(_variant_t(str),(IDispatch*)pApp->m_pConnection, 
			adOpenDynamic,adLockOptimistic,	adCmdText); 
		
		if(!m_pRecordset->EndOfFile) 
		{
			int is1=m_pRecordset->GetCollect ("sucess").iVal ;
			if(is1!=1) 
			{
				m_pRecordset->Close();
				return ;
			}
			*is=m_pRecordset->GetCollect ("speed").intVal;
			*iv=m_pRecordset->GetCollect ("volume").intVal ;
			*ip=m_pRecordset->GetCollect ("person").intVal ;
		}
		
	}
	catch (_com_error err)
	{
		pApp->EventLog(err.ErrorMessage ());
	}
	return ;
}
/*
BOOL TTS2FILE(CString strFile,CString strSource,CString strUser)
{

	////取用户设置
	int is,iv,ip;
	GetUserTtsSet(strUser,&is,&iv,&ip);
	g_config.nVolume=iv;
	g_config.nSpeed=is;
	g_config.nPitch=ip;

	CString strName=strFile+".law";

	ERRCODE err = jTTS_PlayToFile(strSource, strName, g_nFormat, &g_config, 
		g_nFileHeadFlag, g_bCallbackFunc ? CallBackProc2 : NULL, 0x12345678);
	if (err != ERR_NONE)
	{
		ErrorMessage(err);
		return false;
	}
	char error[200];
	char fileS[200];
	char fileD[200];
	strcpy(fileS,strName);
	strcpy(fileD,strFile+".voc");
	BYTE by;
	BOOL b=HU_AdpcmEncode(fileS,fileD,1,24,1,error,by);
	if(!b) return false;
	DeleteFile(strName);
	return true;
}
*/
int  GetMoMsg(MOMSG *pMoMsg)
{
	CAppServerApp *pApp=(CAppServerApp*)AfxGetApp();
	_RecordsetPtr m_pRecordset; 
	if(!m_pRecordset.CreateInstance(_uuidof(Recordset))) return 0;
	_variant_t TheValue; 
	CString str;
	str.Format ("proc_GetMoMsg ");

	try{
		
		m_pRecordset->Open(_variant_t(str),(IDispatch*)pApp->m_pConnection, 
			adOpenDynamic,adLockOptimistic,	adCmdText); 
		
		if(!m_pRecordset->EndOfFile) 
		{
			int is=m_pRecordset->GetCollect ("sucess").iVal ;
			if(is!=1) 
			{
				m_pRecordset->Close();
				return 0;
			}
			str=m_pRecordset->GetCollect ("sp").bstrVal;
			strcpy(pMoMsg->spNumber,str);
			str=m_pRecordset->GetCollect ("usernumber").bstrVal ;
			strcpy(pMoMsg->userNumber,str);
			str=m_pRecordset->GetCollect ("msg").bstrVal ;
			strcpy(pMoMsg->smsg,str);
			is=m_pRecordset->GetCollect ("linkid").intVal ;
			pMoMsg->linkId=is;
			return 1;
		}
		
	}
	catch (_com_error err)
	{
		pApp->EventLog(err.ErrorMessage ());
		return 0;
	}
	return 0;
}

void CAppServerApp::ReadParam()
{
	_RecordsetPtr m_pRecordset; 
	m_pRecordset.CreateInstance(_uuidof(Recordset));
	CString str;
	str.Format("proc_GetOperInfo");
	int ioperid;
	try{
		m_pRecordset->Open(_variant_t(str),(IDispatch*)m_pConnection, 
			adOpenDynamic,adLockOptimistic,	adCmdText); 
		
		while(!m_pRecordset->EndOfFile) 
		{
			ioperid=m_pRecordset->GetCollect ("OperID").intVal ;
			str=m_pRecordset->GetCollect ("OperName").bstrVal;
			operInfo[ioperid-1].name=str;
			str=m_pRecordset->GetCollect ("VocSpnum").bstrVal ;
			operInfo[ioperid-1].VSpnumber=str;
			str=m_pRecordset->GetCollect ("SmsSpnum").bstrVal ;
			operInfo[ioperid-1].SSpnumber=str;
			str=m_pRecordset->GetCollect ("SmsSpnum1").bstrVal ;
			operInfo[ioperid-1].SSpnumber1=str;
			m_pRecordset->MoveNext();
		}
		
	}
	catch (_com_error err)
	{
		EventLog(err.ErrorMessage ());
	}
}

void CAppServerApp::SendCallOut(CString scaller, CString scalled, int ich,CString strTime)
{
	((CAppServerDlg * )m_pMainWnd)->SendCallOut(scaller,scalled,-1);
	CString str;
	str.Format("发现点歌任务:'%s'-->'%s','%s'",scalled,scalled,strTime);
	((CAppServerDlg * )m_pMainWnd)->AddListMessage(1,str);
				
}

⌨️ 快捷键说明

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