Restructure repository to include all source folders

Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 20:17:20 +09:00
parent 5d3cd64a25
commit dd97ddec92
11602 changed files with 1446576 additions and 0 deletions

110
Server/Billing/Billing.sln Normal file
View File

@@ -0,0 +1,110 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetHanBilling", "GetHanBilling\GetHanBilling.vcproj", "{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}"
ProjectSection(ProjectDependencies) = postProject
{68041CA4-DB5B-4716-BB34-AFD654BD9D33} = {68041CA4-DB5B-4716-BB34-AFD654BD9D33}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DB", "DB\DB.vcproj", "{68041CA4-DB5B-4716-BB34-AFD654BD9D33}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaWebBilling", "MediaWebBilling\MediaWebBilling.vcproj", "{FD74ADE2-6961-4304-B23A-89DA3665477E}"
ProjectSection(ProjectDependencies) = postProject
{68041CA4-DB5B-4716-BB34-AFD654BD9D33} = {68041CA4-DB5B-4716-BB34-AFD654BD9D33}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BillingTestModule", "한게임 통합빌링 테스트모듈\BillingTestModule.vcproj", "{45133C4E-218B-4327-A547-9B64F0CACD5D}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Executable", "Executable\Executable.vcproj", "{139979E4-819A-4CA7-9003-013C000CD09A}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetHanBillingLogData", "GetHanBillingLogData\GetHanBillingLogData.vcproj", "{96F0B439-8858-4D3F-BF05-3EE915CFDD94}"
ProjectSection(ProjectDependencies) = postProject
{68041CA4-DB5B-4716-BB34-AFD654BD9D33} = {68041CA4-DB5B-4716-BB34-AFD654BD9D33}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetCharacterData", "GetCharacterData\GetCharacterData.vcproj", "{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}"
ProjectSection(ProjectDependencies) = postProject
{68041CA4-DB5B-4716-BB34-AFD654BD9D33} = {68041CA4-DB5B-4716-BB34-AFD654BD9D33}
EndProjectSection
EndProject
Global
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 8
SccLocalPath0 = .
CanCheckoutShared = false
SolutionUniqueID = {6DB76421-C111-47FC-8938-CF0298994E9F}
SccProjectUniqueName1 = DB\\DB.vcproj
SccLocalPath1 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection1 = DB\\
SccProjectUniqueName2 = Executable\\Executable.vcproj
SccLocalPath2 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection2 = Executable\\
SccProjectUniqueName3 = GetCharacterData\\GetCharacterData.vcproj
SccLocalPath3 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection3 = GetCharacterData\\
SccProjectUniqueName4 = GetHanBilling\\GetHanBilling.vcproj
SccLocalPath4 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection4 = GetHanBilling\\
SccProjectUniqueName5 = GetHanBillingLogData\\GetHanBillingLogData.vcproj
SccLocalPath5 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection5 = GetHanBillingLogData\\
SccProjectUniqueName6 = MediaWebBilling\\MediaWebBilling.vcproj
SccLocalPath6 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection6 = MediaWebBilling\\
SccProjectUniqueName7 = 한게임\u0020통합빌링\u0020테스트모듈\\BillingTestModule.vcproj
SccLocalPath7 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection7 = 한게임\u0020통합빌링\u0020테스트모듈\\
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}.Debug.ActiveCfg = Debug|Win32
{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}.Debug.Build.0 = Debug|Win32
{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}.Release.ActiveCfg = Release|Win32
{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}.Release.Build.0 = Release|Win32
{68041CA4-DB5B-4716-BB34-AFD654BD9D33}.Debug.ActiveCfg = Debug|Win32
{68041CA4-DB5B-4716-BB34-AFD654BD9D33}.Debug.Build.0 = Debug|Win32
{68041CA4-DB5B-4716-BB34-AFD654BD9D33}.Release.ActiveCfg = Release|Win32
{68041CA4-DB5B-4716-BB34-AFD654BD9D33}.Release.Build.0 = Release|Win32
{FD74ADE2-6961-4304-B23A-89DA3665477E}.Debug.ActiveCfg = Debug|Win32
{FD74ADE2-6961-4304-B23A-89DA3665477E}.Debug.Build.0 = Debug|Win32
{FD74ADE2-6961-4304-B23A-89DA3665477E}.Release.ActiveCfg = Release|Win32
{FD74ADE2-6961-4304-B23A-89DA3665477E}.Release.Build.0 = Release|Win32
{45133C4E-218B-4327-A547-9B64F0CACD5D}.Debug.ActiveCfg = Debug|Win32
{45133C4E-218B-4327-A547-9B64F0CACD5D}.Debug.Build.0 = Debug|Win32
{45133C4E-218B-4327-A547-9B64F0CACD5D}.Release.ActiveCfg = Release|Win32
{45133C4E-218B-4327-A547-9B64F0CACD5D}.Release.Build.0 = Release|Win32
{139979E4-819A-4CA7-9003-013C000CD09A}.Debug.ActiveCfg = Debug|Win32
{139979E4-819A-4CA7-9003-013C000CD09A}.Debug.Build.0 = Debug|Win32
{139979E4-819A-4CA7-9003-013C000CD09A}.Release.ActiveCfg = Release|Win32
{139979E4-819A-4CA7-9003-013C000CD09A}.Release.Build.0 = Release|Win32
{96F0B439-8858-4D3F-BF05-3EE915CFDD94}.Debug.ActiveCfg = Debug|Win32
{96F0B439-8858-4D3F-BF05-3EE915CFDD94}.Debug.Build.0 = Debug|Win32
{96F0B439-8858-4D3F-BF05-3EE915CFDD94}.Release.ActiveCfg = Release|Win32
{96F0B439-8858-4D3F-BF05-3EE915CFDD94}.Release.Build.0 = Release|Win32
{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}.Debug.ActiveCfg = Debug|Win32
{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}.Debug.Build.0 = Debug|Win32
{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}.Release.ActiveCfg = Release|Win32
{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

BIN
Server/Billing/Billing.suo Normal file

Binary file not shown.

View File

@@ -0,0 +1,65 @@
#include "Config.h"
#include <windows.h>
CConfigurator::CConfigurator()
{
}
CConfigurator::~CConfigurator()
{
}
bool CConfigurator::Load(const char* szFileName)
{
FILE* lpFile = fopen(szFileName, "rt");
if(NULL != lpFile)
{
const int MAX_READ = 4096;
char szRead[MAX_READ];
char* szDelimitChars = " =\t\n\r";
while(fgets(szRead, MAX_READ, lpFile))
{
const char* szCommand = strtok(szRead, szDelimitChars);
const char* szValue = strtok(NULL, szDelimitChars);
if(0 != szCommand && 0 != szValue)
{
if(0 != strncmp(szCommand, TEXT("//"), strlen(TEXT("//"))))
{
m_ConfigMap.insert(std::make_pair(szCommand, szValue));
}
}
}
fclose(lpFile);
return true;
}
return false;
}
const char* CConfigurator::Get(const char* szKey)
{
ConfigMap::iterator end = m_ConfigMap.end();
ConfigMap::iterator find = m_ConfigMap.find(szKey);
if(end != find)
{
return find->second.c_str();
}
return 0;
}
void CConfigurator::Clear()
{
m_ConfigMap.clear();
}

View File

@@ -0,0 +1,25 @@
#ifndef _GAMA_DB_CONFIGURATOR_
#define _GAMA_DB_CONFIGURATOR_
#include <string>
#include <map>
class CConfigurator
{
public:
CConfigurator();
~CConfigurator();
bool Load(const char* szFileName);
const char* Get(const char* szKey);
void Clear();
private:
typedef std::map<std::string, std::string> ConfigMap;
ConfigMap m_ConfigMap;
};
#endif

137
Server/Billing/Db/DB.vcproj Normal file
View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="DB"
ProjectGUID="{68041CA4-DB5B-4716-BB34-AFD654BD9D33}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/DB.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/DB.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\Config.cpp">
</File>
<File
RelativePath=".\Log.cpp">
</File>
<File
RelativePath=".\myOLEDB.cpp">
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\Config.h">
</File>
<File
RelativePath=".\Log.h">
</File>
<File
RelativePath=".\myOLEDB.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

93
Server/Billing/Db/Log.cpp Normal file
View File

@@ -0,0 +1,93 @@
#include "Log.h"
#include <windows.h>
CLog::CLog()
: m_stdout(0), m_stderr(0)
{
}
CLog::~CLog()
{
if(0 != m_stderr)
{
fclose(m_stderr);
m_stderr = 0;
}
if(0 != m_stdout)
{
fclose(m_stdout);
m_stdout = 0;
}
}
bool CLog::RedirectStdErr(const char* szFileName)
{
char szLogFileName[MAX_PATH];
if(MakeFileName(szFileName, szLogFileName))
{
m_stderr = freopen(szLogFileName, "at", stderr);
return (0 != m_stderr);
}
return false;
}
bool CLog::RedirectStdOut(const char *szFileName)
{
char szLogFileName[MAX_PATH];
if(MakeFileName(szFileName, szLogFileName))
{
m_stdout = freopen(szLogFileName, "at", stdout);
return (0 != m_stdout);
}
return false;
}
bool CLog::MakeFileName(const char* szFileName, char* szLogFileName)
{
// create log file name in good order
for(unsigned long dwSpinCount = 0; TRUE; ++dwSpinCount)
{
int nLength = _snprintf(szLogFileName, MAX_PATH, "%s%04d.log",
szFileName, dwSpinCount);
if(nLength < 0)
{
return false;
}
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(szLogFileName))
{
break;
}
else
{
HANDLE hFile = CreateFile(szLogFileName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwFileHighSize = 0;
DWORD dwFileSize = GetFileSize(hFile, &dwFileHighSize);
CloseHandle(hFile);
if(0 == dwFileHighSize && dwFileSize < 10 * 1024 * 1024)
{
break;
}
}
}
}
return true;
}

24
Server/Billing/Db/Log.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef _GAMA_STD_LOG_H_
#define _GAMA_STD_LOG_H_
#include <cstdio>
class CLog
{
public:
CLog();
~CLog();
bool RedirectStdErr(const char* szFileName);
bool RedirectStdOut(const char* szFileName);
private:
bool MakeFileName(const char* szFileName, char* szLogFileName);
FILE* m_stdout;
FILE* m_stderr;
};
#endif

View File

@@ -0,0 +1,21 @@
========================================================================
정적 라이브러리 : DB 프로젝트 개요
========================================================================
응용 프로그램 마법사에서 이 DB 라이브러리 프로젝트를 만들었습니다.
프로젝트에 대해 소스 파일은 만들어지지 않았습니다.
DB.vcproj
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
프로젝트 기능에 대한 정보가 들어 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
/////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

118
Server/Billing/Db/myOLEDB.h Normal file
View File

@@ -0,0 +1,118 @@
///////////////////////////////////////////////////////////////////////////////////////////////
//
// OleDB
//
//////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _OleDB
#define _OleDB
#include <oledb.h>
#include <oledberr.h>
//#define _CHECK_OLEDB_PERFORMANCE // DB 퍼포먼스 체크
#ifdef _CHECK_OLEDB_PERFORMANCE
#define DB_PERFORMANCE_CHECK(x) x
#else
#define DB_PERFORMANCE_CHECK(x) (void*)0;
#endif
//////////////////////////////////////////////////////////////////////////////////////////////
//
// 클래스 정의
//
///////////////////////////////////////////////////////////////////////////////////////////////
class OleDB
{
public:
const static unsigned long MaxRowNum = 2000; // 최대 열 숫자
const static unsigned long MaxErrorLen = 512; // 최대 에러 길이
const static unsigned long MaxQueryTextLen = 5000; // 최대 쿼리 문자열 길이
protected:
typedef struct _COL_INFO
{
const static unsigned short MaxColNameLen = 100; // 최대 컬럼 이름 길이
char ColName[MaxColNameLen]; // 컬럼 이름
unsigned long ColSize; // 컬럼 사이즈
}COL_INFO, *LPCOL_INFO;
typedef struct _RESULT_COLS
{
unsigned long ColNum;
DBCOLUMNINFO* lpDBColumnInfo;
WCHAR* lpStringsBuffer;
}RESULT_COLS, *LPRESULT_COLS;
WCHAR m_QueryText[MaxQueryTextLen]; // 쿼리 문자열
COL_INFO m_ColInfo;
public:
enum ConnType { ConnType_ODBC = 0, ConnType_MSSQL = 1, ConnType_ORACLE };
enum Rowset { Rowset_Get = 0, Rowset_Update = 1 }; // 쿼리 실행후 로우셋
typedef struct _PARAM_INFO
{
const static unsigned short MaxColNum = 20; // 최대 컬럼 이름 길이
unsigned long ColNum; // 컬럼 숫자
unsigned long ColSize[MaxColNum]; // 컬럼 사이즈
unsigned short ColType[MaxColNum];
}PARAM_INFO, *LPPARAM_INFO;
typedef struct _SET_BINARY
{
unsigned long Size;
}SET_BINARY, *LPSET_BINARY;
public:
IDBInitialize* m_pIDBInit;
IDBCreateSession* m_pIDBCreateSession;
IDBCreateCommand* m_pIDBCreateCommand;
IRowset* m_pIRowset;
IRowsetChange* m_pIRowsetChange;
char m_ErrorString[MaxErrorLen];
public:
OleDB(void);
virtual ~OleDB(void);
char* GetErrorString(void) { return m_ErrorString; }
bool ConnectDataSourcePrompt(HWND hWnd_In);
bool ConnectSQLServer(LPCTSTR ServerName_In, LPCTSTR DataBaseName_In, LPCTSTR UserID_In, LPCTSTR UserPass_In, ConnType ConnType_In);
bool DisconnectDataSource(void);
bool ExcuteQuery(LPCTSTR Query_In, Rowset Rowset_In = Rowset_Get);
bool ExcuteQueryWithParams(LPCTSTR Query_In, char *Data_In, PARAM_INFO& ColInfo_In, Rowset Rowset_In);
bool ExcuteQueryGetData(LPCTSTR Query_In, void *Buffer_Out);
bool GetData(void *Buffer_Out);
bool GetData(void **Buffer_Out, int RowSize_In, int Row_In, int *pGetRow_Out);
bool SetBinaryData(int ColNum_In, LPSET_BINARY lpSetBinary);
COL_INFO& GetColInfo(void) { return m_ColInfo; }
private:
bool HandleError(int ErrorLine_In, HRESULT hResult_In, char *Buffer_In);
bool CreateSession(void);
bool DBCreateCommand(void);
bool AllocResultCols(IUnknown* lpIUnknown_In, RESULT_COLS &Rsult_Cols);
bool ReleaseResultCols(IUnknown* lpIUnknown_In, RESULT_COLS &Rsult_Cols);
bool SetConnectionProperties(LPCTSTR ServerName_In, LPCTSTR DataBaseName_In, LPCTSTR UserID_In, LPCTSTR UserPass_In);
DBBINDING* AllocBindGetData(int ColsNum_In, DBCOLUMNINFO* pDBColumnInfo_In);
DBBINDING* AllocBindParamInputData(PARAM_INFO &ColInfo_In);
};
#endif

View File

@@ -0,0 +1,11 @@
// 한게임 서버
HanServerName = gamabill
HanDBName = scott
HanUserName = scott
HanPassword = scott
// 과금서버
BillingServerName = GAMADBMAN\GAMASQL
BillingDBName = RYLBILLINGDB
BillingUserName = sa
BillingPassword = gamadb

View File

@@ -0,0 +1,11 @@
// 한게임 서버 (Select)
HanServerName = 61.251.229.189
HanDBName = RylbillingDBLOG
HanUserName = gama
HanPassword = 1234
// 가마 서버 (Insert)
GamaServerName = 192.168.3.4
GamaDBName = RylbillingDB_LOG
GamaUserName = sa
GamaPassword = 1234

View File

