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

📄 smsviagateway.cpp

📁 网关发送短信的程序网关发送短信的程序 网关发送短信的程序
💻 CPP
字号:
// SMSViaGateway.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "SMSViaGateway.h"
#include "SMSViaGatewayDlg.h"
#include "md5class.h"
#include "XMLParse.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

const char *pXmlFile = "c:\\TestXML.xml";

void CreateXMLFile ( CXMLParse &XMLParse )
{
	BOOL bRet = FALSE;
	int nRet = 0;
	const int	nParentNodeNum = 4,
				nChildNodeNum =  2,
				nAttrNum = 2;

	bRet = XMLParse.CreateNewXMLDOM ( "TestXML" );

	CString csElementName, csElementValue;
	CString csAttrName, csAttrValue;
	for ( int i=0; i<nParentNodeNum; i++ )	// 插入节点
	{
		csElementName.Format ( "ElementName_%d", i );
		XMLParse.InsertChildElement ( csElementName );
		nRet = XMLParse.GoTo_Child();
		nRet = XMLParse.GoTo_ParallelNode(i);
		csElementValue.Format ( "ElementValue_%d", i );
		XMLParse.SetElementValue ( csElementValue );
		for ( int j=0; j<nAttrNum; j++ )
		{
			csAttrValue.Format ( "AttrValue_%d-%d", i, j );
			csAttrName.Format ( "AttrName_%d-%d", i, j );
			XMLParse.SetAttributeValue ( csAttrName, csAttrValue );
		}
		for ( int ii=0; ii<nChildNodeNum; ii++ )
		{
			csElementName.Format ( "ElementName_%d_%d", i, ii );
			if ( ii == 0 )
			{
				XMLParse.InsertChildElement ( csElementName );
				nRet = XMLParse.GoTo_Child();
			}
			else
			{
				XMLParse.InsertElement ( csElementName );
				nRet = XMLParse.GoTo_ParallelNode(ii);
			}
			csElementValue.Format ( "ElementValue_%d_%d", i, ii );
			XMLParse.SetElementValue ( csElementValue );
			for ( int j=0; j<nAttrNum; j++ )
			{
				csAttrValue.Format ( "AttrValue_%d_%d-%d", i, ii, j );
				csAttrName.Format ( "AttrName_%d_%d-%d", i, ii, j );
				XMLParse.SetAttributeValue ( csAttrName, csAttrValue );
			}
			TRACE ( "ii=%d\n", ii );
		}
		nRet = XMLParse.GoTo_Parent();
		nRet = XMLParse.GoTo_Parent();
		TRACE ( "i=%d, ii=%d\n", i, ii );
	}

	bRet = XMLParse.Save ( pXmlFile );
}

void TestParseXml ( CXMLParse &XMLParse )
{
	BOOL bRet = FALSE;
	bRet = XMLParse.Load ( pXmlFile );
	TRACE ( "%s, %s\n", XMLParse.GetElementName(),
		XMLParse.Having_ChildNode()?"Having Child":"Having NO Child" );
	bRet = XMLParse.GoTo_Root();
	TRACE ( "%s, %s\n", XMLParse.GetElementName(),
		XMLParse.Having_ChildNode()?"Having Child":"Having NO Child" );

	XMLParse.GoTo_TagName ( "ElementName_1_0" );
//	bRet = XMLParse.Save ( pXmlFile );
}

BOOL TestReadXml ( CXMLParse &XMLParse )
{
	CStringArray StrAryFieldsName;
	CUIntArray IntAryFieldsWidth, IntAryFieldsType;
	BOOL bRet = FALSE;
	char szTempBuf[256] = {0};
	bRet = XMLParse.Load ( "c:\\UserInfo_000.xml" );
	if ( !bRet ) return FALSE;

	bRet = XMLParse.GoTo_TagName ( "hwSchema" );
	if ( !bRet ) return FALSE;

	CString csTableName = XMLParse.GetAttributeValue ( "TableName" );

	bRet = XMLParse.GoTo_Child ();
	if ( !bRet ) return FALSE;
	bRet = XMLParse.GoTo_Child ();
	if ( !bRet ) return FALSE;

	CString csAttriBuffer[4];
	for ( int i=0; ; i++ )
	{
		csAttriBuffer[0] = XMLParse.GetAttributeValue ( "name" );
		csAttriBuffer[1] = XMLParse.GetAttributeValue ( "FieldName" );
		csAttriBuffer[2] = XMLParse.GetAttributeValue ( "FieldWidth" );
		csAttriBuffer[3] = XMLParse.GetAttributeValue ( "FieldType" );
		if ( !XMLParse.GoTo_ParallelNode ( i+1 ) ) break;
		StrAryFieldsName.Add ( csAttriBuffer[1] );
		IntAryFieldsWidth.Add ( atoi(csAttriBuffer[2]) );
		IntAryFieldsType.Add ( atoi(csAttriBuffer[3]) );
	}

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CSMSViaGatewayApp

BEGIN_MESSAGE_MAP(CSMSViaGatewayApp, CWinApp)
	//{{AFX_MSG_MAP(CSMSViaGatewayApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSMSViaGatewayApp construction

CSMSViaGatewayApp::CSMSViaGatewayApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CSMSViaGatewayApp object

CSMSViaGatewayApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CSMSViaGatewayApp initialization

BOOL CSMSViaGatewayApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
	
	// 初始化 COM 环境
	if ( FAILED( ::CoInitialize(NULL) ) )
	{
		AfxMessageBox ( "CoInitialize failed" );
		return FALSE;
	}

/*	{	//d
		CXMLParse XMLParse;
		CreateXMLFile ( XMLParse );
		TestParseXml ( XMLParse );
		TestReadXml ( XMLParse );
		return FALSE;
	}	//d
*/
	CSMSViaGatewayDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

int CSMSViaGatewayApp::ExitInstance() 
{
	::CoUninitialize();

	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

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