AppGlobalF.cpp 25 KB

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