@@ -0,0 +1,12 @@
// 게임 서버 (Select)
GameServerID = 4
GameServerName = datastation
GameDBName = HighLand
GameUserName = gama
GamePassword = 1234
// 가마 서버 (Insert)
GamaServerName = 61.251.229.189
GamaDBName = RylBillingDBLOG
GamaUserName = gama
GamaPassword = 1234

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Executable"
ProjectGUID="{139979E4-819A-4CA7-9003-013C000CD09A}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Executable.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Executable.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Debug"
Filter="">
<File
RelativePath=".\Debug\BillingInfo.cfg">
</File>
<File
RelativePath=".\Debug\BillingLogData.cfg">
</File>
<File
RelativePath=".\Debug\CharacterData.cfg">
</File>
<File
RelativePath=".\Debug\MWBillingInfo.cfg">
</File>
</Filter>
<Filter
Name="Release"
Filter="">
<File
RelativePath=".\Release\BillingInfo.cfg">
</File>
<File
RelativePath=".\Release\BillingLogData.cfg">
</File>
<File
RelativePath=".\Release\CharacterData.cfg">
</File>
<File
RelativePath=".\Release\MWBillingInfo.cfg">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,11 @@
// 미디어웹
MWServerName = gamabill
MWDBName = scott
MWUserName = scott
MWPassword = scott
// 과금서버
BillingServerName = GAMADBMAN\GAMASQL
BillingDBName = RYLBILLINGDB
BillingUserName = sa
BillingPassword = gamadb

View File

