AppGlobalF.cpp 25 KB

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