FrmUtilMainF.cpp 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <IniFiles.hpp>
  4. #include "ITSDbF.h"
  5. #pragma hdrstop
  6. #include "FrmUtilMainF.h"
  7. #include <stdio.h>
  8. #include <locale.h>
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxCheckBox"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxEdit"
  16. #pragma link "cxGraphics"
  17. #pragma link "cxGroupBox"
  18. #pragma link "cxLabel"
  19. #pragma link "cxLookAndFeelPainters"
  20. #pragma link "cxLookAndFeels"
  21. #pragma link "cxProgressBar"
  22. #pragma link "cxTextEdit"
  23. #pragma link "dxSkinsCore"
  24. #pragma link "dxSkinBlack"
  25. #pragma link "dxSkinMcSkin"
  26. #pragma link "dxmdaset"
  27. #pragma resource "*.dfm"
  28. TFrmUtilMain *FrmUtilMain;
  29. //---------------------------------------------------------------------------
  30. #define XML_DIR "\\MAPDATA\\layers\\"
  31. APP_CONFIG g_AppCfg;
  32. //Provider=tbprov.Tbprov.5;Cache Authentication=False;Encrypt Password=False;Integrated Security="";Mask Password=False;Persist Encrypted=False;Persist Security Info=False;User ID="";Bind Flags=0;Initial Catalog="";Data Source=GMUTIS;Impersonation Level=Anonymous;Location="";Lock Owner="";Mode=ReadWrite;Protection Level=None;Extended Properties="";Updatable Cursor=False;Enlist=None
  33. //Provider=tbprov.Tbprov.5;Cache Authentication=False;Encrypt Password=False;Integrated Security="";Mask Password=False;Persist Encrypted=False;Persist Security Info=False;User ID=itsdev;Bind Flags=0;Initial Catalog="";Data Source=GMUTIS;Impersonation Level=Anonymous;Location="";Lock Owner="";Mode=ReadWrite;Protection Level=None;Updatable Cursor=False;Enlist=None;
  34. bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
  35. {
  36. String sCfgFile;
  37. TIniFile *pIniFile = NULL;
  38. g_AppCfg.bAppClose = false;
  39. String sAppDir = ExtractFilePath(Application->ExeName);
  40. String sCfgDir = sAppDir + "Cfg\\";
  41. String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
  42. if (!ACfgFile.IsEmpty())
  43. sIniFile = ACfgFile + ".ini";
  44. sCfgFile = sCfgDir + sIniFile;
  45. String sMapDir = sAppDir + XML_DIR;
  46. ForceDirectories(sMapDir.c_str());
  47. try
  48. {
  49. String sTmp;
  50. pIniFile = new TIniFile(sCfgFile);
  51. String sSqlLog;
  52. g_AppCfg.itsdb.bSqlLog = false;
  53. g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
  54. g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
  55. g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
  56. g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
  57. g_AppCfg.link.bSqlLog = false;
  58. g_AppCfg.link.sProvider = pIniFile->ReadString("ITSDB_LINK", "PROVIDER", "OraOLEDB.Oracle.1");
  59. g_AppCfg.link.sServerName = pIniFile->ReadString("ITSDB_LINK", "SERVERNAME", "HANTE");
  60. g_AppCfg.link.sUserName = pIniFile->ReadString("ITSDB_LINK", "USERNAME", "hnits");
  61. g_AppCfg.link.sPassword = pIniFile->ReadString("ITSDB_LINK", "PASSWORD", "hnits");
  62. g_AppCfg.ifsc.bSqlLog = false;
  63. g_AppCfg.ifsc.sProvider = pIniFile->ReadString("ITSDB_IFSC", "PROVIDER", "OraOLEDB.Oracle.1");
  64. g_AppCfg.ifsc.sServerName = pIniFile->ReadString("ITSDB_IFSC", "SERVERNAME", "HANTE");
  65. g_AppCfg.ifsc.sUserName = pIniFile->ReadString("ITSDB_IFSC", "USERNAME", "hnits");
  66. g_AppCfg.ifsc.sPassword = pIniFile->ReadString("ITSDB_IFSC", "PASSWORD", "hnits");
  67. g_AppCfg.road.bSqlLog = false;
  68. g_AppCfg.road.sProvider = pIniFile->ReadString("ITSDB_ROAD", "PROVIDER", "OraOLEDB.Oracle.1");
  69. g_AppCfg.road.sServerName = pIniFile->ReadString("ITSDB_ROAD", "SERVERNAME", "HANTE");
  70. g_AppCfg.road.sUserName = pIniFile->ReadString("ITSDB_ROAD", "USERNAME", "hnits");
  71. g_AppCfg.road.sPassword = pIniFile->ReadString("ITSDB_ROAD", "PASSWORD", "hnits");
  72. String sTemp = g_AppCfg.itsdb.sProvider.UpperCase();
  73. if (sTemp.Pos("TIBERO"))
  74. {
  75. //g_AppCfg.itsdb.sProvider = "bprov.MSDTB.5";
  76. }
  77. g_AppCfg.flashmap.sMainMap = pIniFile->ReadString("FLASHMAP", "MAINMAP", "");
  78. g_AppCfg.flashmap.sLinkMap = pIniFile->ReadString("FLASHMAP", "LINKMAP", "");
  79. #if 0
  80. if (g_AppCfg.flashmap.sMainMap == "" ||
  81. g_AppCfg.flashmap.sLinkMap == "")
  82. {
  83. Application->MessageBox(L"지도 설정 정보를 읽어오는데 실패하였습니다.!!!!!!!!!!",
  84. L"환경설정 정보 로딩 오류!!!",
  85. MB_OK|MB_ICONERROR);
  86. }
  87. #endif
  88. g_AppCfg.flashmap.sMainMap = sAppDir + g_AppCfg.flashmap.sMainMap;
  89. g_AppCfg.flashmap.sLinkMap = sAppDir + g_AppCfg.flashmap.sLinkMap;
  90. }
  91. __finally
  92. {
  93. if (pIniFile) delete pIniFile;
  94. pIniFile = NULL;
  95. }
  96. return true;
  97. }
  98. //---------------------------------------------------------------------------
  99. void DB_CLOSE()
  100. {
  101. ITSDb_Close();
  102. }
  103. //---------------------------------------------------------------------------
  104. bool DB_OPEN(DB_INFO *ADbInfo)
  105. {
  106. DB_CLOSE();
  107. ITSDb_SetInfo(ADbInfo->sProvider, ADbInfo->sServerName, ADbInfo->sUserName, ADbInfo->sPassword);
  108. if (!ITSDb_Open())
  109. {
  110. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n환경파일에서 데이터베이스 연결 정보를 확인하세요.",
  111. L"데이터베이스 접속 오류!!!",
  112. MB_OK|MB_ICONERROR);
  113. return false;
  114. }
  115. return true;
  116. }
  117. __fastcall TFrmUtilMain::TFrmUtilMain(TComponent* Owner)
  118. : TForm(Owner)
  119. {
  120. Application->OnException = OnAppException;
  121. }
  122. //---------------------------------------------------------------------------
  123. void __fastcall TFrmUtilMain::OnAppException(TObject *Sender, Exception *exception)
  124. {
  125. String sClassName = (NULL != Sender) ? Sender->ClassName() : String("Unknown_Class");
  126. String sErrMsg = (NULL != exception) ? exception->Message : String("Unknown_Error");
  127. String sError = sClassName + " : " + sErrMsg;
  128. //Application->ShowException(&exception);
  129. //WriteLog(logError, "OnAppException: [%s]", AnsiString(sError).c_str());
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TFrmUtilMain::CommClose()
  133. {
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TFrmUtilMain::FormClose(TObject *Sender, TCloseAction &Action)
  137. {
  138. CommClose();
  139. //Action = caFree;
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TFrmUtilMain::FormCreate(TObject *Sender)
  143. {
  144. FOnMessage = Application->OnMessage;
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TFrmUtilMain::FormDestroy(TObject *Sender)
  148. {
  149. try
  150. {
  151. //::OleUninitialize();
  152. //::CoUninitialize();
  153. }
  154. catch(Exception &exception)
  155. {
  156. //WriteLog(logError, "FormDestroy: [%s]", AnsiString(exception.ClassName()+exception.Message).c_str());
  157. }
  158. }
  159. //---------------------------------------------------------------------------
  160. void __fastcall TFrmUtilMain::FormShow(TObject *Sender)
  161. {
  162. Application->ProcessMessages();
  163. edPath->Text = ExtractFilePath(Application->ExeName) + XML_DIR;
  164. Refresh();
  165. Application->ProcessMessages();
  166. TmrOnShow->Enabled = true;
  167. }
  168. //---------------------------------------------------------------------------
  169. void __fastcall TFrmUtilMain::FormCloseQuery(TObject *Sender, bool &CanClose)
  170. {
  171. // 폼이 닫히기 전에 수행해야 할 모뮬 기술
  172. // 프로그램 종료를 사용자가 확인할 수 있도록...
  173. if (!g_AppCfg.bAppClose)
  174. {
  175. String strMsg;
  176. strMsg = "";
  177. strMsg = "[ " + Caption + " ]\r\n\n";
  178. strMsg+= "프로그램을 종료 하시겠습니까?";
  179. //if(Application->MessageBox(strMsg.c_str(), String("프로그램 종료 확인").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES)
  180. {
  181. /*
  182. * 화면관련 작업을 못하도록 여기에 코드를 적자...
  183. */
  184. ITSDb_ApplicationTerm();
  185. g_AppCfg.bAppClose = true;
  186. }
  187. CanClose = false;
  188. }
  189. }
  190. //---------------------------------------------------------------------------
  191. void __fastcall TFrmUtilMain::BtnCloseClick(TObject *Sender)
  192. {
  193. g_AppCfg.bAppClose = true;
  194. Close();
  195. }
  196. //---------------------------------------------------------------------------
  197. void __fastcall TFrmUtilMain::TmrOnShowTimer(TObject *Sender)
  198. {
  199. TmrOnShow->Enabled = false;
  200. #if 0
  201. if (!ITSDb_Open())
  202. {
  203. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n환경파일에서 데이터베이스 연결 정보를 확인하세요.\r\n\r\n프로그램을 종료합니다.",
  204. L"데이터베이스 접속 오류!!!",
  205. MB_OK|MB_ICONERROR);
  206. g_AppCfg.bAppClose = true;
  207. Close();
  208. return;
  209. }
  210. #endif
  211. TmrAppState->Enabled = true;
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TFrmUtilMain::TmrAppStateTimer(TObject *Sender)
  215. {
  216. TmrAppState->Enabled = false;
  217. if (g_AppCfg.bAppClose)
  218. {
  219. ITSDb_Close();
  220. Close();
  221. try {
  222. Application->Terminate();
  223. } catch(Exception &exception) {}
  224. }
  225. else
  226. {
  227. TmrAppState->Enabled = true;
  228. }
  229. }
  230. //---------------------------------------------------------------------------
  231. void __fastcall TFrmUtilMain::UpdateProgress(int AProg, String AMsg/*=""*/)
  232. {
  233. try {
  234. cxProgressBar1->Position = AProg;
  235. if (AMsg != "") LblStatus->Caption = AMsg;
  236. Application->ProcessMessages();
  237. } catch(Exception &exception) {}
  238. }
  239. //---------------------------------------------------------------------------
  240. void __fastcall TFrmUtilMain::cxButton1Click(TObject *Sender)
  241. {
  242. #if 0
  243. // 데이터베이스 버텍스 정보 설정
  244. int nStep;
  245. String sQry;
  246. TADOQuery *pADO = NULL;
  247. if (Application->MessageBox(L"데이터베이스 Vertex 정보를 생성하시겠습니까?\r\n기존의 정보가 삭제되고 새로운 정보가 입력됩니다.",
  248. L"데이터베이스 Vertex 정보생성", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES)
  249. {
  250. return;
  251. }
  252. cxProgressBar1->Properties->Max = 9;
  253. PnlProg->Left = 16;
  254. PnlProg->Top = 304;
  255. PnlProg->Visible = true;
  256. cxButton1->Enabled = false;
  257. cxButton2->Enabled = false;
  258. try
  259. {
  260. pADO = new TADOQuery(NULL);
  261. ITSDb_GetConnection()->BeginTrans();
  262. pADO->Connection = ITSDb_GetConnection();
  263. try {
  264. nStep = 1;
  265. UpdateProgress(nStep, cxLabel3->Caption);
  266. sQry = "DELETE TB_ROAD_VRTX_ARR";
  267. pADO->Close();
  268. pADO->SQL->Text = sQry;
  269. pADO->ExecSQL();
  270. LblDb01->Caption = "성공";
  271. sQry = "INSERT INTO TB_ROAD_VRTX_ARR \r\n"
  272. "SELECT X.ROAD_ID, X.LEVL, Y.CRDN_CNT, X.X_CRDN_ARR, X.Y_CRDN_ARR, \r\n"
  273. " Y.X_CRDN_MIN, Y.X_CRDN_MAX, Y.Y_CRDN_MIN, Y.Y_CRDN_MAX \r\n"
  274. " FROM (SELECT ROAD_ID, :p01 AS LEVL, \r\n"
  275. " SUBSTR(MAX(SYS_CONNECT_BY_PATH (X_CRDN, ',')), 2) X_CRDN_ARR, \r\n"
  276. " SUBSTR(MAX(SYS_CONNECT_BY_PATH (Y_CRDN, ',')), 2) Y_CRDN_ARR \r\n"
  277. " FROM (SELECT ROAD_ID, X_CRDN, Y_CRDN, \r\n"
  278. " ROW_NUMBER () OVER (PARTITION BY ROAD_ID ORDER BY ORD) RNUM \r\n"
  279. " FROM (SELECT ROAD_ID, ORD, X_CRDN, Y_CRDN \r\n"
  280. " FROM TB_ROAD_VRTX \r\n"
  281. " WHERE LEVL = :p02 \r\n"
  282. " ) \r\n"
  283. " ) \r\n"
  284. " START WITH RNUM = 1 \r\n"
  285. " CONNECT BY PRIOR RNUM = RNUM - 1 AND PRIOR ROAD_ID = ROAD_ID \r\n"
  286. " GROUP BY ROAD_ID) X, \r\n"
  287. " (SELECT ROAD_ID, LEVL, COUNT(1) AS CRDN_CNT, \r\n"
  288. " MIN(X_CRDN) AS X_CRDN_MIN, MAX(X_CRDN) AS X_CRDN_MAX, \r\n"
  289. " MIN(Y_CRDN) AS Y_CRDN_MIN, MAX(Y_CRDN) AS Y_CRDN_MAX \r\n"
  290. " FROM TB_ROAD_VRTX \r\n"
  291. " GROUP BY ROAD_ID, LEVL) Y \r\n"
  292. " WHERE X.ROAD_ID = Y.ROAD_ID \r\n"
  293. " AND X.LEVL = Y.LEVL \r\n"
  294. " AND X.ROAD_ID IN (SELECT ROAD_ID FROM TB_ROAD WHERE DEL_YN = 'N') \r\n";
  295. nStep = 2;
  296. UpdateProgress(nStep, cxLabel4->Caption);
  297. pADO->Close();
  298. pADO->SQL->Text = sQry;
  299. pADO->Parameters->ParamByName("p01")->Value = "1000";
  300. pADO->Parameters->ParamByName("p02")->Value = "1000";
  301. pADO->ExecSQL();
  302. LblDb02->Caption = "성공";
  303. nStep = 3;
  304. UpdateProgress(nStep, cxLabel5->Caption);
  305. //pADO->Close();
  306. //pADO->SQL->Text = sQry;
  307. pADO->Parameters->ParamByName("p01")->Value = "2000";
  308. pADO->Parameters->ParamByName("p02")->Value = "2000";
  309. pADO->ExecSQL();
  310. LblDb03->Caption = "성공";
  311. nStep = 4;
  312. UpdateProgress(nStep, cxLabel6->Caption);
  313. //pADO->Close();
  314. //pADO->SQL->Text = sQry;
  315. pADO->Parameters->ParamByName("p01")->Value = "4000";
  316. pADO->Parameters->ParamByName("p02")->Value = "4000";
  317. pADO->ExecSQL();
  318. LblDb04->Caption = "성공";
  319. nStep = 5;
  320. UpdateProgress(nStep, cxLabel7->Caption);
  321. sQry = "DELETE TB_IFSC_VRTX_ARR";
  322. pADO->Close();
  323. pADO->SQL->Text = sQry;
  324. pADO->ExecSQL();
  325. LblDb05->Caption = "성공";
  326. sQry = "INSERT INTO TB_IFSC_VRTX_ARR \r\n"
  327. "SELECT X.IFSC_ID, X.LEVL, Y.CRDN_CNT, X.X_CRDN_ARR, X.Y_CRDN_ARR, \r\n"
  328. " Y.X_CRDN_MIN, Y.X_CRDN_MAX, Y.Y_CRDN_MIN, Y.Y_CRDN_MAX \r\n"
  329. " FROM (SELECT IFSC_ID, :p01 AS LEVL, \r\n"
  330. " SUBSTR(MAX(SYS_CONNECT_BY_PATH (X_CRDN, ',')), 2) X_CRDN_ARR, \r\n"
  331. " SUBSTR(MAX(SYS_CONNECT_BY_PATH (Y_CRDN, ',')), 2) Y_CRDN_ARR \r\n"
  332. " FROM (SELECT IFSC_ID, X_CRDN, Y_CRDN, \r\n"
  333. " ROW_NUMBER () OVER (PARTITION BY IFSC_ID ORDER BY ORD) RNUM \r\n"
  334. " FROM (SELECT IFSC_ID, ORD, X_CRDN, Y_CRDN \r\n"
  335. " FROM TB_IFSC_VRTX \r\n"
  336. " WHERE LEVL = :p02 \r\n"
  337. " ) \r\n"
  338. " ) \r\n"
  339. " START WITH RNUM = 1 \r\n"
  340. " CONNECT BY PRIOR RNUM = RNUM - 1 AND PRIOR IFSC_ID = IFSC_ID \r\n"
  341. " GROUP BY IFSC_ID) X, \r\n"
  342. " (SELECT IFSC_ID, LEVL, COUNT(1) AS CRDN_CNT, \r\n"
  343. " MIN(X_CRDN) AS X_CRDN_MIN, MAX(X_CRDN) AS X_CRDN_MAX, \r\n"
  344. " MIN(Y_CRDN) AS Y_CRDN_MIN, MAX(Y_CRDN) AS Y_CRDN_MAX \r\n"
  345. " FROM TB_IFSC_VRTX \r\n"
  346. " GROUP BY IFSC_ID, LEVL) Y \r\n"
  347. " WHERE X.IFSC_ID = Y.IFSC_ID \r\n"
  348. " AND X.LEVL = Y.LEVL \r\n"
  349. " AND X.IFSC_ID IN (SELECT IFSC_ID FROM TB_IFSC WHERE DEL_YN = 'N') \r\n";
  350. nStep = 6;
  351. UpdateProgress(nStep, cxLabel8->Caption);
  352. pADO->Close();
  353. pADO->SQL->Text = sQry;
  354. pADO->Parameters->ParamByName("p01")->Value = "50";
  355. pADO->Parameters->ParamByName("p02")->Value = "50";
  356. pADO->ExecSQL();
  357. LblDb06->Caption = "성공";
  358. nStep = 7;
  359. UpdateProgress(nStep, cxLabel9->Caption);
  360. //pADO->Close();
  361. //pADO->SQL->Text = sQry;
  362. pADO->Parameters->ParamByName("p01")->Value = "100";
  363. pADO->Parameters->ParamByName("p02")->Value = "100";
  364. pADO->ExecSQL();
  365. LblDb07->Caption = "성공";
  366. nStep = 8;
  367. UpdateProgress(nStep, cxLabel10->Caption);
  368. //pADO->Close();
  369. //pADO->SQL->Text = sQry;
  370. pADO->Parameters->ParamByName("p01")->Value = "250";
  371. pADO->Parameters->ParamByName("p02")->Value = "250";
  372. pADO->ExecSQL();
  373. LblDb08->Caption = "성공";
  374. nStep = 9;
  375. UpdateProgress(nStep, cxLabel11->Caption);
  376. //pADO->Close();
  377. //pADO->SQL->Text = sQry;
  378. pADO->Parameters->ParamByName("p01")->Value = "500";
  379. pADO->Parameters->ParamByName("p02")->Value = "500";
  380. pADO->ExecSQL();
  381. LblDb09->Caption = "성공";
  382. ITSDb_GetConnection()->CommitTrans();
  383. Application->MessageBox(L"데이터베이스 Vertex 정보를 생성하였습니다.", L"데이터베이스 Vertex 정보생성", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  384. } catch(Exception &exception) {
  385. ITSDb_GetConnection()->RollbackTrans();
  386. switch(nStep)
  387. {
  388. case 1: LblDb01->Caption = "실패"; break;
  389. case 2: LblDb02->Caption = "실패"; break;
  390. case 3: LblDb03->Caption = "실패"; break;
  391. case 4: LblDb04->Caption = "실패"; break;
  392. case 5: LblDb05->Caption = "실패"; break;
  393. case 6: LblDb06->Caption = "실패"; break;
  394. case 7: LblDb07->Caption = "실패"; break;
  395. case 8: LblDb08->Caption = "실패"; break;
  396. case 9: LblDb09->Caption = "실패"; break;
  397. }
  398. String sErrMsg;
  399. sErrMsg = "데이터베이스 작업중에 오류가 발생 하였습니다.\r\n";
  400. sErrMsg+= String(exception.ClassName()) + exception.Message;
  401. Application->MessageBox(sErrMsg.c_str(), L"데이터베이스 Vertex 정보 생성 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  402. return;
  403. }
  404. }
  405. __finally
  406. {
  407. PnlProg->Visible = false;
  408. cxButton1->Enabled = true;
  409. cxButton2->Enabled = true;
  410. if (pADO)
  411. {
  412. pADO->Close();
  413. delete pADO;
  414. }
  415. }
  416. #endif
  417. }
  418. //---------------------------------------------------------------------------
  419. void __fastcall TFrmUtilMain::cxButton2Click(TObject *Sender)
  420. {
  421. int nStep;
  422. String sQry;
  423. TADOQuery *pADO = NULL;
  424. if ((!ChkLinkVertex->Checked) &&
  425. (!ChkIfscVertex->Checked) &&
  426. (!ChkRoadVertex->Checked)
  427. )
  428. {
  429. Application->MessageBox(L"작업 대상 정보를 선택하십시요.", L"XML 파일 생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  430. return;
  431. }
  432. if (Application->MessageBox(L"선택한 정보의 좌표파일을 신규로 생성하시겠습니까?\r\n기존의 파일은 삭제되고 새로운 파일이 생성됩니다.",
  433. L"지도 좌표 파일 생성", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES)
  434. {
  435. return;
  436. }
  437. try
  438. {
  439. //_wsetlocale(LC_ALL, L"kor");
  440. cxProgressBar1->Properties->Max = 2;
  441. PnlProg->Left = 16;
  442. PnlProg->Top = 124;
  443. PnlProg->Visible = true;
  444. pADO = new TADOQuery(NULL);
  445. pADO->Connection = ITSDb_GetConnection();
  446. pADO->CursorLocation = clUseClient;
  447. pADO->CursorType = ctStatic;//ctOpenForwardOnly;
  448. pADO->LockType = ltReadOnly;//ltBatchOptimistic;
  449. pADO->DisableControls();
  450. if (ChkLinkVertex->Checked) MakeLinkVertexXml(pADO);
  451. if (ChkIfscVertex->Checked) MakeIfscVertexXml(pADO);
  452. if (ChkRoadVertex->Checked) MakeRoadVertexXml(pADO);
  453. Application->MessageBox(L"선택한 정보의 좌표파일 생성을 완료하였습니다.", L"지도 좌표 파일 생성", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  454. }
  455. __finally
  456. {
  457. PnlProg->Visible = false;
  458. cxButton2->Enabled = true;
  459. if (pADO)
  460. {
  461. pADO->Close();
  462. delete pADO;
  463. }
  464. }
  465. }
  466. //---------------------------------------------------------------------------
  467. bool __fastcall TFrmUtilMain::MakeLinkVertexXml(TADOQuery *pADO)
  468. {
  469. if (DB_OPEN(&g_AppCfg.link) == false)
  470. {
  471. return false;
  472. }
  473. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "LINK.dat";
  474. AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "LINK_"+Now().FormatString("yyyymmddhhnnss")+".dat";
  475. try
  476. {
  477. CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
  478. }
  479. catch(Exception &e)
  480. {
  481. }
  482. FILE *fd = NULL;
  483. UpdateProgress(1, "링크 구간좌표 정보 파일생성");
  484. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  485. {
  486. Application->MessageBox(L"링크 구간좌표 정보 파일 파일을 생성하지 못하였습니다.",
  487. L"링크 구간좌표 정보 파일 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  488. return false;
  489. }
  490. int nRows= 0;
  491. int nCnt = 0;
  492. String sQry;
  493. try
  494. {
  495. try
  496. {
  497. //sQry = "SELECT A.LINK_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
  498. sQry = "SELECT A.LINK_ID AS ID, \r\n"
  499. " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
  500. " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
  501. " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
  502. " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
  503. " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
  504. " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
  505. " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
  506. " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
  507. " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
  508. " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
  509. " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
  510. " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
  511. " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
  512. " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
  513. " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
  514. " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
  515. " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
  516. " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
  517. " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
  518. " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
  519. " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
  520. " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
  521. " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
  522. " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
  523. " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
  524. " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
  525. " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
  526. " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
  527. " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
  528. " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
  529. " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
  530. " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
  531. " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
  532. " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
  533. " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
  534. " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
  535. " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
  536. " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
  537. " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
  538. " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
  539. " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
  540. " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
  541. " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
  542. " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
  543. " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
  544. " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
  545. " FROM TB_LINK_VRTX_ARR A, \r\n"
  546. " TB_LINK B \r\n"
  547. " WHERE B.DEL_YN = 'N' \r\n"
  548. " AND B.LINK_ID = A.LINK_ID \r\n"
  549. " AND A.LEVL = 1 \r\n";
  550. pADO->Close();
  551. pADO->SQL->Text = sQry;
  552. pADO->Open();
  553. nRows = pADO->RecordCount;
  554. cxProgressBar1->Properties->Max = nRows;
  555. String ID;
  556. String XAddr;
  557. String YAddr;
  558. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  559. {
  560. ID = pADO->FieldByName("ID")->AsString;
  561. //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
  562. //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
  563. XAddr = "";
  564. YAddr = "";
  565. String sColNm;
  566. for (int ii = 1; ii < 24; ii++)
  567. {
  568. sColNm.printf(L"XMSG%02d", ii);
  569. XAddr += pADO->FieldByName(sColNm)->AsWideString;
  570. sColNm.printf(L"YMSG%02d", ii);
  571. YAddr += pADO->FieldByName(sColNm)->AsWideString;
  572. }
  573. fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
  574. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  575. }
  576. }
  577. catch(Exception &exception)
  578. {
  579. throw Exception(String(exception.ClassName()) + exception.Message);
  580. return false;
  581. }
  582. }
  583. __finally
  584. {
  585. UpdateProgress(nRows);
  586. if (fd)
  587. {
  588. fclose(fd);
  589. }
  590. pADO->Close();
  591. DB_CLOSE();
  592. }
  593. return true;
  594. }
  595. //---------------------------------------------------------------------------
  596. bool __fastcall TFrmUtilMain::MakeIfscVertexXml2(TADOQuery *pADO)
  597. {
  598. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC.dat";
  599. AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC_"+Now().FormatString("yyyymmddhhnnss")+".dat";
  600. try
  601. {
  602. CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
  603. }
  604. catch(Exception &e)
  605. {
  606. }
  607. FILE *fd = NULL;
  608. UpdateProgress(1, "정보제공구간 구간좌표 정보 파일생성");
  609. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  610. {
  611. Application->MessageBox(L"정보제공구간 구간좌표 정보 파일을 생성하지 못하였습니다.",
  612. L"정보제공구간 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  613. return false;
  614. }
  615. int nRows= 0;
  616. int nCnt = 0;
  617. String sQry;
  618. int nTotal = 0;
  619. #if 0
  620. sQry = "SELECT A.IFSC_ID AS ID, \r\n"
  621. " SUBSTR(A.X_CRDN_ARR, 1, 400) AS XMSG01, \r\n"
  622. " SUBSTR(A.X_CRDN_ARR, 401, 400) AS XMSG02, \r\n"
  623. " SUBSTR(A.X_CRDN_ARR, 801, 400) AS XMSG03, \r\n"
  624. " SUBSTR(A.X_CRDN_ARR, 1201, 400) AS XMSG04, \r\n"
  625. " SUBSTR(A.X_CRDN_ARR, 1601, 400) AS XMSG05, \r\n"
  626. " SUBSTR(A.X_CRDN_ARR, 2001, 400) AS XMSG06, \r\n"
  627. " SUBSTR(A.X_CRDN_ARR, 2401, 400) AS XMSG07, \r\n"
  628. " SUBSTR(A.X_CRDN_ARR, 2801, 400) AS XMSG08, \r\n"
  629. " SUBSTR(A.X_CRDN_ARR, 3201, 400) AS XMSG09, \r\n"
  630. " SUBSTR(A.X_CRDN_ARR, 3601, 400) AS XMSG10, \r\n"
  631. " SUBSTR(A.X_CRDN_ARR, 4001, 400) AS XMSG11, \r\n"
  632. " SUBSTR(A.X_CRDN_ARR, 4401, 400) AS XMSG12, \r\n"
  633. " SUBSTR(A.Y_CRDN_ARR, 1, 400) AS YMSG01, \r\n"
  634. " SUBSTR(A.Y_CRDN_ARR, 401, 400) AS YMSG02, \r\n"
  635. " SUBSTR(A.Y_CRDN_ARR, 801, 400) AS YMSG03, \r\n"
  636. " SUBSTR(A.Y_CRDN_ARR, 1201, 400) AS YMSG04, \r\n"
  637. " SUBSTR(A.Y_CRDN_ARR, 1601, 400) AS YMSG05, \r\n"
  638. " SUBSTR(A.Y_CRDN_ARR, 2001, 400) AS YMSG06, \r\n"
  639. " SUBSTR(A.Y_CRDN_ARR, 2401, 400) AS YMSG07, \r\n"
  640. " SUBSTR(A.Y_CRDN_ARR, 2801, 400) AS YMSG08, \r\n"
  641. " SUBSTR(A.Y_CRDN_ARR, 3201, 400) AS YMSG09, \r\n"
  642. " SUBSTR(A.Y_CRDN_ARR, 3601, 400) AS YMSG10, \r\n"
  643. " SUBSTR(A.Y_CRDN_ARR, 4001, 400) AS YMSG11, \r\n"
  644. " SUBSTR(A.Y_CRDN_ARR, 4401, 400) AS YMSG12 \r\n"
  645. " FROM TB_IFSC_VRTX_ARR A, \r\n"
  646. " TB_IFSC B \r\n"
  647. " WHERE B.DEL_YN = 'N' \r\n"
  648. " AND B.IFSC_ID = A.IFSC_ID \r\n"
  649. " AND A.LEVL = 5 \r\n";
  650. #if 1
  651. sQry = "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
  652. " FROM TB_IFSC_VRTX_ARR A, \r\n"
  653. " TB_IFSC B \r\n"
  654. " WHERE B.DEL_YN = 'N' \r\n"
  655. " AND B.IFSC_ID = A.IFSC_ID \r\n"
  656. " AND A.LEVL = 5 \r\n";
  657. #endif
  658. #endif
  659. try
  660. {
  661. try
  662. {
  663. sQry = "SELECT COUNT(1) AS TOTAL_CNT \r\n"
  664. " FROM TB_IFSC_VRTX_ARR A, \r\n"
  665. " TB_IFSC B \r\n"
  666. " WHERE B.DEL_YN = 'N' \r\n"
  667. " AND B.IFSC_ID = A.IFSC_ID \r\n"
  668. " AND A.LEVL = 5 \r\n";
  669. pADO->Close();
  670. pADO->SQL->Text = sQry;
  671. pADO->Open();
  672. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  673. {
  674. nTotal = pADO->FieldByName("TOTAL_CNT")->AsInteger;
  675. }
  676. }
  677. catch(Exception &exception)
  678. {
  679. throw Exception(String(exception.ClassName()) + exception.Message);
  680. return false;
  681. }
  682. }
  683. __finally
  684. {
  685. pADO->Close();
  686. }
  687. int nFetchRows = 500;
  688. int nFetchCnts = nTotal / nFetchRows;
  689. nFetchCnts = nFetchCnts + ((nTotal % nFetchRows) ? 1 : 0);
  690. for (int seq = 0; seq < nFetchCnts; seq++)
  691. {
  692. try
  693. {
  694. try
  695. {
  696. sQry = "SELECT ID, X_CRDN_ARR, Y_CRDN_ARR \r\n"
  697. " FROM ( \r\n"
  698. "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR, ROWNUM AS DATA_SEQ \r\n"
  699. " FROM TB_IFSC_VRTX_ARR A, \r\n"
  700. " TB_IFSC B \r\n"
  701. " WHERE B.DEL_YN = 'N' \r\n"
  702. " AND B.IFSC_ID = A.IFSC_ID \r\n"
  703. " AND A.LEVL = 5 \r\n"
  704. " ORDER BY A.IFSC_ID \r\n"
  705. " ) \r\n"
  706. " WHERE DATA_SEQ >= :p01 AND DATA_SEQ < :p02 \r\n";
  707. pADO->Close();
  708. pADO->SQL->Text = sQry;
  709. pADO->Parameters->ParamByName("p01")->Value = seq*nFetchRows;
  710. pADO->Parameters->ParamByName("p02")->Value = (seq+1)*nFetchRows;
  711. pADO->Open();
  712. //nRows = pADO->RecordCount;
  713. //cxProgressBar1->Properties->Max = nRows;
  714. String ID;
  715. String XAddr;
  716. String YAddr;
  717. nCnt = 0;
  718. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  719. {
  720. ID = pADO->FieldByName("ID")->AsString;
  721. XAddr = pADO->FieldByName("X_CRDN_ARR")->AsString;
  722. YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsString;
  723. fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
  724. //if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  725. Application->ProcessMessages();
  726. }
  727. }
  728. catch(Exception &exception)
  729. {
  730. throw Exception(String(exception.ClassName()) + exception.Message);
  731. return false;
  732. }
  733. }
  734. __finally
  735. {
  736. //UpdateProgress(nRows);
  737. if (fd)
  738. {
  739. fclose(fd);
  740. }
  741. pADO->Close();
  742. }
  743. }
  744. return true;
  745. }
  746. //---------------------------------------------------------------------------
  747. bool __fastcall TFrmUtilMain::MakeIfscVertexXml(TADOQuery *pADO)
  748. {
  749. if (DB_OPEN(&g_AppCfg.ifsc) == false)
  750. {
  751. return false;
  752. }
  753. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC.dat";
  754. AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC_"+Now().FormatString("yyyymmddhhnnss")+".dat";
  755. try
  756. {
  757. CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
  758. }
  759. catch(Exception &e)
  760. {
  761. }
  762. FILE *fd = NULL;
  763. UpdateProgress(1, "정보제공구간 구간좌표 정보 파일생성");
  764. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  765. {
  766. Application->MessageBox(L"정보제공구간 구간좌표 정보 파일을 생성하지 못하였습니다.",
  767. L"정보제공구간 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  768. return false;
  769. }
  770. int nRows= 0;
  771. int nCnt = 0;
  772. String sQry;
  773. try
  774. {
  775. try
  776. {
  777. //sQry = "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
  778. sQry = "SELECT A.IFSC_ID AS ID, \r\n"
  779. " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
  780. " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
  781. " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
  782. " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
  783. " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
  784. " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
  785. " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
  786. " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
  787. " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
  788. " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
  789. " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
  790. " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
  791. " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
  792. " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
  793. " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
  794. " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
  795. " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
  796. " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
  797. " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
  798. " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
  799. " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
  800. " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
  801. " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
  802. " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
  803. " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
  804. " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
  805. " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
  806. " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
  807. " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
  808. " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
  809. " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
  810. " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
  811. " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
  812. " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
  813. " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
  814. " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
  815. " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
  816. " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
  817. " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
  818. " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
  819. " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
  820. " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
  821. " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
  822. " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
  823. " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
  824. " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
  825. " FROM TB_IFSC_VRTX_ARR A, \r\n"
  826. " TB_IFSC B \r\n"
  827. " WHERE B.DEL_YN = 'N' \r\n"
  828. " AND B.IFSC_ID = A.IFSC_ID \r\n"
  829. " AND A.LEVL = 5 \r\n";
  830. pADO->Close();
  831. pADO->SQL->Text = sQry;
  832. pADO->Open();
  833. nRows = pADO->RecordCount;
  834. cxProgressBar1->Properties->Max = nRows;
  835. String ID;
  836. String XAddr;
  837. String YAddr;
  838. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  839. {
  840. ID = pADO->FieldByName("ID")->AsString;
  841. //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
  842. //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
  843. XAddr = "";
  844. YAddr = "";
  845. String sColNm;
  846. for (int ii = 1; ii < 24; ii++)
  847. {
  848. sColNm.printf(L"XMSG%02d", ii);
  849. XAddr += pADO->FieldByName(sColNm)->AsWideString;
  850. sColNm.printf(L"YMSG%02d", ii);
  851. YAddr += pADO->FieldByName(sColNm)->AsWideString;
  852. }
  853. fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
  854. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  855. }
  856. }
  857. catch(Exception &exception)
  858. {
  859. throw Exception(String(exception.ClassName()) + exception.Message);
  860. return false;
  861. }
  862. }
  863. __finally
  864. {
  865. UpdateProgress(nRows);
  866. if (fd)
  867. {
  868. fclose(fd);
  869. }
  870. pADO->Close();
  871. DB_CLOSE();
  872. }
  873. return true;
  874. }
  875. //---------------------------------------------------------------------------
  876. bool __fastcall TFrmUtilMain::MakeRoadVertexXml(TADOQuery *pADO)
  877. {
  878. if (DB_OPEN(&g_AppCfg.road) == false)
  879. {
  880. return false;
  881. }
  882. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "ROAD.dat";
  883. AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "ROAD_"+Now().FormatString("yyyymmddhhnnss")+".dat";
  884. try
  885. {
  886. CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
  887. }
  888. catch(Exception &e)
  889. {
  890. }
  891. FILE *fd = NULL;
  892. UpdateProgress(1, "도로 구간좌표 정보 파일생성");
  893. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  894. {
  895. Application->MessageBox(L"도로 구간좌표 정보 파일을 생성하지 못하였습니다.",
  896. L"도로 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  897. return false;
  898. }
  899. int nRows= 0;
  900. int nCnt = 0;
  901. String sQry;
  902. try
  903. {
  904. try
  905. {
  906. //sQry = "SELECT A.ROAD_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
  907. sQry = "SELECT A.ROAD_ID AS ID, \r\n"
  908. " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
  909. " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
  910. " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
  911. " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
  912. " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
  913. " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
  914. " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
  915. " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
  916. " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
  917. " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
  918. " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
  919. " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
  920. " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
  921. " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
  922. " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
  923. " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
  924. " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
  925. " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
  926. " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
  927. " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
  928. " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
  929. " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
  930. " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
  931. " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
  932. " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
  933. " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
  934. " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
  935. " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
  936. " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
  937. " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
  938. " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
  939. " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
  940. " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
  941. " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
  942. " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
  943. " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
  944. " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
  945. " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
  946. " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
  947. " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
  948. " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
  949. " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
  950. " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
  951. " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
  952. " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
  953. " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
  954. " FROM TB_ROAD_VRTX_ARR A, \r\n"
  955. " TB_ROAD B \r\n"
  956. " WHERE B.DEL_YN = 'N' \r\n"
  957. " AND B.ROAD_ID = A.ROAD_ID \r\n"
  958. " AND A.LEVL = 7 \r\n";
  959. pADO->Close();
  960. pADO->SQL->Text = sQry;
  961. pADO->Open();
  962. nRows = pADO->RecordCount;
  963. cxProgressBar1->Properties->Max = nRows;
  964. String ID;
  965. String XAddr;
  966. String YAddr;
  967. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  968. {
  969. ID = pADO->FieldByName("ID")->AsString;
  970. //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
  971. //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
  972. XAddr = "";
  973. YAddr = "";
  974. String sColNm;
  975. for (int ii = 1; ii < 24; ii++)
  976. {
  977. sColNm.printf(L"XMSG%02d", ii);
  978. XAddr += pADO->FieldByName(sColNm)->AsWideString;
  979. sColNm.printf(L"YMSG%02d", ii);
  980. YAddr += pADO->FieldByName(sColNm)->AsWideString;
  981. }
  982. fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
  983. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  984. }
  985. }
  986. catch(Exception &exception)
  987. {
  988. throw Exception(String(exception.ClassName()) + exception.Message);
  989. return false;
  990. }
  991. }
  992. __finally
  993. {
  994. UpdateProgress(nRows);
  995. if (fd)
  996. {
  997. fclose(fd);
  998. }
  999. pADO->Close();
  1000. DB_CLOSE();
  1001. }
  1002. return true;
  1003. }
  1004. //---------------------------------------------------------------------------
  1005. bool __fastcall TFrmUtilMain::WriteXmlHead(FILE *AFd, bool AHead/*=true*/)
  1006. {
  1007. try
  1008. {
  1009. if (AFd == NULL) return false;
  1010. if (AHead)
  1011. {
  1012. fprintf(AFd, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
  1013. fprintf(AFd, "<DataList>\n");
  1014. }
  1015. else
  1016. {
  1017. fprintf(AFd, "</DataList>\n");
  1018. }
  1019. }
  1020. catch(Exception &exception)
  1021. {
  1022. throw Exception(String(exception.ClassName()) + exception.Message);
  1023. return false;
  1024. }
  1025. return true;
  1026. }
  1027. //---------------------------------------------------------------------------
  1028. bool __fastcall TFrmUtilMain::WriteXmlObject(FILE *AFd, String AObject)
  1029. {
  1030. try
  1031. {
  1032. if (AFd == NULL) return false;
  1033. fwprintf(AFd, L"<object>%s</object>\n", AObject.c_str());
  1034. }
  1035. catch(Exception &exception)
  1036. {
  1037. throw Exception(String(exception.ClassName()) + exception.Message);
  1038. return false;
  1039. }
  1040. return true;
  1041. }
  1042. //---------------------------------------------------------------------------
  1043. bool __fastcall TFrmUtilMain::WriteXmlRecordCount(FILE *AFd, int ARows)
  1044. {
  1045. try
  1046. {
  1047. if (AFd == NULL) return false;
  1048. fprintf(AFd, "<count>%d</count>\n", ARows);
  1049. }
  1050. catch(Exception &exception)
  1051. {
  1052. throw Exception(String(exception.ClassName()) + exception.Message);
  1053. return false;
  1054. }
  1055. return true;
  1056. }
  1057. //---------------------------------------------------------------------------
  1058. bool __fastcall TFrmUtilMain::MakeNodeXml(TADOQuery *pADO)
  1059. {
  1060. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Node.xml";
  1061. FILE *fd = NULL;
  1062. UpdateProgress(1, "노드정보 XML 파일생성");
  1063. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  1064. {
  1065. Application->MessageBox(L"노드정보 XML 파일을 생성하지 못하였습니다.",
  1066. L"노드정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  1067. return false;
  1068. }
  1069. WriteXmlHead(fd, true);
  1070. WriteXmlObject(fd, "node");
  1071. int nRows= 0;
  1072. int nCnt = 0;
  1073. String sQry;
  1074. try
  1075. {
  1076. try
  1077. {
  1078. sQry = "SELECT A.NODE_ID, A.NODE_TYPE, A.NODE_NAME, \r\n"
  1079. " A.TURN_P, A.RMRK, A.X_CRDN, A.Y_CRDN \r\n"
  1080. " FROM TB_NODE A \r\n"
  1081. " ORDER BY A.NODE_ID \r\n";
  1082. pADO->Close();
  1083. pADO->SQL->Text = sQry;
  1084. pADO->Open();
  1085. nRows = pADO->RecordCount;
  1086. cxProgressBar1->Properties->Max = nRows;
  1087. WriteXmlRecordCount(fd, nRows);
  1088. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  1089. {
  1090. String NODE_ID = pADO->FieldByName("NODE_ID")->AsString; //노드ID
  1091. //String NODE_TYPE = pADO->FieldByName("NODE_TYPE")->AsString; //노드유형
  1092. String NODE_NAME = pADO->FieldByName("NODE_NAME")->AsString.Trim(); //교차로명칭
  1093. //String TURN_P = pADO->FieldByName("TURN_P")->AsString; //회전제한유무
  1094. //String RMRK = pADO->FieldByName("RMRK")->AsString.Trim(); //비고
  1095. String X_CRDN = pADO->FieldByName("X_CRDN")->AsString; //X 좌표
  1096. String Y_CRDN = pADO->FieldByName("Y_CRDN")->AsString; //Y 좌표
  1097. fwprintf(fd, L" <node>");
  1098. fwprintf(fd, L"<id>%s</id><x>%s</x><y>%s</y>", NODE_ID.c_str(), X_CRDN.c_str(), Y_CRDN.c_str());
  1099. fprintf(fd, "<name>%s</name>", UTF8Encode(NODE_NAME).c_str());
  1100. fwprintf(fd, L"</node>\n");
  1101. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  1102. }
  1103. }
  1104. catch(Exception &exception)
  1105. {
  1106. throw Exception(String(exception.ClassName()) + exception.Message);
  1107. return false;
  1108. }
  1109. }
  1110. __finally
  1111. {
  1112. UpdateProgress(nRows);
  1113. if (fd)
  1114. {
  1115. WriteXmlHead(fd, false);
  1116. fclose(fd);
  1117. }
  1118. pADO->Close();
  1119. }
  1120. return true;
  1121. }
  1122. //---------------------------------------------------------------------------
  1123. bool __fastcall TFrmUtilMain::MakeLinkXml(TADOQuery *pADO)
  1124. {
  1125. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Link.xml";
  1126. FILE *fd = NULL;
  1127. UpdateProgress(1, "링크정보 XML 파일생성");
  1128. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  1129. {
  1130. Application->MessageBox(L"링크정보 XML 파일을 생성하지 못하였습니다.",
  1131. L"링크정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  1132. return false;
  1133. }
  1134. WriteXmlHead(fd);
  1135. WriteXmlObject(fd, "link");
  1136. int nRows= 0;
  1137. int nCnt = 0;
  1138. String sQry;
  1139. try
  1140. {
  1141. try
  1142. {
  1143. sQry = "SELECT A.LINK_ID, A.F_NODE, A.T_NODE, TRIM(A.ROAD_NAME) ROAD_NAME, \r\n"
  1144. " NVL(B.NODE_NAME, '') F_NAME, NVL(C.NODE_NAME, '') T_NAME, \r\n"
  1145. " A.ROAD_USE, A.LANES, A.ROAD_RANK, TRIM(A.ROAD_TYPE) AS ROAD_TYPE, A.ROAD_NO, \r\n"
  1146. " A.MAX_SPD, A.LINK_LENG, A.DEL_YN, DECODE(A.AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
  1147. " FROM TB_LINK A, TB_NODE B, TB_NODE C \r\n"
  1148. " WHERE A.F_NODE = B.NODE_ID(+) \r\n"
  1149. " AND A.T_NODE = C.NODE_ID(+) \r\n"
  1150. " ORDER BY LINK_ID \r\n";
  1151. pADO->Close();
  1152. pADO->SQL->Text = sQry;
  1153. pADO->Open();
  1154. nRows = pADO->RecordCount;
  1155. cxProgressBar1->Properties->Max = nRows;
  1156. WriteXmlRecordCount(fd, nRows);
  1157. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  1158. {
  1159. String LINK_ID = pADO->FieldByName("LINK_ID")->AsString; //'링크ID';;
  1160. String F_NODEID = pADO->FieldByName("F_NODE")->AsString; //'시작노드ID';;
  1161. String T_NODEID = pADO->FieldByName("T_NODE")->AsString; //'종료노드ID';;
  1162. String ROAD_NAME = pADO->FieldByName("ROAD_NAME")->AsString.Trim(); //'도로명';;
  1163. String F_NAME = pADO->FieldByName("F_NAME")->AsString; //'시작노드';;
  1164. String T_NAME = pADO->FieldByName("T_NAME")->AsString; //'종료노드';;
  1165. String ROAD_USE = pADO->FieldByName("ROAD_USE")->AsString; //'도로사용여부';;
  1166. String LANES = pADO->FieldByName("LANES")->AsString; //'차로수';;
  1167. String ROAD_RANK = pADO->FieldByName("ROAD_RANK")->AsString; //'도로등급';;
  1168. String ROAD_TYPE = pADO->FieldByName("ROAD_TYPE")->AsString; //'도로유형';;
  1169. String ROAD_NO = pADO->FieldByName("ROAD_NO")->AsString; //'도로번호';;
  1170. String MAX_SPD = pADO->FieldByName("MAX_SPD")->AsString; //'최고제한속도';;
  1171. String LINK_LENG = pADO->FieldByName("LINK_LENG")->AsString; //'연장';;
  1172. String DEL_YN = pADO->FieldByName("DEL_YN")->AsString; //'삭제 여부';;
  1173. String REGN_YN = pADO->FieldByName("REGN_YN")->AsString; //'로컬지역여부';
  1174. fwprintf(fd, L" <link>");
  1175. fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
  1176. LINK_ID.c_str(), F_NODEID.c_str(), T_NODEID.c_str(), ROAD_RANK.c_str(), LINK_LENG.c_str());
  1177. fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
  1178. UTF8Encode(ROAD_NAME).c_str(), UTF8Encode(F_NAME).c_str(), UTF8Encode(T_NAME).c_str());
  1179. fwprintf(fd, L"</link>\n");
  1180. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  1181. }
  1182. }
  1183. catch(Exception &exception)
  1184. {
  1185. throw Exception(String(exception.ClassName()) + exception.Message);
  1186. return false;
  1187. }
  1188. }
  1189. __finally
  1190. {
  1191. UpdateProgress(nRows);
  1192. if (fd)
  1193. {
  1194. WriteXmlHead(fd, false);
  1195. fclose(fd);
  1196. }
  1197. pADO->Close();
  1198. }
  1199. return true;
  1200. }
  1201. //---------------------------------------------------------------------------
  1202. bool __fastcall TFrmUtilMain::MakeIfscXml(TADOQuery *pADO)
  1203. {
  1204. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Ifsc.xml";
  1205. FILE *fd = NULL;
  1206. UpdateProgress(1, "정보제공구간 XML 파일생성");
  1207. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  1208. {
  1209. Application->MessageBox(L"정보제공구간 XML 파일을 생성하지 못하였습니다.",
  1210. L"정보제공구간 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  1211. return false;
  1212. }
  1213. WriteXmlHead(fd);
  1214. WriteXmlObject(fd, "ifsc");
  1215. int nRows= 0;
  1216. int nCnt = 0;
  1217. String sQry;
  1218. try
  1219. {
  1220. try
  1221. {
  1222. sQry = "SELECT IFSC_ID, IFSC_NM, DRCT_CD, STRT_NM, END_NM, SECT_LNGT, \r\n"
  1223. " EXTR_CNCT_SECT_YN, DEL_YN, RMRK, F_NODE_ID, T_NODE_ID, \r\n"
  1224. " SECT_GRAD_CD, AREA_CD, DECODE(AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
  1225. " FROM TB_IFSC \r\n"
  1226. " ORDER BY IFSC_ID \r\n";
  1227. pADO->Close();
  1228. pADO->SQL->Text = sQry;
  1229. pADO->Open();
  1230. nRows = pADO->RecordCount;
  1231. cxProgressBar1->Properties->Max = nRows;
  1232. WriteXmlRecordCount(fd, nRows);
  1233. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  1234. {
  1235. String IFSC_ID = pADO->FieldByName("IFSC_ID")->AsString;
  1236. String IFSC_NM = pADO->FieldByName("IFSC_NM")->AsString.Trim();
  1237. String DRCT_CD = pADO->FieldByName("DRCT_CD")->AsString;
  1238. //String RMRK = pADO->FieldByName("RMRK")->AsString.Trim();
  1239. //String EXTR_CNCT_SECT_YN = pADO->FieldByName("EXTR_CNCT_SECT_YN")->AsString;
  1240. //String DEL_YN = pADO->FieldByName("DEL_YN")->AsString;
  1241. String SECT_LNGT = pADO->FieldByName("SECT_LNGT")->AsString;
  1242. //String SECT_GRAD_CD = pADO->FieldByName("SECT_GRAD_CD")->AsString;
  1243. String F_NODE_ID = pADO->FieldByName("F_NODE_ID")->AsString;
  1244. String T_NODE_ID = pADO->FieldByName("T_NODE_ID")->AsString;
  1245. String STRT_NM = pADO->FieldByName("STRT_NM")->AsString.Trim();
  1246. String END_NM = pADO->FieldByName("END_NM")->AsString.Trim();
  1247. //String REGN_YN = pADO->FieldByName("REGN_YN")->AsString;
  1248. //String AREA_CD = pADO->FieldByName("AREA_CD")->AsString;
  1249. fwprintf(fd, L" <link>");
  1250. fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
  1251. IFSC_ID.c_str(), F_NODE_ID.c_str(), T_NODE_ID.c_str(), DRCT_CD.c_str(), SECT_LNGT.c_str());
  1252. fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
  1253. UTF8Encode(IFSC_NM).c_str(), UTF8Encode(STRT_NM).c_str(), UTF8Encode(END_NM).c_str());
  1254. fwprintf(fd, L"</link>\n");
  1255. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  1256. }
  1257. }
  1258. catch(Exception &exception)
  1259. {
  1260. throw Exception(String(exception.ClassName()) + exception.Message);
  1261. return false;
  1262. }
  1263. }
  1264. __finally
  1265. {
  1266. UpdateProgress(nRows);
  1267. if (fd)
  1268. {
  1269. WriteXmlHead(fd, false);
  1270. fclose(fd);
  1271. }
  1272. pADO->Close();
  1273. }
  1274. return true;
  1275. }
  1276. //---------------------------------------------------------------------------
  1277. bool __fastcall TFrmUtilMain::MakeRoadXml(TADOQuery *pADO)
  1278. {
  1279. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Road.xml";
  1280. FILE *fd = NULL;
  1281. UpdateProgress(1, "도로정보 XML 파일생성");
  1282. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  1283. {
  1284. Application->MessageBox(L"도로정보 XML 파일을 생성하지 못하였습니다.",
  1285. L"도로정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  1286. return false;
  1287. }
  1288. WriteXmlHead(fd);
  1289. WriteXmlObject(fd, "road");
  1290. int nRows= 0;
  1291. int nCnt = 0;
  1292. String sQry;
  1293. try
  1294. {
  1295. try
  1296. {
  1297. sQry = "SELECT ROAD_ID, ROAD_NAME, DRCT_CD, STRT_NM, END_NM, \r\n"
  1298. " DEL_YN, SECT_LNGT, F_NODE_ID, T_NODE_ID, \r\n"
  1299. " SECT_GRAD_CD, AREA_CD, \r\n"
  1300. " DECODE(AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
  1301. " FROM TB_ROAD \r\n"
  1302. //" WHERE DEL_YN = 'N' \r\n"
  1303. " ORDER BY ROAD_ID \r\n";
  1304. pADO->Close();
  1305. pADO->SQL->Text = sQry;
  1306. pADO->Open();
  1307. nRows = pADO->RecordCount;
  1308. cxProgressBar1->Properties->Max = nRows;
  1309. WriteXmlRecordCount(fd, nRows);
  1310. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  1311. {
  1312. String ROAD_ID = pADO->FieldByName("ROAD_ID")->AsString;
  1313. String ROAD_NAME = pADO->FieldByName("ROAD_NAME")->AsString.Trim();
  1314. String DRCT_CD = pADO->FieldByName("DRCT_CD")->AsString;
  1315. String STRT_NM = pADO->FieldByName("STRT_NM")->AsString.Trim();
  1316. String END_NM = pADO->FieldByName("END_NM")->AsString.Trim();
  1317. //String DEL_YN = pADO->FieldByName("DEL_YN")->AsString;
  1318. String SECT_LNGT = pADO->FieldByName("SECT_LNGT")->AsString;
  1319. String F_NODE_ID = pADO->FieldByName("F_NODE_ID")->AsString;
  1320. String T_NODE_ID = pADO->FieldByName("T_NODE_ID")->AsString;
  1321. //String SECT_GRAD_CD = pADO->FieldByName("SECT_GRAD_CD")->AsString;
  1322. //String AREA_CD = pADO->FieldByName("AREA_CD")->AsString;
  1323. //String REGN_YN = pADO->FieldByName("REGN_YN")->AsString;
  1324. fwprintf(fd, L" <link>");
  1325. fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
  1326. ROAD_ID.c_str(), F_NODE_ID.c_str(), T_NODE_ID.c_str(), DRCT_CD.c_str(), SECT_LNGT.c_str());
  1327. fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
  1328. UTF8Encode(ROAD_NAME).c_str(), UTF8Encode(STRT_NM).c_str(), UTF8Encode(END_NM).c_str());
  1329. fwprintf(fd, L"</link>\n");
  1330. if ((nCnt % 50) == 0) UpdateProgress(nCnt);
  1331. }
  1332. }
  1333. catch(Exception &exception)
  1334. {
  1335. throw Exception(String(exception.ClassName()) + exception.Message);
  1336. return false;
  1337. }
  1338. }
  1339. __finally
  1340. {
  1341. UpdateProgress(nRows);
  1342. if (fd)
  1343. {
  1344. WriteXmlHead(fd, false);
  1345. fclose(fd);
  1346. }
  1347. pADO->Close();
  1348. }
  1349. return true;
  1350. }
  1351. //---------------------------------------------------------------------------
  1352. bool __fastcall TFrmUtilMain::MakeRegionVertexXml(TADOQuery *pADO)
  1353. {
  1354. AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "RegionVertex.xml";
  1355. FILE *fd = NULL;
  1356. UpdateProgress(1, "행정구역 Vertex XML 파일생성");
  1357. if ((fd = fopen(sFile.c_str(), "w")) == NULL)
  1358. {
  1359. Application->MessageBox(L"행정구역 Vertex 정보 파일을 생성하지 못하였습니다.",
  1360. L"행정구역 Vertex 정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  1361. return false;
  1362. }
  1363. WriteXmlHead(fd);
  1364. WriteXmlObject(fd, "region_vertex");
  1365. int nRows= 0;
  1366. int nCnt = 0;
  1367. String sQry;
  1368. try
  1369. {
  1370. try
  1371. {
  1372. sQry = "SELECT CONFIGSEQ AS ORD, COORDX AS X_CRDN, COORDY AS Y_CRDN \r\n"
  1373. " FROM LINK_SUBSECTION \r\n"
  1374. " WHERE SUBSECTIONKIND = 'B' \r\n"
  1375. " AND DISPLAYLEVEL = 1 \r\n"
  1376. " ORDER BY CONFIGSEQ \r\n";
  1377. pADO->Close();
  1378. pADO->SQL->Text = sQry;
  1379. pADO->Open();
  1380. nRows = pADO->RecordCount;
  1381. cxProgressBar1->Properties->Max = nRows;
  1382. WriteXmlRecordCount(fd, nRows);
  1383. String sPosX = "";
  1384. String sPosY = "";
  1385. String sMinXY = "";
  1386. String sMaxXY = "";
  1387. int nOrd, nOrdCnt;
  1388. nOrd = 1;
  1389. for( ; !pADO->Eof; pADO->Next(), nCnt++)
  1390. {
  1391. sPosX += pADO->FieldByName("X_CRDN")->AsString;
  1392. sPosY += pADO->FieldByName("Y_CRDN")->AsString;
  1393. sPosX = sPosX.SubString(1, sPosX.Length()-1);
  1394. sPosY = sPosY.SubString(1, sPosY.Length()-1);
  1395. fwprintf(fd, L" <pos><order>%d</order><x>%s</x><y>%s</y></pos>\n", nOrd++, sPosX.c_str(), sPosY.c_str());
  1396. sPosX = "";
  1397. sPosY = "";
  1398. if ((nCnt % 20) == 0) UpdateProgress(nCnt);
  1399. }
  1400. }
  1401. catch(Exception &exception)
  1402. {
  1403. throw Exception(String(exception.ClassName()) + exception.Message);
  1404. return false;
  1405. }
  1406. }
  1407. __finally
  1408. {
  1409. UpdateProgress(nRows);
  1410. if (fd)
  1411. {
  1412. WriteXmlHead(fd, false);
  1413. fclose(fd);
  1414. }
  1415. pADO->Close();
  1416. }
  1417. return true;
  1418. }
  1419. //---------------------------------------------------------------------------