FrmVmsLogMsgSubF.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2011/12/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "AppGlobalF.h"
  13. #include "ITSSkinF.h"
  14. #include "ITSUtilF.h"
  15. #include "ITSDbF.h"
  16. #include "ITSLogF.h"
  17. #include "ITSLangTransF.h"
  18. #pragma hdrstop
  19. #include "FrmVmsLogMsgSubF.h"
  20. #include "TCDSFontF.h"
  21. //---------------------------------------------------------------------------
  22. #pragma package(smart_init)
  23. #pragma link "cxButtons"
  24. #pragma link "cxCalc"
  25. #pragma link "cxCheckBox"
  26. #pragma link "cxClasses"
  27. #pragma link "cxContainer"
  28. #pragma link "cxControls"
  29. #pragma link "cxCustomData"
  30. #pragma link "cxData"
  31. #pragma link "cxDataStorage"
  32. #pragma link "cxEdit"
  33. #pragma link "cxFilter"
  34. #pragma link "cxGraphics"
  35. #pragma link "cxGrid"
  36. #pragma link "cxGridCustomTableView"
  37. #pragma link "cxGridCustomView"
  38. #pragma link "cxGridLevel"
  39. #pragma link "cxGridTableView"
  40. #pragma link "cxLookAndFeelPainters"
  41. #pragma link "cxLookAndFeels"
  42. #pragma link "cxSplitter"
  43. #pragma link "cxStyles"
  44. #pragma link "cxTextEdit"
  45. #pragma link "dxSkinBlack"
  46. #pragma link "dxSkinBlue"
  47. #pragma link "dxSkinCaramel"
  48. #pragma link "dxSkinCoffee"
  49. #pragma link "dxSkinDarkRoom"
  50. #pragma link "dxSkinDarkSide"
  51. #pragma link "dxSkinFoggy"
  52. #pragma link "dxSkinGlassOceans"
  53. #pragma link "dxSkiniMaginary"
  54. #pragma link "dxSkinLilian"
  55. #pragma link "dxSkinLiquidSky"
  56. #pragma link "dxSkinLondonLiquidSky"
  57. #pragma link "dxSkinMcSkin"
  58. #pragma link "dxSkinMoneyTwins"
  59. #pragma link "dxSkinOffice2007Black"
  60. #pragma link "dxSkinOffice2007Blue"
  61. #pragma link "dxSkinOffice2007Green"
  62. #pragma link "dxSkinOffice2007Pink"
  63. #pragma link "dxSkinOffice2007Silver"
  64. #pragma link "dxSkinOffice2010Black"
  65. #pragma link "dxSkinOffice2010Blue"
  66. #pragma link "dxSkinOffice2010Silver"
  67. #pragma link "dxSkinsCore"
  68. #pragma link "dxSkinscxPCPainter"
  69. #pragma link "dxSkinSeven"
  70. #pragma link "dxSkinSharp"
  71. #pragma link "dxSkinSilver"
  72. #pragma link "dxSkinStardust"
  73. #pragma link "cxLabel"
  74. #pragma link "cxGroupBox"
  75. #pragma link "cxDropDownEdit"
  76. #pragma link "cxImage"
  77. #pragma link "cxSpinEdit"
  78. #pragma resource "*.dfm"
  79. //TFrmVmsLogMsgSub *FrmVmsLogMsgSub = NULL;
  80. //---------------------------------------------------------------------------
  81. __fastcall TFrmVmsLogMsgSub::TFrmVmsLogMsgSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  82. : TForm(Owner)
  83. {
  84. LangTrans->Translate(this, ITSDb_GetConnection());
  85. ITSSkin_Load(this);
  86. //CMM_LoadForm(g_sFormsDir, this);
  87. FParent = hHandle;
  88. FStDateTime = sFrom;
  89. FEdDateTime = sTo;
  90. FIdList = sIdList;
  91. TvVmsMsg->OptionsView->DataRowHeight = 0;
  92. TvVmsMsg->OptionsView->CellAutoHeight = true;
  93. TvVmsMsg->OptionsView->Indicator = false;
  94. TvVmsMsg->OptionsCustomize->ColumnMoving = false;
  95. TvVmsMsg->OptionsCustomize->ColumnSorting = false;
  96. TvVmsMsg->Columns[0]->Width = 40;
  97. TvVmsMsg->Columns[0]->Options->HorzSizing = false;
  98. FVmsNmbr = "";
  99. FDsplDt = "";
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TFrmVmsLogMsgSub::FormInit()
  103. {
  104. ADOQry->Connection = ITSDb_GetConnection();
  105. m_pGDC = TvList->DataController;
  106. TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
  107. LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TFrmVmsLogMsgSub::FormShow(TObject *Sender)
  111. {
  112. FormInit();
  113. Refresh();
  114. TmrShow->Enabled = true;
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TFrmVmsLogMsgSub::CommClose()
  118. {
  119. //CMM_SaveForm(g_sFormsDir, this);
  120. //FrmVmsLogSub = NULL;
  121. }
  122. //---------------------------------------------------------------------------
  123. void __fastcall TFrmVmsLogMsgSub::TmrShowTimer(TObject *Sender)
  124. {
  125. TmrShow->Enabled = false;
  126. SelHistory();
  127. }
  128. //---------------------------------------------------------------------------
  129. void __fastcall TFrmVmsLogMsgSub::ChkExpandClick(TObject *Sender)
  130. {
  131. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TFrmVmsLogMsgSub::SelHistory()
  135. {
  136. TSqlCursor sqlCrs;
  137. String sQry;
  138. TADOQuery *pADO = ADOQry;
  139. sQry = "SELECT A.*, B.VMS_CTLR_ID, B.VMS_NM, B.VMS_USAG_TYPE_CD, \r\n"
  140. " B.FORMSIZE, B.FORMW, B.FORMH \r\n"
  141. " FROM TB_VMS_DSPL_HS A, \r\n"
  142. " (SELECT A.*, \r\n"
  143. " (SELECT CMMN_CD_KOR_NM \r\n"
  144. " FROM TB_CMMN_CD \r\n"
  145. " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
  146. " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMSIZE, \r\n"
  147. " (SELECT NVL(ATRB1, '320') \r\n"
  148. " FROM TB_CMMN_CD \r\n"
  149. " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
  150. " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMW, \r\n"
  151. " (SELECT NVL(ATRB2, '64') \r\n"
  152. " FROM TB_CMMN_CD \r\n"
  153. " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
  154. " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMH \r\n"
  155. " FROM TB_VMS_CTLR A) B \r\n"
  156. " WHERE B.VMS_CTLR_NMBR IN(" + FIdList + ") \r\n"
  157. " AND A.DSPL_DT BETWEEN :p01 AND :p02 \r\n"
  158. " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n"
  159. " ORDER BY A.VMS_CTLR_NMBR, A.DSPL_DT, A.DSPL_PHASE_NUM \r\n";
  160. try
  161. {
  162. ITSDb_SQLText(pADO, sQry);
  163. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  164. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  165. ITSDb_SQLOpen(pADO);
  166. }
  167. catch(EDatabaseError &E)
  168. {
  169. DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
  170. throw Exception(String(E.ClassName()) + E.Message);
  171. }
  172. catch(Exception &e)
  173. {
  174. DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
  175. throw Exception(String(e.ClassName()) + e.Message);
  176. }
  177. DspHistory();
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TFrmVmsLogMsgSub::DspHistory()
  181. {
  182. TADOQuery *pADO = ADOQry;
  183. try
  184. {
  185. TcxGridChartSeries *pChart = NULL;
  186. CMM_ClearGridTableView(TvList);
  187. int nRow = 0;
  188. int nDataCnt = 0;
  189. try {
  190. TvList->BeginUpdate(lsimImmediate);
  191. nDataCnt = pADO->RecordCount;
  192. m_pGDC->RecordCount = nDataCnt;
  193. for( ; !pADO->Eof; pADO->Next(), nRow++)
  194. {
  195. m_pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  196. m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
  197. m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_NM")->AsString;
  198. m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("DSPL_DT")->AsString).FormatString(STR_DATETIME);
  199. m_pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("DSPL_PHASE_NUM")->AsString;
  200. m_pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("VMS_DSPL_MSG_TXT")->AsString;
  201. m_pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("DNLD_YN")->AsString == "Y" ? lblSucc->Caption : lblFai->Caption;//"성공" : "실패";
  202. String VMS_USAG_TYPE_CD = pADO->FieldByName("VMS_USAG_TYPE_CD")->AsString;
  203. if (VMS_USAG_TYPE_CD == "VUTN") m_pGDC->Values[nRow][Col10->Index] = lblText->Caption;//"문자식";
  204. else m_pGDC->Values[nRow][Col10->Index] = lblFigure->Caption;//"도형식";
  205. m_pGDC->Values[nRow][Col11->Index] = pADO->FieldByName("FORMSIZE")->AsString+" ";
  206. m_pGDC->Values[nRow][Col12->Index] = pADO->FieldByName("FORMW")->AsString.ToIntDef(384);
  207. m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("FORMH")->AsString.ToIntDef(64);
  208. m_pGDC->Values[nRow][Col14->Index] = pADO->FieldByName("DSPL_DT")->AsString;
  209. int nFormType = pADO->FieldByName("TRFC_SITU_TYPE_CD")->AsString.ToIntDef(0);
  210. String sFormType = "";
  211. switch(nFormType)
  212. {
  213. case 11: sFormType = lblForm11->Caption; break;//"소통상황(1단)"; break;
  214. case 12: sFormType = lblForm12->Caption; break;//"소통상황(2단)"; break;
  215. case 13: sFormType = lblForm13->Caption; break;//"소통상황(3단)"; break;
  216. case 14: sFormType = lblForm14->Caption; break;//"소통상황(4단)"; break;
  217. case 15: sFormType = lblForm15->Caption; break;//"도형식배경소통정보"; break;
  218. case 20: sFormType = lblForm20->Caption; break;//"돌발문안"; break;
  219. case 30: sFormType = lblForm30->Caption; break;//"공사/행사문안"; break;
  220. case 40: sFormType = lblForm40->Caption; break;//"홍보문안"; break;
  221. case 50: sFormType = lblForm50->Caption; break;//"우회도로"; break;
  222. }
  223. #if 0
  224. switch(nFormType)
  225. {
  226. case 11: sFormType = "Traffic(1 Row)"; break;
  227. case 12: sFormType = "Traffic(2 Row)"; break;
  228. case 13: sFormType = "Traffic(3 Row)"; break;
  229. case 14: sFormType = "Traffic(4 Row)"; break;
  230. case 15: sFormType = "Trafffic(Background)"; break;
  231. case 20: sFormType = "Incident"; break;
  232. case 30: sFormType = "Construction/Event"; break;
  233. case 40: sFormType = "Notice"; break;
  234. case 50: sFormType = "Detour"; break;
  235. }
  236. #endif
  237. m_pGDC->Values[nRow][Col15->Index] = sFormType;
  238. }
  239. }
  240. __finally
  241. {
  242. if (pADO)
  243. {
  244. pADO->Close();
  245. }
  246. TvList->EndUpdate();
  247. //CxList->SetFocus();
  248. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  249. }
  250. }
  251. catch(EDatabaseError &E)
  252. {
  253. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  254. throw Exception(String(E.ClassName()) + E.Message);
  255. }
  256. catch(Exception &e)
  257. {
  258. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  259. throw Exception(String(e.ClassName()) + e.Message);
  260. }
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TFrmVmsLogMsgSub::BtnExlSaveClick(TObject *Sender)
  264. {
  265. TcxGrid *pGrid = CxList;
  266. TcxGridTableView *pView = TvList;
  267. String sTitle= Caption;
  268. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TFrmVmsLogMsgSub::FormClose(TObject *Sender, TCloseAction &Action)
  272. {
  273. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  274. CommClose();
  275. }
  276. //---------------------------------------------------------------------------
  277. void __fastcall TFrmVmsLogMsgSub::FormDestroy(TObject *Sender)
  278. {
  279. //
  280. }
  281. //---------------------------------------------------------------------------
  282. void __fastcall TFrmVmsLogMsgSub::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  283. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  284. bool &ADone)
  285. {
  286. try
  287. {
  288. TColor tColor;
  289. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  290. tColor = ACanvas->Brush->Color;
  291. if (sVmsMode == lblFai->Caption)//"실패")
  292. tColor = clRed;
  293. //else tColor = clLime;
  294. ACanvas->SetBrushColor(tColor);
  295. }
  296. catch(Exception &e)
  297. {
  298. }
  299. }
  300. //---------------------------------------------------------------------------
  301. void __fastcall TFrmVmsLogMsgSub::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
  302. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  303. bool ANewItemRecordFocusingChanged)
  304. {
  305. if (!AFocusedRecord) return;
  306. DisplayVmsMsg();
  307. }
  308. //---------------------------------------------------------------------------
  309. void __fastcall TFrmVmsLogMsgSub::DisplayVmsMsg()
  310. {
  311. TcxGridDataController *pGDC = TvList->DataController;
  312. int nSelIdx = CMM_GetRecordIndex(TvList);
  313. if (nSelIdx < 0) return;
  314. String sVmsNmbr = VarToStr(pGDC->Values[nSelIdx][Col00->Index]);
  315. String sDsplDt = VarToStr(pGDC->Values[nSelIdx][Col14->Index]);
  316. EdId->Text = VarToStr(pGDC->Values[nSelIdx][Col01->Index]);
  317. EdName->Text = VarToStr(pGDC->Values[nSelIdx][Col02->Index]);
  318. EdSvcDt->Text = VarToStr(pGDC->Values[nSelIdx][Col04->Index]);
  319. FWidth = pGDC->Values[nSelIdx][Col12->Index];
  320. FHeight = pGDC->Values[nSelIdx][Col13->Index];
  321. if (FVmsNmbr != sVmsNmbr || FDsplDt != sDsplDt)
  322. {
  323. LoadVmsMsg(sVmsNmbr, sDsplDt);
  324. }
  325. }
  326. //---------------------------------------------------------------------------
  327. TColor CodeToColor(int ACode)
  328. {
  329. TColor clColor = clBlack;
  330. switch(ACode)
  331. {
  332. case 0: clColor = clBlack; break;
  333. case 1: clColor = clRed; break;
  334. case 2: clColor = clLime; break;
  335. case 3: clColor = clYellow; break;
  336. }
  337. return clColor;
  338. }
  339. //---------------------------------------------------------------------------
  340. String CodeToFont(int ACode)
  341. {
  342. AnsiString sFont = "맑은 고딕";
  343. if (g_AppCfg.sLang == "en")
  344. {
  345. sFont = "Tahoma";
  346. }
  347. #if 0
  348. #ifdef LANG_ENG
  349. switch(ACode)
  350. {
  351. case font_malgun: sFont = "맑은 고딕"; break;
  352. case font_hygmj: sFont = "HY견명조"; break;
  353. case font_gulim: sFont = "굴림체"; break;
  354. case font_gungsuh: sFont = "궁서체"; break;
  355. case font_dotum: sFont = "돋움체"; break;
  356. case font_batang: sFont = "바탕체"; break;
  357. }
  358. #else
  359. AnsiString sFont = "맑은 고딕";
  360. switch(ACode)
  361. {
  362. case font_malgun: sFont = "맑은 고딕"; break;
  363. case font_hygmj: sFont = "HY견명조"; break;
  364. case font_gulim: sFont = "굴림체"; break;
  365. case font_gungsuh: sFont = "궁서체"; break;
  366. case font_dotum: sFont = "돋움체"; break;
  367. case font_batang: sFont = "바탕체"; break;
  368. }
  369. #endif
  370. #else
  371. TCDSFont *pObj = FontManager->FLists.Find(ACode);
  372. if (pObj)
  373. sFont = pObj->FontName;
  374. #endif
  375. return sFont;
  376. }
  377. //---------------------------------------------------------------------------
  378. TColor GradeToFillColor(int AGrade)
  379. {
  380. TColor clColor = clLime;
  381. switch(AGrade)
  382. {
  383. case 1: clColor = clLime; break;
  384. case 2: clColor = clYellow; break;
  385. case 3: clColor = clRed; break;
  386. }
  387. return clColor;
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TFrmVmsLogMsgSub::LoadVmsMsg(String AVmsNmbr, String ADsplDt)
  391. {
  392. FVmsNmbr = AVmsNmbr;
  393. FDsplDt = ADsplDt;
  394. CMM_ClearGridTableView(TvVmsMsg);
  395. EdMsgCnt->Text = "";
  396. String sQry;
  397. TADOQuery *pADO = NULL;
  398. TImage *pImage = NULL;
  399. sQry = "SELECT A.DSPL_PHASE_NUM, A.VMS_DSPL_MSG_DATA, DNLD_YN \r\n"
  400. " FROM TB_VMS_DSPL_HS A \r\n"
  401. " WHERE A.VMS_CTLR_NMBR = :p01 \r\n"
  402. " AND A.DSPL_DT = :p02 \r\n"
  403. " ORDER BY A.DSPL_PHASE_NUM \r\n";
  404. TcxDataController *pGDC = TvVmsMsg->DataController;
  405. try
  406. {
  407. int nRow;
  408. TvVmsMsg->BeginUpdate(lsimImmediate);
  409. pGDC->BeginUpdate();
  410. try
  411. {
  412. pADO = new TADOQuery(NULL);
  413. pADO->Close();
  414. pADO->Connection = ITSDb_GetConnection();
  415. ITSDb_SQLText(pADO, sQry);
  416. ITSDb_SQLBind(pADO, "p01", AVmsNmbr);
  417. ITSDb_SQLBind(pADO, "p02", ADsplDt);
  418. ITSDb_SQLOpen(pADO);
  419. EdMsgCnt->Text = "Forms: " + String(pADO->RecordCount);
  420. for( ; !pADO->Eof; pADO->Next())
  421. {
  422. String sData = pADO->FieldByName("VMS_DSPL_MSG_DATA")->AsString;
  423. //폼종류/표출시간/배경색상
  424. //sCont.printf("%02d%02X%02X|", pForm->FormKind, pForm->DisplayTime, pForm->BkColor);
  425. int nFormKind = StrToInt("0x" + sData.SubString(1,2));
  426. int nDispTime = StrToInt("0x" + sData.SubString(3,2));
  427. int nBkColor = StrToInt("0x" + sData.SubString(5,2));
  428. int nObjType, nObjLen;
  429. try
  430. {
  431. pImage = new TImage(NULL);
  432. pImage->Canvas->Lock();
  433. pImage->AutoSize = true;
  434. pImage->Picture->Bitmap->PixelFormat = pf24bit;
  435. pImage->Picture->Bitmap->Height = FHeight;
  436. pImage->Picture->Bitmap->Width = FWidth;
  437. pImage->Canvas->Brush->Color = CodeToColor(nBkColor);
  438. pImage->Canvas->FloodFill(0, 0, pImage->Picture->Bitmap->Canvas->Pixels[0][0], fsSurface);
  439. TStringList *pList = new TStringList;
  440. pList->Delimiter = '|';
  441. pList->StrictDelimiter = true;
  442. pList->DelimitedText = sData;
  443. int nObjCnt = pList->Count;
  444. if (nObjCnt > 1)
  445. {
  446. for (int ii = 1; ii < nObjCnt-1; ii++)
  447. {
  448. String sTmp = pList->Strings[ii];
  449. nObjType = StrToInt("0x" + sTmp.SubString(1, 2));
  450. nObjLen = StrToInt("0x" + sTmp.SubString(3, 2));
  451. int nBlink = StrToInt("0x" + sTmp.SubString( 5, 2));
  452. int nLeft = StrToInt("0x" + sTmp.SubString( 7, 4));
  453. int nTop = StrToInt("0x" + sTmp.SubString(11, 4));
  454. int nBkColor = StrToInt("0x" + sTmp.SubString(15, 2));
  455. if (nObjType == 1) //text
  456. {
  457. int nFontSize = StrToInt("0x" + sTmp.SubString(17, 2));
  458. int nFontColor = StrToInt("0x" + sTmp.SubString(19, 2));
  459. int nFontName = StrToInt("0x" + sTmp.SubString(21, 2));
  460. int nFontBold = StrToInt("0x" + sTmp.SubString(23, 2));
  461. int nTextSize = StrToInt("0x" + sTmp.SubString(25, 2));
  462. String sText = sTmp.SubString(27, nTextSize);
  463. pImage->Canvas->Brush->Color = CodeToColor(nBkColor);
  464. pImage->Canvas->Font->Color = CodeToColor(nFontColor);
  465. pImage->Canvas->Font->Name = CodeToFont(nFontName);
  466. pImage->Canvas->Font->Size = nFontSize;
  467. if (nFontBold)
  468. pImage->Canvas->Font->Style = TFontStyles() << fsBold;
  469. else
  470. pImage->Canvas->Font->Style = TFontStyles();
  471. pImage->Canvas->TextOut(nLeft, nTop, sText);
  472. }
  473. else
  474. if (nObjType == 2) //symbol id
  475. {
  476. String sBmpId = sTmp.SubString(17, sTmp.Length()-16);
  477. TImage *pTmpImage = GetSymbolImage(sBmpId);
  478. if (pImage)
  479. {
  480. pImage->Canvas->Draw(nLeft, nTop, pTmpImage->Picture->Graphic);
  481. pTmpImage->Picture->Assign(NULL);
  482. SAFE_DELETE(pTmpImage);
  483. }
  484. }
  485. else
  486. if (nObjType == 3) //draw traffic
  487. {
  488. TStringList *pTmpList = new TStringList;
  489. pTmpList->Delimiter = '+';
  490. pTmpList->StrictDelimiter = true;
  491. pTmpList->DelimitedText = sTmp;
  492. if (pTmpList->Count == 2)
  493. {
  494. sTmp = pTmpList->Strings[0];
  495. String sBmpId = sTmp.SubString(17, sTmp.Length()-16);
  496. TImage *pTmpImage = GetSymbolImage(sBmpId);
  497. if (pImage)
  498. {
  499. sTmp = pTmpList->Strings[1];
  500. if (sTmp != "X")
  501. {
  502. int nCellX, nCellY, nTraff;
  503. int nVertex = StrToInt("0x" + sTmp.SubString(1, 2));
  504. for (int jj = 0; jj < nVertex; jj++)
  505. {
  506. nCellX = sTmp.SubString((jj*7)+3,3).ToIntDef(0);
  507. nCellY = sTmp.SubString((jj*7)+6,3).ToIntDef(0);
  508. nTraff = sTmp.SubString((jj*7)+9,1).ToIntDef(0);
  509. pTmpImage->Picture->Bitmap->Canvas->Brush->Color = GradeToFillColor(nTraff);
  510. pTmpImage->Picture->Bitmap->Canvas->FloodFill(nCellX,
  511. nCellY,
  512. pTmpImage->Picture->Bitmap->Canvas->Pixels[nCellX][nCellY],
  513. fsSurface);
  514. }
  515. }
  516. pImage->Canvas->Draw(nLeft, nTop, pTmpImage->Picture->Graphic);
  517. pTmpImage->Picture->Assign(NULL);
  518. SAFE_DELETE(pTmpImage);
  519. }
  520. }
  521. SAFE_DELETE(pTmpList);
  522. }
  523. }
  524. }
  525. SAFE_DELETE(pList);
  526. Graphics::TBitmap *pBitmap = pImage->Picture->Bitmap;
  527. TStream *pImgStream = new TMemoryStream();
  528. try
  529. {
  530. nRow = pGDC->AppendRecord();
  531. pGDC->Values[nRow][ColSch01->Index] = String(nRow+1);
  532. pBitmap->SaveToStream(pImgStream);
  533. void *p;
  534. Variant v;
  535. int aBound[]={0, pImgStream->Size - 1};
  536. v = VarArrayCreate(aBound, 1, varByte);
  537. p = VarArrayLock(v);
  538. pImgStream->Position = 0;
  539. pImgStream->Read(p, pImgStream->Size);
  540. VarArrayUnlock(v);
  541. pGDC->Values[nRow][ColSch02->Index] = v;
  542. } catch(Exception &e) {}
  543. SAFE_DELETE(pImgStream);
  544. }
  545. __finally
  546. {
  547. pImage->Picture->Assign(NULL);
  548. pImage->Canvas->Unlock();
  549. SAFE_DELETE(pImage);
  550. }
  551. }
  552. }
  553. catch(EDatabaseError &E)
  554. {
  555. DBERRORMSG("VMS Display History", String(E.ClassName()), E.Message, sQry);
  556. throw Exception(String(E.ClassName()) + E.Message);
  557. }
  558. catch(Exception &e)
  559. {
  560. DBERRORMSG("VMS Display History", String(e.ClassName()), e.Message, sQry);
  561. throw Exception(String(e.ClassName()) + e.Message);
  562. }
  563. }
  564. __finally
  565. {
  566. if (pADO)
  567. {
  568. pADO->Close();
  569. delete pADO;
  570. }
  571. pGDC->EndUpdate();
  572. TvVmsMsg->EndUpdate();
  573. //TvVmsMsg->ApplyBestFit(NULL, false, false);
  574. }
  575. }
  576. //---------------------------------------------------------------------------
  577. TImage * __fastcall TFrmVmsLogMsgSub::GetSymbolImage(String ASymbolId)
  578. {
  579. String sQry;
  580. TADOQuery *pADO = NULL;
  581. TImage *pImage = NULL;
  582. sQry = "SELECT IMAG_DATA \r\n"
  583. " FROM TB_VMS_SYMB_LIB \r\n"
  584. " WHERE SYMBLIB_NMBR = :p01 \r\n";
  585. try
  586. {
  587. try
  588. {
  589. pADO = new TADOQuery(NULL);
  590. pADO->Close();
  591. pADO->Connection = ITSDb_GetConnection();
  592. ITSDb_SQLText(pADO, sQry);
  593. ITSDb_SQLBind(pADO, "p01", ASymbolId);
  594. ITSDb_SQLOpen(pADO);
  595. pADO->First();
  596. if (!pADO->IsEmpty() || !pADO->Eof)
  597. {
  598. TStream *pStream = NULL;
  599. pStream = pADO->CreateBlobStream(pADO->FieldByName("IMAG_DATA"), bmRead);
  600. try
  601. {
  602. try {
  603. pImage = new TImage(NULL);
  604. pImage->Canvas->Lock();
  605. pStream->Position = 0;
  606. pImage->Picture->Bitmap->LoadFromStream(pStream);
  607. } catch(...) {}
  608. }__finally{
  609. pImage->Canvas->Unlock();
  610. if (pStream)
  611. delete pStream;
  612. }
  613. }
  614. }
  615. catch(EDatabaseError &E)
  616. {
  617. DBERRORMSG("VMS Symbol Query", String(E.ClassName()), E.Message, sQry);
  618. throw Exception(String(E.ClassName()) + E.Message);
  619. }
  620. catch(Exception &e)
  621. {
  622. DBERRORMSG("VMS Symbol Qeury", String(e.ClassName()), e.Message, sQry);
  623. throw Exception(String(e.ClassName()) + e.Message);
  624. }
  625. }
  626. __finally
  627. {
  628. if (pADO)
  629. {
  630. pADO->Close();
  631. delete pADO;
  632. }
  633. }
  634. return pImage;
  635. }
  636. //---------------------------------------------------------------------------