540 lines
14 KiB
C++
540 lines
14 KiB
C++
|
|
// ServiceManagerEx.cpp : <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
#include "stdafx.h"
|
|||
|
|
#include "ServiceManagerEx.h"
|
|||
|
|
#include "MainFrm.h"
|
|||
|
|
#include "ServiceManagerExDoc.h"
|
|||
|
|
#include "ServiceManagerExView.h"
|
|||
|
|
|
|||
|
|
#include "ServiceServer.h"
|
|||
|
|
#include "Log.h"
|
|||
|
|
#include "DataManager.h"
|
|||
|
|
#include "DNBAM.h"
|
|||
|
|
#include "IniFile.h"
|
|||
|
|
#include "Version.h"
|
|||
|
|
|
|||
|
|
#include "MainSplit.h"
|
|||
|
|
#include "LogViewDisplayer.h"
|
|||
|
|
#include "LogBuilder.h"
|
|||
|
|
#include "LogSplit.h"
|
|||
|
|
#include "Scheduler.h"
|
|||
|
|
#include "ServerReporter.h"
|
|||
|
|
#include <sstream>
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#define new DEBUG_NEW
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
extern TServiceManagerConfig g_Config;
|
|||
|
|
extern CServiceServer * g_pServiceServer;
|
|||
|
|
|
|||
|
|
extern CLog g_Log;
|
|||
|
|
extern CLog s_CountLog;
|
|||
|
|
extern CLog g_ExceptionReportLog;
|
|||
|
|
extern CLog g_DBDelayLog;
|
|||
|
|
extern CLog s_ExcuteLog;
|
|||
|
|
extern CLog g_GameDelayLog;
|
|||
|
|
extern CLog g_VillageDelayLog;
|
|||
|
|
extern CLog g_DBErrorLog;
|
|||
|
|
extern CLog g_DBSystemErrorLog;
|
|||
|
|
extern CLog g_MonitorLog;
|
|||
|
|
extern CLog g_FileLog;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> CAboutDlg <20><>ȭ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
class CAboutDlg : public CDialog
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CAboutDlg();
|
|||
|
|
|
|||
|
|
// <20><>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
enum { IDD = IDD_ABOUTBOX };
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
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()
|
|||
|
|
|
|||
|
|
// CServiceManagerExApp
|
|||
|
|
|
|||
|
|
BEGIN_MESSAGE_MAP(CServiceManagerExApp, CWinApp)
|
|||
|
|
ON_COMMAND(ID_APP_ABOUT, &CServiceManagerExApp::OnAppAbout)
|
|||
|
|
// ǥ<><C7A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ʷ<EFBFBD> <20>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
|
|||
|
|
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
|
|||
|
|
// ǥ<><C7A5> <20>μ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
|
|||
|
|
END_MESSAGE_MAP()
|
|||
|
|
|
|||
|
|
// CServiceManagerExApp <20><><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
CServiceManagerExApp::CServiceManagerExApp()
|
|||
|
|
: m_pLogDisplayer(NULL), m_hMutex(NULL)
|
|||
|
|
{
|
|||
|
|
// TODO: <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ڵ带 <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
|||
|
|
// InitInstance<63><65> <20><><EFBFBD><EFBFBD> <20>߿<EFBFBD><DFBF><EFBFBD> <20>ʱ<EFBFBD>ȭ <20>۾<EFBFBD><DBBE><EFBFBD> <20><>ġ<EFBFBD>մϴ<D5B4>.
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CServiceManagerExApp::~CServiceManagerExApp()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CServiceManagerExApp <20><>ü<EFBFBD>Դϴ<D4B4>.
|
|||
|
|
|
|||
|
|
CServiceManagerExApp theApp;
|
|||
|
|
|
|||
|
|
int CServiceManagerExApp::ExitInstance(){
|
|||
|
|
//<2F>α<EFBFBD> <20><><EFBFBD>º<EFBFBD><C2BA><EFBFBD> <20>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
g_Log.SetDisplayer(NULL);
|
|||
|
|
|
|||
|
|
m_GSMServer.Close();
|
|||
|
|
if(g_pServiceServer)
|
|||
|
|
g_pServiceServer->Close();
|
|||
|
|
|
|||
|
|
SAFE_DELETE(g_pServiceServer);
|
|||
|
|
SAFE_DELETE(m_pLogDisplayer);
|
|||
|
|
|
|||
|
|
m_Scheduler.Clear();
|
|||
|
|
m_ConfigEx.Reset();
|
|||
|
|
::ReleaseMutex(m_hMutex);
|
|||
|
|
return CWinApp::ExitInstance();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// CServiceManagerExApp <20>ʱ<EFBFBD>ȭ
|
|||
|
|
BOOL CServiceManagerExApp::InitInstance()
|
|||
|
|
{
|
|||
|
|
m_hMutex = ::CreateMutex(NULL, TRUE, L"ServiceManagerEx");
|
|||
|
|
if (::GetLastError() == ERROR_ALREADY_EXISTS)
|
|||
|
|
{
|
|||
|
|
::AfxMessageBox(L"ServiceManagerEx is already running.");
|
|||
|
|
return FALSE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SetMiniDump();
|
|||
|
|
LoadConfigEx();
|
|||
|
|
CLogBuilder::Initialize();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20>Ŵ<EFBFBD><C5B4>佺Ʈ<E4BDBA><C6AE> ComCtl32.dll <20><><EFBFBD><EFBFBD> 6 <20>̻<EFBFBD><CCBB><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD>־<EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD>, Windows XP <20><EFBFBD> <20>ݵ<EFBFBD><DDB5><EFBFBD> InitCommonControlsEx()<29><> <20>ʿ<EFBFBD><CABF>մϴ<D5B4>.
|
|||
|
|
// InitCommonControlsEx()<29><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> â<><C3A2> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
|||
|
|
INITCOMMONCONTROLSEX InitCtrls;
|
|||
|
|
InitCtrls.dwSize = sizeof(InitCtrls);
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>
|
|||
|
|
// <20><> <20><EFBFBD><D7B8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͻʽÿ<CABD>.
|
|||
|
|
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
|||
|
|
InitCommonControlsEx(&InitCtrls);
|
|||
|
|
|
|||
|
|
CWinApp::InitInstance();
|
|||
|
|
|
|||
|
|
// OLE <20><><EFBFBD>̺귯<CCBA><EAB7AF><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ<EFBFBD>մϴ<D5B4>.
|
|||
|
|
if (!AfxOleInit())
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(IDP_OLE_INIT_FAILED);
|
|||
|
|
return FALSE;
|
|||
|
|
}
|
|||
|
|
AfxEnableControlContainer();
|
|||
|
|
// ǥ<><C7A5> <20>ʱ<EFBFBD>ȭ
|
|||
|
|
// <20>̵<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<>⸦ <20><><EFBFBD>̷<EFBFBD><CCB7><EFBFBD>
|
|||
|
|
// <20>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD> <20>ʿ<EFBFBD> <20><><EFBFBD><EFBFBD> Ư<><C6AF> <20>ʱ<EFBFBD>ȭ
|
|||
|
|
// <20><>ƾ<EFBFBD><C6BE> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>մϴ<D5B4>.
|
|||
|
|
// <20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD>Ͻʽÿ<CABD>.
|
|||
|
|
// TODO: <20><> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> ȸ<><C8B8> <20>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>մϴ<D5B4>.
|
|||
|
|
SetRegistryKey(_T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1>"));
|
|||
|
|
LoadStdProfileSettings(4); // MRU<52><55> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> ǥ<><C7A5> INI <20><><EFBFBD><EFBFBD> <20>ɼ<EFBFBD><C9BC><EFBFBD> <20>ε<EFBFBD><CEB5>մϴ<D5B4>.
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> â <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>մϴ<D5B4>.
|
|||
|
|
CSingleDocTemplate* pDocTemplate;
|
|||
|
|
pDocTemplate = new CSingleDocTemplate(
|
|||
|
|
IDR_MAINFRAME,
|
|||
|
|
RUNTIME_CLASS(CServiceManagerExDoc),
|
|||
|
|
RUNTIME_CLASS(CMainFrame), // <20><> SDI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> â<>Դϴ<D4B4>.
|
|||
|
|
RUNTIME_CLASS(CServiceManagerExView));
|
|||
|
|
if (!pDocTemplate)
|
|||
|
|
return FALSE;
|
|||
|
|
AddDocTemplate(pDocTemplate);
|
|||
|
|
|
|||
|
|
// ǥ<><C7A5> <20><> <20><><EFBFBD><EFBFBD>, DDE, <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>м<EFBFBD><D0BC>մϴ<D5B4>.
|
|||
|
|
CCommandLineInfo cmdInfo;
|
|||
|
|
ParseCommandLine(cmdInfo);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ٿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>մϴ<D5B4>.
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> /RegServer, /Register, /Unregserver <20>Ǵ<EFBFBD> /Unregister<65><72> <20><><EFBFBD>۵<EFBFBD> <20><><EFBFBD><EFBFBD> FALSE<53><45> <20><>ȯ<EFBFBD>մϴ<D5B4>.
|
|||
|
|
if (!ProcessShellCommand(cmdInfo))
|
|||
|
|
return FALSE;
|
|||
|
|
|
|||
|
|
if (!InitServiceManager())
|
|||
|
|
return FALSE;
|
|||
|
|
|
|||
|
|
Sleep(1000);
|
|||
|
|
|
|||
|
|
if (!CreateDisplayer())
|
|||
|
|
return FALSE;
|
|||
|
|
|
|||
|
|
BuildSchedule();
|
|||
|
|
|
|||
|
|
BuildView();
|
|||
|
|
RefreshStateView();
|
|||
|
|
|
|||
|
|
// â <20>ϳ<EFBFBD><CFB3><EFBFBD> <20>ʱ<EFBFBD>ȭ<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20≯<EFBFBD> ǥ<><C7A5><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD>մϴ<D5B4>.
|
|||
|
|
m_pMainWnd->SetWindowTextW(L"ServiceManagerEx");
|
|||
|
|
m_pMainWnd->ShowWindow(SW_SHOW);
|
|||
|
|
m_pMainWnd->UpdateWindow();
|
|||
|
|
// <20><><EFBFBD>̻簡 <20><><EFBFBD><EFBFBD> <20><><EFBFBD>쿡<EFBFBD><ECBFA1> DragAcceptFiles<65><73> ȣ<><C8A3><EFBFBD>մϴ<D5B4>.
|
|||
|
|
// SDI <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ProcessShellCommand <20>Ŀ<EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><EFBFBD><DFBB>ؾ<EFBFBD> <20>մϴ<D5B4>.
|
|||
|
|
|
|||
|
|
return TRUE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::LoadConfig()
|
|||
|
|
{
|
|||
|
|
wstring wszFileName = L"./Config/DNServiceManager.ini"; // <20>ѱ<EFBFBD>
|
|||
|
|
if (!g_IniFile.Open(wszFileName.c_str())){
|
|||
|
|
g_Log.Log(LogType::_FILELOG, L"%s File not Found!!\n", wszFileName.c_str());
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
memset(&g_Config, 0, sizeof(TServiceManagerConfig));
|
|||
|
|
|
|||
|
|
g_IniFile.GetValue(L"Region", L"RegionInfo", g_Config.wszRegion);
|
|||
|
|
|
|||
|
|
g_IniFile.GetValue(L"Connection", L"NetLauncherPort", &g_Config.nLauncherPort);
|
|||
|
|
g_IniFile.GetValue(L"Connection", L"ServicePort", &g_Config.nServicePort);
|
|||
|
|
g_IniFile.GetValue(L"Connection", L"ServicePatcherPort", &g_Config.nServicePatcherPort);
|
|||
|
|
g_IniFile.GetValue(L"Connection", L"GSMPort", &g_Config.nGSMPort);
|
|||
|
|
g_IniFile.GetValue(L"Connection", L"MonitorPort", &g_Config.nMonitorPort);
|
|||
|
|
|
|||
|
|
g_IniFile.GetValue(L"GSMInfo", L"IP", g_Config.wszGSMIP, IPLENMAX);
|
|||
|
|
g_IniFile.GetValue(L"GSMInfo", L"CodePage", g_Config.wszGSMCodePage);
|
|||
|
|
g_IniFile.GetValue(L"PatchInfo", L"BaseUrl", g_Config.wszPatchBaseURL);
|
|||
|
|
g_IniFile.GetValue(L"PatchInfo", L"PatchUrl", g_Config.wszPatchURL);
|
|||
|
|
g_IniFile.GetValue(L"PatchInfo", L"PatchDir", g_Config.wszPatchDir);
|
|||
|
|
g_IniFile.GetValue(L"ReserveNoticeInfo", L"FileName", g_Config.wszNoticePath);
|
|||
|
|
strcpy_s(g_Config.szVersion, szServiceManagerVersion);
|
|||
|
|
|
|||
|
|
g_Log.Log(LogType::_FILELOG, L"## LauncherPort:%d, ServicePort:%d GsmPort:%d ESMPort:%d MonitorPort:%d\r\n", g_Config.nLauncherPort, g_Config.nServicePort, g_Config.nGSMPort, g_Config.nServicePatcherPort, g_Config.nMonitorPort);
|
|||
|
|
g_Log.Log(LogType::_FILELOG, L"## ServiceManager Version : %S\r\n", szServiceManagerVersion);
|
|||
|
|
if (_access("./System", 0) == -1)
|
|||
|
|
{
|
|||
|
|
mkdir("./System");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::LoadConfigEx()
|
|||
|
|
{
|
|||
|
|
m_ConfigEx.SetDefault();
|
|||
|
|
m_ConfigEx.LoadConfig();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::ReloadConfigEx()
|
|||
|
|
{
|
|||
|
|
LoadConfigEx();
|
|||
|
|
ClearSchedule();
|
|||
|
|
BuildSchedule();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::CreateDisplayer()
|
|||
|
|
{
|
|||
|
|
CLogSplit& logSplit = ((CMainFrame*)GetMainWnd())->GetLogSplit();
|
|||
|
|
m_pLogDisplayer = new CLogViewDisplayer(&logSplit);
|
|||
|
|
g_Log.SetDisplayer(m_pLogDisplayer);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::InitServiceManager()
|
|||
|
|
{
|
|||
|
|
//SetMiniDump();
|
|||
|
|
|
|||
|
|
//ASSERT(m_pLogDisplayer);
|
|||
|
|
g_Log.Init(L"ServiceManager", LOGTYPE_CRT_FILE_DAY);
|
|||
|
|
s_CountLog.Init(L"LogCount", LOGTYPE_FILE_DAY);
|
|||
|
|
g_ExceptionReportLog.Init(L"ExceptionReport", LOGTYPE_FILE_DAY);
|
|||
|
|
g_DBDelayLog.Init(L"DBDelay", LOGTYPE_FILE_DAY);
|
|||
|
|
s_ExcuteLog.Init(L"Excute", LOGTYPE_FILE_DAY);
|
|||
|
|
g_GameDelayLog.Init(L"GameDelay", LOGTYPE_FILE_DAY);
|
|||
|
|
g_VillageDelayLog.Init(L"VillageDelay", LOGTYPE_FILE_DAY);
|
|||
|
|
g_DBErrorLog.Init(L"DBError", LOGTYPE_FILE_DAY);
|
|||
|
|
g_DBSystemErrorLog.Init(L"DBSystemError", LOGTYPE_FILE_DAY);
|
|||
|
|
g_MonitorLog.Init(L"MonitorLog", LOGTYPE_FILE_DAY);
|
|||
|
|
g_FileLog.Init(L"ServiceManager", LOGTYPE_FILE_DAY);
|
|||
|
|
|
|||
|
|
if (LoadConfig() == false)
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
int nSocketCount = 1000;
|
|||
|
|
if (!_wcsicmp(g_Config.wszRegion, L"KR") || !_wcsicmp(g_Config.wszRegion, L"KOR") || !_wcsicmp(g_Config.wszRegion, L"DEV"))
|
|||
|
|
setlocale(LC_ALL, "Korean");
|
|||
|
|
else if (!_wcsicmp(g_Config.wszRegion, L"CH") || !_wcsicmp(g_Config.wszRegion, L"CHN"))
|
|||
|
|
{
|
|||
|
|
setlocale(LC_ALL, "chinese-simplified");
|
|||
|
|
nSocketCount = 3000;
|
|||
|
|
}
|
|||
|
|
else if (!_wcsicmp(g_Config.wszRegion, L"JP") || !_wcsicmp(g_Config.wszRegion, L"JPN"))
|
|||
|
|
setlocale(LC_ALL, "japanese");
|
|||
|
|
else if (!_wcsicmp(g_Config.wszRegion, L"US") || !_wcsicmp(g_Config.wszRegion, L"USA"))
|
|||
|
|
setlocale(LC_ALL, "us");
|
|||
|
|
|
|||
|
|
//#if defined(_KR)
|
|||
|
|
// g_pBAM = new CDNBAM;
|
|||
|
|
// if (!g_pBAM) return;
|
|||
|
|
//#endif // #if defined(_KR)
|
|||
|
|
|
|||
|
|
#ifdef _UNICODE
|
|||
|
|
g_pServiceManager = new CServiceManager(this);
|
|||
|
|
#else
|
|||
|
|
char szIP[IPLENMAX], szCode[256];
|
|||
|
|
WideCharToMultiByte(CP_ACP, 0, g_Config.wszGSMIP, -1, szIP, IPLENMAX, NULL, NULL);
|
|||
|
|
WideCharToMultiByte(CP_ACP, 0, g_Config.wszGSMCodePage, -1, szCode, IPLENMAX, NULL, NULL);
|
|||
|
|
|
|||
|
|
g_pServiceManager = new CServiceManager(szIP, szCode);
|
|||
|
|
#endif
|
|||
|
|
if (!g_pServiceManager)
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
//g_pServiceManager->InitializeCommand();
|
|||
|
|
|
|||
|
|
g_pServiceServer = new CServiceServer();
|
|||
|
|
if (!g_pServiceServer)
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
if (!g_pServiceServer->Initialize(nSocketCount, g_Config.nLauncherPort, g_Config.nServicePort, g_Config.nServicePatcherPort, g_Config.nMonitorPort))
|
|||
|
|
{
|
|||
|
|
ErrorMessage(L"Service server initialize failed.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!m_GSMServer.Open(g_Config.nGSMPort))
|
|||
|
|
{
|
|||
|
|
ErrorMessage(L"Already used GSM port. Program will exit.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::BuildView()
|
|||
|
|
{
|
|||
|
|
((CMainFrame*)GetMainWnd())->BuildView();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::RefreshView()
|
|||
|
|
{
|
|||
|
|
((CMainFrame*)GetMainWnd())->RefreshView();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::RefreshStateView()
|
|||
|
|
{
|
|||
|
|
((CMainFrame*)GetMainWnd())->RefreshStateView();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BOOL CServiceManagerExApp::OnIdle(LONG lCount)
|
|||
|
|
{
|
|||
|
|
m_Scheduler.Update();
|
|||
|
|
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.Update();
|
|||
|
|
|
|||
|
|
::Sleep(1);
|
|||
|
|
|
|||
|
|
return TRUE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnPatchStart()
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnPatchStart();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnPatchProgress(int id, const wchar_t* key, unsigned long progress, unsigned long progressMax)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnPatchProgress(id, key, progress, progressMax);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnPatchEnd(bool succeeded)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnPatchEnd(succeeded);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnUnzipProgress(int id, const wchar_t* filename, unsigned long progress, unsigned long progressMax)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnUnzipProgress(id, filename, progress, progressMax);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnWorldMaxUser(int id, int maxUser)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnWorldMaxUser(id, maxUser);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::OnPatchFail(int id, const wchar_t* msg)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnPatchFail(id, msg);
|
|||
|
|
}
|
|||
|
|
void CServiceManagerExApp::OnPatchCompleted(int id)
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnPatchCompleted(id);
|
|||
|
|
}
|
|||
|
|
void CServiceManagerExApp::OnCommandPatch()
|
|||
|
|
{
|
|||
|
|
CMainSplit& mainSplit = ((CMainFrame*)GetMainWnd())->GetMainSplit();
|
|||
|
|
mainSplit.OnCommandPatch();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȭ <20><><EFBFBD>ڸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
|||
|
|
void CServiceManagerExApp::OnAppAbout()
|
|||
|
|
{
|
|||
|
|
CAboutDlg aboutDlg;
|
|||
|
|
aboutDlg.DoModal();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BOOL CServiceManagerExApp::PreTranslateMessage(MSG* pMsg)
|
|||
|
|
{
|
|||
|
|
// TODO: <20><><EFBFBD> Ư<><C6AF>ȭ<EFBFBD><C8AD> <20>ڵ带 <20>߰<EFBFBD> <20><>/<2F>Ǵ<EFBFBD> <20>⺻ Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD>մϴ<D5B4>.
|
|||
|
|
|
|||
|
|
return CWinApp::PreTranslateMessage(pMsg);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::ReportExceptionToClipboard()
|
|||
|
|
{
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Starting report build to clipboard.\n");
|
|||
|
|
|
|||
|
|
ServerReport::CServerReporter reporter;
|
|||
|
|
|
|||
|
|
wstring report;
|
|||
|
|
reporter.Report(m_ConfigEx.serverReportDays, m_ConfigEx.serverReportDetail, report);
|
|||
|
|
|
|||
|
|
if (!SaveToClipboard(report))
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Copy to Clipboard completed.\n");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::ReportExceptionToBuffer(size_t days, OUT wstring& buffer)
|
|||
|
|
{
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Starting report build to buffer.\n");
|
|||
|
|
|
|||
|
|
ServerReport::CServerReporter reporter;
|
|||
|
|
reporter.Report(days, m_ConfigEx.serverReportDetail, buffer);
|
|||
|
|
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Buffer set completed.\n");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::ReportExceptionToFile(const wstring& filename)
|
|||
|
|
{
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Starting report build to file.\n");
|
|||
|
|
|
|||
|
|
ServerReport::CServerReporter reporter;
|
|||
|
|
|
|||
|
|
wstring report;
|
|||
|
|
reporter.Report(m_ConfigEx.serverReportDays, m_ConfigEx.serverReportDetail, report);
|
|||
|
|
|
|||
|
|
HANDLE file = 0;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
file = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|||
|
|
if (file == INVALID_HANDLE_VALUE)
|
|||
|
|
throw;
|
|||
|
|
|
|||
|
|
DWORD written_size;
|
|||
|
|
if (!WriteFile(file, report.c_str(), (DWORD)report.size(), &written_size, NULL))
|
|||
|
|
throw;
|
|||
|
|
|
|||
|
|
CloseHandle(file);
|
|||
|
|
}
|
|||
|
|
catch (...)
|
|||
|
|
{
|
|||
|
|
CloseHandle(file);
|
|||
|
|
g_Log.Log(LogType::_ERROR, L"Copy to file failed.\n");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
g_Log.Log(LogType::_NORMAL, L"Copy to file completed.\n");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CServiceManagerExApp::SaveToClipboard(const wstring& report)
|
|||
|
|
{
|
|||
|
|
if (!OpenClipboard(NULL))
|
|||
|
|
{
|
|||
|
|
g_Log.Log(LogType::_ERROR, L"Copy to Clipboard failed. (open)\n");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!EmptyClipboard())
|
|||
|
|
{
|
|||
|
|
g_Log.Log(LogType::_ERROR, L"Copy to Clipboard failed. (empty)\n");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
size_t size = report.length() * sizeof(wchar_t);
|
|||
|
|
|
|||
|
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, size + sizeof(wchar_t));
|
|||
|
|
if (!hMem)
|
|||
|
|
{
|
|||
|
|
CloseClipboard();
|
|||
|
|
g_Log.Log(LogType::_ERROR, L"Copy to Clipboard failed. (alloc)\n");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
wchar_t* pBuf = (wchar_t*)GlobalLock(hMem);
|
|||
|
|
::memcpy(pBuf, report.c_str(), size);
|
|||
|
|
GlobalUnlock(hMem);
|
|||
|
|
|
|||
|
|
if (!::SetClipboardData(CF_UNICODETEXT, hMem))
|
|||
|
|
{
|
|||
|
|
GlobalFree(hMem);
|
|||
|
|
CloseClipboard();
|
|||
|
|
g_Log.Log(LogType::_ERROR, L"Copy to Clipboard failed. (set)\n");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GlobalFree(hMem);
|
|||
|
|
CloseClipboard();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::BuildSchedule()
|
|||
|
|
{
|
|||
|
|
CTime curTime = CTime::GetCurrentTime();
|
|||
|
|
|
|||
|
|
for each (const ScheduleJob* pScheduleJob in m_ConfigEx.schedules)
|
|||
|
|
{
|
|||
|
|
SimpleScheduler::CScheduleObj* pScheduleObj = SimpleScheduler::CScheduler::GenerateScheduleObj(this, curTime, pScheduleJob);
|
|||
|
|
if (!pScheduleObj)
|
|||
|
|
continue;
|
|||
|
|
|
|||
|
|
m_Scheduler.Register(pScheduleObj);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CServiceManagerExApp::ClearSchedule()
|
|||
|
|
{
|
|||
|
|
m_Scheduler.Clear();
|
|||
|
|
}
|