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

📄 mydatabase.cpp

📁 关于联通的一个统一定制程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		pCmd->Execute(NULL, NULL, adCmdStoredProc);
		nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();
		if (nRet == -5)
			nRet = 0;
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_usercustom_add失败!ERROR=%s", (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		return -2;
	}
	catch(...)
	{
		szLog = _T("调用sp_usercustom_add失败!ERROR=未知错误。");
		theData.WriteLog(szLog, "-o");
		return -2;
	}

	return nRet;
}

int CMyDatabase::DeleteCustom(LPCTSTR PushType, LPCTSTR CustomerNo, LPCTSTR bSendTime, LPCTSTR eSendTime,
								LPCTSTR ReceiverNo, LPCTSTR Param1, LPCTSTR Param2, long Status, long CustomMode)
{
	if (!m_bOpenned)
	{
		CloseDB();
		if (!OpenDB())
			return -2;
	}

	CString szLog;
	int nRet = 0;
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection = m_pConn;
		pCmd->CommandText = L"sp_usercustom_search";
		pCmd->CommandType = adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(PushType);
		pCmd->Parameters->GetItem(2l)->PutValue(CustomerNo);
		pCmd->Parameters->GetItem(3l)->PutValue(bSendTime);
		pCmd->Parameters->GetItem(4l)->PutValue(eSendTime);
		pCmd->Parameters->GetItem(5l)->PutValue(ReceiverNo);
		pCmd->Parameters->GetItem(6l)->PutValue(Param1);
		pCmd->Parameters->GetItem(7l)->PutValue(Param2);
		pCmd->Parameters->GetItem(8l)->PutValue(Status);
		_RecordsetPtr pRs = pCmd->Execute(NULL, NULL, adCmdStoredProc);
		if (pRs->GetState() != adStateClosed && !pRs->adoEOF)
		{
			_CommandPtr p1;

			TESTHR(p1.CreateInstance(__uuidof(Command)));
			p1->ActiveConnection = m_pConn;
			p1->CommandType = adCmdStoredProc;
			p1->CommandText = _bstr_t("sp_usercustom_delete_asid");

			while (!pRs->adoEOF)
			{
				long customno = (long)pRs->GetCollect(L"CustomNo");
				p1->Parameters->Refresh();
				p1->Parameters->GetItem(1l)->PutValue(PushType);
				p1->Parameters->GetItem(2l)->PutValue(customno);
				p1->Parameters->GetItem(3l)->PutValue(CustomMode);
				p1->Execute(0, 0, adCmdStoredProc);
				pRs->MoveNext();
				nRet++;
			}
		}
		else
			nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();

		if (pRs->GetState() != adStateClosed)
			pRs->Close();
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_usercustom_delete_asid失败!ERROR=%s", (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		return -2;
	}
	catch(...)
	{
		szLog = _T("调用sp_usercustom_delete_asid失败!ERROR=未知错误。");
		theData.WriteLog(szLog, "-o");
		return -2;
	}

	return nRet;
}

int CMyDatabase::QueryCustom(LPCTSTR PushType, LPCTSTR CustomerNo, LPCTSTR bSendTime, LPCTSTR eSendTime,
								LPCTSTR ReceiverNo, LPCTSTR Param1, LPCTSTR Param2, long Status, CString& szOut)
{
	if (!m_bOpenned)
	{
		CloseDB();
		if (!OpenDB())
			return -2;
	}

	CString szLog;
	int nRet = 0;
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection = m_pConn;
		pCmd->CommandText = L"sp_usercustom_search";
		pCmd->CommandType = adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(PushType);
		pCmd->Parameters->GetItem(2l)->PutValue(CustomerNo);
		pCmd->Parameters->GetItem(3l)->PutValue(bSendTime);
		pCmd->Parameters->GetItem(4l)->PutValue(eSendTime);
		pCmd->Parameters->GetItem(5l)->PutValue(ReceiverNo);
		pCmd->Parameters->GetItem(6l)->PutValue(Param1);
		pCmd->Parameters->GetItem(7l)->PutValue(Param2);
		pCmd->Parameters->GetItem(8l)->PutValue(Status);

		_RecordsetPtr pRs = pCmd->Execute(NULL, NULL, adCmdStoredProc);
		if (pRs->GetState() != adStateClosed && !pRs->adoEOF)
		{
			while (!pRs->adoEOF)
			{
				if (!szOut.IsEmpty())
					szOut += _T(",");
				szOut += (LPTSTR)_bstr_t(pRs->GetCollect(L"ReceiverNo"));

				pRs->MoveNext();
			}
			szOut.Remove(' ');
		}
		else
			nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();

		if (pRs->GetState() != adStateClosed)
			pRs->Close();
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_usercustom_search失败!ERROR=%s", (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		return -2;
	}
	catch(...)
	{
		szLog = _T("调用sp_usercustom_search失败!ERROR=未知错误。");
		theData.WriteLog(szLog, "-o");
		return -2;
	}

	return nRet;
}