@@ -0,0 +1,275 @@
// GetGameCharacterData.cpp : 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <myOLEDB.h>
#include <Config.h>
#include <Log.h>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <list>
#pragma pack(1)
struct CharacterData
{
int CID;
int Class;
int Level;
char CreateTime[20];
char UpdateTime[20];
};
#pragma pack()
using namespace std;
template<class _Elem, class _Traits>
inline basic_ostream<_Elem, _Traits>& __cdecl writetime(basic_ostream<_Elem, _Traits>& _Ostr)
{
SYSTEMTIME systime;
GetLocalTime(&systime);
_Elem fill = _Ostr.fill();
_Ostr << setfill('0')
<< "["
<< setw(4) << systime.wYear << "-"
<< setw(2) << systime.wMonth << "-"
<< setw(2) << systime.wDay << " "
<< setw(2) << systime.wHour << ":"
<< setw(2) << systime.wMinute << ":"
<< setw(2) << systime.wSecond << "] " << setfill(fill);
return (_Ostr);
}
bool LoadLastProcessedTime(const char* szFileName, __time64_t* lpLastProcessedTime)
{
FILE* file = fopen(szFileName, "rb");
if(0 != file)
{
if(0 != lpLastProcessedTime)
{
tm tmLastProcessedTime;
memset(&tmLastProcessedTime, 0, sizeof(tm));
fscanf(file, "%04d-%02d-%02d %02d:%02d:%02d",
&tmLastProcessedTime.tm_year, &tmLastProcessedTime.tm_mon, &tmLastProcessedTime.tm_mday,
&tmLastProcessedTime.tm_hour, &tmLastProcessedTime.tm_min, &tmLastProcessedTime.tm_sec);
tmLastProcessedTime.tm_year -= 1900;
tmLastProcessedTime.tm_mon -= 1;
*lpLastProcessedTime = _mktime64(&tmLastProcessedTime);
fclose(file);
return true;
}
fclose(file);
}
return false;
}
bool SaveLastProcessedTime(const char* szFileName, __time64_t LastProcessedTime)
{
FILE* file = fopen(szFileName, "wt");
if(0 != file)
{
tm tmLastProcessedTime = *_localtime64(&LastProcessedTime);
fprintf(file, "%04d-%02d-%02d %02d:%02d:%02d",
tmLastProcessedTime.tm_year + 1900, tmLastProcessedTime.tm_mon + 1, tmLastProcessedTime.tm_mday,
tmLastProcessedTime.tm_hour, tmLastProcessedTime.tm_min, tmLastProcessedTime.tm_sec);
fclose(file);
return true;
}
return false;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CLog log;
CConfigurator config;
OleDB gameDB;
OleDB gamaDB;
char szSelectQuery[OleDB::MaxQueryTextLen];
char szInserQuery[OleDB::MaxQueryTextLen];
int nQueryLen = 0;
if(!log.RedirectStdOut("GetCharacterDataLog"))
{
return -1;
}
cout << endl << writetime << "쿼리를 실행합니다." << endl;
TCHAR* tszConfigFileName = TEXT("CharacterData.cfg");
if(!config.Load(tszConfigFileName))
{
cout << writetime << tszConfigFileName << "DB설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
const char* szTimeFileName = "GetCharacterDataTime.txt";
unsigned long dwServerID = atoi(config.Get("GameServerID"));
const char* szGameServerName = config.Get("GameServerName");
const char* szGameDBName = config.Get("GameDBName");
const char* szGameUserName = config.Get("GameUserName");
const char* szGamePassword = config.Get("GamePassword");
if(!gameDB.ConnectSQLServer(szGameServerName, szGameDBName,
szGameUserName, szGamePassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "게임DB : 접속할 수 없습니다. : " << gameDB.GetErrorString()
<< " ServerName : " << szGameServerName
<< " DBName : " << szGameDBName
<< " UserName : " << szGameUserName
<< " Password : " << szGamePassword
<< endl;
return -1;
}
const char* szGamaServerName = config.Get("GamaServerName");
const char* szGamaDBName = config.Get("GamaDBName");
const char* szGamaUserName = config.Get("GamaUserName");
const char* szGamaPassword = config.Get("GamaPassword");
if(!gamaDB.ConnectSQLServer(szGamaServerName, szGamaDBName,
szGamaUserName, szGamaPassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "가마DB : 접속할 수 없습니다. : " << gamaDB.GetErrorString()
<< " ServerName : " << szGamaServerName
<< " DBName : " << szGamaDBName
<< " UserName : " << szGamaUserName
<< " Password : " << szGamaPassword
<< endl;
return -1;
}
__time64_t lastTime = 0;
if(!LoadLastProcessedTime(szTimeFileName, &lastTime))
{
cout << writetime << szTimeFileName << "시간 설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
__time64_t currentTime = _time64(0);
tm tmLastTime = *_localtime64(&lastTime);
tm tmCurrentTime = *_localtime64(&currentTime);
_snprintf(szSelectQuery, OleDB::MaxQueryTextLen - 1, "SELECT "
"CAST(CID AS INT), "
"CAST(Class AS INT), "
"CAST(Level AS INT), "
"CONVERT(varchar(20), CreateTime, 20), "
"CONVERT(varchar(20), UpdateTime, 20) "
"FROM CharInfo A "
"JOIN (SELECT CID,CreateTime,UpdateTime FROM CharInfo_Time WHERE UpdateTime >= '%04d-%02d-%02d %02d:%02d:%02d') B ON A.UID = B.CID",
tmLastTime.tm_year + 1900, tmLastTime.tm_mon + 1, tmLastTime.tm_mday,
tmLastTime.tm_hour, tmLastTime.tm_min, tmLastTime.tm_sec);
szSelectQuery[OleDB::MaxQueryTextLen - 1] = 0;
if(!gameDB.ExcuteQuery(szSelectQuery))
{
cout << writetime << "게임DB : 캐릭터 데이터 가져오기 실패"
<< gameDB.GetErrorString() << endl;
return -1;
}
typedef std::list<std::pair<int, CharacterData*> > InsertList;
InsertList insertList;
const int MAX_DATA = OleDB::MaxRowNum;
CharacterData* lpCharacterData = new CharacterData[MAX_DATA];
int nReturnRow = 0;
int nTotalRow = 0;
while(gameDB.GetData((void**)lpCharacterData,
sizeof(CharacterData), MAX_DATA, &nReturnRow))
{
if(0 == nReturnRow)
{
if(0 != lpCharacterData)
{
delete [] lpCharacterData;
lpCharacterData = 0;
}
break;
}
nTotalRow += nReturnRow;
insertList.push_back(std::make_pair(nReturnRow, lpCharacterData));
lpCharacterData = new CharacterData[MAX_DATA];
}
int nTotal_InsertRow = 0;
InsertList::iterator pos = insertList.begin();
InsertList::iterator end = insertList.end();
for(;pos != end; ++pos)
{
CharacterData* lpCharacterData = pos->second;
CharacterData* lpCharacterDataEnd = lpCharacterData + pos->first;
for(; lpCharacterData != lpCharacterDataEnd; ++lpCharacterData)
{
_snprintf(szInserQuery, OleDB::MaxQueryTextLen - 1,
"Statics_InsertCharData %d, %d, %d, %d, '%s', '%s'",
dwServerID, lpCharacterData->CID, lpCharacterData->Class, lpCharacterData->Level,
lpCharacterData->CreateTime, lpCharacterData->UpdateTime);
szInserQuery[OleDB::MaxQueryTextLen - 1] = 0;
if(!gamaDB.ExcuteQuery(szInserQuery))
{
cout << writetime << "가마DB : 게임DB에서 얻어온 데이터를 세팅할 수 없습니다. : "
<< gamaDB.GetErrorString() << " " << szInserQuery;
}
else
{
++nTotal_InsertRow;
}
}
delete [] pos->second;
}
if(!SaveLastProcessedTime(szTimeFileName, currentTime))
{
cout << writetime << szTimeFileName << "시간 설정 파일에 저장할 수 없습니다." << endl;
return -1;
}
if(nTotal_InsertRow != nTotalRow)
{
cout << writetime << "삽입 건수 : " << nTotal_InsertRow << " 읽은 건수 : " << nTotalRow << endl;
}
cout << writetime << "쿼리 : " << szSelectQuery << "실행에 성공했습니다. 처리 건수 : " << nTotalRow << endl;
return 0;
}

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="GetCharacterData"
ProjectGUID="{EBA2EBB1-86CE-4CFB-8A63-CA622558BAA6}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetCharacterData.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/GetCharacterData.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetCharacterData.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\GetCharacterData.cpp">
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,373 @@
// GetHanBilling.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <myOLEDB.h>
#include <Config.h>
#include <Log.h>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <vector>
#include <oledb.h>
#include <srv.h>
using namespace std;
#pragma pack(1)
//##### KTE - EDIT 20041207 #####
struct HanBillingData
{
//DBCHAR m_EndDate[20];
//DBCHAR m_MemberID[20];
//DBCHAR m_BillNum[11];
//DBCHAR m_RylUID[11];
//DBCHAR m_GameMin[11];
//DBCHAR m_BillingType[2];
DBCHAR m_MemberID[20];
DBCHAR m_RegDate[20];
DBCHAR m_BillEndDate[20];
DBCHAR m_KeeperSeq[11];
DBCHAR m_RylUID[11];
DBCHAR m_AddedDay[11];
DBCHAR m_AddedTime[11];
DBCHAR m_AddedMonth[11];
DBCHAR m_AutoBill[2];
};
#pragma pack()
template<class _Elem, class _Traits>
inline basic_ostream<_Elem, _Traits>& __cdecl writetime(basic_ostream<_Elem, _Traits>& _Ostr)
{
SYSTEMTIME systime;
GetLocalTime(&systime);
_Elem fill = _Ostr.fill();
_Ostr << setfill('0')
<< "["
<< setw(4) << systime.wYear << "-"
<< setw(2) << systime.wMonth << "-"
<< setw(2) << systime.wDay << " "
<< setw(2) << systime.wHour << ":"
<< setw(2) << systime.wMinute << ":"
<< setw(2) << systime.wSecond << "] " << setfill(fill);
return (_Ostr);
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CLog log;
CConfigurator config;
OleDB hanDB;
OleDB billingDB;
char szQuery[OleDB::MaxQueryTextLen];
int nQueryLen = 0;
if(!log.RedirectStdOut("GetHanBillingLog"))
{
return -1;
}
cout << endl << writetime << "쿼리를 실행합니다." << endl;
TCHAR* tszConfigFileName = TEXT("BillingInfo.cfg");
if(!config.Load(tszConfigFileName))
{
cout << writetime << tszConfigFileName << "DB설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
const char* szHanServerName = config.Get("HanServerName");
const char* szHanDBName = config.Get("HanDBName");
const char* szHanUserName = config.Get("HanUserName");
const char* szHanPassword = config.Get("HanPassword");
if(!hanDB.ConnectSQLServer(szHanServerName, szHanDBName,
szHanUserName, szHanPassword, OleDB::ConnType_ORACLE))
{
cout << writetime << "한게임DB : 접속할 수 없습니다. : " << hanDB.GetErrorString()
<< " ServerName : " << szHanServerName
<< " DBName : " << szHanDBName
<< " UserName : " << szHanUserName
<< " Password : " << szHanPassword
<< endl;
return -1;
}
const char* szBillingServerName = config.Get("BillingServerName");
const char* szBillingDBName = config.Get("BillingDBName");
const char* szBillingUserName = config.Get("BillingUserName");
const char* szBillingPassword = config.Get("BillingPassword");
if(!billingDB.ConnectSQLServer(szBillingServerName, szBillingDBName,
szBillingUserName, szBillingPassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "빌링DB : 접속할 수 없습니다. : " << billingDB.GetErrorString()
<< " ServerName : " << szBillingServerName
<< " DBName : " << szBillingDBName
<< " UserName : " << szBillingUserName
<< " Password : " << szBillingPassword
<< endl;
return -1;
}
// 테이블 클리어
if(!billingDB.ExcuteQuery("EXEC agt_PersonBilling_Delete"))
{
cout << writetime << "빌링DB : 임시 테이블 삭제에 실패했습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
// 데이터 가져오기
int nMinNum = 0;
if(!billingDB.ExcuteQueryGetData(
"SELECT intCount FROM TblImportedNum WHERE strCompType = 'H'", &nMinNum))
{
cout << writetime << "빌링DB : 마지막으로 처리된 데이터 건수 번호를 얻어올 수 없습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
//##### KTE - EDIT 20041207 #####
//nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
// "SELECT TO_CHAR(ENDDATE, 'YYYY-MM-DD HH24:MI:SS '), "
// "MEMBERID, "
// "CAST(BILLNUM AS VARCHAR(11)),"
// "CAST(RYLUID AS VARCHAR(11)),"
// "CAST(GAMEMIN AS VARCHAR(11)),"
// "CAST(BILLTYPE AS VARCHAR(2)) "
// " FROM RYLBILLINGT WHERE BILLNUM > ? AND HanCHK = 'N' ORDER BY BILLNUM ASC");
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"SELECT MEMBERID,"
"TO_CHAR(REGDATE, 'YYYY-MM-DD HH24:MI:SS '),"
"TO_CHAR(BILLENDDATE,'YYYY-MM-DD HH24:MI:SS '),"
"CAST(KEEPERSEQ AS VARCHAR(11)),"
"CAST(RYLUID AS VARCHAR(11)),"
"CAST(ADDEDDAY AS VARCHAR(11)),"
"CAST(ADDEDTIME AS VARCHAR(11)),"
"CAST(ADDEDMONTH AS VARCHAR(11)),"
"CAST(AUTOBILL AS VARCHAR(2)) "
"FROM RYLCHECKT WHERE KEEPERSEQ > ? AND CHECKFLAG = 'N' ORDER BY KEEPERSEQ ASC");
if(nQueryLen < 0)
{
cout << writetime << "한게임DB : 빌링 데이터를 얻어오는 쿼리를 만들 수 없습니다." << endl;
return -1;
}
OleDB::PARAM_INFO BillingInfoParam;
memset(&BillingInfoParam, 0, sizeof(OleDB::PARAM_INFO));
BillingInfoParam.ColNum = 1;
BillingInfoParam.ColSize[0] = sizeof(int);
BillingInfoParam.ColType[0] = DBTYPE_I4;
if(!hanDB.ExcuteQueryWithParams(szQuery,
reinterpret_cast<char*>(&nMinNum), BillingInfoParam, OleDB::Rowset_Get))
{
cout << writetime << "한게임DB : 빌링 정보를 얻어올 수 없습니다 : "
<< hanDB.GetErrorString() << endl;
return -1;
}
typedef std::vector<HanBillingData> BillingDataArray;
BillingDataArray hanBillingArray;
hanBillingArray.reserve(5000);
const int MAX_DATA = 1000;
HanBillingData hanBillingData[MAX_DATA];
memset(hanBillingData, 0, sizeof(HanBillingData) * MAX_DATA);
int nReturnRow = 0;
while(hanDB.GetData((void**)&hanBillingData,
sizeof(HanBillingData), MAX_DATA, &nReturnRow))
{
if(0 == nReturnRow)
{
break;
}
hanBillingArray.insert(hanBillingArray.end(),
hanBillingData, hanBillingData + nReturnRow);
memset(hanBillingData, 0, sizeof(HanBillingData) * MAX_DATA);
}
//##### KTE - EDIT 20041207 #####
// BillNum, MemberID, RylUID, BillingType, EndTime, GameMin
//const char* szInsertQuery = "INSERT INTO TblPersonBilling_log "
// "(intIndex, strClientID, UID, strBillingType, dateEndTime, intServiceTime, strConvertChk, dateInsertTime) "
// "values (%s, '%s', %s, '%s', '%s', %s, 'N', GetDate())";
//const char* szNullEndInsertQuery = "INSERT INTO TblPersonBilling_log "
// "(intIndex, strClientID, UID, strBillingType, dateEndTime, intServiceTime, strConvertChk, dateInsertTime) "
// "values (%s, '%s', %s, '%s', NULL, %s, 'N', GetDate())";
// BillNum , ClientID , UID , RegDate , AddedDay , AddedTime , AddedMonth , BillEndDate , AutoBill ,CheckFlag,InsertTime
const char* szInsertQuery = "INSERT INTO dbo.TblRYLCheckT "
"(BillNum , ClientID , UID , RegDate , AddedDay , AddedTime , AddedMonth , BillEndDate , AutoBill,CheckFlag ,InsertTime) "
"VALUES (%s, '%s' , %s , '%s' , %s , %s , %s , '%s' , '%s' , 'N' , GETDATE() )" ;
const char* szNullEndInsertQuery = "INSERT INTO dbo.TblRYLCheckT "
"(BillNum , ClientID , UID , RegDate , AddedDay , AddedTime , AddedMonth , AutoBill,CheckFlag ,InsertTime) "
"VALUES (%s, '%s' , %s , '%s' , %s , %s , %s , '%s' , 'N' , GETDATE() )" ;
BillingDataArray::iterator pos = hanBillingArray.begin();
BillingDataArray::iterator end = hanBillingArray.end();
for(; pos != end; ++pos)
{
HanBillingData& data = *pos;
//if(0 == strlen(data.m_EndDate))
//{
// nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen, szNullEndInsertQuery,
// data.m_BillNum, data.m_MemberID, data.m_RylUID, data.m_BillingType, data.m_GameMin);
//}
//else
//{
// nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen, szInsertQuery,
// data.m_BillNum, data.m_MemberID, data.m_RylUID, data.m_BillingType,
// data.m_EndDate, data.m_GameMin);
//}
if( 0 == strlen(data.m_BillEndDate))
{
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,szNullEndInsertQuery,
data.m_KeeperSeq, data.m_MemberID, data.m_RylUID, data.m_RegDate,
data.m_AddedDay, data.m_AddedTime, data.m_AddedMonth, data.m_AutoBill);
}
else
{
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,szInsertQuery,
data.m_KeeperSeq, data.m_MemberID, data.m_RylUID, data.m_RegDate,
data.m_AddedDay, data.m_AddedTime, data.m_AddedMonth, data.m_BillEndDate, data.m_AutoBill);
}
if(nQueryLen < 0)
{
return -1;
}
if(!billingDB.ExcuteQuery(szQuery))
{
cout << writetime << "빌링DB : 한게임에서 가져온 데이터를 기록할 수 없습니다. : " << billingDB.GetErrorString()
<< " 현재 BillNum : " << data.m_KeeperSeq << endl;
return -1;
}
}
int nMaxNum = 0;
//##### KTE - EDIT 20041207 #####
//if(!billingDB.ExcuteQueryGetData(
// "SELECT MAX(intIndex) FROM TblPersonBilling_log WHERE strConvertCHK ='N'", &nMaxNum))
if(!billingDB.ExcuteQueryGetData(
"SELECT MAX(BillNum) FROM dbo.TblRYLCheckT WHERE CheckFlag = 'N'", &nMaxNum))
{
cout << writetime << "빌링DB : 한게임에서 가져온 데이터 건수 최대 번호를 얻어올 수 없습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
if(0 < nMaxNum)
{
//##### KTE - EDIT 20041207 #####
//nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
// "UPDATE RYLBILLINGT SET HANCHK = 'Y' "
// "WHERE BILLNUM > ? AND BILLNUM <= ? AND HANCHK = 'N'");
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"UPDATE RYLCHECKT SET CHECKFLAG = 'Y' "
"WHERE KEEPERSEQ > ? AND KEEPERSEQ <= ? AND CHECKFLAG = 'N'");
if(nQueryLen < 0)
{
cout << writetime << "한게임DB : 과금 처리 업데이트 실패 - 쿼리 생성 실패" << endl;
return -1;
}
OleDB::PARAM_INFO BillingUpdateParam;
memset(&BillingUpdateParam, 0, sizeof(OleDB::PARAM_INFO));
BillingUpdateParam.ColNum = 2;
BillingUpdateParam.ColSize[0] = sizeof(int);
BillingUpdateParam.ColType[0] = DBTYPE_I4;
BillingUpdateParam.ColSize[1] = sizeof(int);
BillingUpdateParam.ColType[1] = DBTYPE_I4;
char szData[sizeof(int) * 2];
memcpy(szData, &nMinNum, sizeof(int));
memcpy(szData + sizeof(int), &nMaxNum, sizeof(int));
if(!hanDB.ExcuteQueryWithParams(szQuery, szData, BillingUpdateParam, OleDB::Rowset_Update))
{
cout << writetime << "한게임DB : 과금 처리 업데이트 실패 - 쿼리 실패 : "
<< hanDB.GetErrorString() << endl;
return -1;
}
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"UPDATE TblImportedNum SET intCount = %d WHERE strCompType = 'H'", nMaxNum);
if(nQueryLen < 0)
{
cout << writetime << "빌링DB : 과금 처리 업데이트 실패 - 쿼리 생성 실패 "
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum << endl;
return -1;
}
if(!billingDB.ExcuteQuery(szQuery, OleDB::Rowset_Update))
{
cout << writetime << "빌링DB : 과금 처리 업데이트 실패 - 쿼리 실패 : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum << endl;
return -1;
}
}
// 데이터 처리
if(!billingDB.ExcuteQuery("EXEC agt_PersonBilling_CHK"))
{
cout << writetime << "빌링DB : 가져온 데이터를 처리하는 데 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum << endl;
return -1;
}
cout << writetime << "쿼리 실행 완료." << endl;
return 0;
}

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="GetHanBilling"
ProjectGUID="{56E2A7F7-7BAD-4095-BCDB-AE1015B981D0}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetHanBilling.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/GetHanBilling.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetHanBilling.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\GetHanBilling.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\stdafx.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,32 @@
========================================================================
콘솔 응용 프로그램 : GetHanBilling 프로젝트 개요
========================================================================
응용 프로그램 마법사에서 이 GetHanBilling 응용 프로그램을 만들었습니다.
이 파일에는 GetHanBilling 응용 프로그램을 구성하는 각각의 파일에
들어 있는 요약 설명이 포함되어 있습니다.
GetHanBilling.vcproj
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
프로젝트 기능에 대한 정보가 들어 있습니다.
GetHanBilling.cpp
기본 응용 프로그램 소스 파일입니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h 및 StdAfx.cpp는
GetHanBilling.pch라는 이름의 PCH(미리 컴파일된 헤더) 파일과
StdAfx.obj라는 이름의 미리 컴파일된 형식 파일을 빌드하는 데 사용됩니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// GetHanBilling.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.

View File

@@ -0,0 +1,12 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#include <iostream>
#include <tchar.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.

View File

@@ -0,0 +1,295 @@
// GetHanBillingLogData.cpp : 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <myOLEDB.h>
#include <Config.h>
#include <Log.h>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <list>
#pragma pack(1)
struct BillingLogData
{
char strClientID[20];
int UID;
int intCRMIndex;
char strIP[15];
char strBillingType[2];
int tinyServerID;
char firstLoginTime[20];
char loginTime[20];
char logoutTime[20];
int intPlayTime;
};
#pragma pack()
using namespace std;
template<class _Elem, class _Traits>
inline basic_ostream<_Elem, _Traits>& __cdecl writetime(basic_ostream<_Elem, _Traits>& _Ostr)
{
SYSTEMTIME systime;
GetLocalTime(&systime);
_Elem fill = _Ostr.fill();
_Ostr << setfill('0')
<< "["
<< setw(4) << systime.wYear << "-"
<< setw(2) << systime.wMonth << "-"
<< setw(2) << systime.wDay << " "
<< setw(2) << systime.wHour << ":"
<< setw(2) << systime.wMinute << ":"
<< setw(2) << systime.wSecond << "] " << setfill(fill);
return (_Ostr);
}
bool LoadLastProcessedTime(const char* szFileName, __time64_t* lpLastProcessedTime)
{
FILE* file = fopen(szFileName, "rb");
if(0 != file)
{
if(0 != lpLastProcessedTime)
{
tm tmLastProcessedTime;
memset(&tmLastProcessedTime, 0, sizeof(tm));
fscanf(file, "%04d-%02d-%02d %02d:%02d:%02d",
&tmLastProcessedTime.tm_year, &tmLastProcessedTime.tm_mon, &tmLastProcessedTime.tm_mday,
&tmLastProcessedTime.tm_hour, &tmLastProcessedTime.tm_min, &tmLastProcessedTime.tm_sec);
tmLastProcessedTime.tm_year -= 1900;
tmLastProcessedTime.tm_mon -= 1;
*lpLastProcessedTime = _mktime64(&tmLastProcessedTime);
fclose(file);
return true;
}
fclose(file);
}
return false;
}
bool SaveLastProcessedTime(const char* szFileName, __time64_t LastProcessedTime)
{
FILE* file = fopen(szFileName, "wt");
if(0 != file)
{
tm tmLastProcessedTime = *_localtime64(&LastProcessedTime);
fprintf(file, "%04d-%02d-%02d %02d:%02d:%02d",
tmLastProcessedTime.tm_year + 1900, tmLastProcessedTime.tm_mon + 1, tmLastProcessedTime.tm_mday,
tmLastProcessedTime.tm_hour, tmLastProcessedTime.tm_min, tmLastProcessedTime.tm_sec);
fclose(file);
return true;
}
return false;
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CLog log;
CConfigurator config;
OleDB hanDB;
OleDB gamaDB;
char szQuery[OleDB::MaxQueryTextLen];
int nQueryLen = 0;
if(!log.RedirectStdOut("GetHanBillingLogData_Log"))
{
return -1;
}
cout << endl << writetime << "쿼리를 실행합니다." << endl;
TCHAR* tszConfigFileName = TEXT("BillingLogData.cfg");
if(!config.Load(tszConfigFileName))
{
cout << writetime << tszConfigFileName << "DB설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
const char* szTimeFileName = "GetHanBillingLogDataTime.txt";
const char* szHanServerName = config.Get("HanServerName");
const char* szHanDBName = config.Get("HanDBName");
const char* szHanUserName = config.Get("HanUserName");
const char* szHanPassword = config.Get("HanPassword");
if(!hanDB.ConnectSQLServer(szHanServerName, szHanDBName,
szHanUserName, szHanPassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "한게임DB : 접속할 수 없습니다. : " << hanDB.GetErrorString()
<< " ServerName : " << szHanServerName
<< " DBName : " << szHanDBName
<< " UserName : " << szHanUserName
<< " Password : " << szHanPassword
<< endl;
return -1;
}
const char* szGamaServerName = config.Get("GamaServerName");
const char* szGamaDBName = config.Get("GamaDBName");
const char* szGamaUserName = config.Get("GamaUserName");
const char* szGamaPassword = config.Get("GamaPassword");
if(!gamaDB.ConnectSQLServer(szGamaServerName, szGamaDBName,
szGamaUserName, szGamaPassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "가마DB : 접속할 수 없습니다. : " << gamaDB.GetErrorString()
<< " ServerName : " << szGamaServerName
<< " DBName : " << szGamaDBName
<< " UserName : " << szGamaUserName
<< " Password : " << szGamaPassword
<< endl;
return -1;
}
__time64_t lastTime = 0;
if(!LoadLastProcessedTime(szTimeFileName, &lastTime))
{
cout << writetime << szTimeFileName << "시간 설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
__time64_t currentTime = _time64(0);
tm tmLastTime = *_localtime64(&lastTime);
tm tmCurrentTime = *_localtime64(&currentTime);
_snprintf(szQuery, OleDB::MaxQueryTextLen - 1, "select "
"strClientID, "
"UID, "
"intCRMIndex, "
"strIp, "
"CAST(strBillingType AS VARCHAR(2)), "
"CAST(tinyServerID AS INT), "
"CONVERT(varchar(20), FirstLoginTime, 20), "
"CONVERT(varchar(20), LoginTime, 20), "
"CONVERT(varchar(20), LogoutTime, 20), "
"intPlayTime "
"from tblcurrentuser_log where firstlogintime >='%04d-%02d-%02d %02d:%02d:%02d' "
"and firstlogintime < '%04d-%02d-%02d %02d:%02d:%02d'",
tmLastTime.tm_year + 1900, tmLastTime.tm_mon + 1, tmLastTime.tm_mday,
tmLastTime.tm_hour, tmLastTime.tm_min, tmLastTime.tm_sec,
tmCurrentTime.tm_year + 1900, tmCurrentTime.tm_mon + 1, tmCurrentTime.tm_mday,
tmCurrentTime.tm_hour, tmCurrentTime.tm_min, tmCurrentTime.tm_sec);
szQuery[OleDB::MaxQueryTextLen - 1] = 0;
if(!hanDB.ExcuteQuery(szQuery))
{
cout << writetime << "한게임DB : 과금 로그 가져오기 실패"
<< hanDB.GetErrorString() << endl;
return -1;
}
typedef std::list<std::pair<int, BillingLogData*> > InsertList;
InsertList insertList;
const int MAX_DATA = OleDB::MaxRowNum;
BillingLogData* lpBillingLogData = new BillingLogData[MAX_DATA];
int nReturnRow = 0;
int nTotalRow = 0;
while(hanDB.GetData((void**)lpBillingLogData,
sizeof(BillingLogData), MAX_DATA, &nReturnRow))
{
if(0 == nReturnRow)
{
if(0 != lpBillingLogData)
{
delete [] lpBillingLogData;
lpBillingLogData = 0;
}
break;
}
nTotalRow += nReturnRow;
insertList.push_back(std::make_pair(nReturnRow, lpBillingLogData));
lpBillingLogData = new BillingLogData[MAX_DATA];
}
InsertList::iterator pos = insertList.begin();
InsertList::iterator end = insertList.end();
int nInsertRow = 0;
for(;pos != end; ++pos)
{
BillingLogData* lpBillingLogData = pos->second;
BillingLogData* lpBillingLogDataEnd = lpBillingLogData + pos->first;
for(; lpBillingLogData != lpBillingLogDataEnd; ++lpBillingLogData)
{
_snprintf(szQuery, OleDB::MaxQueryTextLen - 1,
"INSERT INTO Tblcurrentuser_log values ('%s', %d, %d, '%s', '%c', %d, '%s', '%s', '%s', %d)",
lpBillingLogData->strClientID,
lpBillingLogData->UID,
lpBillingLogData->intCRMIndex,
lpBillingLogData->strIP,
lpBillingLogData->strBillingType[0],
lpBillingLogData->tinyServerID,
lpBillingLogData->firstLoginTime,
lpBillingLogData->loginTime,
lpBillingLogData->logoutTime,
lpBillingLogData->intPlayTime);
szQuery[OleDB::MaxQueryTextLen - 1] = 0;
if(!gamaDB.ExcuteQuery(szQuery, OleDB::Rowset_Update))
{
cout << writetime << "가마DB : 한게임에서 얻어온 데이터를 세팅할 수 없습니다. : "
<< gamaDB.GetErrorString() << " " << szQuery;
}
else
{
++nInsertRow;
}
}
delete [] pos->second;
}
if(!SaveLastProcessedTime(szTimeFileName, currentTime))
{
cout << writetime << szTimeFileName << "시간 설정 파일에 저장할 수 없습니다." << endl;
return -1;
}
if(nInsertRow != nTotalRow)
{
cout << writetime << "삽입 건수 : " << nInsertRow << " 읽어온 건수 : " << nTotalRow << endl;
}
cout << writetime << "쿼리 실행에 성공했습니다. : 처리 건수 : " << nTotalRow << endl;
return 0;
}

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="GetHanBillingLogData"
ProjectGUID="{96F0B439-8858-4D3F-BF05-3EE915CFDD94}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetHanBillingLogData.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/GetHanBillingLogData.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/GetHanBillingLogData.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\GetHanBillingLogData.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\stdafx.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// GetHanBillingLogData.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.

View File

@@ -0,0 +1,18 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
// Windows 헤더 파일입니다.
#include <windows.h>
// C의 런타임 헤더 파일입니다.
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.

View File

@@ -0,0 +1,539 @@
// MediaWebBilling.cpp : 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include "MediaWebBilling.h"
#include <myOLEDB.h>
#include <Config.h>
#include <Log.h>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <vector>
#include <oledb.h>
#include <srv.h>
using namespace std;
template<class _Elem, class _Traits>
inline basic_ostream<_Elem, _Traits>& __cdecl writetime(basic_ostream<_Elem, _Traits>& _Ostr)
{
SYSTEMTIME systime;
GetLocalTime(&systime);
_Elem fill = _Ostr.fill();
_Ostr << setfill('0')
<< "["
<< setw(4) << systime.wYear << "-"
<< setw(2) << systime.wMonth << "-"
<< setw(2) << systime.wDay << " "
<< setw(2) << systime.wHour << ":"
<< setw(2) << systime.wMinute << ":"
<< setw(2) << systime.wSecond << "] " << setfill(fill);
return (_Ostr);
}
inline std::string& addNumber(std::string& str, const char* szData)
{
const char* szWriteData = (0 == strlen(szData)) ? "NULL" : szData;
str += szWriteData;
str += ", ";
return str;
}
inline std::string& addString(std::string& str, const char* szData)
{
if(0 == strlen(szData))
{
str += "NULL, ";
}
else
{
str += "'";
str += szData;
str += "', ";
}
return str;
}
#pragma pack(1)
struct MWBillingData
{
DBCHAR m_CRMCode[16]; // PC방 CRMCode
DBCHAR m_Command[16]; // 처리 command
DBCHAR m_CRMIP1[13]; // 서비스ip대역1
DBCHAR m_CRMIP2[13]; // 서비스ip대역2
DBCHAR m_CRMIP3[13]; // 서비스ip대역3
DBCHAR m_Index[11]; // 자동증가(SEQID)
DBCHAR m_ServiceTime[11]; // 정량제시간
DBCHAR m_EndTime[11]; // 선승일, 보상 요청시간
DBCHAR m_ServiceIPNum[11]; // 정액제구매ip개수
DBCHAR m_SysDay[20]; // 결재일 YYYY-MM-DD HH24:MI:SS
DBCHAR m_ServiceDay[11]; // 정액제만료일 YYYY-MM-DD
DBCHAR m_EndDay[11]; // 선승일, 보상 만료일 YYYY-MM-DD
DBCHAR m_CRMStartIP1[4]; // 서비스ip대역시작1
DBCHAR m_CRMStopIP1[4]; // 서비스ip대역끝1
DBCHAR m_CRMStartIP2[4]; // 서비스ip대역시작2
DBCHAR m_CRMStopIP2[4]; // 서비스ip대역끝2
DBCHAR m_CRMStartIP3[4]; // 서비스ip대역시작3
DBCHAR m_CRMStopIP3[4]; // 서비스ip대역끝3
DBCHAR m_TimeProcess[2]; // 잔여일처리 방법 (m = -처리, z = 끊음)
DBCHAR m_PriceType[2]; // 정액제,정량제 여부 (D 정액제, T 정량제)
};
struct RemainTimeLog
{
DBCHAR m_CRMCode[20];
DBCHAR m_IntServiceTime[11];
DBCHAR m_DelColumn[2];
};
#pragma pack()
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CLog log;
CConfigurator config;
OleDB mwDB;
OleDB billingDB;
char szQuery[OleDB::MaxQueryTextLen];
int nQueryLen = 0;
if(!log.RedirectStdOut("MediaWebBilling"))
{
return -1;
}
cout << endl << writetime << "쿼리를 실행합니다." << endl;
TCHAR* tszConfigFileName = TEXT("MWBillingInfo.cfg");
if(!config.Load(tszConfigFileName))
{
cout << writetime << tszConfigFileName << "DB설정 파일을 읽을 수 없습니다." << endl;
return -1;
}
const char* szMWServerName = config.Get("MWServerName");
const char* szMWDBName = config.Get("MWDBName");
const char* szMWUserName = config.Get("MWUserName");
const char* szMWPassword = config.Get("MWPassword");
if(!mwDB.ConnectSQLServer(szMWServerName, szMWDBName,
szMWUserName, szMWPassword, OleDB::ConnType_ORACLE))
{
cout << writetime << "미디어웹DB : 접속할 수 없습니다. : " << mwDB.GetErrorString()
<< " ServerName : " << szMWServerName
<< " DBName : " << szMWDBName
<< " UserName : " << szMWUserName
<< " Password : " << szMWPassword
<< endl;
return -1;
}
const char* szBillingServerName = config.Get("BillingServerName");
const char* szBillingDBName = config.Get("BillingDBName");
const char* szBillingUserName = config.Get("BillingUserName");
const char* szBillingPassword = config.Get("BillingPassword");
if(!billingDB.ConnectSQLServer(szBillingServerName, szBillingDBName,
szBillingUserName, szBillingPassword, OleDB::ConnType_MSSQL))
{
cout << writetime << "빌링DB : 접속할 수 없습니다. : " << billingDB.GetErrorString()
<< " ServerName : " << szBillingServerName
<< " DBName : " << szBillingDBName
<< " UserName : " << szBillingUserName
<< " Password : " << szBillingPassword
<< endl;
return -1;
}
// 1. 테이블 클리어
if(!billingDB.ExcuteQuery("EXEC agt_CRM_RYLLOG_Delete"))
{
cout << writetime << "빌링DB : 임시 테이블 삭제에 실패했습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
// 2. 미디어웹(Oracle) 에서 데이터 가져오기
int nMinNum = 0;
if(!billingDB.ExcuteQueryGetData(
"SELECT intCount FROM TblImportedNum WHERE strCompType = 'M'", &nMinNum))
{
cout << writetime << "빌링DB : 마지막으로 처리된 데이터 건수 번호를 얻어올 수 없습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"SELECT "
" CAST(crmcode AS VARCHAR(16)), "
" CAST(command AS VARCHAR(16)), "
" CAST(crmip1 AS VARCHAR(13)), "
" CAST(crmip2 AS VARCHAR(13)), "
" CAST(crmip3 AS VARCHAR(13)), "
" CAST(seqid AS VARCHAR(11)), "
" CAST(servicetime AS VARCHAR(11)), "
" CAST(endtime AS VARCHAR(11)), "
" CAST(serviceipnum AS VARCHAR(11)), "
" TO_CHAR(regdate, 'YYYY-MM-DD HH24:MI:SS '), "
" TO_CHAR(serviceday, 'YYYY-MM-DD '), "
" TO_CHAR(endday, 'YYYY-MM-DD '), "
" CAST(startcrmip1 AS VARCHAR(4)), "
" CAST(endcrmip1 AS VARCHAR(4)), "
" CAST(startcrmip2 AS VARCHAR(4)), "
" CAST(endcrmip2 AS VARCHAR(4)), "
" CAST(startcrmip3 AS VARCHAR(4)), "
" CAST(endcrmip3 AS VARCHAR(4)), "
" CAST(timeprocess AS VARCHAR(2)), "
" CAST(pricetype AS VARCHAR(2)) "
" FROM CRM.CRM_RYLLOG WHERE SEQID > %d AND RYLCHK = 'N' ORDER BY SEQID ASC", nMinNum);
if(nQueryLen < 0)
{
cout << writetime << "미디어웹DB : 빌링 데이터를 얻어오는 쿼리를 만들 수 없습니다." << endl;
return -1;
}
if(!mwDB.ExcuteQuery(szQuery))
{
cout << writetime << "미디어웹DB : 빌링 정보를 얻어올 수 없습니다 : "
<< mwDB.GetErrorString()
<< " Query : " << szQuery << endl;
return -1;
}
typedef std::vector<MWBillingData> BillingDataArray;
BillingDataArray mwBillingArray;
mwBillingArray.reserve(5000);
const int MAX_DATA = 1000;
MWBillingData mwBillingData[MAX_DATA];
memset(mwBillingData, 0, sizeof(MWBillingData) * MAX_DATA);
int nReturnRow = 0;
while(mwDB.GetData((void**)&mwBillingData,
sizeof(MWBillingData), MAX_DATA, &nReturnRow))
{
if(0 == nReturnRow)
{
break;
}
mwBillingArray.insert(mwBillingArray.end(),
mwBillingData, mwBillingData + nReturnRow);
memset(mwBillingData, 0, sizeof(MWBillingData) * MAX_DATA);
}
// BillNum, MemberID, RylUID, BillingType, EndTime, GameMin
const char* szInsertQuery = "INSERT INTO TblCRM_RYLLOG "
" (intIndex, strCRMCode, strPriceType, dateSysDay, strCommand, "
" strCRMIP1,strStartCRMIP1,strEndCRMIP1, "
" strCRMIP2,strStartCRMIP2,strEndCRMIP2, "
" strCRMIP3,strStartCRMIP3,strEndCRMIP3, "
" strTimeprocess, intServiceTime, dateServiceDay, "
" TinyServiceIPNum, dateEndday, intEndTime, strRylChk) values ( ";
BillingDataArray::iterator pos = mwBillingArray.begin();
BillingDataArray::iterator end = mwBillingArray.end();
std::string strQuery;
strQuery.reserve(OleDB::MaxQueryTextLen);
for(; pos != end; ++pos)
{
MWBillingData& data = *pos;
strQuery.assign(szInsertQuery);
addNumber(strQuery, data.m_Index);
addString(strQuery, data.m_CRMCode);
addString(strQuery, data.m_PriceType);
addString(strQuery, data.m_SysDay);
addString(strQuery, data.m_Command);
addString(strQuery, data.m_CRMIP1);
addNumber(strQuery, data.m_CRMStartIP1);
addNumber(strQuery, data.m_CRMStopIP1);
addString(strQuery, data.m_CRMIP2);
addNumber(strQuery, data.m_CRMStartIP2);
addNumber(strQuery, data.m_CRMStopIP2);
addString(strQuery, data.m_CRMIP3);
addNumber(strQuery, data.m_CRMStartIP3);
addNumber(strQuery, data.m_CRMStopIP3);
addString(strQuery, data.m_TimeProcess);
addNumber(strQuery, data.m_ServiceTime);
addString(strQuery, data.m_ServiceDay);
addNumber(strQuery, data.m_ServiceIPNum);
addString(strQuery, data.m_EndDay);
addNumber(strQuery, data.m_EndTime);
strQuery += " 'N')";
if(!billingDB.ExcuteQuery(strQuery.c_str(), OleDB::Rowset_Update))
{
cout << writetime << "빌링DB : 미디어웹에서 가져온 데이터를 기록할 수 없습니다. : " << billingDB.GetErrorString()
<< " 현재 SEQIndex : " << data.m_Index
<< " Query : " << strQuery << endl;
return -1;
}
}
int nMaxNum = 0;
if(!billingDB.ExcuteQueryGetData(
"SELECT MAX(intIndex) FROM TblCRM_RYLLOG WHERE strRYLCHK = 'N' AND strConvertCHK ='N'", &nMaxNum))
{
cout << writetime << "빌링DB : 미디어웹에서 가져온 데이터 건수 최대 번호를 얻어올 수 없습니다 : "
<< billingDB.GetErrorString() << endl;
return -1;
}
if(0 < nMaxNum)
{
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"UPDATE CRM.CRM_RYLLOG SET RYLCHK = 'Y'"
"WHERE SEQID > %d AND SEQID <= %d AND RYLCHK = 'N'", nMinNum, nMaxNum);
if(nQueryLen < 0)
{
cout << writetime << "미디어웹DB : 과금 처리 업데이트 실패 - 쿼리 생성 실패" << endl;
return -1;
}
if(!mwDB.ExcuteQuery(szQuery, OleDB::Rowset_Update))
{
cout << writetime << "미디어웹DB : 과금 처리 업데이트 실패 - 쿼리 실패 : "
<< mwDB.GetErrorString() << " Query : " << szQuery << endl;
return -1;
}
nQueryLen = _snprintf(szQuery, OleDB::MaxQueryTextLen,
"UPDATE TblImportedNum SET intCount = %d WHERE strCompType = 'M'", nMaxNum);
if(nQueryLen < 0)
{
cout << writetime << "빌링DB : 과금 처리 업데이트 실패 - 쿼리 생성 실패 "
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< " Query : " << szQuery << endl;
return -1;
}
if(!billingDB.ExcuteQuery(szQuery, OleDB::Rowset_Update))
{
cout << writetime << "빌링DB : 과금 처리 업데이트 실패 - 쿼리 실패 : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< " Query : " << szQuery << endl;
return -1;
}
}
// 3. 데이터 처리
if(!billingDB.ExcuteQuery("EXEC agt_CRM_RYLLOG_EXECUTE"))
{
cout << writetime << "빌링DB : agt_CRM_RYLLOG_EXECUTE을 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< endl;
// 빠져나가지 않는다. 데이터 오류가 있으면 에러가 날 수 있다.
// return -1;
}
// 4. 남은 서비스 타임 계산
if(!billingDB.ExcuteQuery("EXEC agt_CRM_RemainServiceTime"))
{
cout << writetime << "빌링DB : agt_CRM_RemainServiceTime을 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< endl;
return -1;
}
// 5. 잔여시간 넘겨주기 agt_CRM_RemainServiceTime_Transfer
if(!billingDB.ExcuteQuery(
"SELECT strCRMCode, "
" CAST(MIN(intServiceTime) AS VARCHAR(11)), "
" CAST(delColumn AS VARCHAR(2)) "
" FROM TblCRM_SERVICETIME WHERE WebCHK = 'N' "
" GROUP BY strCRMCode,delColumn"))
{
cout << writetime << "빌링DB : 잔여시간을 얻어오는 데 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< endl;
return -1;
}
typedef std::vector<RemainTimeLog> RemainTimeLogArray;
RemainTimeLogArray remainTimeLogArray;
remainTimeLogArray.reserve(10000);
const int MAX_REMAIN_TIME_DATA = 1000;
RemainTimeLog remainTimes[MAX_REMAIN_TIME_DATA];
memset(remainTimes, 0, sizeof(RemainTimeLog) * MAX_REMAIN_TIME_DATA);
int nGetRemainTimesNum = 0;
while(billingDB.GetData((void**)&remainTimes, sizeof(RemainTimeLog),
MAX_REMAIN_TIME_DATA, &nGetRemainTimesNum))
{
if(0 == nGetRemainTimesNum)
{
break;
}
remainTimeLogArray.insert(remainTimeLogArray.end(),
remainTimes, remainTimes + nGetRemainTimesNum);
memset(remainTimes, 0, sizeof(RemainTimeLog) * MAX_REMAIN_TIME_DATA);
}
if(!billingDB.ExcuteQuery("UPDATE TblCRM_SERVICETIME SET WebCHK = 'Y' WHERE WebCHK ='N'",
OleDB::Rowset_Update))
{
cout << writetime << "빌링DB : WebCHK를 Y로 설정하는 데 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< endl;
return -1;
}
RemainTimeLogArray::iterator rtpos = remainTimeLogArray.begin();
RemainTimeLogArray::iterator rtend = remainTimeLogArray.end();
for(; rtpos != rtend; ++rtpos)
{
RemainTimeLog& data = *rtpos;
char szCRMCode[20];
memset(szCRMCode, 0, sizeof(char) * 20);
strQuery = "SELECT CRMCODE FROM GAME.CRM_SERVICETIME WHERE CRMCODE = '";
strQuery += data.m_CRMCode;
strQuery += "' AND GAMECODE ='002' ";
if(!mwDB.ExcuteQuery(strQuery.c_str()))
{
cout << writetime << "미디어웹DB : CRMCODE검색에 실패했습니다. : "
<< mwDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< " Query : " << strQuery << endl;
return -1;
}
mwDB.GetData(szCRMCode);
if(0 != strlen(szCRMCode))
{
strQuery = "UPDATE GAME.CRM_SERVICETIME SET SERVICETIME = ";
strQuery += data.m_IntServiceTime;
strQuery += ",DELCHK = '";
strQuery += data.m_DelColumn;
strQuery += "' WHERE CRMCODE = '";
strQuery += data.m_CRMCode;
strQuery += "' AND GAMECODE ='002'";
if(!mwDB.ExcuteQuery(strQuery.c_str(), OleDB::Rowset_Update))
{
cout << writetime << "미디어웹DB : ServiceTime Update에 실패했습니다. : "
<< mwDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< " Query : " << strQuery << endl;
return -1;
}
}
else
{
strQuery = "INSERT INTO GAME.CRM_SERVICETIME (CRMCODE,GAMECODE,SERVICETIME,DELCHK) VALUES ('";
strQuery += data.m_CRMCode;
strQuery += "','002',";
strQuery += data.m_IntServiceTime;
strQuery += ", '";
strQuery += data.m_DelColumn;
strQuery += "') ";
if(!mwDB.ExcuteQuery(strQuery.c_str(), OleDB::Rowset_Update))
{
cout << writetime << "미디어웹DB : ServiceTime Insert에 실패했습니다. : "
<< mwDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< " Query : " << strQuery << endl;
return -1;
}
}
}
// 6. 잔여시간 로그남기기
if(!billingDB.ExcuteQuery("EXEC agt_CRM_RemainServiceTime_LOG"))
{
cout << writetime << "빌링DB : agt_CRM_RemainServiceTime_LOG를 실패했습니다. : "
<< billingDB.GetErrorString()
<< " MinBillingNum : " << nMinNum
<< " MaxBillingNum : " << nMaxNum
<< endl;
return -1;
}
cout << writetime << "쿼리 실행 완료." << endl;
return 0;
}

View File

@@ -0,0 +1,3 @@
#pragma once
#include "resource.h"

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,128 @@
//Microsoft Visual C++에서 생성한 리소스 스크립트입니다.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE 2 리소스에서 생성되었습니다.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
LANGUAGE 18, 1
#pragma code_page(949)
/////////////////////////////////////////////////////////////////////////////
//
// 아이콘
//
// 응용 프로그램 아이콘이 모든 시스템에서 일관적인 상태를 유지하도록 하기 위해
// 가장 낮은 ID 값을 갖는 아이콘을 처음에 배치하였습니다.
IDI_MEDIAWEBBILLING ICON "MediaWebBilling.ico"
IDI_SMALL ICON "small.ico"
/////////////////////////////////////////////////////////////////////////////
//
// 메뉴
//
IDC_MEDIAWEBBILLING MENU
BEGIN
POPUP "파일(&F)"
BEGIN
MENUITEM "끝내기(&X)", IDM_EXIT
END
POPUP "도움말(&H)"
BEGIN
MENUITEM "정보(&A)...", IDM_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// 액셀러레이터 키
//
IDC_MEDIAWEBBILLING ACCELERATORS
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
END
/////////////////////////////////////////////////////////////////////////////
//
// 대화 상자
//
IDD_ABOUTBOX DIALOG 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "정보"
FONT 9, "System"
BEGIN
ICON IDI_MEDIAWEBBILLING,IDC_MYICON,14,9,16,16
LTEXT "MediaWebBilling 버전 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
LTEXT "Copyright (C) 2003",IDC_STATIC,49,20,119,8
DEFPUSHBUTTON "확인",IDOK,195,6,30,11,WS_GROUP
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// 문자열 테이블
//
STRINGTABLE
BEGIN
IDC_MEDIAWEBBILLING "MEDIAWEBBILLING"
IDS_APP_TITLE "MediaWebBilling"
END
#endif
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE 3 리소스에서 생성되었습니다.
//
/////////////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED가 아닙니다.

View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="MediaWebBilling"
ProjectGUID="{FD74ADE2-6961-4304-B23A-89DA3665477E}"
SccProjectName=""
SccLocalPath=""
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/MediaWebBilling.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/MediaWebBilling.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../DB"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/MediaWebBilling.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\MediaWebBilling.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\MediaWebBilling.h">
</File>
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath=".\stdafx.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
<File
RelativePath=".\MediaWebBilling.ico">
</File>
<File
RelativePath=".\MediaWebBilling.rc">
</File>
<File
RelativePath=".\small.ico">
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,53 @@
========================================================================
Win32 응용 프로그램 : MediaWebBilling 프로젝트 개요
========================================================================
응용 프로그램 마법사에서 이 MediaWebBilling 응용 프로그램을 만들었습니다.
이 파일에는 MediaWebBilling 응용 프로그램을 구성하는 각각의 파일에
들어 있는 요약 설명이 포함되어 있습니다.
MediaWebBilling.vcproj
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
프로젝트 기능에 대한 정보가 들어 있습니다.
MediaWebBilling.cpp
기본 응용 프로그램 소스 파일입니다.
/////////////////////////////////////////////////////////////////////////////
응용 프로그램 마법사에서 다음 리소스를 만들었습니다.
MediaWebBilling.rc
프로그램에서 사용하는 모든
Microsoft Windows 리소스의 목록입니다. RES 하위 디렉터리에 저장된
아이콘, 비트맵, 및 커서 등이 여기에 포함됩니다. 이 파일은
Microsoft Visual C++에서 직접 편집할 수 있습니다.
Resource.h
새 리소스 ID를 정의하는 표준 헤더 파일입니다.
Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다.
MediaWebBilling.ico
아이콘 파일이며, 응용 프로그램의 아이콘(32x32)으로 사용됩니다.
해당 아이콘은 기본 리소스 파일인 MediaWebBilling.rc에 의해 포함됩니다.
small.ico
아이콘 파일이며, 응용 프로그램 아이콘의 더 작은 버전(16x16)이
들어 있습니다. 해당 아이콘은 기본 리소스 파일인
MediaWebBilling.rc에 의해 포함됩니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h 및 StdAfx.cpp는
MediaWebBilling.pch라는 이름의 PCH(미리 컴파일된 헤더) 파일과
StdAfx.obj라는 이름의 미리 컴파일된 형식 파일을 빌드하는 데 사용됩니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,29 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MediaWebBilling.rc
//
#define IDS_APP_TITLE 103
#define IDR_MAINFRAME 128
#define IDD_MEDIAWEBBILLING_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_MEDIAWEBBILLING 107
#define IDI_SMALL 108
#define IDC_MEDIAWEBBILLING 109
#define IDC_MYICON 2
#define IDC_STATIC -1
// 새 개체에 대한 다음 기본값입니다.
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 130
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// MediaWebBilling.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.

View File

@@ -0,0 +1,18 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
// Windows 헤더 파일입니다.
#include <windows.h>
// C의 런타임 헤더 파일입니다.
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.

View File

@@ -0,0 +1,240 @@
// BillingAsyncSocket.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "BillingTestModule.h"
#include "BillingAsyncSocket.h"
#include ".\billingasyncsocket.h"
// CBillingAsyncSocket
CBillingAsyncSocket::CBillingAsyncSocket()
: m_eConnectionMode(ACTIVE_CONNECTION),
m_nAddressLen(0),
m_nRefCount(1),
m_nSendBytesFirstPacket(0),
m_nBufferUsed(0)
{
memset(&m_PeerAddress, 0, sizeof(SOCKADDR));
}
CBillingAsyncSocket::~CBillingAsyncSocket()
{
}
// CBillingAsyncSocket 멤버 함수입니다.
CBillingAsyncSocket* CBillingAsyncSocket::CreateBillingSocket(int nSocketType, UINT nSocketPort)
{
CBillingAsyncSocket* lpSocket = new CBillingAsyncSocket;
if(0 != lpSocket)
{
if(!lpSocket->Create(nSocketPort, nSocketType))
{
delete lpSocket;
lpSocket = 0;
}
}
return lpSocket;
}
void CBillingAsyncSocket::OnAccept(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(0 == nErrorCode)
{
CBillingAsyncSocket* lpSocket = new CBillingAsyncSocket;
if(0 != lpSocket)
{
lpSocket->m_nAddressLen = sizeof(SOCKADDR_IN);
if(Accept(*lpSocket, &lpSocket->m_PeerAddress, &lpSocket->m_nAddressLen))
{
lpSocket->m_eConnectionMode = PASSIVE_CONNECTION;
theApp.RegisterSocket(*lpSocket);
lpSocket->OnReceive(0);
}
else
{
lpSocket->Release();
lpSocket = 0;
}
}
}
else
{
// TODO : Make log here
Close();
}
CAsyncSocket::OnAccept(nErrorCode);
}
void CBillingAsyncSocket::OnReceive(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(0 == nErrorCode)
{
while(true)
{
int nReceived = Receive(m_szRecvBuffer + m_nBufferUsed,
MAX_RECV_BUFFER - m_nBufferUsed);
if(SOCKET_ERROR != nReceived)
{
m_nBufferUsed += nReceived;
size_t nBufferPos = 0;
while(sizeof(unsigned short) + nBufferPos <= m_nBufferUsed)
{
unsigned short usPacketSize = ntohs(*reinterpret_cast<unsigned short*>(m_szRecvBuffer + nBufferPos))
+ sizeof(unsigned short) + sizeof(unsigned short) + sizeof(unsigned long);
if(m_nBufferUsed < usPacketSize + nBufferPos)
{
break;
}
theApp.AddRecvPacket(*this, m_szRecvBuffer, usPacketSize);
nBufferPos += usPacketSize;
}
if(0 != nBufferPos)
{
memmove(m_szRecvBuffer, m_szRecvBuffer + nBufferPos,
m_nBufferUsed - nBufferPos);
m_nBufferUsed -= nBufferPos;
}
}
else
{
if(GetLastError() != WSAEWOULDBLOCK)
{
// TODO : Make Log here
Close();
}
break;
}
}
}
else
{
// TODO : Make Log here
Close();
}
CAsyncSocket::OnReceive(nErrorCode);
}
void CBillingAsyncSocket::OnSend(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(0 == nErrorCode || WSAEWOULDBLOCK == nErrorCode)
{
SendPacket();
}
else
{
// TODO : Make Log here
Close();
}
CAsyncSocket::OnSend(nErrorCode);
}
void CBillingAsyncSocket::OnClose(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
theApp.RemoveSocket(*this);
CAsyncSocket::OnClose(nErrorCode);
if(m_eConnectionMode == PASSIVE_CONNECTION)
{
// 세션 삭제.
Release();
}
}
void CBillingAsyncSocket::OnConnect(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
m_eConnectionMode = ACTIVE_CONNECTION;
CAsyncSocket::OnConnect(nErrorCode);
}
LONG CBillingAsyncSocket::AddRef()
{
return ++m_nRefCount;
}
LONG CBillingAsyncSocket::Release()
{
LONG nRefCount = --m_nRefCount;
if(0 == nRefCount)
{
delete this;
}
return nRefCount;
}
void CBillingAsyncSocket::SendPending(const HanUnitedBilling::GLTransStruct& glTransStruct)
{
m_SendPacketList.push_back(glTransStruct);
SendPacket();
}
void CBillingAsyncSocket::SendPacket()
{
while(!m_SendPacketList.empty())
{
HanUnitedBilling::GLTransStruct& sendTransStruct = m_SendPacketList.front();
int nTotalBytes = ntohs(sendTransStruct.DataSize) + sizeof(sendTransStruct.DataSize)
+ sizeof(sendTransStruct.HeaderMsg) + sizeof(sendTransStruct.SeqID);
int nSendLen = Send(
reinterpret_cast<char*>(&sendTransStruct) + m_nSendBytesFirstPacket,
nTotalBytes - m_nSendBytesFirstPacket);
if(SOCKET_ERROR != nSendLen)
{
m_nSendBytesFirstPacket += nSendLen;
if(m_nSendBytesFirstPacket == nTotalBytes)
{
m_SendPacketList.pop_front();
m_nSendBytesFirstPacket = 0;
}
}
else
{
if(GetLastError() != WSAEWOULDBLOCK)
{
// TODO : Make Log here
Close();
}
else
{
break;
}
}
}
}

View File

@@ -0,0 +1,63 @@
#pragma once
#include <deque>
#include "HanUnitedBillingPacket.h"
// CBillingAsyncSocket ¸í·É ´ë»óÀÔ´Ï´Ù.
class CBillingAsyncSocket : public CAsyncSocket
{
public:
enum ConnectionMode
{
ACTIVE_CONNECTION,
PASSIVE_CONNECTION
};
static CBillingAsyncSocket* CreateBillingSocket(int nSocketType = SOCK_STREAM, UINT nSocketPort = 0);
void SendPending(const HanUnitedBilling::GLTransStruct& glTransStruct);
void SendPacket();
const SOCKADDR& GetPeerAddr() { return m_PeerAddress; }
const char* GetPeerAddrString() { return inet_ntoa(reinterpret_cast<SOCKADDR_IN&>(m_PeerAddress).sin_addr); }
virtual void OnAccept(int nErrorCode);
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnConnect(int nErrorCode);
LONG AddRef();
LONG Release();
protected:
CBillingAsyncSocket();
virtual ~CBillingAsyncSocket();
private:
typedef std::deque<HanUnitedBilling::GLTransStruct> SendPacketList;
SOCKADDR m_PeerAddress;
int m_nAddressLen;
ConnectionMode m_eConnectionMode;
LONG m_nRefCount;
SendPacketList m_SendPacketList;
size_t m_nSendBytesFirstPacket;
enum
{
MAX_RECV_BUFFER = sizeof(HanUnitedBilling::GLTransStruct) * 10
};
char m_szRecvBuffer[MAX_RECV_BUFFER];
size_t m_nBufferUsed;
};

View File

@@ -0,0 +1,242 @@
// BillingTestModule.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "BillingTestModule.h"
#include "BillingTestModuleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <mmsystem.h>
#include <algorithm>
// CBillingTestModuleApp
BEGIN_MESSAGE_MAP(CBillingTestModuleApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CBillingTestModuleApp::Packet::Packet(CBillingAsyncSocket& billingAsyncSocket,
const HanUnitedBilling::GLTransStruct glTransStruct,
unsigned long dwDelayMSec)
: m_billingAsyncSocket(billingAsyncSocket),
m_glTransStruct(glTransStruct),
m_dwPendingTime(timeGetTime()),
m_dwDelayMSec(dwDelayMSec)
{
}
// CBillingTestModuleApp 생성
CBillingTestModuleApp::CBillingTestModuleApp()
: m_lpBillingTestModule(0), m_lpListenAsyncSocket(0)
{
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CBillingTestModuleApp 개체입니다.
CBillingTestModuleApp theApp;
// CBillingTestModuleApp 초기화
BOOL CBillingTestModuleApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControls()가 필요합니다.
// InitCommonControls()를 사용하지 않으면 창을 만들 수 없습니다.
InitCommonControls();
CWinApp::InitInstance();
if(!AfxSocketInit())
{
AfxMessageBox("소켓 초기화 실패!");
return FALSE;
}
m_lpListenAsyncSocket = CBillingAsyncSocket::CreateBillingSocket(SOCK_STREAM, LISTEN_PORT);
if(0 == m_lpListenAsyncSocket
|| !m_lpListenAsyncSocket->Listen())
{
AfxMessageBox("소켓 리슨 실패!");
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성한 응용 프로그램"));
CBillingTestModuleDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 여기에 대화 상자가 확인을 눌러 없어지는 경우 처리할
// 코드를 배치합니다.
}
else if (nResponse == IDCANCEL)
{
// TODO: 여기에 대화 상자가 취소를 눌러 없어지는 경우 처리할
// 코드를 배치합니다.
}
m_lpListenAsyncSocket->Close();
m_lpListenAsyncSocket->Release();
m_lpListenAsyncSocket = 0;
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고
// 응용 프로그램을 끝낼 수 있도록 FALSE를 반환합니다.
return FALSE;
}
void CBillingTestModuleApp::ProcessPacket()
{
const int MAX_PROCESS_COUNT = 100;
int nProcessCount = 0;
CBillingTestModuleDlg* lpDlg = GetMainDlg();
if(0 != lpDlg)
{
unsigned long dwCurrentTime = timeGetTime();
while(!m_RecvPacketList.empty() && nProcessCount < MAX_PROCESS_COUNT)
{
Packet& packet = m_RecvPacketList.front();
// 시간이 충분히 지난 후 패킷을 처리.
if(0 < static_cast<long>((packet.m_dwDelayMSec + packet.m_dwPendingTime) - dwCurrentTime))
{
break;
}
// 로그인, 로그아웃을 처리한다.
packet.m_glTransStruct.HeaderMsg = ntohs(packet.m_glTransStruct.HeaderMsg);
packet.m_glTransStruct.DataSize = ntohs(packet.m_glTransStruct.DataSize);
packet.m_glTransStruct.SeqID = ntohl(packet.m_glTransStruct.SeqID);
const char* szIP = packet.m_glTransStruct.Data;
const char* szID = packet.m_glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN;
switch(packet.m_glTransStruct.HeaderMsg)
{
case HanUnitedBilling::AUTH:
lpDlg->Login(packet.m_billingAsyncSocket, packet.m_glTransStruct.SeqID, szID, szIP);
break;
case HanUnitedBilling::LOGOUT:
lpDlg->Logout(packet.m_billingAsyncSocket, packet.m_glTransStruct.SeqID, szID, szIP);
break;
case HanUnitedBilling::BILL_AUTH:
lpDlg->BillAuth(packet.m_billingAsyncSocket, packet.m_glTransStruct.SeqID, szID, szIP);
break;
}
packet.m_billingAsyncSocket.Release();
m_RecvPacketList.pop_front();
}
}
}
void CBillingTestModuleApp::AddRecvPacket(CBillingAsyncSocket& billingAsyncSocket,
const char* szBuffer, unsigned short usDataLen)
{
CBillingTestModuleDlg* lpDlg = GetMainDlg();
HanUnitedBilling::GLTransStruct glTransStruct;
memset(&glTransStruct, 0, sizeof(HanUnitedBilling::GLTransStruct));
memcpy(&glTransStruct, szBuffer, min(usDataLen, sizeof(HanUnitedBilling::GLTransStruct)));
if(0 != lpDlg)
{
unsigned long dwDelayMSec = 0;
CBillingTestModuleDlg::Behavior behavior = CBillingTestModuleDlg::NORMAL_PROCESS;
switch(ntohs(glTransStruct.HeaderMsg))
{
case HanUnitedBilling::AUTH:
{
behavior = lpDlg->GetLoginAckType();
if(CBillingTestModuleDlg::DELAY_ALL_PROCESS == behavior)
{
dwDelayMSec = lpDlg->GetLoginAckDelay();
}
}
break;
case HanUnitedBilling::BILL_AUTH:
{
behavior = lpDlg->GetBillAuthAckType();
if(CBillingTestModuleDlg::DELAY_ALL_PROCESS == behavior)
{
dwDelayMSec = lpDlg->GetBillAuthAckDelay();
}
}
break;
}
if(CBillingTestModuleDlg::DROP_ALL_PROCESS != behavior)
{
billingAsyncSocket.AddRef();
m_RecvPacketList.push_back(Packet(
billingAsyncSocket, glTransStruct, dwDelayMSec));
}
else
{
lpDlg->AddLog(NORMAL_LOG, "SS:0x%p/UID_IP:%s/Cmd:%d/SeqID:%d/패킷을 Drop합니다.",
&billingAsyncSocket, billingAsyncSocket.GetPeerAddrString(),
ntohs(glTransStruct.HeaderMsg), ntohl(glTransStruct.SeqID));
}
}
}
void CBillingTestModuleApp::RegisterSocket(CBillingAsyncSocket& billingAsyncSocket)
{
if(m_SocketList.end() == std::find(m_SocketList.begin(), m_SocketList.end(), &billingAsyncSocket))
{
m_SocketList.push_back(&billingAsyncSocket);
}
}
void CBillingTestModuleApp::RemoveSocket(CBillingAsyncSocket& billingAsyncSocket)
{
SocketList::iterator pos = std::find(m_SocketList.begin(), m_SocketList.end(), &billingAsyncSocket);
if(pos != m_SocketList.end())
{
m_SocketList.erase(pos);
}
}
void CBillingTestModuleApp::SendPendingAll(const HanUnitedBilling::GLTransStruct& glTransStruct)
{
SocketList::iterator pos = m_SocketList.begin();
SocketList::iterator end = m_SocketList.end();
for(; pos != end; ++pos)
{
(*pos)->SendPending(glTransStruct);
}
}

View File

@@ -0,0 +1,99 @@
// BillingTestModule.h : PROJECT_NAME 응용 프로그램에 대한 주 헤더 파일입니다.
//
#pragma once
#ifndef __AFXWIN_H__
#error PCH에서 이 파일을 포함하기 전에 'stdafx.h'를 포함하십시오.
#endif
#include "resource.h" // 주 기호
#include "BillingAsyncSocket.h"
#include "HanUnitedBillingPacket.h"
#include <deque>
#include <list>
class CBillingTestModuleDlg;
// CBillingTestModuleApp:
// 이 클래스의 구현에 대해서는 BillingTestModule.cpp을 참조하십시오.
//
class CBillingTestModuleApp : public CWinApp
{
public:
CBillingTestModuleApp();
// 재정의
public:
virtual BOOL InitInstance();
// 구현
DECLARE_MESSAGE_MAP()
public:
enum
{
LISTEN_PORT = 10800
};
void ProcessPacket();
void AddRecvPacket(CBillingAsyncSocket& billingAsyncSocket,
const char* szBuffer, unsigned short usDataLen);
void SetMainDlg(CBillingTestModuleDlg& billingTestModule) { m_lpBillingTestModule = &billingTestModule; }
void ResetMainDlg(CBillingTestModuleDlg& billingTestModule)
{
if(m_lpBillingTestModule == &billingTestModule)
{
m_lpBillingTestModule = 0;
}
}
CBillingTestModuleDlg* GetMainDlg() { return m_lpBillingTestModule; }
size_t GetConnectedSocketNum() { return m_SocketList.size(); }
void RegisterSocket(CBillingAsyncSocket& billingAsyncSocket);
void RemoveSocket(CBillingAsyncSocket& billingAsyncSocket);
void SendPendingAll(const HanUnitedBilling::GLTransStruct& glTransStruct);
private:
bool ProcessLogin(CBillingAsyncSocket& billingAsyncSocket,
const HanUnitedBilling::GLTransStruct& glTransStruct);
bool ProcessLogout(CBillingAsyncSocket& billingAsyncSocket,
const HanUnitedBilling::GLTransStruct& glTransStruct);
bool ProcessBillAuth(CBillingAsyncSocket& billingAsyncSocket,
const HanUnitedBilling::GLTransStruct& glTransStruct);
struct Packet
{
CBillingAsyncSocket& m_billingAsyncSocket;
HanUnitedBilling::GLTransStruct m_glTransStruct;
unsigned long m_dwPendingTime;
unsigned long m_dwDelayMSec;
explicit Packet(CBillingAsyncSocket& billingAsyncSocket,
const HanUnitedBilling::GLTransStruct glTransStruct, unsigned long dwDelayMSec);
};
typedef std::deque<Packet> PacketList;
typedef std::list<CBillingAsyncSocket*> SocketList;
PacketList m_RecvPacketList;
SocketList m_SocketList;
CBillingAsyncSocket* m_lpListenAsyncSocket;
CBillingTestModuleDlg* m_lpBillingTestModule;
};
extern CBillingTestModuleApp theApp;

View File

@@ -0,0 +1,243 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 한국어 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
#ifdef _WIN32
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
#pragma code_page(949)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)\r\n"
"LANGUAGE 18, 1\r\n"
"#pragma code_page(949)\r\n"
"#include ""res\\BillingTestModule.rc2"" // Microsoft Visual C++에서 편집되지 않은 리소스\r\n"
"#include ""afxres.rc"" // 표준 구성 요소\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\BillingTestModule.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "BillingTestModule 정보"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "BillingTestModule Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2004",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "확인",IDOK,178,7,50,16,WS_GROUP
END
IDD_BILLINGTESTMODULE_DIALOG DIALOGEX 0, 0, 599, 373
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "BillingTestModule"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "",IDC_CURRENT_USER_LIST,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,10,17,257,128
CONTROL "",IDC_IP_START,"SysIPAddress32",WS_TABSTOP,24,181,74,13
CONTROL "",IDC_IP_END,"SysIPAddress32",WS_TABSTOP,118,181,74,13
PUSHBUTTON "IP 대역 추가",IDC_IP_ADD,196,181,57,13,BS_FLAT
CONTROL "",IDC_LOGIN_IP_LIST,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,10,204,256,122
GROUPBOX "◆ 현재 접속자 정보",IDC_STATIC,4,4,269,147,BS_FLAT
GROUPBOX "▶ 접속 가능 IP 대역",IDC_STATIC,4,158,269,176,BS_FLAT
LTEXT "~",IDC_STATIC,105,183,8,9
GROUPBOX "▷ 새 IP 정보",IDC_STATIC,10,170,256,29
LTEXT "로그인 동작 방식",IDC_STATIC,12,341,54,8
COMBOBOX IDC_LOGIN_ACK_TYPE,70,338,48,67,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
LTEXT "과금 가능 동작 방식",IDC_STATIC,134,341,63,8
EDITTEXT IDC_LOGIN_ACK_DELAY,70,352,48,12,ES_AUTOHSCROLL
LTEXT "응답 지연 시간(ms)",IDC_STATIC,9,355,61,8
LTEXT "응답 지연 시간(ms)",IDC_STATIC,135,355,61,8
COMBOBOX IDC_BILL_AUTH_ACK_TYPE,199,338,48,69,CBS_DROPDOWN |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_BILL_AUTH_ACK_DELAY,199,352,48,12,ES_AUTOHSCROLL
GROUPBOX "▶ 로그",IDC_STATIC,281,4,314,330,BS_FLAT
PUSHBUTTON "로그를 파일로 저장",IDC_SAVELOG,344,344,64,14,BS_FLAT
CONTROL "",IDC_LOG_LIST,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,289,16,299,310
PUSHBUTTON "로그 클리어",IDC_CLEARLOG,487,344,50,14,BS_FLAT
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "041203b5"
BEGIN
VALUE "CompanyName", "TODO: <회사 이름>"
VALUE "FileDescription", "TODO: <파일 설명>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "BillingTestModule.exe"
VALUE "LegalCopyright", "TODO: (c) <회사 이름>. All rights reserved."
VALUE "OriginalFilename", "BillingTestModule.exe"
VALUE "ProductName", "TODO: <제품 이름>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "변환", 0x412, 949
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_BILLINGTESTMODULE_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 595
TOPMARGIN, 4
BOTTOMMARGIN, 369
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_CONTEXT_MENU MENU
BEGIN
POPUP "Menu1(&A)"
BEGIN
MENUITEM "접속 끊기(&D)", ID_DISCONNECT_USER
MENUITEM SEPARATOR
MENUITEM "메세지 보내기(&M)", ID_SEND_MSG_USER
END
POPUP "Menu2(&B)"
BEGIN
MENUITEM "삭제(&D)", ID_IP_DELETE
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "BillingTestModule 정보(&A)..."
END
#endif // 한국어 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
LANGUAGE 18, 1
#pragma code_page(949)
#include "res\BillingTestModule.rc2" // Microsoft Visual C++에서 편집되지 않은 리소스
#include "afxres.rc" // 표준 구성 요소
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="BillingTestModule"
ProjectGUID="{45133C4E-218B-4327-A547-9B64F0CACD5D}"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="winmm.lib"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="FALSE"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../Executable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
MinimalRebuild="FALSE"
RuntimeLibrary="0"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="winmm.lib"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="FALSE"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\BillingAsyncSocket.cpp">
</File>
<File
RelativePath=".\BillingTestModule.cpp">
</File>
<File
RelativePath=".\BillingTestModuleDlg.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\BillingAsyncSocket.h">
</File>
<File
RelativePath=".\BillingTestModule.h">
</File>
<File
RelativePath=".\BillingTestModuleDlg.h">
</File>
<File
RelativePath=".\HanUnitedBillingPacket.h">
</File>
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath=".\stdafx.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
<File
RelativePath=".\res\BillingTestModule.ico">
</File>
<File
RelativePath=".\BillingTestModule.rc">
</File>
<File
RelativePath=".\res\BillingTestModule.rc2">
</File>
</Filter>
<File
RelativePath=".\res\BillingTestModule.manifest">
</File>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
<Global
Name="RESOURCE_FILE"
Value="BillingTestModule.rc"/>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,802 @@
// BillingTestModuleDlg.cpp : 구현 파일
//
#include "stdafx.h"
#include "BillingTestModule.h"
#include "BillingTestModuleDlg.h"
#include ".\billingtestmoduledlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <vector>
#include <algorithm>
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 대화 상자 데이터
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원
// 구현
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CBillingTestModuleDlg 대화 상자
const int ID_PROCESS_PACKET_TIMER = 1000;
CBillingTestModuleDlg::CBillingTestModuleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBillingTestModuleDlg::IDD, pParent)
, m_LoginAckDelay(0)
, m_BillAuthAckDelay(0)
, m_nSocketNum(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBillingTestModuleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CURRENT_USER_LIST, m_ctrlCurrentUserList);
DDX_Control(pDX, IDC_LOGIN_IP_LIST, m_ctrlLoginIPList);
DDX_Control(pDX, IDC_IP_START, m_StartIP);
DDX_Control(pDX, IDC_IP_END, m_EndIP);
DDX_Control(pDX, IDC_LOGIN_ACK_TYPE, m_LoginAckType);
DDX_Control(pDX, IDC_BILL_AUTH_ACK_TYPE, m_BillAuthAckType);
DDX_Text(pDX, IDC_LOGIN_ACK_DELAY, m_LoginAckDelay);
DDX_Text(pDX, IDC_BILL_AUTH_ACK_DELAY, m_BillAuthAckDelay);
DDX_Control(pDX, IDC_LOG_LIST, m_BillingLog);
DDX_Control(pDX, IDC_LOGIN_ACK_DELAY, m_LoginAckDelayDlg);
DDX_Control(pDX, IDC_BILL_AUTH_ACK_DELAY, m_BillAuthAckDelayDlg);
}
BEGIN_MESSAGE_MAP(CBillingTestModuleDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_DISCONNECT_USER, OnDisconnectUser)
ON_COMMAND(ID_SEND_MSG_USER, OnSendMsgUser)
ON_COMMAND(ID_IP_DELETE, OnIpDelete)
ON_BN_CLICKED(IDC_IP_ADD, OnBnClickedIPAdd)
ON_BN_CLICKED(IDC_SAVELOG, OnBnClickedSaveLog)
ON_BN_CLICKED(IDC_CLEARLOG, OnBnClickedClearLog)
ON_WM_TIMER()
ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_LOGIN_ACK_TYPE, OnCbnSelchangeLoginAckType)
ON_CBN_SELCHANGE(IDC_BILL_AUTH_ACK_TYPE, OnCbnSelchangeBillAuthAckType)
END_MESSAGE_MAP()
// CBillingTestModuleDlg 메시지 처리기
BOOL CBillingTestModuleDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
// 프레임워크가 이 작업을 자동으로 수행합니다.
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
// TODO: 여기에 추가 초기화 작업을 추가합니다.
m_ctrlCurrentUserList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_FLATSB);
m_ctrlCurrentUserList.InsertColumn( 0, "ID", LVCFMT_LEFT, 200);
m_ctrlCurrentUserList.InsertColumn( 1, "접속중인 IP", LVCFMT_LEFT, 200);
m_ctrlLoginIPList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_FLATSB);
m_ctrlLoginIPList.InsertColumn( 0, "IP 대역 시작", LVCFMT_LEFT, 200);
m_ctrlLoginIPList.InsertColumn( 1, "IP 대역 끝", LVCFMT_LEFT, 200);
m_BillingLog.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_FLATSB);
m_BillingLog.InsertColumn(0, "로그", LVCFMT_LEFT, 500);
LoadAddress();
m_LoginAckType.InsertString(NORMAL_PROCESS, "기본 처리");
m_LoginAckType.InsertString(SUCCESS_ALL_PROCESS, "모두 성공");
m_LoginAckType.InsertString(FAIL_ALL_PROCESS, "모두 실패");
m_LoginAckType.InsertString(DELAY_ALL_PROCESS, "지연 처리");
m_LoginAckType.InsertString(DROP_ALL_PROCESS, "요청 버림");
m_LoginAckType.SetCurSel(NORMAL_PROCESS);
m_LoginAckDelayDlg.SetReadOnly();
m_BillAuthAckType.InsertString(NORMAL_PROCESS, "기본 처리");
m_BillAuthAckType.InsertString(SUCCESS_ALL_PROCESS, "모두 성공");
m_BillAuthAckType.InsertString(FAIL_ALL_PROCESS, "모두 실패");
m_BillAuthAckType.InsertString(DELAY_ALL_PROCESS, "지연 처리");
m_BillAuthAckType.InsertString(DROP_ALL_PROCESS, "요청 버림");
m_BillAuthAckType.SetCurSel(NORMAL_PROCESS);
m_BillAuthAckDelayDlg.SetReadOnly();
m_LoginAckDelay = 0;
m_BillAuthAckDelay = 0;
CString windowName;
windowName.Format("BillingTestModule : Port(%u)", CBillingTestModuleApp::LISTEN_PORT);
SetWindowText(windowName);
UpdateData(false);
theApp.SetMainDlg(*this);
SetTimer(ID_PROCESS_PACKET_TIMER, 200, 0);
return TRUE; // 컨트롤에 대한 포커스를 설정하지 않을 경우 TRUE를 반환합니다.
}
void CBillingTestModuleDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.
void CBillingTestModuleDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 아이콘을 그립니다.
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
HCURSOR CBillingTestModuleDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CBillingTestModuleDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
if( (pWnd->GetSafeHwnd() == m_ctrlCurrentUserList.GetSafeHwnd())
&& (0 < m_ctrlCurrentUserList.GetSelectedCount()) )
{
CMenu muTemp, *pContextMenu;
muTemp.LoadMenu(IDR_CONTEXT_MENU);
pContextMenu = muTemp.GetSubMenu(0);
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
}
else if( (pWnd->GetSafeHwnd() == m_ctrlLoginIPList.GetSafeHwnd())
&& (0 < m_ctrlLoginIPList.GetSelectedCount()) )
{
CMenu muTemp, *pContextMenu;
muTemp.LoadMenu(IDR_CONTEXT_MENU);
pContextMenu = muTemp.GetSubMenu(1);
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
}
}
void CBillingTestModuleDlg::OnOK()
{
//CDialog::OnOK();
}
BOOL CBillingTestModuleDlg::PreTranslateMessage(MSG* pMsg)
{
if( ( WM_KEYDOWN == pMsg->message ) && ( VK_RETURN == pMsg->wParam ) )
{
if( (GetFocus() == GetDlgItem(IDC_IP_END)->GetFocus()) )
{
// 여기서 IP 추가
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CBillingTestModuleDlg::OnDisconnectUser()
{
// 강제로 접속끊기
POSITION pos = m_ctrlCurrentUserList.GetFirstSelectedItemPosition();
int nPos = m_ctrlCurrentUserList.GetNextSelectedItem(pos);
int nLength = 0;
while(-1 != nPos)
{
HanUnitedBilling::GLTransStruct glTransStruct;
memset(&glTransStruct, 0, sizeof(HanUnitedBilling::GLTransStruct));
nLength = m_ctrlCurrentUserList.GetItemText(nPos, 1, glTransStruct.Data, HanUnitedBilling::MAX_IP_LEN);
glTransStruct.Data[nLength] = 0;
nLength = m_ctrlCurrentUserList.GetItemText(nPos, 0,
glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN, HanUnitedBilling::MAX_ID_LEN);
glTransStruct.Data[nLength + HanUnitedBilling::MAX_IP_LEN] = 0;
glTransStruct.HeaderMsg = htons(HanUnitedBilling::CUT_IP);
glTransStruct.DataSize = htons(
HanUnitedBilling::MAX_ID_LEN +
HanUnitedBilling::MAX_IP_LEN);
glTransStruct.SeqID = 0;
theApp.SendPendingAll(glTransStruct);
nPos = m_ctrlLoginIPList.GetNextSelectedItem(pos);
}
}
void CBillingTestModuleDlg::OnSendMsgUser()
{
// 유저에게 메세지 보내기
// 강제로 접속끊기
POSITION pos = m_ctrlCurrentUserList.GetFirstSelectedItemPosition();
int nPos = m_ctrlCurrentUserList.GetNextSelectedItem(pos);
int nLength = 0;
while(-1 != nPos)
{
HanUnitedBilling::GLTransStruct glTransStruct;
memset(&glTransStruct, 0, sizeof(HanUnitedBilling::GLTransStruct));
nLength = m_ctrlCurrentUserList.GetItemText(nPos, 1, glTransStruct.Data, HanUnitedBilling::MAX_IP_LEN);
glTransStruct.Data[nLength] = 0;
nLength = m_ctrlCurrentUserList.GetItemText(nPos, 0,
glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN, HanUnitedBilling::MAX_ID_LEN);
glTransStruct.Data[nLength + HanUnitedBilling::MAX_IP_LEN] = 0;
nLength = _sntprintf(glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN + HanUnitedBilling::MAX_ID_LEN,
HanUnitedBilling::MAX_MSG_LEN - 1, "이 가난뱅이 녀석, 돈을 제때 넣으란 말이다. 우하하하");
glTransStruct.Data[nLength + HanUnitedBilling::MAX_IP_LEN + HanUnitedBilling::MAX_ID_LEN] = 0;
glTransStruct.HeaderMsg = htons(HanUnitedBilling::WARNNOTICE);
glTransStruct.DataSize = htons(
HanUnitedBilling::MAX_ID_LEN +
HanUnitedBilling::MAX_IP_LEN +
HanUnitedBilling::MAX_MSG_LEN);
glTransStruct.SeqID = 0;
theApp.SendPendingAll(glTransStruct);
nPos = m_ctrlLoginIPList.GetNextSelectedItem(pos);
}
}
void CBillingTestModuleDlg::OnIpDelete()
{
// IP 대역 삭제
POSITION pos = m_ctrlLoginIPList.GetFirstSelectedItemPosition();
std::vector<int> deletePos;
int nPos = m_ctrlLoginIPList.GetNextSelectedItem(pos);
while(-1 != nPos)
{
deletePos.push_back(nPos);
nPos = m_ctrlLoginIPList.GetNextSelectedItem(pos);
}
std::sort(deletePos.begin(), deletePos.end(), std::greater<int>());
std::vector<int>::iterator pos_delete = deletePos.begin();
std::vector<int>::iterator end_delete = deletePos.end();
for(; pos_delete != end_delete; ++pos_delete)
{
m_ctrlLoginIPList.DeleteItem(*pos_delete);
}
SaveAddress();
}
void CBillingTestModuleDlg::OnBnClickedIPAdd()
{
// IP 대역 추가
if(!m_StartIP.IsBlank() && !m_EndIP.IsBlank())
{
DWORD dwStartAddress = 0;
DWORD dwEndAddress = 0;
m_StartIP.GetAddress(dwStartAddress);
m_EndIP.GetAddress(dwEndAddress);
std::pair<in_addr, in_addr> addressPair;
addressPair.first.S_un.S_addr = htonl(dwStartAddress);
addressPair.second.S_un.S_addr = htonl(dwEndAddress);
AddAddress(addressPair.first, addressPair.second);
SaveAddress();
}
}
void CBillingTestModuleDlg::AddAddress(in_addr addressStart, in_addr addressEnd)
{
int nMaxCount = m_ctrlLoginIPList.GetItemCount();
m_ctrlLoginIPList.InsertItem(nMaxCount, 0);
m_ctrlLoginIPList.SetItemText(nMaxCount, 0, inet_ntoa(addressStart));
m_ctrlLoginIPList.SetItemText(nMaxCount, 1, inet_ntoa(addressEnd));
}
const TCHAR* g_szBillingAddress = "BillingAddress.txt";
void CBillingTestModuleDlg::SaveAddress()
{
FILE* file = fopen(g_szBillingAddress, "wt");
if(0 != file)
{
int nMaxCount = m_ctrlLoginIPList.GetItemCount();
for(int nCount = 0; nCount < nMaxCount; ++nCount)
{
fprintf(file, "%s\t%s\n",
m_ctrlLoginIPList.GetItemText(nCount, 0),
m_ctrlLoginIPList.GetItemText(nCount, 1));
}
fclose(file);
}
}
void CBillingTestModuleDlg::LoadAddress()
{
FILE* file = fopen(g_szBillingAddress, "rt");
if(0 != file)
{
const int MAX_BUFFER = 4096;
char szBuffer[MAX_BUFFER];
char szIPStart[MAX_BUFFER];
char szIPEnd[MAX_BUFFER];
in_addr addrStart;
in_addr addrEnd;
while(fgets(szBuffer, MAX_BUFFER - 1, file))
{
szBuffer[MAX_BUFFER - 1] = 0;
if(EOF != sscanf(szBuffer, "%s\t%s\n", szIPStart, szIPEnd))
{
addrStart.S_un.S_addr = inet_addr(szIPStart);
addrEnd.S_un.S_addr = inet_addr(szIPEnd);
AddAddress(addrStart, addrEnd);
}
}
}
}
void CBillingTestModuleDlg::OnBnClickedSaveLog()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
const int MAX_LOG_LINE = 4096;
TCHAR szLogText[MAX_LOG_LINE];
const char* szLogFileName = "HanUnitedBillingLog.log";
FILE* file = fopen(szLogFileName, "at");
if(0 != file)
{
int nMAXCount = m_BillingLog.GetItemCount();
for(int nCount = 0; nCount < nMAXCount; ++nCount)
{
int nLength = m_BillingLog.GetItemText(nCount, 0, szLogText, MAX_LOG_LINE - 1);
if(0 < nLength && nLength < MAX_LOG_LINE)
{
szLogText[nLength] = 0;
fprintf(file, "%s\n", szLogText);
}
}
fclose(file);
}
m_BillingLog.DeleteAllItems();
AfxMessageBox("로그를 저장하는 데 성공했습니다.");
}
void CBillingTestModuleDlg::OnBnClickedClearLog()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_BillingLog.DeleteAllItems();
}
void CBillingTestModuleDlg::AddLog(DlgLogType eDlgLogType, const TCHAR* szFormat, ...)
{
const int MAX_LOG_LINE = 4096;
TCHAR szLogText[MAX_LOG_LINE];
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
const TCHAR* szLogType = _T("UNK");
switch(eDlgLogType)
{
case NORMAL_LOG: szLogType = _T("NOR"); break;
case ERROR_LOG: szLogType = _T("ERR"); break;
}
int nTotalLength = _sntprintf(szLogText, MAX_LOG_LINE - 1, _T("[%s][%04d-%02d-%02d %02d:%02d:%02d] "),
szLogType, sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
va_list arglist;
va_start(arglist, szFormat);
int nLength = _vsntprintf(szLogText + nTotalLength,
MAX_LOG_LINE - nTotalLength - 1, szFormat, arglist);
va_end(arglist);
if(0 < nLength && nTotalLength + nLength < MAX_LOG_LINE)
{
nTotalLength += nLength;
szLogText[nTotalLength] = 0;
m_BillingLog.InsertItem(m_BillingLog.GetItemCount(), szLogText);
}
}
bool CBillingTestModuleDlg::Login(CBillingAsyncSocket& billingAsyncSocket,
unsigned long dwSeqID, const char* szID, const char* szIP)
{
HanUnitedBilling::GLTransStruct glTransStruct;
memset(&glTransStruct, 0, sizeof(HanUnitedBilling::GLTransStruct));
unsigned short usSuccess = 0;
switch(GetLoginAckType())
{
case SUCCESS_ALL_PROCESS:
usSuccess = 1;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 로그인 처리 무조건 성공", szID, szIP, dwSeqID);
break;
case FAIL_ALL_PROCESS:
usSuccess = 0;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 로그인 처리 무조건 실패", szID, szIP, dwSeqID);
break;
default:
if(-1 != FindCurrentUserPos(szID, szIP))
{
usSuccess = 0;
AddLog(ERROR_LOG, "ID:%s/IP:%s/SeqID:%u/유저 로그인 처리 실패(중복 로그인)", szID, szIP, dwSeqID);
}
else if(!CheckIPList(szIP))
{
usSuccess = 0;
AddLog(ERROR_LOG, "ID:%s/IP:%s/SeqID:%u/유저 로그인 처리 실패(IP리스트에 없음)", szID, szIP, dwSeqID);
}
else
{
usSuccess = 1;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 로그인 처리 성공", szID, szIP, dwSeqID);
int nCount = m_ctrlCurrentUserList.GetItemCount();
m_ctrlCurrentUserList.InsertItem(nCount, "");
m_ctrlCurrentUserList.SetItemText(nCount, 0, szID);
m_ctrlCurrentUserList.SetItemText(nCount, 1, szIP);
}
break;
}
glTransStruct.HeaderMsg = htons(HanUnitedBilling::AUTH_RESULT);
glTransStruct.DataSize = htons(
HanUnitedBilling::MAX_ID_LEN +
HanUnitedBilling::MAX_IP_LEN +
sizeof(unsigned short));
glTransStruct.SeqID = htonl(dwSeqID);
_snprintf(glTransStruct.Data, HanUnitedBilling::MAX_IP_LEN, "%s", szIP);
_snprintf(glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN, HanUnitedBilling::MAX_ID_LEN, "%s", szID);
usSuccess = htons(usSuccess);
memcpy(glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN + HanUnitedBilling::MAX_ID_LEN,
&usSuccess, sizeof(unsigned short));
billingAsyncSocket.SendPending(glTransStruct);
return true;
}
bool CBillingTestModuleDlg::Logout(CBillingAsyncSocket& billingAsyncSocket,
unsigned long dwSeqID, const char* szID, const char* szIP)
{
int nPos = FindCurrentUserPos(szID, szIP);
if(-1 != nPos)
{
m_ctrlCurrentUserList.DeleteItem(nPos);
AddLog(NORMAL_LOG, "ID:%s/IP:%s/유저 로그아웃 처리 성공", szID, szIP);
return true;
}
AddLog(ERROR_LOG, "ID:%s/IP:%s/유저 로그아웃 처리 실패. 유저가 없습니다.", szID, szIP);
return false;
}
bool CBillingTestModuleDlg::BillAuth(CBillingAsyncSocket& billingAsyncSocket,
unsigned long dwSeqID, const char* szID, const char* szIP)
{
HanUnitedBilling::GLTransStruct glTransStruct;
memset(&glTransStruct, 0, sizeof(HanUnitedBilling::GLTransStruct));
unsigned short usSuccess = 0;
switch(GetLoginAckType())
{
case SUCCESS_ALL_PROCESS:
usSuccess = 1;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 과금 가능 여부 무조건 성공", szID, szIP, dwSeqID);
break;
case FAIL_ALL_PROCESS:
usSuccess = 0;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 과금 가능 여부 무조건 실패", szID, szIP, dwSeqID);
break;
default:
if(-1 != FindCurrentUserPos(szID, szIP))
{
usSuccess = 0;
AddLog(ERROR_LOG, "ID:%s/IP:%s/SeqID:%u/유저 과금 불가능 (중복 로그인)", szID, szIP, dwSeqID);
}
else if(!CheckIPList(szIP))
{
usSuccess = 0;
AddLog(ERROR_LOG, "ID:%s/IP:%s/SeqID:%u/유저 과금 불가능 (과금 내역 없음)", szID, szIP, dwSeqID);
}
else
{
usSuccess = 1;
AddLog(NORMAL_LOG, "ID:%s/IP:%s/SeqID:%u/유저 과금 가능", szID, szIP, dwSeqID);
}
break;
}
glTransStruct.HeaderMsg = htons(HanUnitedBilling::BILL_AUTH_RESULT);
glTransStruct.DataSize = htons(
HanUnitedBilling::MAX_ID_LEN +
HanUnitedBilling::MAX_IP_LEN +
sizeof(unsigned short));
glTransStruct.SeqID = htonl(dwSeqID);
_snprintf(glTransStruct.Data, HanUnitedBilling::MAX_IP_LEN, "%s", szIP);
_snprintf(glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN, HanUnitedBilling::MAX_ID_LEN, "%s", szID);
usSuccess = htons(usSuccess);
memcpy(glTransStruct.Data + HanUnitedBilling::MAX_IP_LEN + HanUnitedBilling::MAX_ID_LEN,
&usSuccess, sizeof(unsigned short));
billingAsyncSocket.SendPending(glTransStruct);
return true;
}
int CBillingTestModuleDlg::FindCurrentUserPos(const char* szID, const char* szIP)
{
int nMaxCount = m_ctrlCurrentUserList.GetItemCount();
TCHAR szUserID[HanUnitedBilling::MAX_ID_LEN + 1];
TCHAR szUserIP[HanUnitedBilling::MAX_IP_LEN + 1];
int nLength = 0;
for(int nCount = 0; nCount < nMaxCount; ++nCount)
{
nLength = m_ctrlCurrentUserList.GetItemText(nCount, 0,
szUserID, HanUnitedBilling::MAX_ID_LEN);
szUserID[nLength] = 0;
nLength = m_ctrlCurrentUserList.GetItemText(nCount, 1,
szUserIP, HanUnitedBilling::MAX_IP_LEN);
szUserIP[nLength] = 0;
if(0 == _tcsncmp(szID, szUserID, HanUnitedBilling::MAX_ID_LEN)
&& 0 == _tcsncmp(szIP, szUserIP, HanUnitedBilling::MAX_IP_LEN))
{
return nCount;
}
}
return -1;
}
bool CBillingTestModuleDlg::CheckIPList(const char* szIP)
{
in_addr address;
address.S_un.S_addr = inet_addr(szIP);
char szIPStart[HanUnitedBilling::MAX_IP_LEN + 1];
char szIPEnd[HanUnitedBilling::MAX_IP_LEN + 1];
in_addr addr_start;
in_addr addr_end;
int nLength = 0;
int nMaxCount = m_ctrlLoginIPList.GetItemCount();
for(int nCount = 0; nCount < nMaxCount; ++nCount)
{
nLength = m_ctrlLoginIPList.GetItemText(nCount, 0, szIPStart, HanUnitedBilling::MAX_IP_LEN);
szIPStart[nLength] = 0;
nLength = m_ctrlLoginIPList.GetItemText(nCount, 1, szIPEnd, HanUnitedBilling::MAX_IP_LEN);
szIPEnd[nLength] = 0;
addr_start.S_un.S_addr = inet_addr(szIPStart);
addr_end.S_un.S_addr = inet_addr(szIPEnd);
if(addr_start.S_un.S_un_b.s_b1 <= address.S_un.S_un_b.s_b1 &&
address.S_un.S_un_b.s_b1 <= addr_end.S_un.S_un_b.s_b1 &&
addr_start.S_un.S_un_b.s_b2 <= address.S_un.S_un_b.s_b2 &&
address.S_un.S_un_b.s_b2 <= addr_end.S_un.S_un_b.s_b2 &&
addr_start.S_un.S_un_b.s_b3 <= address.S_un.S_un_b.s_b3 &&
address.S_un.S_un_b.s_b3 <= addr_end.S_un.S_un_b.s_b3 &&
addr_start.S_un.S_un_b.s_b3 <= address.S_un.S_un_b.s_b3 &&
address.S_un.S_un_b.s_b3 <= addr_end.S_un.S_un_b.s_b3)
{
return true;
}
}
return false;
}
void CBillingTestModuleDlg::OnTimer(UINT nIDEvent)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
if(nIDEvent == ID_PROCESS_PACKET_TIMER)
{
theApp.ProcessPacket();
size_t nSocketNum = theApp.GetConnectedSocketNum();
if(m_nSocketNum != nSocketNum)
{
CString windowName;
windowName.Format("BillingTestModule : Port(%u) - %d Connection now.",
CBillingTestModuleApp::LISTEN_PORT, nSocketNum);
SetWindowText(windowName);
m_nSocketNum = nSocketNum;
}
}
CDialog::OnTimer(nIDEvent);
}
void CBillingTestModuleDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
KillTimer(ID_PROCESS_PACKET_TIMER);
theApp.ResetMainDlg(*this);
}
void CBillingTestModuleDlg::OnCbnSelchangeLoginAckType()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(DELAY_ALL_PROCESS != GetLoginAckType())
{
m_LoginAckDelayDlg.SetReadOnly();
}
else
{
m_LoginAckDelayDlg.SetReadOnly(false);
}
}
void CBillingTestModuleDlg::OnCbnSelchangeBillAuthAckType()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(DELAY_ALL_PROCESS != GetBillAuthAckType())
{
m_BillAuthAckDelayDlg.SetReadOnly();
}
else
{
m_BillAuthAckDelayDlg.SetReadOnly(false);
}
}

