123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /****************************************************************************
- * @source : VMSCommSvr.cpp
- * @description : VMS 통신 서버
- ****************************************************************************
- * DATE AUTHOR DESCRIPTION
- * --------------------------------------------------------------------------
- * 2012/03/09 CYM [100] First Cut
- *
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #define COMM_EXCEPTION_MESSAGE 0
- //---------------------------------------------------------------------------
- #include "AppGlobalF.h"
- #include <tchar.h>
- //---------------------------------------------------------------------------
- USEFORM("FrmMainF.cpp", FrmMain);
- USEFORM("DM\DMCOMMF.cpp", DMCOMM); /* TDataModule: File Type */
- USEFORM("FRM\FrmVmsLogF.cpp", FrmVmsLog);
- USEFORM("FRM\FrmOptionF.cpp", FrmOption);
- USEFORM("FRM\FrmVmsInfoF.cpp", FrmVmsInfo);
- USEFORM("FRM\FrmSysLogF.cpp", FrmSysLog);
- //---------------------------------------------------------------------------
- WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
- {
- DateSeparator = '-';
- TimeSeparator = ':';
- ShortDateFormat ="yyyy-MM-dd";
- ShortTimeFormat = "hh:nn:ss";
- LongTimeFormat = "hh:nn:ss";
- int nPid = (int)GetCurrentProcessId();
- g_sAppDir = ExtractFilePath(Application->ExeName);
- g_sAppName = ChangeFileExt(ExtractFileName(Application->ExeName), "");
- g_sCfgDir = g_sAppDir + "Cfg\\";
- g_sLogDir = g_sAppDir + "Log\\";
- g_sTempDir = g_sAppDir + "Temp\\";
- g_sImgDir = g_sAppDir + "Image\\";
- g_sFtpDir = g_sAppDir + "Ftp\\";
- g_sFormDir = g_sAppDir + "Form\\";
- ForceDirectories(g_sCfgDir.c_str());
- ForceDirectories(g_sLogDir.c_str());
- ForceDirectories(g_sTempDir.c_str());
- ForceDirectories(g_sImgDir.c_str());
- ForceDirectories(g_sFtpDir.c_str());
- ForceDirectories(g_sFormDir.c_str());
- String sTmpDir = g_sLogDir + "Comm\\";
- ForceDirectories(sTmpDir.c_str());
- ChDir(g_sAppDir);
- g_AppCfg.Clear();
- APP_LoadConfigInfo();
- /* 환경설정에 저장되어 있는 ftp 디렉토리 */
- ForceDirectories(g_sFtpDir.c_str());
- ITSLog = new TITSLog(g_sLogDir, g_sAppName, g_AppCfg.sLogDay);
- FDbLog = new TITSLog(g_sLogDir + "Db\\", "Database", g_AppCfg.sLogDay);
- ITSLog->FLogCfg = g_LogCfg;
- FDbLog->FLogCfg = g_LogCfg;
- LOGINFO("VMSCommServer Start....");
- try
- {
- AnsiString sPidFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".pid");
- AnsiString sMutexName = "HANTE_VMSCommServerYI.lock";
- if (SYS_ApplicationSingleInstance(sMutexName, g_sCfgDir+sPidFile))
- {
- LOGWARN("Program already running. program exit...");
- #if 0
- int nMsgType = MB_OK|MB_ICONERROR|MB_APPLMODAL;
- String sMsgTitle = g_AppCfg.sTitle;
- String sMsgError = ExtractFileName(Application->ExeName) + "\r\nProgram is already running.\r\nPlease check the program in the task manager.";
- Application->MessageBox(sMsgError.c_str(), sMsgTitle.c_str(), nMsgType);
- #endif
- return 0;
- }
- }
- catch (Exception &exception)
- {
- //Application->ShowException(&exception);
- return 0;
- }
- /* allocate memory for system */
- if ((g_SysInfo = (SYSTEM_INFORMATION *) malloc(sizeof(SYSTEM_INFORMATION))) == NULL)
- {
- return 0;
- }
- memset(g_SysInfo, 0x00, sizeof(SYSTEM_INFORMATION));
- try
- {
- Application->Initialize();
- Application->MainFormOnTaskBar = true;
- Application->Title = "VMS Communication Server";
- Application->CreateForm(__classid(TFrmMain), &FrmMain);
- Application->CreateForm(__classid(TDMCOMM), &DMCOMM);
- Application->CreateForm(__classid(TFrmVmsLog), &FrmVmsLog);
- Application->Run();
- }
- catch (Exception &exception)
- {
- #if COMM_EXCEPTION_MESSAGE
- Application->ShowException(&exception);
- #endif
- }
- catch (...)
- {
- #if COMM_EXCEPTION_MESSAGE
- try
- {
- throw Exception("");
- }
- catch (Exception &exception)
- {
- Application->ShowException(&exception);
- }
- #endif
- }
- //g_Log->WriteLog(LOG_INFO, "VMSCommSvr End...");
- LOGINFO("VMSCommServer End....");
- /* free memory */
- free(g_SysInfo);
- return 0;
- }
- //---------------------------------------------------------------------------
|