int CMyDatabase::AddCustom(_ConnectionPtr& pConn, LPCTSTR pszMobile, LPCTSTR pszSQL, long nChannel, LPCTSTR pszReceiver)
{
	CString szPassword;
	int nRet=RegisterUser(pszMobile, szPassword);
	if (nRet==-6)
		return -6;
	else if (nRet<0 && nRet!=-3)
		return -2;

	CString szLog;
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection = pConn;
		pCmd->CommandText = L"sp_registeruser_uni";
		pCmd->CommandType = adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Parameters->GetItem(2l)->PutValue(nChannel);
		pCmd->Parameters->GetItem(3l)->PutValue(pszReceiver);
		pCmd->Execute(NULL, NULL, adCmdStoredProc);
		nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();
//		if (nRet == -3)
//			nRet=0;
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_registeruser_uni[MOBILE=%s,SQL=%s]失败!ERROR=%s", pszMobile, pszSQL, (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}
	catch(...)
	{
		szLog.Format("调用sp_registeruser_uni[MOBILE=%s,SQL=%s]失败!ERROR=未知错误。", pszMobile, pszSQL);
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}

	return nRet;
}

int CMyDatabase::DeleteCustom(_ConnectionPtr& pConn, LPCTSTR pszMobile, LPCTSTR pszSQL, long nChannel)
{
	CString szLog;
	int nRet(0);
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection = pConn;
		pCmd->CommandText = L"sp_unregisteruser_uni";
		pCmd->CommandType = adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Parameters->GetItem(2l)->PutValue(nChannel);
		pCmd->Execute(NULL, NULL, adCmdStoredProc);
		nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();
//		if (nRet == -3)
//			nRet=0;
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_unregisteruser_uni[MOBILE=%s,SQL=%s]失败!ERROR=%s", pszMobile, pszSQL, (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}
	catch(...)
	{
		szLog.Format("调用sp_unregisteruser_uni[MOBILE=%s,SQL=%s]失败!ERROR=未知错误。", pszMobile, pszSQL);
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}

	return nRet;
}

int CMyDatabase::QueryCustom(_ConnectionPtr& pConn, LPCTSTR pszMobile, LPCTSTR pszSQL)
{
	CString szLog;
	int nRet(0);
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection = pConn;
		pCmd->CommandText = L"sp_usersearch_uni";
		pCmd->CommandType = adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Execute(NULL, NULL, adCmdStoredProc);
		nRet = (long)pCmd->Parameters->GetItem(0l)->GetValue();
//		if (nRet == -3)
//			nRet=0;
	}
	catch (_com_error& e)
	{
		szLog.Format("调用sp_usersearch_uni[MOBILE=%s,SQL=%s]失败!ERROR=%s", pszMobile, pszSQL, (LPTSTR)e.Description());
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}
	catch(...)
	{
		szLog.Format("调用sp_usersearch_uni[MOBILE=%s,SQL=%s]失败!ERROR=未知错误。", pszMobile, pszSQL);
		theData.WriteLog(szLog, "-o");
		nRet=-2;
	}

	return nRet;
}

