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:
57
Server/UserStatistics/StatServer/StatisticsDB.cpp
Normal file
57
Server/UserStatistics/StatServer/StatisticsDB.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "stdafx.h"
|
||||
#include "StatServer.h"
|
||||
#include "StatisticsDB.h"
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
#include <DB/OLEDB.h>
|
||||
|
||||
|
||||
const TCHAR* g_szFileName = _T("./StatServerSetup.ini");
|
||||
|
||||
|
||||
CStatisticsDB& CStatisticsDB::GetInstance()
|
||||
{
|
||||
static CStatisticsDB statisticsDB;
|
||||
return statisticsDB;
|
||||
}
|
||||
|
||||
CStatisticsDB::CStatisticsDB()
|
||||
: m_lpOleDB(new (std::nothrow) OleDB)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CStatisticsDB::~CStatisticsDB()
|
||||
{
|
||||
if(0 != m_lpOleDB)
|
||||
{
|
||||
delete m_lpOleDB;
|
||||
m_lpOleDB = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool CStatisticsDB::ConnectStatDB()
|
||||
{
|
||||
if(0 == m_lpOleDB)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = 256;
|
||||
char szDBIP[MAX_BUFFER], szDBName[MAX_BUFFER], szDBAccount[MAX_BUFFER], szDBPass[MAX_BUFFER];
|
||||
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_IP", 0, szDBIP, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_NAME", 0, szDBName, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_ACCOUNT", 0, szDBAccount, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_PASS", 0, szDBPass, MAX_BUFFER, g_szFileName);
|
||||
|
||||
if(!m_lpOleDB->ConnectSQLServer(szDBIP, szDBName, szDBAccount, szDBPass, OleDB::ConnType_MSSQL))
|
||||
{
|
||||
ERRLOG4(g_Log, "StatDB Connection Failed: %s/%s/%s/%s", szDBIP, szDBName, szDBAccount, szDBPass);
|
||||
return false;
|
||||
}
|
||||
|
||||
INFLOG0(g_Log, "StatDB Connection Success");
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user