AppGlobalF.cpp 25 KB

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