AppGlobalF.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "AppGlobalF.h"
  5. #include "ITSDbF.h"
  6. #include "ITSUtilF.h"
  7. #include "CDSCodeF.h"
  8. #include <inifiles.hpp>
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. //---------------------------------------------------------------------------
  12. int g_nPid = -1; // Application Process ID
  13. String g_sAppDir = ""; // Application Directory
  14. String g_sAppName= ""; // Program name
  15. String g_sCfgDir = ""; // Config File Directory
  16. String g_sLogDir = ""; // Program Log Directory
  17. String g_sTempDir = ""; // Program Temp Directory
  18. String g_sFormsDir = ""; // Program Forms Directory
  19. String g_sBlackBox = "";
  20. String g_sLangDir = "";
  21. String g_sImageDir = "";
  22. String g_sVideoDir = "";
  23. String g_sMapDir = "";
  24. APP_CONFIG g_AppCfg;
  25. LOG_INFO g_LogCfg;
  26. TITSLog *ITSLog = NULL;
  27. String g_sLang = "kr";
  28. String g_IniFileDir = "";
  29. String g_IniFileName = "Option";
  30. bool g_bControlAuth = true;
  31. //---------------------------------------------------------------------------
  32. bool CheckApplicationParam() {
  33. int nArgs = ParamCount();
  34. if (nArgs != 2) {
  35. return false;
  36. }
  37. g_AppCfg.MAGIC_ID = ParamStr(1);
  38. g_AppCfg.OPER_ID = ParamStr(2);
  39. g_AppCfg.OPER_ID = g_AppCfg.OPER_ID.SubString(1, 10);
  40. if (g_AppCfg.MAGIC_ID.UpperCase() != "ICAIR") {
  41. return false;
  42. }
  43. return true;
  44. }
  45. //---------------------------------------------------------------------------
  46. void ActiveProgram(String AClassName, String ATitle) {
  47. //String AClassName = "TFrmVmsFormEdit";
  48. //String ATitle = g_AppCfg.sTitle + " - Active";
  49. HWND hExeForm = FindWindow(AClassName.c_str(), ATitle.c_str());
  50. if (hExeForm)
  51. {
  52. bool bResult = SetWindowPos(hExeForm, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  53. if (bResult) {
  54. bResult = ShowWindow(hExeForm, SW_RESTORE);
  55. SetForegroundWindow(hExeForm);
  56. }
  57. }
  58. }
  59. //---------------------------------------------------------------------------
  60. bool ApplicationSingleRun(String AClassName, String ATitle) {
  61. HANDLE hMutex;
  62. try
  63. {
  64. String sLockFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".lock");
  65. String sProgMutexNm = "ICAIR_" + sLockFile;
  66. if ((hMutex=OpenMutex(MUTEX_ALL_ACCESS, false, sProgMutexNm.c_str()))==NULL)
  67. hMutex = CreateMutex(NULL, true, sProgMutexNm.c_str());
  68. else
  69. {
  70. ActiveProgram(AClassName, ATitle);
  71. return false;
  72. }
  73. }
  74. catch (Exception &exception)
  75. {
  76. Application->ShowException(&exception);
  77. return false;
  78. }
  79. return true;
  80. }
  81. //---------------------------------------------------------------------------
  82. void LoadIcon(TIniFile* AIniFile, String ASection, String AItem, String& AValue)
  83. {
  84. try
  85. {
  86. AValue = AIniFile->ReadString(ASection, AItem, "");
  87. if (AValue != "")
  88. {
  89. AValue = g_sAppDir + "Image\\" + AValue;
  90. if (!FileExists(AValue)) AValue = "";
  91. }
  92. }
  93. catch(Exception &e)
  94. {
  95. }
  96. }
  97. //---------------------------------------------------------------------------
  98. #include <windows.h>
  99. #include <shlwapi.h>
  100. #pragma comment (lib, "shlwapi.lib")
  101. bool IsDirectoryExists(LPCTSTR path)
  102. {
  103. return PathFileExists(path);
  104. #if 0
  105. struct _stat buffer;
  106. int iRetTemp = 0;
  107. memset((void*)&buffer, 0, sizeof(buffer));
  108. iRetTemp = _stat(path, &buffer);
  109. if (iRetTemp == 0)
  110. {
  111. if (buffer.st_mode & _S_IFDIR)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. #endif
  118. }
  119. //---------------------------------------------------------------------------
  120. bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
  121. {
  122. String sCfgFile;
  123. TIniFile *pIniFile = NULL;
  124. String sIniFile = ACfgFile + ".ini";
  125. sCfgFile = g_sCfgDir + sIniFile;
  126. g_AppCfg.sConfigFile = sCfgFile;
  127. pIniFile = new TIniFile(sCfgFile);
  128. try
  129. {
  130. g_AppCfg.sLang = "kr";
  131. g_sLang = g_AppCfg.sLang;
  132. g_AppCfg.sLogDay = pIniFile->ReadString("VMS", "LOGDAY", "");
  133. g_AppCfg.sSkinName = pIniFile->ReadString("VMS", "SKINNAME", "Silver");
  134. g_AppCfg.bSaveForm = pIniFile->ReadString("VMS", "SAVEFORM", "0").ToIntDef(1) == 1 ? true : false;
  135. g_AppCfg.isDispOfflineMsg = pIniFile->ReadString("VMS", "DISPOFFLINEMSG", "1").ToIntDef(1) == 1 ? true : false;
  136. g_AppCfg.itsdb.bSqlLog = pIniFile->ReadString("DB", "SQLLOG", "0").ToIntDef(0) == 1 ? true : false;
  137. g_AppCfg.itsdb.sConnectStr = pIniFile->ReadString("DB", "CONNECTSTR", "");
  138. if (g_AppCfg.itsdb.sConnectStr == "")
  139. {
  140. g_AppCfg.itsdb.sProvider = pIniFile->ReadString("DB", "PROVIDER", "OraOLEDB.Oracle.1");
  141. //g_AppCfg.itsdb.sProvider = pIniFile->ReadString("DB", "PROVIDER", "MSDAORA.1");
  142. g_AppCfg.itsdb.sServerName = pIniFile->ReadString("DB", "NAME", "ORCL");
  143. g_AppCfg.itsdb.sUserName = pIniFile->ReadString("DB", "USER", "ICAIR");
  144. g_AppCfg.itsdb.sPassword = pIniFile->ReadString("DB", "PASS", "ICAIR");
  145. }
  146. //VMS FTP
  147. g_AppCfg.vmsFtp.SERVER = pIniFile->ReadString("VMS_FTP", "SERVER", "");
  148. g_AppCfg.vmsFtp.PORT = pIniFile->ReadString("VMS_FTP", "PORT", "21").ToIntDef(21);
  149. g_AppCfg.vmsFtp.USER = pIniFile->ReadString("VMS_FTP", "USER", "");
  150. g_AppCfg.vmsFtp.PSWD = pIniFile->ReadString("VMS_FTP", "PSWD", "");
  151. g_AppCfg.vmsFtp.PASSIVE = pIniFile->ReadString("VMS_FTP", "PASSIVE", "0").ToIntDef(0) == 0 ? false : true;
  152. }
  153. __finally
  154. {
  155. if (pIniFile) delete pIniFile;
  156. pIniFile = NULL;
  157. //WriteConfigInfo(g_AppCfg.sConfigFile, "AUTOLOGOUT", "LOGOUTEXIT", "0");
  158. }
  159. return true;
  160. }
  161. //---------------------------------------------------------------------------
  162. /*
  163. * 환경설정 정보를 저장하는 함수.
  164. * arguments
  165. * String : RegisterKey 또는 파일이름
  166. * return
  167. * bool : 실패하면 false
  168. */
  169. bool WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue)
  170. {
  171. String ConfigFile;
  172. TIniFile *pIniFile = NULL;
  173. ConfigFile = sCfgFile;
  174. try
  175. {
  176. pIniFile = new TIniFile(ConfigFile);
  177. if (pIniFile == NULL)
  178. {
  179. return false;
  180. }
  181. pIniFile->WriteString(sTitle, sItem, sValue);
  182. }
  183. catch(...)
  184. {
  185. }
  186. if (pIniFile)
  187. {
  188. pIniFile->Free();
  189. pIniFile = NULL;
  190. }
  191. return true;
  192. }
  193. //---------------------------------------------------------------------------
  194. /*
  195. * 환경설정 정보를 읽어오는 함수.
  196. * arguments
  197. * String : RegisterKey 또는 파일이름
  198. * return
  199. * bool : 실패하면 false
  200. */
  201. bool ReadConfigInfo(String sCfgFile, String sTitle, String sItem, String &sValue)
  202. {
  203. bool bRes;
  204. String ConfigFile;
  205. TIniFile *pIniFile = NULL;
  206. bRes = false;
  207. ConfigFile = sCfgFile;
  208. try
  209. {
  210. pIniFile = new TIniFile(ConfigFile);
  211. if (pIniFile == NULL)
  212. {
  213. return bRes;
  214. }
  215. sValue = pIniFile->ReadString(sTitle, sItem, "");
  216. if (sValue != "")
  217. {
  218. bRes = true;
  219. }
  220. }
  221. catch(...)
  222. {
  223. }
  224. if (pIniFile)
  225. {
  226. pIniFile->Free();
  227. pIniFile = NULL;
  228. }
  229. return bRes;
  230. }
  231. //---------------------------------------------------------------------------
  232. void ShowErrorMsg(String ATitle, String AErrMsg)
  233. {
  234. Application->NormalizeTopMosts();
  235. Application->MessageBox(AErrMsg.c_str(), ATitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  236. Application->RestoreTopMosts();
  237. }
  238. //----------------------------------------------------------------------------
  239. String APP_FillCode(TcxComboBox *ACombo, String ACode)
  240. {
  241. String sReturn = "";
  242. if (SysCodeManager == NULL) {
  243. SysCodeManager = new TSysCodeManager();
  244. SysCodeManager->LoadFromDb();
  245. }
  246. TNotifyEvent evt = ACombo->Properties->OnChange;
  247. ACombo->Properties->OnChange = NULL;
  248. ACombo->Properties->Items->Clear();
  249. TSysClssCode *pSysClssCd = SysCodeManager->FLists.Find(ACode);
  250. if (pSysClssCd) {
  251. FOR_STL(TSysCode *, pSubCode, pSysClssCd->FLists)
  252. {
  253. if (pSubCode->USE_YN == "N") continue;
  254. ACombo->Properties->Items->Add(" [" + pSubCode->CODE_NO + "] " + pSubCode->CD_NM);
  255. if (sReturn == "") {
  256. sReturn = " [" + pSubCode->CODE_NO + "] " + pSubCode->CD_NM;
  257. }
  258. }
  259. }
  260. ACombo->ItemIndex = 0;
  261. ACombo->Properties->OnChange = evt;
  262. return sReturn;
  263. }
  264. //----------------------------------------------------------------------------
  265. String APP_GetCode(TcxComboBox *ACombo)
  266. {
  267. String sReturn = "";
  268. if (ACombo->ItemIndex >= 0)
  269. {
  270. String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
  271. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  272. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  273. sReturn = sCode;
  274. }
  275. return sReturn;
  276. }
  277. //----------------------------------------------------------------------------
  278. String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode)
  279. {
  280. String sReturn = "";
  281. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  282. {
  283. String sDesc = ACombo->Properties->Items->Strings[ii];
  284. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  285. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  286. if (ACode == sCode)
  287. {
  288. sReturn = sDesc;
  289. break;
  290. }
  291. }
  292. return sReturn;
  293. }
  294. //----------------------------------------------------------------------------
  295. String APP_GetCodeName(TcxComboBox *ACombo)
  296. {
  297. String sReturn = "";
  298. if (ACombo->ItemIndex >= 0)
  299. {
  300. String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
  301. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  302. sReturn = sName.Trim();
  303. }
  304. return sReturn;
  305. }
  306. //----------------------------------------------------------------------------
  307. String APP_GetCodeName(TcxComboBox *ACombo, String ACode)
  308. {
  309. String sReturn = "";
  310. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  311. {
  312. String sDesc = ACombo->Properties->Items->Strings[ii];
  313. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  314. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  315. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  316. if (ACode == sCode)
  317. {
  318. sReturn = sName.Trim();
  319. break;
  320. }
  321. }
  322. return sReturn;
  323. }
  324. //----------------------------------------------------------------------------
  325. String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName)
  326. {
  327. String sReturn = "3";
  328. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  329. {
  330. String sDesc = ACombo->Properties->Items->Strings[ii];
  331. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  332. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  333. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  334. if (sName.Trim() == AName.Trim())
  335. {
  336. sReturn = sCode;
  337. break;
  338. }
  339. }
  340. return sReturn;
  341. }
  342. //----------------------------------------------------------------------------
  343. String APP_GetCodeDefCode(TcxComboBox *ACombo)
  344. {
  345. String sReturn = "";
  346. if (ACombo->Properties->Items->Count > 0)
  347. {
  348. String sDesc = ACombo->Properties->Items->Strings[0];
  349. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  350. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  351. sReturn = sCode;
  352. }
  353. return sReturn;
  354. }
  355. //----------------------------------------------------------------------------
  356. String APP_GetCodeDefDesc(TcxComboBox *ACombo)
  357. {
  358. String sReturn = "";
  359. if (ACombo->Properties->Items->Count > 0)
  360. {
  361. String sDesc = ACombo->Properties->Items->Strings[0];
  362. sReturn = sDesc;
  363. }
  364. return sReturn;
  365. }
  366. //----------------------------------------------------------------------------
  367. int APP_SetCode(TcxComboBox *ACombo, String ACode)
  368. {
  369. int nItemIndex = -1;
  370. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  371. {
  372. String sDesc = ACombo->Properties->Items->Strings[ii];
  373. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  374. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  375. if (ACode == sCode)
  376. {
  377. nItemIndex = ii;
  378. break;
  379. }
  380. }
  381. ACombo->ItemIndex = nItemIndex;
  382. return nItemIndex;
  383. }
  384. //----------------------------------------------------------------------------
  385. ULONG ProcIDFromWnd(HWND hwnd) // 윈도우 핸들로 프로세스 아이디 얻기
  386. {
  387. ULONG idProc;
  388. GetWindowThreadProcessId( hwnd, &idProc );
  389. return idProc;
  390. }
  391. //----------------------------------------------------------------------------
  392. HWND GetWinHandle(ULONG pid) // 프로세스 아이디로 윈도우 핸들 얻기
  393. {
  394. HWND tempHwnd = FindWindow(NULL,NULL); // 최상위 윈도우 핸들 찾기
  395. while( tempHwnd != NULL )
  396. {
  397. if( GetParent(tempHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
  398. if( pid == ProcIDFromWnd(tempHwnd) )
  399. return tempHwnd;
  400. tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); // 다음 윈도우 핸들 찾기
  401. }
  402. return NULL;
  403. }
  404. //----------------------------------------------------------------------------
  405. TColor g_DispColor[MAX_DISPCOLOR];
  406. void APP_InitDisplayColor()
  407. {
  408. #if 0
  409. g_DispColor[ 0] = Graphics::clBlue;
  410. g_DispColor[ 1] = Graphics::clRed;
  411. g_DispColor[ 2] = Graphics::clLime;
  412. g_DispColor[ 3] = Graphics::clMaroon;
  413. g_DispColor[ 4] = Graphics::clGreen;
  414. g_DispColor[ 5] = Graphics::clMenuHighlight;
  415. g_DispColor[ 6] = Graphics::clBackground;
  416. g_DispColor[ 7] = Graphics::clPurple;
  417. g_DispColor[ 8] = Graphics::clTeal;
  418. g_DispColor[ 9] = Graphics::clYellow;
  419. g_DispColor[10] = Graphics::clFuchsia;
  420. g_DispColor[11] = Graphics::clAqua;
  421. g_DispColor[12] = Graphics::clMoneyGreen;
  422. g_DispColor[13] = Graphics::clSkyBlue;
  423. g_DispColor[14] = Graphics::clRed;
  424. g_DispColor[15] = Graphics::clLime;
  425. g_DispColor[16] = Graphics::clYellow;
  426. g_DispColor[17] = Graphics::clBlue;
  427. g_DispColor[18] = Graphics::clFuchsia;
  428. g_DispColor[19] = Graphics::clAqua;
  429. g_DispColor[20] = Graphics::clMoneyGreen;
  430. g_DispColor[21] = Graphics::clActiveCaption;
  431. #else
  432. g_DispColor[ 0] = Graphics::clLime;
  433. g_DispColor[ 1] = (TColor)RGB(0xFF, 0x00, 0x00);
  434. g_DispColor[ 2] = (TColor)RGB(0x00, 0x00, 0xFF);
  435. g_DispColor[ 3] = (TColor)RGB(0xFF, 0x82, 0x00);
  436. g_DispColor[ 4] = (TColor)RGB(0x94, 0x00, 0xD3);
  437. g_DispColor[ 5] = Graphics::clPurple;//(TColor)RGB(0x00, 0x00, 0x00);
  438. g_DispColor[ 6] = (TColor)RGB(0x82, 0x82, 0x82);
  439. g_DispColor[ 7] = (TColor)RGB(0x1E, 0x90, 0xFF);
  440. g_DispColor[ 8] = (TColor)RGB(0xB9, 0x06, 0x2F);
  441. g_DispColor[ 9] = (TColor)RGB(0x8c, 0x00, 0x8c);
  442. g_DispColor[10] = (TColor)RGB(0xFF, 0x82, 0x00);
  443. g_DispColor[11] = (TColor)RGB(0x94, 0x00, 0xD3);
  444. g_DispColor[12] = (TColor)RGB(0xB0, 0xC4, 0xDE);
  445. g_DispColor[13] = (TColor)RGB(0x00, 0xBF, 0xFF);
  446. g_DispColor[14] = (TColor)RGB(0x87, 0xCE, 0xEB);
  447. g_DispColor[15] = (TColor)RGB(0x87, 0xCE, 0xFA);
  448. g_DispColor[16] = (TColor)RGB(0xAD, 0xD8, 0xE6);
  449. g_DispColor[17] = (TColor)RGB(0xB0, 0xE0, 0xE6);
  450. g_DispColor[18] = (TColor)RGB(0xE6, 0xE6, 0xFA);
  451. g_DispColor[19] = (TColor)RGB(0xF0, 0xF8, 0xFF);
  452. #endif
  453. }
  454. //---------------------------------------------------------------------------
  455. TColor APP_GetDisplayColor(int ASeq)
  456. {
  457. return g_DispColor[ASeq % MAX_DISPCOLOR];
  458. }
  459. //---------------------------------------------------------------------------
  460. void APP_DelVmsSizeCombo(TcxComboBox *cboBox)
  461. {
  462. TStrings *pStrItems;
  463. TVmsSizeType *Ov;
  464. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  465. for (int ii = pStrItems->Count-1; ii >= 0; ii--)
  466. {
  467. Ov = (TVmsSizeType *)pStrItems->Objects[ii];
  468. if (Ov != NULL)
  469. {
  470. delete Ov;
  471. Ov = NULL;
  472. }
  473. }
  474. }
  475. //---------------------------------------------------------------------------
  476. void APP_FillVmsSizeType(TcxComboBox *cboBox, bool bAddAll/*=false*/)
  477. {
  478. String sQry;
  479. TStrings *pStrItems;
  480. TADOQuery *pADO = NULL;
  481. if (!VmsTypeManager)
  482. {
  483. VmsTypeManager = new TVmsTypeManager();
  484. VmsTypeManager->LoadFromDb();
  485. }
  486. TNotifyEvent evt = cboBox->Properties->OnChange;
  487. cboBox->Properties->OnChange = NULL;
  488. APP_DelVmsSizeCombo(cboBox);
  489. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  490. ((TcxComboBox *)cboBox)->Properties->Items->Clear();
  491. FOR_STL(TVmsType*, pObj, VmsTypeManager->FLists)
  492. {
  493. String sTypeCd = pObj->VMS_MODL_KIND;
  494. String sTypeNm = pObj->VMS_MODL_KIND_NM;
  495. int nW = pObj->VMS_WDTH;
  496. int nH = pObj->VMS_HGHT;
  497. int nR = pObj->VMS_MODL_ROW;
  498. int nC = pObj->VMS_MODL_COL;
  499. pStrItems->AddObject(" [" + sTypeCd + "] " + sTypeNm + " (" + String(nH) + "*" + String(nW) + ")", new TVmsSizeType(sTypeCd, sTypeNm, nW, nH, nR, nC) );
  500. }
  501. if (bAddAll)
  502. {
  503. String sAllName = "전체";
  504. pStrItems->AddObject(" [ALL] 전체" , new TVmsSizeType("ALL", sAllName, 384, 64, 2, 12));
  505. }
  506. cboBox->ItemIndex = 0;
  507. cboBox->Properties->OnChange = evt;
  508. }
  509. //---------------------------------------------------------------------------
  510. TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox)
  511. {
  512. TStrings *pStrItems;
  513. TVmsSizeType *Ov = NULL;
  514. int nItemIndex;
  515. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  516. nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
  517. if (nItemIndex < 0)
  518. {
  519. return Ov;
  520. }
  521. Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
  522. if (Ov == NULL)
  523. {
  524. Ov = NULL;
  525. }
  526. return Ov;
  527. }
  528. //---------------------------------------------------------------------------
  529. void APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color)
  530. {
  531. try
  532. {
  533. c->Pen->Color = clWhite;
  534. c->Pen->Width = 0;
  535. c->Pen->Style = psClear;
  536. c->Brush->Style = bsSolid;
  537. c->Brush->Color = color;
  538. c->Rectangle(offX, offY, w+offX+2, h+offY+2);
  539. }
  540. catch(...)
  541. {
  542. }
  543. }
  544. //---------------------------------------------------------------------------
  545. #include <DateUtils.hpp>
  546. TDateTime APP_StrToDateTime(String AStrDateTime)
  547. {
  548. TDateTime dtReturnValue = NULL;
  549. if (AStrDateTime.IsEmpty()) return dtReturnValue;
  550. if (AStrDateTime.Length() != 14) return dtReturnValue;
  551. AnsiString sDateTime = AnsiString(AStrDateTime);
  552. try
  553. {
  554. #if 0
  555. sDateTime.printf(L"%s-%s-%s %s:%s:%s",
  556. AStrDateTime.SubString( 1, 4).c_str(),
  557. AStrDateTime.SubString( 5, 2).c_str(),
  558. AStrDateTime.SubString( 7, 2).c_str(),
  559. AStrDateTime.SubString( 9, 2).c_str(),
  560. AStrDateTime.SubString(11, 2).c_str(),
  561. AStrDateTime.SubString(13, 2).c_str());
  562. dtReturnValue = StrToDateTime(sDateTime);
  563. #endif
  564. // swscanf(sRgb.c_str(), L"%d,%d,%d", &r, &g, &b);
  565. int year, month, day, hour, minute, second;
  566. sscanf(sDateTime.c_str(), "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
  567. dtReturnValue = EncodeDateTime(year, month, day, hour, minute, second, 0);
  568. }
  569. catch(...)
  570. {
  571. }
  572. return dtReturnValue;
  573. }
  574. //---------------------------------------------------------------------------
  575. #include <jpeg.hpp>
  576. bool APP_CheckBmpFile(String AInFileName, String &AOutFileName)
  577. {
  578. String sFilePath = ExtractFilePath(AInFileName);
  579. String sFileName = ExtractFileName(AInFileName);
  580. String sFileExt = ExtractFileExt(AInFileName);
  581. AOutFileName = AInFileName;
  582. if (sFileExt.UpperCase() == ".BMP")
  583. {
  584. return true;
  585. }
  586. AOutFileName = AInFileName + ".bmp";
  587. TImage *Image1 = new TImage(NULL);
  588. TMemoryStream *pImgStream = new TMemoryStream();
  589. try
  590. {
  591. try
  592. {
  593. pImgStream->LoadFromFile(AInFileName);
  594. sFileExt = sFileExt.UpperCase();
  595. if (sFileExt == ".PNG")
  596. {
  597. TdxPNGImage *img = new TdxPNGImage;
  598. img->LoadFromStream(pImgStream);
  599. Image1->Picture->Bitmap->Assign(img);
  600. Image1->Picture->Bitmap->PixelFormat = pf24bit;
  601. Image1->Picture->Bitmap->SaveToFile(AOutFileName);
  602. SAFE_DELETE(img);
  603. return true;
  604. }
  605. else
  606. if (sFileExt == ".JPG" || sFileExt == ".JPEG")
  607. {
  608. TJPEGImage *img = new TJPEGImage();
  609. img->LoadFromStream(pImgStream);
  610. Image1->Picture->Bitmap->Assign(img);
  611. Image1->Picture->Bitmap->PixelFormat = pf24bit;
  612. Image1->Picture->Bitmap->SaveToFile(AOutFileName);
  613. SAFE_DELETE(img);
  614. return true;
  615. }
  616. }
  617. catch(Exception &e)
  618. {
  619. }
  620. }
  621. __finally
  622. {
  623. SAFE_DELETE(pImgStream);
  624. SAFE_DELETE(Image1);
  625. }
  626. return false;
  627. }
  628. //---------------------------------------------------------------------------
  629. void APP_DbLoading() {
  630. try
  631. {
  632. Application->ProcessMessages();
  633. if (!SysCodeManager)
  634. {
  635. SysCodeManager = new TSysCodeManager();
  636. SysCodeManager->LoadFromDb();
  637. }
  638. if (!CDSFontManager)
  639. {
  640. CDSFontManager = new TCDSFontManager();
  641. CDSFontManager->LoadFontInfo();
  642. }
  643. if (!CDSAtmpManager)
  644. {
  645. CDSAtmpManager = new TCDSAtmpManager();
  646. #ifdef USE_ATMP
  647. // CDSAtmpManager->LoadFromDb();
  648. #endif
  649. }
  650. if (!CDSParkManager)
  651. {
  652. CDSParkManager = new TCDSParkManager();
  653. #ifdef USE_PARK
  654. // CDSParkManager->LoadFromDb();
  655. #endif
  656. }
  657. if (!CDSVmsFormManager)
  658. {
  659. CDSVmsFormManager = new TCDSVmsFormManager();
  660. CDSVmsFormManager->LoadFromDb();
  661. }
  662. if (!VmsTypeManager)
  663. {
  664. VmsTypeManager = new TVmsTypeManager();
  665. VmsTypeManager->LoadFromDb();
  666. }
  667. Application->ProcessMessages();
  668. if (!VmsCtlrManager)
  669. {
  670. VmsCtlrManager = new TVmsCtlrManager();
  671. VmsCtlrManager->LoadVmsModlSize();
  672. VmsCtlrManager->LoadFromDb();
  673. #if 0
  674. VmsCtlrManager->LoadVmsFormUsage();
  675. //VmsCtlrManager->LoadStatusFromDb();
  676. VmsCtlrManager->LoadIfscRltn();
  677. //VmsCtlrManager->LoadEvspRltn();
  678. //VmsCtlrManager->LoadVmsMsg();
  679. #endif
  680. }
  681. //정보제공구간-정보제공구간정보만 사용(소통정보사용안함)
  682. Application->ProcessMessages();
  683. if (!IfscManager)
  684. {
  685. IfscManager = new TIfscManager();
  686. #if 0
  687. IfscManager->LoadFromDb();
  688. if (g_AppCfg.isLoadFromFile)
  689. {
  690. IfscManager->LoadVertexFromFile();
  691. }
  692. else
  693. {
  694. IfscManager->LoadVertexFromDb();
  695. }
  696. #endif
  697. }
  698. }
  699. catch(...)
  700. {
  701. }
  702. }
  703. //---------------------------------------------------------------------------
  704. String DbPictTypeToReal(String APictType)
  705. {
  706. if (APictType == "B") return "bmp";
  707. if (APictType == "G") return "gif";
  708. if (APictType == "A") return "gif";
  709. if (APictType == "J") return "jpg";
  710. if (APictType == "P") return "png";
  711. if (APictType == "I") return "ico";
  712. return "bmp";
  713. }
  714. //---------------------------------------------------------------------------
  715. String RealPictTypeToDb(String APictType)
  716. {
  717. if (APictType == "B") return "bmp";
  718. //if (APictType == "gif") return "G";
  719. if (APictType == "gif") return "A";
  720. if (APictType == "jpg") return "J";
  721. if (APictType == "jpeg")return "J";
  722. if (APictType == "png") return "P";
  723. if (APictType == "ico") return "I";
  724. return "B";
  725. }
  726. //---------------------------------------------------------------------------
  727. String DbMovieTypeToReal(String APictType)
  728. {
  729. if (APictType == "AV") return "avi";
  730. if (APictType == "MP") return "mpeg";
  731. if (APictType == "MK") return "mkv";
  732. if (APictType == "M4") return "mp4";
  733. return "avi";
  734. }
  735. //---------------------------------------------------------------------------
  736. String RealMovieTypeToDb(String APictType)
  737. {
  738. if (APictType == "avi") return "AV";
  739. if (APictType == "mpge") return "MP";
  740. if (APictType == "mkv") return "MK";
  741. if (APictType == "mp4") return "M4";
  742. return "AV";
  743. }
  744. //---------------------------------------------------------------------------