123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [IT], 保留所有权利;
- /* 模 块 名:服务的主要处理类;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[IT];
- /* 日 期:[5/6/2016];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[IT];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #ifndef __MAIN_PROCESS__
- #define __MAIN_PROCESS__
- #pragma once
- #include "HPSocket4C.h"
- #include "helper.h"
- class CMainProcess
- {
- CMainProcess(void);
- public:
- // 单例对象模式;
- static CMainProcess* GetInstance()
- {
- if (m_spThis == NULL )
- {
- m_spThis = new CMainProcess;
- }
- return m_spThis;
- }
- ~CMainProcess(void);
- private:
- static const USHORT PORT;
- static const LPCTSTR ADDRESS;
- EnAppState m_enState;
- CString m_strAddress;
- static CMainProcess* m_spThis;
- HP_TcpPackServer m_pServer;
- HP_TcpServerListener m_pListener;
- static En_HP_HandleResult __stdcall OnPrepareListen(SOCKET soListen);
- static En_HP_HandleResult __stdcall OnAccept(HP_CONNID dwConnID, SOCKET soClient);
- static En_HP_HandleResult __stdcall OnSend(HP_CONNID dwConnID, const BYTE* pData, int iLength);
- static En_HP_HandleResult __stdcall OnReceive(HP_CONNID dwConnID, const BYTE* pData, int iLength);
- static En_HP_HandleResult __stdcall OnClose(HP_CONNID dwConnID, En_HP_SocketOperation enOperation, int iErrorCode);
- static En_HP_HandleResult __stdcall OnShutdown();
- protected:
- // 线程控制句柄;
- HANDLE m_hEvent1;
- // 检查服务线程句柄;
- HANDLE m_hCheckServices;
- // 线程控制句柄;
- HANDLE m_hEvent2;
- // 备份数据库线程句柄;
- HANDLE m_hBackupDatabase;
- // 其他接口;
- public:
- // 工作开始函数;
- void StartWork();
- // 工作结束函数;
- void EndofWork();
- // 检测服务在线线程;
- static DWORD WINAPI CheckSvcStatusThread(LPVOID lpVoid);
- static DWORD WINAPI BackupDatabaseThread(LPVOID lpVoid);
- public:
- // 启动/退出;
- static BOOL Start();
- static BOOL Stop();
- static BOOL Disconnect(IN const DWORD& dwConnId);
- // 登录登出;
- static void Req_Login(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- static void Req_LogOut(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- // 部门;
- static void New_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- static void Del_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- static void Mod_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- static EnHandleResult Ask_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
- };
- #endif
|