View File

@@ -0,0 +1,111 @@
// BillingTestModuleDlg.h : 헤더 파일
//
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include <winsock2.h>
#include <list>
#include <utility>
#include "BillingAsyncSocket.h"
// forward decl.
class CBillingAsyncSocket;
enum DlgLogType
{
NORMAL_LOG,
ERROR_LOG
};
// CBillingTestModuleDlg 대화 상자
class CBillingTestModuleDlg : public CDialog
{
// 생성
public:
CBillingTestModuleDlg(CWnd* pParent = NULL); // 표준 생성자
// 대화 상자 데이터
enum { IDD = IDD_BILLINGTESTMODULE_DIALOG };
enum Behavior
{
NORMAL_PROCESS = 0,
SUCCESS_ALL_PROCESS = 1,
FAIL_ALL_PROCESS = 2,
DELAY_ALL_PROCESS = 3,
DROP_ALL_PROCESS = 4
};
protected:
HICON m_hIcon;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원
virtual void OnOK();
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
private:
void AddAddress(in_addr addressStart, in_addr addressEnd);
void SaveAddress();
void LoadAddress();
int FindCurrentUserPos(const char* szID, const char* szIP);
bool CheckIPList(const char* szIP);
CListCtrl m_ctrlCurrentUserList;
CListCtrl m_ctrlLoginIPList;
CListCtrl m_BillingLog;
CIPAddressCtrl m_StartIP;
CIPAddressCtrl m_EndIP;
CComboBox m_LoginAckType;
CComboBox m_BillAuthAckType;
DWORD m_LoginAckDelay;
DWORD m_BillAuthAckDelay;
CEdit m_LoginAckDelayDlg;
CEdit m_BillAuthAckDelayDlg;
size_t m_nSocketNum;
public:
void AddLog(DlgLogType eLogType, const TCHAR* szFormat, ...);
bool Login(CBillingAsyncSocket& billingAsyncSocket, unsigned long dwSeqID, const char* szID, const char* szIP);
bool Logout(CBillingAsyncSocket& billingAsyncSocket, unsigned long dwSeqID, const char* szID, const char* szIP);
bool BillAuth(CBillingAsyncSocket& billingAsyncSocket, unsigned long dwSeqID, const char* szID, const char* szIP);
Behavior GetLoginAckType() { return static_cast<Behavior>(m_LoginAckType.GetCurSel()); }
Behavior GetBillAuthAckType() { return static_cast<Behavior>(m_BillAuthAckType.GetCurSel()); }
DWORD GetLoginAckDelay() { UpdateData(true); return m_LoginAckDelay; }
DWORD GetBillAuthAckDelay() { UpdateData(true); return m_BillAuthAckDelay; }
afx_msg void OnDisconnectUser();
afx_msg void OnSendMsgUser();
afx_msg void OnIpDelete();
afx_msg void OnBnClickedIPAdd();
afx_msg void OnBnClickedSaveLog();
afx_msg void OnBnClickedClearLog();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
afx_msg void OnCbnSelchangeLoginAckType();
afx_msg void OnCbnSelchangeBillAuthAckType();
};

