AppGlobalF.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "AppGlobalF.h"
  5. #include "ITSDbF.h"
  6. #include "ITSUtilF.h"
  7. #include "ITSLogF.h"
  8. #include <inifiles.hpp>
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. //---------------------------------------------------------------------------
  12. String CenterCd = ""; // 지역센터 코드
  13. String CenterId = ""; // 지역센터 아이디
  14. String CenterName = ""; // 지역센터 명칭
  15. int g_nPid = -1; // Application Process ID
  16. String g_sAppDir = ""; // Application Directory
  17. String g_sAppName= ""; // Program name
  18. String g_sCfgDir = ""; // Config File Directory
  19. String g_sLogDir = ""; // Program Log Directory
  20. String g_sTempDir = ""; // Program Temp Directory
  21. String g_sFormsDir = ""; // Program Forms Directory
  22. String g_sLangDir = "";
  23. APP_CONFIG g_AppCfg;
  24. LOGININFO *g_pLOGIN = NULL;
  25. LOG_INFO g_LogCfg;
  26. TITSLog *ITSLog = NULL;
  27. //---------------------------------------------------------------------------
  28. bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
  29. {
  30. String sCfgFile;
  31. TIniFile *pIniFile = NULL;
  32. String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
  33. if (!ACfgFile.IsEmpty())
  34. sIniFile = ACfgFile + ".ini";
  35. sCfgFile = g_sCfgDir + sIniFile;
  36. g_AppCfg.sConfigFile = sCfgFile;
  37. g_AppCfg.AutoLogout.Enabled = false;
  38. g_AppCfg.AutoLogout.IntervalMin = 0;
  39. g_AppCfg.AutoLogout.LogoutExit = false;
  40. g_AppCfg.thr.pThread = NULL;
  41. g_AppCfg.thr.dwThreadId = 0;
  42. g_AppCfg.thr.nHandle = 0;
  43. g_AppCfg.thr.bRunning = false;
  44. g_AppCfg.bAppClose = false;
  45. try
  46. {
  47. String sTmp;
  48. pIniFile = new TIniFile(sCfgFile);
  49. g_AppCfg.sTitle = pIniFile->ReadString("APPLICATION", "TITLE", "광역교통정보 교통관리시스템");
  50. g_AppCfg.sProcessId = pIniFile->ReadString("APPLICATION", "PROCESSID", "999999");
  51. g_AppCfg.sLogDay = pIniFile->ReadString("APPLICATION", "LOGDAY", "");
  52. g_AppCfg.sSkinName = pIniFile->ReadString("APPLICATION", "SKINNAME", "Black");
  53. if (g_AppCfg.sSkinName.IsEmpty()) g_AppCfg.sSkinName = "Blue";
  54. sTmp = pIniFile->ReadString("APPLICATION", "SAVEFORM", "1");
  55. g_AppCfg.bSaveForm = (sTmp == "1") ? true : false;
  56. sTmp = "1";
  57. sTmp = pIniFile->ReadString("APPLICATION", "LOGINPROMPT", "1");
  58. g_AppCfg.bLoginPrompt = (sTmp == "1") ? true : false;
  59. g_AppCfg.sDefUseId = pIniFile->ReadString("APPLICATION", "LASTUSER", "");
  60. g_AppCfg.sLang = pIniFile->ReadString("APPLICATION", "LANGUAGE", "en");
  61. g_AppCfg.sLang = g_AppCfg.sLang.LowerCase();
  62. if (g_AppCfg.sLang != "en" && g_AppCfg.sLang != "kr")
  63. g_AppCfg.sLang = "kr";
  64. g_AppCfg.bDebug = false;
  65. sTmp = pIniFile->ReadString("APPLICATION", "DEBUG", "0");
  66. if (sTmp == "1") g_AppCfg.bDebug = true;
  67. sTmp = pIniFile->ReadString("ALARM", "WINDOW", "1");
  68. g_AppCfg.Alarm.Window = (sTmp == "1") ? true : false;
  69. sTmp = pIniFile->ReadString("ALARM", "ENABLED", "0");
  70. g_AppCfg.Alarm.Enabled = (sTmp == "1") ? true : false;
  71. sTmp = pIniFile->ReadString("ALARM", "TIMEOUT", "10");
  72. g_AppCfg.Alarm.TimeOut = sTmp.ToIntDef(0);
  73. if (g_AppCfg.Alarm.TimeOut == 0) g_AppCfg.Alarm.TimeOut = 10;
  74. if (g_AppCfg.Alarm.TimeOut > 60) g_AppCfg.Alarm.TimeOut = 60;
  75. sTmp = pIniFile->ReadString("TEMPERATURE", "ALARMVALUE", "45");
  76. g_AppCfg.Temp.AlarmValue = sTmp.ToIntDef(0);
  77. sTmp = pIniFile->ReadString("INCIDENT", "WINDOW", "1");
  78. g_AppCfg.Incident.Window = (sTmp == "1") ? true : false;
  79. sTmp = pIniFile->ReadString("INCIDENT", "ENABLED", "0");
  80. g_AppCfg.Incident.Enabled = (sTmp == "1") ? true : false;
  81. sTmp = pIniFile->ReadString("INCIDENT", "TIMEOUT", "30");
  82. g_AppCfg.Incident.TimeOut = sTmp.ToIntDef(0);
  83. if (g_AppCfg.Incident.TimeOut == 0) g_AppCfg.Incident.TimeOut = 30;
  84. if (g_AppCfg.Incident.TimeOut > 300) g_AppCfg.Incident.TimeOut = 60;
  85. sTmp = pIniFile->ReadString("AUTOLOGOUT", "ENABLED", "0");
  86. g_AppCfg.AutoLogout.Enabled = (sTmp == "1") ? true : false;
  87. sTmp = pIniFile->ReadString("AUTOLOGOUT", "INTERVALMIN", "10");
  88. g_AppCfg.AutoLogout.IntervalMin = sTmp.ToIntDef(0);
  89. if (g_AppCfg.AutoLogout.IntervalMin == 0) g_AppCfg.AutoLogout.IntervalMin = 10;
  90. sTmp = pIniFile->ReadString("AUTOLOGOUT", "LOGOUTEXIT", "0");
  91. g_AppCfg.AutoLogout.LogoutExit = (sTmp == "1") ? true : false;
  92. String sSqlLog;
  93. g_AppCfg.itsdb.bSqlLog = false;
  94. g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
  95. g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
  96. g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
  97. g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
  98. //sSqlLog = pIniFile->ReadString("ITSDB", "SQLLOG", "0");
  99. //if (sSqlLog == "1") g_AppCfg.itsdb.bSqlLog = true;
  100. #if 0
  101. //세종시
  102. g_AppCfg.vmscam.sComModel = pIniFile->ReadString("VMSCAMERA", "COMPANY", "Samsung");
  103. g_AppCfg.vmscam.sDevModel = pIniFile->ReadString("VMSCAMERA", "DEVICE", "Samsung Network Camera/Encoder");
  104. #else
  105. g_AppCfg.vmscam.sComModel = pIniFile->ReadString("VMSCAMERA", "COMPANY", "Samsung");
  106. g_AppCfg.vmscam.sDevModel = pIniFile->ReadString("VMSCAMERA", "DEVICE", "SNP-3371TH");
  107. #endif
  108. CenterId = pIniFile->ReadString("CENTER", "CENTERID", "L01");
  109. CenterName = pIniFile->ReadString("CENTER", "CENTERNAME", "중앙센터");
  110. CenterCd = String(StrToInt(CenterId.SubString(2, 2)));
  111. #if 0
  112. g_AppCfg.flashmap.sMainMap = pIniFile->ReadString("FLASHMAP", "MAINMAP", "");
  113. g_AppCfg.flashmap.sLinkMap = pIniFile->ReadString("FLASHMAP", "LINKMAP", "");
  114. if (g_AppCfg.flashmap.sMainMap == "" ||
  115. g_AppCfg.flashmap.sLinkMap == "")
  116. {
  117. Application->MessageBox(L"지도 설정 정보를 읽어오는데 실패하였습니다.!!!!!!!!!!",
  118. L"환경설정 정보 로딩 오류!!!",
  119. MB_OK|MB_ICONERROR);
  120. }
  121. g_AppCfg.flashmap.sMainMap = g_sAppDir + g_AppCfg.flashmap.sMainMap;
  122. g_AppCfg.flashmap.sLinkMap = g_sAppDir + g_AppCfg.flashmap.sLinkMap;
  123. #endif
  124. }
  125. __finally
  126. {
  127. if (pIniFile) delete pIniFile;
  128. pIniFile = NULL;
  129. WriteConfigInfo(sIniFile, "AUTOLOGOUT", "LOGOUTEXIT", "0");
  130. }
  131. return true;
  132. }
  133. //---------------------------------------------------------------------------
  134. bool CMM_InsertLoginHist(PLOGININFO pLogin, bool ALogin)
  135. {
  136. String sQry;
  137. bool bResult= false;
  138. TADOQuery *adoQry = NULL;
  139. if (!pLogin) return false;
  140. if (ALogin)
  141. {
  142. sQry = "INSERT INTO TB_USERCNNC_HS ( \r\n"
  143. " LOGIN_HMS, \r\n"
  144. " USER_ID, \r\n"
  145. " LOGOUT_HMS \r\n"
  146. " ) \r\n"
  147. "VALUES ( \r\n"
  148. " :p01, \r\n"
  149. " :p02, \r\n"
  150. " NULL \r\n"
  151. " ) \r\n";
  152. }
  153. else
  154. {
  155. sQry = "UPDATE TB_USERCNNC_HS SET \r\n"
  156. " LOGOUT_HMS = TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') \r\n"
  157. " WHERE LOGIN_HMS = :p01 \r\n"
  158. " AND USER_ID = :p02 \r\n";
  159. }
  160. try
  161. {
  162. try
  163. {
  164. adoQry = new TADOQuery(NULL);
  165. adoQry->Connection = ITSDb_GetConnection();
  166. ITSDb_GetConnection()->BeginTrans();
  167. adoQry->Close();
  168. adoQry->SQL->Text = sQry;
  169. adoQry->Parameters->ParamByName("p01")->Value = pLogin->sLoginTime;
  170. adoQry->Parameters->ParamByName("p02")->Value = pLogin->sUserId;
  171. int nRowCnt = adoQry->ExecSQL();
  172. ITSDb_GetConnection()->CommitTrans();
  173. bResult = nRowCnt > 1 ? true : false;
  174. }
  175. catch (Exception &exception)
  176. {
  177. ITSDb_GetConnection()->RollbackTrans();
  178. throw Exception(String(exception.ClassName()) + exception.Message);
  179. }
  180. catch (...)
  181. {
  182. ITSDb_GetConnection()->RollbackTrans();
  183. }
  184. }
  185. __finally
  186. {
  187. if (adoQry)
  188. {
  189. adoQry->Close();
  190. delete adoQry;
  191. }
  192. }
  193. return bResult;
  194. }
  195. //---------------------------------------------------------------------------
  196. /*
  197. * 환경설정 정보를 저장하는 함수.
  198. * arguments
  199. * String : RegisterKey 또는 파일이름
  200. * return
  201. * bool : 실패하면 false
  202. */
  203. bool WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue)
  204. {
  205. String ConfigFile;
  206. TIniFile *pIniFile = NULL;
  207. ConfigFile = sCfgFile;
  208. try
  209. {
  210. pIniFile = new TIniFile(ConfigFile);
  211. if (pIniFile == NULL)
  212. {
  213. return false;
  214. }
  215. pIniFile->WriteString(sTitle, sItem, sValue);
  216. }
  217. catch(...)
  218. {
  219. }
  220. if (pIniFile)
  221. {
  222. pIniFile->Free();
  223. pIniFile = NULL;
  224. }
  225. return true;
  226. }
  227. //---------------------------------------------------------------------------
  228. /*
  229. * 환경설정 정보를 읽어오는 함수.
  230. * arguments
  231. * String : RegisterKey 또는 파일이름
  232. * return
  233. * bool : 실패하면 false
  234. */
  235. bool ReadConfigInfo(String sCfgFile, String sTitle, String sItem, String &sValue)
  236. {
  237. bool bRes;
  238. String ConfigFile;
  239. TIniFile *pIniFile = NULL;
  240. bRes = false;
  241. ConfigFile = sCfgFile;
  242. try
  243. {
  244. pIniFile = new TIniFile(ConfigFile);
  245. if (pIniFile == NULL)
  246. {
  247. return bRes;
  248. }
  249. sValue = pIniFile->ReadString(sTitle, sItem, "");
  250. if (sValue != "")
  251. {
  252. bRes = true;
  253. }
  254. }
  255. catch(...)
  256. {
  257. }
  258. if (pIniFile)
  259. {
  260. pIniFile->Free();
  261. pIniFile = NULL;
  262. }
  263. return bRes;
  264. }
  265. //---------------------------------------------------------------------------
  266. void ShowErrorMsg(String ATitle, String AErrMsg)
  267. {
  268. Application->NormalizeTopMosts();
  269. Application->MessageBox(AErrMsg.c_str(), ATitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  270. Application->RestoreTopMosts();
  271. }
  272. //----------------------------------------------------------------------------
  273. String APP_FillCode(TcxComboBox *ACombo, String ACode)
  274. {
  275. String sReturn = "";
  276. return sReturn;
  277. }
  278. //----------------------------------------------------------------------------
  279. String APP_GetCode(TcxComboBox *ACombo)
  280. {
  281. String sReturn = "";
  282. if (ACombo->ItemIndex >= 0)
  283. {
  284. String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
  285. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  286. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  287. sReturn = sCode;
  288. }
  289. return sReturn;
  290. }
  291. //----------------------------------------------------------------------------
  292. String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode)
  293. {
  294. String sReturn = "";
  295. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  296. {
  297. String sDesc = ACombo->Properties->Items->Strings[ii];
  298. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  299. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  300. if (ACode == sCode)
  301. {
  302. sReturn = sDesc;
  303. break;
  304. }
  305. }
  306. return sReturn;
  307. }
  308. //----------------------------------------------------------------------------
  309. String APP_GetCodeName(TcxComboBox *ACombo, String ACode)
  310. {
  311. String sReturn = "";
  312. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  313. {
  314. String sDesc = ACombo->Properties->Items->Strings[ii];
  315. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  316. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  317. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  318. if (ACode == sCode)
  319. {
  320. sReturn = sName.Trim();
  321. break;
  322. }
  323. }
  324. return sReturn;
  325. }
  326. //----------------------------------------------------------------------------
  327. String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName)
  328. {
  329. String sReturn = "3";
  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 (sName.Trim() == AName.Trim())
  337. {
  338. sReturn = sCode;
  339. break;
  340. }
  341. }
  342. return sReturn;
  343. }
  344. //----------------------------------------------------------------------------
  345. String APP_GetCodeDefCode(TcxComboBox *ACombo)
  346. {
  347. String sReturn = "";
  348. if (ACombo->Properties->Items->Count > 0)
  349. {
  350. String sDesc = ACombo->Properties->Items->Strings[0];
  351. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  352. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  353. sReturn = sCode;
  354. }
  355. return sReturn;
  356. }
  357. //----------------------------------------------------------------------------
  358. String APP_GetCodeDefDesc(TcxComboBox *ACombo)
  359. {
  360. String sReturn = "";
  361. if (ACombo->Properties->Items->Count > 0)
  362. {
  363. String sDesc = ACombo->Properties->Items->Strings[0];
  364. sReturn = sDesc;
  365. }
  366. return sReturn;
  367. }
  368. //----------------------------------------------------------------------------
  369. int APP_SetCode(TcxComboBox *ACombo, String ACode)
  370. {
  371. int nItemIndex = -1;
  372. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  373. {
  374. String sDesc = ACombo->Properties->Items->Strings[ii];
  375. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  376. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  377. if (ACode == sCode)
  378. {
  379. nItemIndex = ii;
  380. break;
  381. }
  382. }
  383. ACombo->ItemIndex = nItemIndex;
  384. return nItemIndex;
  385. }
  386. //----------------------------------------------------------------------------
  387. ULONG ProcIDFromWnd(HWND hwnd) // 윈도우 핸들로 프로세스 아이디 얻기
  388. {
  389. ULONG idProc;
  390. GetWindowThreadProcessId( hwnd, &idProc );
  391. return idProc;
  392. }
  393. //----------------------------------------------------------------------------
  394. HWND GetWinHandle(ULONG pid) // 프로세스 아이디로 윈도우 핸들 얻기
  395. {
  396. HWND tempHwnd = FindWindow(NULL,NULL); // 최상위 윈도우 핸들 찾기
  397. while( tempHwnd != NULL )
  398. {
  399. if( GetParent(tempHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
  400. if( pid == ProcIDFromWnd(tempHwnd) )
  401. return tempHwnd;
  402. tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); // 다음 윈도우 핸들 찾기
  403. }
  404. return NULL;
  405. }
  406. //----------------------------------------------------------------------------
  407. String ITSUtil_FormatStr(String AStrDateTime, String AFormat)
  408. {
  409. #define SYEAR "-"
  410. #define STIME ":"
  411. #define SPACE " "
  412. String sDateTime = "";
  413. String sInData = AnsiString(AStrDateTime);
  414. //ShowMessage("IN: " + AStrDateTime + " " + sInData + " " + AFormat);
  415. if (sInData.IsEmpty())
  416. return sInData;
  417. //sDateTime = sInData;
  418. try
  419. {
  420. if (AFormat == STR_DATETIME)
  421. {
  422. if (sInData.Length() < 14) return sInData;
  423. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  424. sInData.SubString( 5, 2) + SYEAR +
  425. sInData.SubString( 7, 2) + SPACE +
  426. sInData.SubString( 9, 2) + STIME +
  427. sInData.SubString(11, 2) + STIME +
  428. sInData.SubString(13, 2);
  429. }
  430. else
  431. if (AFormat == STR_HHNN)
  432. {
  433. if (sInData.Length() < 12) return sInData;
  434. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  435. sInData.SubString( 5, 2) + SYEAR +
  436. sInData.SubString( 7, 2) + SPACE +
  437. sInData.SubString( 9, 2) + STIME +
  438. sInData.SubString(11, 2);
  439. }
  440. else
  441. if (AFormat == STR_DATEHOUR)
  442. {
  443. if (sInData.Length() < 10) return sInData;
  444. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  445. sInData.SubString( 5, 2) + SYEAR +
  446. sInData.SubString( 7, 2) + SPACE +
  447. sInData.SubString( 9, 2);
  448. }
  449. else
  450. if (AFormat == STR_DATE)
  451. {
  452. if (sInData.Length() < 8) return sInData;
  453. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  454. sInData.SubString( 5, 2) + SYEAR +
  455. sInData.SubString( 7, 2);
  456. }
  457. else
  458. if (AFormat == STR_MM)
  459. {
  460. if (sInData.Length() < 6) return sInData;
  461. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  462. sInData.SubString( 5, 2);
  463. }
  464. else
  465. {
  466. sDateTime = sInData;
  467. }
  468. }
  469. catch(...)
  470. {
  471. }
  472. //ShowMessage("OUT: " + sDateTime);
  473. return sDateTime;
  474. }
  475. //---------------------------------------------------------------------------
  476. TColor g_DispColor[MAX_DISPCOLOR];
  477. void APP_InitDisplayColor()
  478. {
  479. g_DispColor[ 0] = Graphics::clBlue;
  480. g_DispColor[ 1] = Graphics::clRed;
  481. g_DispColor[ 2] = Graphics::clLime;
  482. g_DispColor[ 3] = Graphics::clMaroon;
  483. g_DispColor[ 4] = Graphics::clGreen;
  484. g_DispColor[ 5] = Graphics::clMenuHighlight;
  485. g_DispColor[ 6] = Graphics::clBackground;
  486. g_DispColor[ 7] = Graphics::clPurple;
  487. g_DispColor[ 8] = Graphics::clTeal;
  488. g_DispColor[ 9] = Graphics::clYellow;
  489. g_DispColor[10] = Graphics::clFuchsia;
  490. g_DispColor[11] = Graphics::clAqua;
  491. g_DispColor[12] = Graphics::clMoneyGreen;
  492. g_DispColor[13] = Graphics::clSkyBlue;
  493. g_DispColor[14] = Graphics::clRed;
  494. g_DispColor[15] = Graphics::clLime;
  495. g_DispColor[16] = Graphics::clYellow;
  496. g_DispColor[17] = Graphics::clBlue;
  497. g_DispColor[18] = Graphics::clFuchsia;
  498. g_DispColor[19] = Graphics::clAqua;
  499. g_DispColor[20] = Graphics::clMoneyGreen;
  500. g_DispColor[21] = Graphics::clActiveCaption;
  501. }
  502. //---------------------------------------------------------------------------
  503. TColor APP_GetDisplayColor(int ASeq)
  504. {
  505. return g_DispColor[ASeq % MAX_DISPCOLOR];
  506. }
  507. //---------------------------------------------------------------------------
  508. void APP_DelVmsSizeCombo(TcxComboBox *cboBox)
  509. {
  510. TStrings *pStrItems;
  511. TVmsSizeType *Ov;
  512. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  513. for (int ii = pStrItems->Count-1; ii >= 0; ii--)
  514. {
  515. Ov = (TVmsSizeType *)pStrItems->Objects[ii];
  516. if (Ov != NULL)
  517. {
  518. delete Ov;
  519. Ov = NULL;
  520. }
  521. }
  522. }
  523. //---------------------------------------------------------------------------
  524. void APP_FillVmsSizeType(TcxComboBox *cboBox, String AType, bool bAddAll/*=false*/)
  525. {
  526. String sQry;
  527. TStrings *pStrItems;
  528. TADOQuery *pADO = NULL;
  529. APP_DelVmsSizeCombo(cboBox);
  530. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  531. ((TcxComboBox *)cboBox)->Properties->Items->Clear();
  532. sQry = "SELECT CMMN_CD, \r\n"
  533. " CMMN_CD_KOR_NM, \r\n"
  534. " NVL(ATRB1, '320') AS FORMW, \r\n"
  535. " NVL(ATRB2, '64') AS FORMH \r\n"
  536. " FROM TB_CMMN_CD \r\n"
  537. " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
  538. " AND USE_YN = 'Y' \r\n"
  539. " AND CMMN_CD IN (SELECT DISTINCT VMS_TYPE_CD \r\n"
  540. " FROM TB_VMS_CTLR) \r\n"
  541. //" WHERE VMS_USAG_TYPE_CD = :p01) \r\n"
  542. " ORDER BY CMMN_CD DESC \r\n";
  543. try
  544. {
  545. try
  546. {
  547. pADO = new TADOQuery(NULL);
  548. pADO->Close();
  549. pADO->Connection = ITSDb_GetConnection();
  550. ITSDb_SQLText(pADO, sQry);
  551. //ITSDb_SQLBind(pADO, "p01", AType);
  552. ITSDb_SQLOpen(pADO);
  553. for( ; !pADO->Eof; pADO->Next())
  554. {
  555. String sTypeCd = pADO->FieldByName("CMMN_CD")->AsString;
  556. String sTypeNm = pADO->FieldByName("CMMN_CD_KOR_NM")->AsString;
  557. String sWidth = pADO->FieldByName("FORMW")->AsString;
  558. String sHeight = pADO->FieldByName("FORMH")->AsString;
  559. int nW = sWidth.ToIntDef(384);
  560. int nH = sHeight.ToIntDef(64);
  561. pStrItems->AddObject(" [" + sTypeCd + "] " + sTypeNm + " (" + String(nW) + "x" + String(nH) + ")", new TVmsSizeType(sTypeCd, sTypeNm, nW, nH) );
  562. }
  563. if (bAddAll)
  564. {
  565. String sAllName = "전체";
  566. pStrItems->AddObject(" [ALL] 전체" , new TVmsSizeType("ALL", sAllName, 384, 64));
  567. }
  568. cboBox->ItemIndex = 0;
  569. }
  570. catch(EDatabaseError &E)
  571. {
  572. DBERRORMSG("APP_FillVmsSizeType", String(E.ClassName()), E.Message, sQry);
  573. throw Exception(String(E.ClassName()) + E.Message);
  574. }
  575. catch(Exception &exception)
  576. {
  577. DBERRORMSG("APP_FillVmsSizeType", String(exception.ClassName()), exception.Message, sQry);
  578. throw Exception(String(exception.ClassName()) + exception.Message);
  579. }
  580. }
  581. __finally
  582. {
  583. if (pADO)
  584. {
  585. pADO->Close();
  586. delete pADO;
  587. }
  588. }
  589. }
  590. //---------------------------------------------------------------------------
  591. TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox)
  592. {
  593. TStrings *pStrItems;
  594. TVmsSizeType *Ov = NULL;
  595. int nItemIndex;
  596. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  597. nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
  598. if (nItemIndex < 0)
  599. {
  600. return Ov;
  601. }
  602. Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
  603. if (Ov == NULL)
  604. {
  605. Ov = NULL;
  606. }
  607. return Ov;
  608. }
  609. //---------------------------------------------------------------------------
  610. void APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color)
  611. {
  612. try
  613. {
  614. c->Pen->Color = clWhite;
  615. c->Pen->Width = 0;
  616. c->Pen->Style = psClear;
  617. c->Brush->Style = bsSolid;
  618. c->Brush->Color = color;
  619. c->Rectangle(offX, offY, w+offX+2, h+offY+2);
  620. }
  621. catch(...)
  622. {
  623. }
  624. }
  625. //---------------------------------------------------------------------------
  626. #include <DateUtils.hpp>
  627. TDateTime APP_StrToDateTime(String AStrDateTime)
  628. {
  629. TDateTime dtReturnValue = NULL;
  630. if (AStrDateTime.IsEmpty()) return dtReturnValue;
  631. if (AStrDateTime.Length() != 14) return dtReturnValue;
  632. AnsiString sDateTime = AnsiString(AStrDateTime);
  633. try
  634. {
  635. #if 0
  636. sDateTime.printf(L"%s-%s-%s %s:%s:%s",
  637. AStrDateTime.SubString( 1, 4).c_str(),
  638. AStrDateTime.SubString( 5, 2).c_str(),
  639. AStrDateTime.SubString( 7, 2).c_str(),
  640. AStrDateTime.SubString( 9, 2).c_str(),
  641. AStrDateTime.SubString(11, 2).c_str(),
  642. AStrDateTime.SubString(13, 2).c_str());
  643. dtReturnValue = StrToDateTime(sDateTime);
  644. #endif
  645. // swscanf(sRgb.c_str(), L"%d,%d,%d", &r, &g, &b);
  646. int year, month, day, hour, minute, second;
  647. sscanf(sDateTime.c_str(), "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
  648. dtReturnValue = EncodeDateTime(year, month, day, hour, minute, second, 0);
  649. }
  650. catch(...)
  651. {
  652. }
  653. return dtReturnValue;
  654. }
  655. //---------------------------------------------------------------------------