int CMyDatabase::GetOutputMsg(LPCTSTR pszMobile, LPCTSTR pszCmd, LPOUTPUTMSGLIST pList)
{
	if (!m_bOpenned)
	{
		CloseDB();
		if (!OpenDB())
			return -2;
	}

	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection=m_pConn;
		pCmd->CommandText=L"sp_custom_getoutputmsg";
		pCmd->CommandType=adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Parameters->GetItem(2l)->PutValue(pszCmd);
		_RecordsetPtr pRs=pCmd->Execute(NULL, NULL, adCmdStoredProc);
		while (pRs->GetState()!=adStateClosed && !pRs->adoEOF)
		{
			OUTPUTMSG msg;
			msg.nType=(int)(long)pRs->GetCollect(L"type");
			msg.szFeeCode=(LPTSTR)_bstr_t(pRs->GetCollect(L"feecode"));
			msg.szFeeType=(LPTSTR)_bstr_t(pRs->GetCollect(L"feetype"));
			msg.szMsg=(LPTSTR)_bstr_t(pRs->GetCollect(L"content"));
			msg.szSendNo=(LPTSTR)_bstr_t(pRs->GetCollect(L"sendno"));
			msg.szSubID=(LPTSTR)_bstr_t(pRs->GetCollect(L"subid"));
			msg.nMsgType=(int)(long)pRs->GetCollect(L"msgtype");
			pList->push_back(msg);
			pRs->MoveNext();
		}
		if (pRs->GetState()!=adStateClosed)
			pRs->Close();
	}
	catch (_com_error& e)
	{
		m_bOpenned=FALSE;
		theData.WriteLog((LPTSTR)e.Description(), "sp_custom_getoutputmsg");
		return -2;
	}
	catch (...)
	{
		return -2;
	}

	return 0;
}
// 返回值
// 
int CMyDatabase::Get00000ProductInfo(LPCTSTR pszMobile, LPCTSTR psz00000Cmd,LPCTSTR pszTypeCode, ULONG lType,LPPRODUCTINFO pPI, LPOUTPUTMSGLIST pList)
{
	if (!m_bOpenned)
	{
		CloseDB();
		if (!OpenDB())
			return -999;
	}
	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection=m_pConn;
		pCmd->CommandText=L"sp_custom_getinfo_00000";
		pCmd->CommandType=adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Parameters->GetItem(2l)->PutValue(psz00000Cmd);
		pCmd->Parameters->GetItem(3l)->PutValue(pszTypeCode);
		pCmd->Parameters->GetItem(4l)->PutValue((long)lType);
		//pCmd->Parameters->GetItem(3l)->PutValue(pszSrcTermID);
		_RecordsetPtr pRs=pCmd->Execute(NULL, NULL, adCmdStoredProc);
		if (pRs==NULL || pRs->GetState()!=adStateOpen)
			return (int)(long)pCmd->Parameters->GetItem(0l)->GetValue();

		while (pRs!=NULL)
		{
			while (!pRs->adoEOF)
			{
				int nRec=(int)(long)pRs->GetCollect(L"code");
				switch (nRec)					
				{
				case 0: // 产品信息
					pPI->szName=(LPTSTR)_bstr_t(pRs->GetCollect(L"name"));
					pPI->szSQL=(LPTSTR)_bstr_t(pRs->GetCollect(L"sql"));
					pPI->nType=(int)(long)pRs->GetCollect(L"type");
					break;
				case 8: // MISC信息
					{
					OUTPUTMSG mm;
				/*	mm.szFeeType=(LPTSTR)_bstr_t(pRs->GetCollect(L"feetype"));
					mm.szSubID=(LPTSTR)_bstr_t(pRs->GetCollect(L"subid"));
					mm.szContent=(LPTSTR)_bstr_t(pRs->GetCollect(L"content"));*/
					_variant_t var=pRs->GetCollect(L"feecode");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.szFeeCode=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"feetype");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.szFeeType=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"content");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.szMsg=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"sendno");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.szSendNo=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"subid");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.szSubID=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"msgtype");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						mm.nMsgType=var.lVal;
					pList->push_back(mm);
					}
					break;
				default:
					return nRec;
					break;
				}
				pRs->MoveNext();
			}

			long lRec=0;
			pRs=pRs->NextRecordset((VARIANT*)lRec);
		}
	}
	catch (_com_error& e)
	{
		m_bOpenned=FALSE;
		theData.WriteLog((LPTSTR)e.Description(), "sp_custom_getinfo_00000");
		return -999;
	}
	catch (...)
	{
		theData.WriteLog("Unknown error occured", "sp_custom_getinfo_00000");
		return -999;
	}

	return 0;

}
int CMyDatabase::GetProductInfo(LPCTSTR pszMobile, LPCTSTR pszCmd, LPCTSTR pszSrcTermID, LPPRODUCTINFO pPI, LPMISCMSGLIST pList, LPOUTPUTMSGLIST pMsgList, LPSERVICEINFO pSI)
{
	if (!m_bOpenned)
	{
		CloseDB();
		if (!OpenDB())
			return -2;
	}

	try
	{
		_CommandPtr pCmd;
		TESTHR(pCmd.CreateInstance(__uuidof(Command)));
		pCmd->ActiveConnection=m_pConn;
		pCmd->CommandText=L"sp_custom_getinfo";
		pCmd->CommandType=adCmdStoredProc;
		pCmd->Parameters->Refresh();
		pCmd->Parameters->GetItem(1l)->PutValue(pszMobile);
		pCmd->Parameters->GetItem(2l)->PutValue(pszCmd);
		pCmd->Parameters->GetItem(3l)->PutValue(pszSrcTermID);
		_RecordsetPtr pRs=pCmd->Execute(NULL, NULL, adCmdStoredProc);
		if (pRs==NULL || pRs->GetState()!=adStateOpen)
			return (int)(long)pCmd->Parameters->GetItem(0l)->GetValue();

		_variant_t var;
		while (pRs!=NULL)
		{
			while (!pRs->adoEOF)
			{
				int nRec=(int)(long)pRs->GetCollect(L"code");
				switch (nRec)
				{
				case 0: // 产品信息
					var=pRs->GetCollect(L"operate");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->nOperate=(int)var.lVal;
					var=pRs->GetCollect(L"type");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->nType=(int)var.lVal;
					var=pRs->GetCollect(L"name");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->szName=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"sql");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->szSQL=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"pushtype");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->szPushType=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"t1");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->szTime1=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"t2");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)
						pPI->szTime2=(LPTSTR)_bstr_t(var);
					var=pRs->GetCollect(L"p1");
					if (var.vt!=VT_NULL && var.vt!=VT_EMPTY)

⌨️ 快捷键说明

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