View File

@@ -0,0 +1,41 @@
#ifndef _HAN_UNITED_BILLING_PACKET_STRUCT_
#define _HAN_UNITED_BILLING_PACKET_STRUCT_
/********** LK->UID,UID->LK 송수신용 구조체 *************************/
namespace HanUnitedBilling
{
#pragma pack(1)
struct GLTransStruct
{
unsigned short DataSize; // Data 의 전체길이
unsigned short HeaderMsg; // 헤더명령메세지부분부분
unsigned long SeqID;
char Data[120]; //Data
};
#pragma pack()
//LK->UID , UID->LK 메세지
enum CMD
{
AUTH = 4000, // UID -> LK
LOGOUT = 4001, // UID -> LK
CUT_IP = 4002, // LK -> UID
WARNNOTICE = 4003, // LK -> UID
BILL_AUTH = 4004, // UID -> LK
AUTH_RESULT = 4005, // LK -> UID
BILL_AUTH_RESULT = 4006 // LK -> UID
};
enum LENGTH
{
MAX_IP_LEN = 17,
MAX_ID_LEN = 25,
MAX_OUT_TIME_LEN = 18,
MAX_MSG_LEN = 70
};
};
#endif

View File

@@ -0,0 +1,77 @@
================================================================================
MFC 라이브러리 : BillingTestModule 프로젝트 개요
================================================================================
응용 프로그램 마법사를 사용하여 BillingTestModule 응용 프로그램을 만듭니다. 이 응용
프로그램에서는 기본적인 MFC 사용 밥법과 응용 프로그램 작성 방법을 설명합니다.
이 파일에는 BillingTestModule 응용 프로그램을 구성하는 각 파일에 대한 개요가 포함되어
있습니다.
BillingTestModule.vcproj
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 주 프로젝트 파일입니다.
이 파일에는 파일을 생성한 Visual C++ 버전 정보 및 응용 프로그램 마법사에서 선택한 플랫폼,
구성, 프로젝트 기능 등의 정보가 포함됩니다.
BillingTestModule.h
응용 프로그램의 주 헤더 파일입니다. 이 파일에는 다른 프로젝트에 관련된 Resource.h와 같은
특정 헤더가 포함되며 CBillingTestModuleApp 응용 프로그램 클래스가 선언됩니다.
BillingTestModule.cpp
CBillingTestModuleApp 응용 프로그램 클래스를 포함하는 주 응용 프로그램의 소스 파일입니다.
BillingTestModule.rc
프로그램에서 사용하는 모든 Microsoft Windows 리소스가 나열된 파일입니다.
이 파일에는 RES 하위 디렉터리에 저장된 아이콘, 비트맵 및 커서가 포함되며
Microsoft Visual C++에서 직접 이 파일을 편집할 수도 있습니다. 사용자의 프로젝트
리소스는 1042에 들어 있습니다.
res\BillingTestModule.ico
응용 프로그램의 아이콘으로 사용되는 아이콘 파일입니다.
이 아이콘은 주 리소스 파일인 BillingTestModule.rc에 포함됩니다.
res\BillingTestModule.rc2
Microsoft Visual C++에서 편집할 수 없는 리소스가 포함된 파일입니다.
리소스 편집기에서 편집할 수 없는 모든 리소스는 이 파일에 포함되어 있습니다.
/////////////////////////////////////////////////////////////////////////////
응용 프로그램 마법사에서는 단일 대화 상자 클래스를 만듭니다.
BillingTestModuleDlg.h, BillingTestModuleDlg.cpp - 대화 상자
CBillingTestModuleDlg 클래스를 포함하는 파일입니다. 이 클래스에는 응용 프로그램의
주 대화 상자에 대한 동작이 정의됩니다. 대화 상자의 템플릿은 BillingTestModule.rc에
있으며 Microsoft Visual C++에서 편집할 수 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 기능
ActiveX 컨트롤
응용 프로그램에서 ActiveX 컨트롤을 사용할 수 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일
StdAfx.h, StdAfx.cpp
미리 컴파일된 헤더 파일(PCH) BillingTestModule.pch 및 미리 컴파일된
형식 파일 StdAfx.obj를 빌드할 때 사용되는 파일입니다.
Resource.h
새로운 리소스 ID를 정의하는 표준 헤더 파일입니다.
Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다.
/////////////////////////////////////////////////////////////////////////////
기타 정보
응용 프로그램 마법사에서는 "TODO:"를 사용하여 추가하거나 사용자 지정해야 하는
소스 코드를 나타냅니다.
응용 프로그램에서 공유 DLL에 MFC를 사용하고 응용 프로그램의 언어가 운영 체제의
언어와 다른 경우 Microsoft Visual C++ CD-ROM의 Win\System 디렉터리에 있는
해당 지역의 리소스인 MFC70XXX.DLL을 컴퓨터의 system 또는 system32 디렉터리에
복사한 다음 MFCLOC.DLL로 이름을 바꾸어야 합니다. "XXX"는 해당 언어를 나타내는
약어입니다. 예를 들어 MFC70DEU.DLL에는 독일어로 변환된 리소스가 포함됩니다.
이런 작업을 하지 않으면 응용 프로그램의 일부 UI 요소가 운영 체제의 언어로
남아 있게 됩니다.
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Microsoft.Windows.BillingTestModule"
type="win32"
/>
<description>여기에 응용 프로그램 설명을 추가합니다.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@@ -0,0 +1,13 @@
//
// BillingTestModule.RC2 - resources Microsoft Visual C++에서 직접 편집하지 않는 리소스
//
#ifdef APSTUDIO_INVOKED
#error 이 파일은 Microsoft Visual C++에서 편집할 수 없습니다.
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// 여기에 수동으로 편집한 리소스를 추가합니다.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,37 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by BillingTestModule.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_BILLINGTESTMODULE_DIALOG 102
#define IDR_MAINFRAME 128
#define IDR_CONTEXT_MENU 129
#define IDC_CURRENT_USER_LIST 1000
#define IDC_LOGIN_IP_LIST 1001
#define IDC_IP_START 1003
#define IDC_IP_END 1004
#define IDC_IP_ADD 1005
#define IDC_LOGIN_ACK_TYPE 1006
#define IDC_LOGIN_ACK_DELAY 1007
#define IDC_BILL_AUTH_ACK_TYPE 1008
#define IDC_BILL_AUTH_ACK_DELAY 1009
#define IDC_BUTTON1 1010
#define IDC_SAVELOG 1010
#define IDC_LOG_LIST 1012
#define IDC_CLEARLOG 1013
#define ID_DISCONNECT_USER 32774
#define ID_SEND_MSG_USER 32775
#define ID_IP_DELETE 32776
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32777
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,7 @@
// stdafx.cpp : 표준 포함 파일을 포함하는 소스 파일입니다.
// BillingTestModule.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj는 미리 컴파일된 형식 정보를 포함합니다.
#include "stdafx.h"

