CDSFormF.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "CDSFormF.h"
  4. #include "VmsUtilsF.h"
  5. #include "VMSCommLibF.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. //---------------------------------------------------------------------------
  9. TCDSFormObj::TCDSFormObj()
  10. {
  11. pImage = NULL;
  12. pImage = new TImage(NULL);
  13. }
  14. //---------------------------------------------------------------------------
  15. TCDSFormObj::~TCDSFormObj()
  16. {
  17. Clear();
  18. if (pImage)
  19. {
  20. delete pImage;
  21. pImage = NULL;
  22. }
  23. }
  24. //---------------------------------------------------------------------------
  25. void TCDSFormObj::Clear()
  26. {
  27. if (pImage)
  28. {
  29. pImage->Picture->Bitmap->FreeImage();
  30. pImage->Picture->Assign(NULL);
  31. }
  32. }
  33. //---------------------------------------------------------------------------
  34. //---------------------------------------------------------------------------
  35. TCDSForm::TCDSForm()
  36. {
  37. TrfIfsc = false;
  38. TrfAxis = false;
  39. TrfFixed = false;
  40. IsNewForm = true;
  41. TrfBakImgId = "";
  42. }
  43. //---------------------------------------------------------------------------
  44. TCDSForm::~TCDSForm()
  45. {
  46. Clear();
  47. FLists.RemoveAll();
  48. }
  49. //---------------------------------------------------------------------------
  50. void TCDSForm::Clear()
  51. {
  52. }
  53. //---------------------------------------------------------------------------
  54. //---------------------------------------------------------------------------
  55. TCDSFormManager *CDSFormManager = NULL;
  56. //---------------------------------------------------------------------------
  57. TCDSFormManager::TCDSFormManager()
  58. {
  59. }
  60. //---------------------------------------------------------------------------
  61. TCDSFormManager::~TCDSFormManager()
  62. {
  63. FLists.RemoveAll();
  64. }
  65. //---------------------------------------------------------------------------
  66. int TCDSFormManager::LoadVmsFormInfo(TADOConnection *ADbConn)
  67. {
  68. String sQry;
  69. TADOQuery *pADO = NULL;
  70. TStream *pStream = NULL;
  71. int nSelCnt = 0;
  72. DDBSTART;
  73. sQry = "SELECT A.VMS_FORM_ID, \r\n"
  74. " A.VMS_TYPE_CD, \r\n"
  75. " A.VMS_FORM_TYPE_CD, \r\n"
  76. " A.VMS_FORM_COLR_CD, \r\n"
  77. " A.VMS_FORM_DSPL_DRCT_CD, \r\n"
  78. " A.VMS_FORM_DSPL_MTHD_CD, \r\n"
  79. " A.SYMBLIB_NMBR, \r\n"
  80. " TRIM(A.VMS_FORM_NM) AS VMS_FORM_NM, \r\n"
  81. " TRIM(A.VMS_FORM_EXPL) AS VMS_FORM_EXPL, \r\n"
  82. " A.UPDT_DT \r\n"
  83. " FROM TB_VMS_FORM A \r\n";
  84. try
  85. {
  86. TCDSForm *pCDSForm;
  87. try
  88. {
  89. pADO = new TADOQuery(NULL);
  90. pADO->Connection = ADbConn;
  91. SQLText(pADO, sQry, true);
  92. SQLOpen(pADO);
  93. for( ; !pADO->Eof; pADO->Next())
  94. {
  95. AnsiString VMS_FORM_ID = pADO->FieldByName("VMS_FORM_ID")->AsString.Trim();
  96. pCDSForm = FLists.Find(VMS_FORM_ID);
  97. if (!pCDSForm)
  98. {
  99. pCDSForm = new TCDSForm();
  100. pCDSForm->VMS_FORM_ID = VMS_FORM_ID;
  101. CDSFormManager->FLists.Push(pCDSForm->VMS_FORM_ID, pCDSForm);
  102. }
  103. pCDSForm->FLists.RemoveAll();
  104. pCDSForm->TrfBakImgId = ""; //소통정보 배경 이미지 ID
  105. pCDSForm->VMS_TYPE_CD = pADO->FieldByName("VMS_TYPE_CD")->AsString;
  106. pCDSForm->VMS_FORM_TYPE_CD = pADO->FieldByName("VMS_FORM_TYPE_CD")->AsInteger;
  107. pCDSForm->VMS_FORM_COLR_CD = pADO->FieldByName("VMS_FORM_COLR_CD")->AsInteger;
  108. pCDSForm->VMS_FORM_DSPL_DRCT_CD = pADO->FieldByName("VMS_FORM_DSPL_DRCT_CD")->AsInteger;
  109. pCDSForm->VMS_FORM_DSPL_MTHD_CD = pADO->FieldByName("VMS_FORM_DSPL_MTHD_CD")->AsInteger;
  110. pCDSForm->VMS_FORM_NM = pADO->FieldByName("VMS_FORM_NM")->AsString;
  111. pCDSForm->VMS_FORM_EXPL = pADO->FieldByName("VMS_FORM_EXPL")->AsString;
  112. pCDSForm->TrfIfsc = false;
  113. pCDSForm->TrfAxis = false;
  114. pCDSForm->TrfFixed = false;
  115. AnsiString UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
  116. // 정적폼(홍보) 같은 경우 최초 또는 변경되었을 때에만 사용할수 있도록(제어기로 한번만 다운로드 할수 있도록)
  117. // 체크 플래그를 두어 확인할수 있도록 한다.
  118. pCDSForm->IsNewForm = false;
  119. if (pCDSForm->VMS_FORM_TYPE_CD == eFormTp_hongbo && pCDSForm->UPDT_DT != UPDT_DT)
  120. {
  121. pCDSForm->IsNewForm = true;
  122. }
  123. #if 0
  124. if (pCDSForm->VMS_FORM_TYPE_CD == eFormTp_hongbo)
  125. {
  126. //정적인 폼인 경우 폼의 이미지를 파일로 저장해 둔다
  127. pCDSForm->LocalFileName = g_sFtpStaticDir + pCDSForm->VMS_FORM_ID + ".bmp";
  128. pCDSForm->FtpFileName = AnsiString(FTP_STATIC) + "\\" + pCDSForm->VMS_FORM_ID + ".bmp";
  129. // 파일이 존재하지 않거나 업데이트 시각이 다르면 새로 홍보폼 이미지를 생성한다.
  130. if (pCDSForm->UPDT_DT != UPDT_DT || !FileExists(pCDSForm->LocalFileName))
  131. {
  132. AnsiString BackupFileName = pCDSForm->LocalFileName+".bak";
  133. if (FileExists(pCDSForm->LocalFileName))
  134. {
  135. try {
  136. //DeleteFile(pCDSForm->LocalFileName);
  137. MoveFile(pCDSForm->LocalFileName.c_str(), BackupFileName.c_str());
  138. } catch(Exception &) {}
  139. }
  140. try
  141. {
  142. TMemoryStream *Stream1 = (TMemoryStream *)pADO->CreateBlobStream(pADO->FieldByName("VMS_FORM_IMAG"), bmRead);
  143. Stream1->SaveToFile(pCDSForm->LocalFileName);
  144. SAFE_DELETE(Stream1);
  145. }
  146. catch(Exception &e)
  147. {
  148. if (FileExists(BackupFileName))
  149. {
  150. MoveFile(BackupFileName.c_str(), pCDSForm->LocalFileName.c_str());
  151. }
  152. pCDSForm->LocalFileName = "";
  153. pCDSForm->FtpFileName = "";
  154. }
  155. }
  156. }
  157. #endif
  158. pCDSForm->UPDT_DT = UPDT_DT;
  159. nSelCnt++;
  160. }
  161. }
  162. catch(EDatabaseError &E)
  163. {
  164. DBERROR(String(E.ClassName()), E.Message, sQry);
  165. return -1;
  166. }
  167. catch(Exception &e)
  168. {
  169. DBERROR(String(e.ClassName()), e.Message, sQry);
  170. return -1;
  171. }
  172. }
  173. __finally
  174. {
  175. SQLFree(pADO);
  176. }
  177. if (LoadVmsFormObjectInfo(ADbConn) < 0)
  178. {
  179. return -1;
  180. }
  181. IDBSTOP(nSelCnt);
  182. return nSelCnt;
  183. }
  184. //---------------------------------------------------------------------------
  185. int TCDSFormManager::LoadVmsFormObjectInfo(TADOConnection *ADbConn)
  186. {
  187. String sQry;
  188. TADOQuery *pADO = NULL;
  189. TStream *pStream = NULL;
  190. int nSelCnt = 0;
  191. DDBSTART;
  192. sQry = "SELECT B.VMS_FORM_ID, \r\n"
  193. " B.FORM_OBJECT_ID, \r\n"
  194. " B.VMS_FORM_DSPL_ROW, \r\n"
  195. " B.VMS_FORM_DSPL_CLMN, \r\n"
  196. " B.VMS_FORM_OBJECT_TYPE_CD, \r\n"
  197. " B.VMS_FONT_NAME_CD, \r\n"
  198. " B.VMS_FONT_COLR_CD, \r\n"
  199. " B.VMS_FONT_BOLD, \r\n"
  200. " B.VMS_FONT_SIZE, \r\n"
  201. " B.VMS_FONT_ALIGN, \r\n"
  202. " B.VMS_DSPL_TXT, \r\n"
  203. " B.VMS_DSPL_XCRDN, \r\n"
  204. " B.VMS_DSPL_YCRDN, \r\n"
  205. " B.VMS_DSPL_WIDTH, \r\n"
  206. " B.VMS_DSPL_HEIGHT, \r\n"
  207. " B.VMS_DSPL_BLINKING, \r\n"
  208. " B.VMS_DSPL_BKCOLOR, \r\n"
  209. " B.VMS_DSPL_SIZE, \r\n"
  210. " B.TRFC_FILL_CD, \r\n"
  211. " B.SYMBLIB_NMBR, \r\n"
  212. " B.VMS_IFSC_ID \r\n"
  213. " FROM TB_VMS_FORM A, \r\n"
  214. " TB_VMS_FORM_OBJECT B, \r\n"
  215. " TB_VMS_SYMB_LIB C \r\n"
  216. " WHERE A.VMS_FORM_ID = B.VMS_FORM_ID \r\n"
  217. " AND B.SYMBLIB_NMBR = C.SYMBLIB_NMBR(+) \r\n"
  218. " ORDER BY B.VMS_FORM_ID, B.FORM_OBJECT_ID \r\n";
  219. int notFound = 0;
  220. try
  221. {
  222. TCDSForm *pCDSForm;
  223. TCDSFormObj *pCDSFormObj;
  224. try
  225. {
  226. pADO = new TADOQuery(NULL);
  227. pADO->Connection = ADbConn;
  228. SQLText(pADO, sQry, true);
  229. SQLOpen(pADO);
  230. for( ; !pADO->Eof; pADO->Next())
  231. {
  232. AnsiString sFormId = pADO->FieldByName("VMS_FORM_ID")->AsString.Trim();
  233. pCDSForm = FLists.Find(sFormId);
  234. if (!pCDSForm)
  235. {
  236. MDEBUG("DCOM Not Found Form Object by FormId: %d", sFormId.c_str());
  237. continue;
  238. }
  239. nSelCnt++;
  240. pCDSFormObj = new TCDSFormObj();
  241. pCDSFormObj->VMS_FORM_OBJECT_ID = pADO->FieldByName("FORM_OBJECT_ID")->AsInteger;
  242. pCDSFormObj->VMS_FORM_ID = pADO->FieldByName("VMS_FORM_ID")->AsString;
  243. pCDSFormObj->VMS_FORM_DSPL_ROW = pADO->FieldByName("VMS_FORM_DSPL_ROW")->AsInteger;
  244. pCDSFormObj->VMS_FORM_DSPL_CLMN = pADO->FieldByName("VMS_FORM_DSPL_CLMN")->AsInteger;
  245. pCDSFormObj->VMS_FORM_OBJECT_TYPE_CD = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsInteger;
  246. pCDSFormObj->VMS_FONT_NAME_CD = pADO->FieldByName("VMS_FONT_NAME_CD")->AsInteger;
  247. pCDSFormObj->VMS_FONT_COLR_CD = pADO->FieldByName("VMS_FONT_COLR_CD")->AsInteger;
  248. pCDSFormObj->VMS_FONT_BOLD = pADO->FieldByName("VMS_FONT_BOLD")->AsInteger;
  249. pCDSFormObj->VMS_FONT_SIZE = pADO->FieldByName("VMS_FONT_SIZE")->AsInteger;
  250. pCDSFormObj->VMS_FONT_ALIGN = pADO->FieldByName("VMS_FONT_ALIGN")->AsInteger;
  251. pCDSFormObj->VMS_DSPL_TXT = pADO->FieldByName("VMS_DSPL_TXT")->AsString;
  252. pCDSFormObj->VMS_DSPL_XCRDN = pADO->FieldByName("VMS_DSPL_XCRDN")->AsInteger;
  253. pCDSFormObj->VMS_DSPL_YCRDN = pADO->FieldByName("VMS_DSPL_YCRDN")->AsInteger;
  254. pCDSFormObj->VMS_DSPL_WIDTH = pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger;
  255. pCDSFormObj->VMS_DSPL_HEIGHT = pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger;
  256. pCDSFormObj->VMS_DSPL_BLINKING = pADO->FieldByName("VMS_DSPL_BLINKING")->AsInteger;
  257. pCDSFormObj->VMS_DSPL_BKCOLOR = pADO->FieldByName("VMS_DSPL_BKCOLOR")->AsInteger;
  258. pCDSFormObj->VMS_DSPL_SIZE = pADO->FieldByName("VMS_DSPL_SIZE")->AsInteger;
  259. pCDSFormObj->TRFC_FILL_CD = pADO->FieldByName("TRFC_FILL_CD")->AsString;
  260. pCDSFormObj->SYMB_LIB_NMBR = pADO->FieldByName("SYMBLIB_NMBR")->AsString;
  261. pCDSFormObj->VMS_IFSC_ID = pADO->FieldByName("VMS_IFSC_ID")->AsString;
  262. pCDSForm->FLists.Push(pCDSFormObj->VMS_FORM_OBJECT_ID, pCDSFormObj);
  263. int nObjType = pCDSFormObj->VMS_FORM_OBJECT_TYPE_CD;
  264. if (pCDSForm->VMS_FORM_TYPE_CD == eFormtp_figure)
  265. {
  266. //도형식 소통정보 폼인데 구간 소통정보를 하단에 표출하는 경우
  267. //하나의 폼이 여러개의 소통정보를 표출되도록 하기 위함
  268. switch(nObjType)
  269. {
  270. //////////////////////// 20200515 추가함(S)
  271. case 0://, , @문자열
  272. case 1://, , @심볼
  273. case 2://, , @이미지
  274. if (pCDSFormObj->TRFC_FILL_CD == "F")
  275. {
  276. //하단고정일 경우 도형식하단에 표출할 소통정보가 없을 경우 표출하는 정보임
  277. pCDSForm->TrfFixed = true;
  278. }
  279. break;
  280. //////////////////////// 20200515 추가함(E)
  281. case 11://, ' @구간명
  282. case 12://, ' @시점명
  283. case 13://, ' @종점명
  284. case 14://, ' @소통상황
  285. case 15://, ' @통행시간
  286. case 16://, ' @통행속도
  287. case 17://, ' @소통정보이미지
  288. case 18://, ' @지점명
  289. pCDSForm->TrfIfsc = true;
  290. break;
  291. case 93://, ' @축시점명(순환)
  292. case 94://, ' @축종점명(순환)
  293. case 95://, ' @축소통상황(순환)
  294. case 96://, ' @축통행시간(순환)
  295. pCDSForm->TrfAxis = true;
  296. break;
  297. }
  298. }
  299. if (nObjType == 3)
  300. {
  301. pCDSForm->TrfBakImgId = pCDSFormObj->SYMB_LIB_NMBR + "0";
  302. }
  303. if (nObjType == 1 || //심볼
  304. nObjType == 2 || //이미지(파일에서 직접입력한것임)
  305. nObjType == 3 || //소통정보배경이미지
  306. nObjType == 17 || //소통정보이미지1
  307. nObjType == 27 || //소통정보이미지2
  308. nObjType == 37 || //소통정보이미지3
  309. nObjType == 47 || //소통정보이미지4
  310. nObjType == 200 || //동영상이미지
  311. nObjType == 300 ) //스트리밍영상이미지
  312. {
  313. pCDSFormObj->Clear();
  314. //pCDSFormObj->pImage->Picture->Bitmap->PixelFormat = g_AppCfg.PixelFormat;//g_AppCfg.PixelFormat;//pf4bit;
  315. //심볼에서 읽지 않고 폼오브젝트에 있는 이미지를 사용함
  316. #if 1
  317. try
  318. {
  319. TCDSImage *pVmsImg = CDSImageManager->FLists.Find(pCDSFormObj->SYMB_LIB_NMBR+"0");
  320. if (pVmsImg && pVmsImg->IMAG_DATA)
  321. {
  322. pCDSFormObj->pImage->Picture->Bitmap->Assign(pVmsImg->IMAG_DATA->Picture->Bitmap);
  323. }
  324. else
  325. {
  326. if (pCDSFormObj->SYMB_LIB_NMBR == "")
  327. notFound++;
  328. else
  329. MERROR("MAIN LoadVmsFormObjectInfo Symbol Not Found: %s", pCDSFormObj->SYMB_LIB_NMBR.c_str());
  330. }
  331. }
  332. catch(Exception &e)
  333. {
  334. MERROR("MAIN LoadVmsFormObjectInfo Symbol Find Failed: %s, %s, %s", pCDSFormObj->SYMB_LIB_NMBR.c_str(), AnsiString(e.ClassName()).c_str(), AnsiString(e.Message).c_str());
  335. }
  336. #else
  337. TStream *pStream = pADO->CreateBlobStream(pADO->FieldByName("IMAG_DATA"), bmRead);
  338. try
  339. {
  340. if (pStream && pStream->Size > 0)
  341. {
  342. pStream->Position = 0;
  343. AssignBmp(pCDSFormObj->pImage, pStream);
  344. }
  345. }
  346. __finally
  347. {
  348. SAFE_DELETE(pStream);
  349. }
  350. #endif
  351. }
  352. }
  353. if (notFound > 0) {
  354. MERROR("MAIN LoadVmsFormObjectInfo Symbol Not Found: %d EA.", notFound);
  355. }
  356. }
  357. catch(EDatabaseError &E)
  358. {
  359. DBERROR(String(E.ClassName()), E.Message, sQry);
  360. return -1;
  361. }
  362. catch(Exception &e)
  363. {
  364. DBERROR(String(e.ClassName()), e.Message, sQry);
  365. return -1;
  366. }
  367. }
  368. __finally
  369. {
  370. SQLFree(pADO);
  371. }
  372. #if 0
  373. if (0)//g_LogCfg.Debug)
  374. {
  375. FOR_STL(TCDSForm*, pTmp, FormManager->FLists)
  376. {
  377. MDEBUG("DCOM Vms Form: %s, Objects: %d", pTmp->VMS_FORM_ID.c_str(), pTmp->FLists.Size());
  378. }
  379. }
  380. #endif
  381. IDBSTOP(nSelCnt);
  382. return nSelCnt;
  383. }
  384. //---------------------------------------------------------------------------