View File

@@ -0,0 +1,43 @@
// stdafx.h : 잘 변경되지 않고 자주 사용하는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Windows 헤더에서 거의 사용되지 않는 내용을 제외시킵니다.
#endif
// 아래 지정된 플랫폼보다 우선하는 플랫폼을 대상으로 하는 경우 다음 정의를 수정하십시오.
// 다른 플랫폼에 사용되는 해당 값의 최신 정보는 MSDN을 참조하십시오.
#ifndef WINVER // Windows 95 및 Windows NT 4 이후 버전에서만 기능을 사용할 수 있습니다.
#define WINVER 0x0400 // Windows 98과 Windows 2000 이후 버전에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINNT // Windows NT 4 이후 버전에서만 기능을 사용할 수 있습니다.
#define _WIN32_WINNT 0x0400 // Windows 98과 Windows 2000 이후 버전에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINDOWS // Windows 98 이후 버전에서만 기능을 사용할 수 있습니다.
#define _WIN32_WINDOWS 0x0410 // Windows Me 이후 버전에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_IE // IE 4.0 이후 버전에서만 기능을 사용할 수 있습니다.
#define _WIN32_IE 0x0400 // IE 5.0 이후 버전에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 일부 CString 생성자는 명시적으로 선언됩니다.
// MFC의 공통 부분과 무시 가능한 경고 메시지에 대한 숨기기를 해제합니다.
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC 핵심 및 표준 구성 요소
#include <afxext.h> // MFC 익스텐션
#include <afxdisp.h> // MFC 자동화 클래스
#include <afxdtctl.h> // Internet Explorer 4 공용 컨트롤에 대한 MFC 지원
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // Windows 공용 컨트롤에 대한 MFC 지원
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h>