123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- /****************************************************************************
- * @source :
- * @description :
- ****************************************************************************
- * DATE AUTHOR DESCRIPTION
- * --------------------------------------------------------------------------
- * 2011/12/24 정승호 최초작성
- *
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "ITSLogF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FrmVmsLogMsgSubF.h"
- #include "TCDSFontF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCalc"
- #pragma link "cxCheckBox"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxSplitter"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinCaramel"
- #pragma link "dxSkinCoffee"
- #pragma link "dxSkinDarkRoom"
- #pragma link "dxSkinDarkSide"
- #pragma link "dxSkinFoggy"
- #pragma link "dxSkinGlassOceans"
- #pragma link "dxSkiniMaginary"
- #pragma link "dxSkinLilian"
- #pragma link "dxSkinLiquidSky"
- #pragma link "dxSkinLondonLiquidSky"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinMoneyTwins"
- #pragma link "dxSkinOffice2007Black"
- #pragma link "dxSkinOffice2007Blue"
- #pragma link "dxSkinOffice2007Green"
- #pragma link "dxSkinOffice2007Pink"
- #pragma link "dxSkinOffice2007Silver"
- #pragma link "dxSkinOffice2010Black"
- #pragma link "dxSkinOffice2010Blue"
- #pragma link "dxSkinOffice2010Silver"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "cxLabel"
- #pragma link "cxGroupBox"
- #pragma link "cxDropDownEdit"
- #pragma link "cxImage"
- #pragma link "cxSpinEdit"
- #pragma resource "*.dfm"
- //TFrmVmsLogMsgSub *FrmVmsLogMsgSub = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmVmsLogMsgSub::TFrmVmsLogMsgSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- //CMM_LoadForm(g_sFormsDir, this);
- FParent = hHandle;
- FStDateTime = sFrom;
- FEdDateTime = sTo;
- FIdList = sIdList;
- TvVmsMsg->OptionsView->DataRowHeight = 0;
- TvVmsMsg->OptionsView->CellAutoHeight = true;
- TvVmsMsg->OptionsView->Indicator = false;
- TvVmsMsg->OptionsCustomize->ColumnMoving = false;
- TvVmsMsg->OptionsCustomize->ColumnSorting = false;
- TvVmsMsg->Columns[0]->Width = 40;
- TvVmsMsg->Columns[0]->Options->HorzSizing = false;
- FVmsNmbr = "";
- FDsplDt = "";
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::FormInit()
- {
- ADOQry->Connection = ITSDb_GetConnection();
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
- LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::FormShow(TObject *Sender)
- {
- FormInit();
- Refresh();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::CommClose()
- {
- //CMM_SaveForm(g_sFormsDir, this);
- //FrmVmsLogSub = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- SelHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::ChkExpandClick(TObject *Sender)
- {
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::SelHistory()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- sQry = "SELECT A.*, B.VMS_CTLR_ID, B.VMS_NM, B.VMS_USAG_TYPE_CD, \r\n"
- " B.FORMSIZE, B.FORMW, B.FORMH \r\n"
- " FROM TB_VMS_DSPL_HS A, \r\n"
- " (SELECT A.*, \r\n"
- " (SELECT CMMN_CD_KOR_NM \r\n"
- " FROM TB_CMMN_CD \r\n"
- " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
- " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMSIZE, \r\n"
- " (SELECT NVL(ATRB1, '320') \r\n"
- " FROM TB_CMMN_CD \r\n"
- " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
- " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMW, \r\n"
- " (SELECT NVL(ATRB2, '64') \r\n"
- " FROM TB_CMMN_CD \r\n"
- " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
- " AND CMMN_CD = A.VMS_TYPE_CD) AS FORMH \r\n"
- " FROM TB_VMS_CTLR A) B \r\n"
- " WHERE B.VMS_CTLR_NMBR IN(" + FIdList + ") \r\n"
- " AND A.DSPL_DT BETWEEN :p01 AND :p02 \r\n"
- " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n"
- " ORDER BY A.VMS_CTLR_NMBR, A.DSPL_DT, A.DSPL_PHASE_NUM \r\n";
- try
- {
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", FStDateTime);
- ITSDb_SQLBind(pADO, "p02", FEdDateTime);
- ITSDb_SQLOpen(pADO);
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- DspHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::DspHistory()
- {
- TADOQuery *pADO = ADOQry;
- try
- {
- TcxGridChartSeries *pChart = NULL;
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- int nDataCnt = 0;
- try {
- TvList->BeginUpdate(lsimImmediate);
- nDataCnt = pADO->RecordCount;
- m_pGDC->RecordCount = nDataCnt;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- m_pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
- m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
- m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_NM")->AsString;
- m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("DSPL_DT")->AsString).FormatString(STR_DATETIME);
- m_pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("DSPL_PHASE_NUM")->AsString;
- m_pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("VMS_DSPL_MSG_TXT")->AsString;
- m_pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("DNLD_YN")->AsString == "Y" ? lblSucc->Caption : lblFai->Caption;//"성공" : "실패";
- String VMS_USAG_TYPE_CD = pADO->FieldByName("VMS_USAG_TYPE_CD")->AsString;
- if (VMS_USAG_TYPE_CD == "VUTN") m_pGDC->Values[nRow][Col10->Index] = lblText->Caption;//"문자식";
- else m_pGDC->Values[nRow][Col10->Index] = lblFigure->Caption;//"도형식";
- m_pGDC->Values[nRow][Col11->Index] = pADO->FieldByName("FORMSIZE")->AsString+" ";
- m_pGDC->Values[nRow][Col12->Index] = pADO->FieldByName("FORMW")->AsString.ToIntDef(384);
- m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("FORMH")->AsString.ToIntDef(64);
- m_pGDC->Values[nRow][Col14->Index] = pADO->FieldByName("DSPL_DT")->AsString;
- int nFormType = pADO->FieldByName("TRFC_SITU_TYPE_CD")->AsString.ToIntDef(0);
- String sFormType = "";
- switch(nFormType)
- {
- case 11: sFormType = lblForm11->Caption; break;//"소통상황(1단)"; break;
- case 12: sFormType = lblForm12->Caption; break;//"소통상황(2단)"; break;
- case 13: sFormType = lblForm13->Caption; break;//"소통상황(3단)"; break;
- case 14: sFormType = lblForm14->Caption; break;//"소통상황(4단)"; break;
- case 15: sFormType = lblForm15->Caption; break;//"도형식배경소통정보"; break;
- case 20: sFormType = lblForm20->Caption; break;//"돌발문안"; break;
- case 30: sFormType = lblForm30->Caption; break;//"공사/행사문안"; break;
- case 40: sFormType = lblForm40->Caption; break;//"홍보문안"; break;
- case 50: sFormType = lblForm50->Caption; break;//"우회도로"; break;
- }
- #if 0
- switch(nFormType)
- {
- case 11: sFormType = "Traffic(1 Row)"; break;
- case 12: sFormType = "Traffic(2 Row)"; break;
- case 13: sFormType = "Traffic(3 Row)"; break;
- case 14: sFormType = "Traffic(4 Row)"; break;
- case 15: sFormType = "Trafffic(Background)"; break;
- case 20: sFormType = "Incident"; break;
- case 30: sFormType = "Construction/Event"; break;
- case 40: sFormType = "Notice"; break;
- case 50: sFormType = "Detour"; break;
- }
- #endif
- m_pGDC->Values[nRow][Col15->Index] = sFormType;
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- TvList->EndUpdate();
- //CxList->SetFocus();
- LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
- }
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= Caption;
- CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::FormClose(TObject *Sender, TCloseAction &Action)
- {
- POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
- CommClose();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::FormDestroy(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- if (sVmsMode == lblFai->Caption)//"실패")
- tColor = clRed;
- //else tColor = clLime;
- ACanvas->SetBrushColor(tColor);
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
- TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
- bool ANewItemRecordFocusingChanged)
- {
- if (!AFocusedRecord) return;
- DisplayVmsMsg();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::DisplayVmsMsg()
- {
- TcxGridDataController *pGDC = TvList->DataController;
- int nSelIdx = CMM_GetRecordIndex(TvList);
- if (nSelIdx < 0) return;
- String sVmsNmbr = VarToStr(pGDC->Values[nSelIdx][Col00->Index]);
- String sDsplDt = VarToStr(pGDC->Values[nSelIdx][Col14->Index]);
- EdId->Text = VarToStr(pGDC->Values[nSelIdx][Col01->Index]);
- EdName->Text = VarToStr(pGDC->Values[nSelIdx][Col02->Index]);
- EdSvcDt->Text = VarToStr(pGDC->Values[nSelIdx][Col04->Index]);
- FWidth = pGDC->Values[nSelIdx][Col12->Index];
- FHeight = pGDC->Values[nSelIdx][Col13->Index];
- if (FVmsNmbr != sVmsNmbr || FDsplDt != sDsplDt)
- {
- LoadVmsMsg(sVmsNmbr, sDsplDt);
- }
- }
- //---------------------------------------------------------------------------
- TColor CodeToColor(int ACode)
- {
- TColor clColor = clBlack;
- switch(ACode)
- {
- case 0: clColor = clBlack; break;
- case 1: clColor = clRed; break;
- case 2: clColor = clLime; break;
- case 3: clColor = clYellow; break;
- }
- return clColor;
- }
- //---------------------------------------------------------------------------
- String CodeToFont(int ACode)
- {
- AnsiString sFont = "맑은 고딕";
- if (g_AppCfg.sLang == "en")
- {
- sFont = "Tahoma";
- }
- #if 0
- #ifdef LANG_ENG
- switch(ACode)
- {
- case font_malgun: sFont = "맑은 고딕"; break;
- case font_hygmj: sFont = "HY견명조"; break;
- case font_gulim: sFont = "굴림체"; break;
- case font_gungsuh: sFont = "궁서체"; break;
- case font_dotum: sFont = "돋움체"; break;
- case font_batang: sFont = "바탕체"; break;
- }
- #else
- AnsiString sFont = "맑은 고딕";
- switch(ACode)
- {
- case font_malgun: sFont = "맑은 고딕"; break;
- case font_hygmj: sFont = "HY견명조"; break;
- case font_gulim: sFont = "굴림체"; break;
- case font_gungsuh: sFont = "궁서체"; break;
- case font_dotum: sFont = "돋움체"; break;
- case font_batang: sFont = "바탕체"; break;
- }
- #endif
- #else
- TCDSFont *pObj = FontManager->FLists.Find(ACode);
- if (pObj)
- sFont = pObj->FontName;
- #endif
- return sFont;
- }
- //---------------------------------------------------------------------------
- TColor GradeToFillColor(int AGrade)
- {
- TColor clColor = clLime;
- switch(AGrade)
- {
- case 1: clColor = clLime; break;
- case 2: clColor = clYellow; break;
- case 3: clColor = clRed; break;
- }
- return clColor;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogMsgSub::LoadVmsMsg(String AVmsNmbr, String ADsplDt)
- {
- FVmsNmbr = AVmsNmbr;
- FDsplDt = ADsplDt;
- CMM_ClearGridTableView(TvVmsMsg);
- EdMsgCnt->Text = "";
- String sQry;
- TADOQuery *pADO = NULL;
- TImage *pImage = NULL;
- sQry = "SELECT A.DSPL_PHASE_NUM, A.VMS_DSPL_MSG_DATA, DNLD_YN \r\n"
- " FROM TB_VMS_DSPL_HS A \r\n"
- " WHERE A.VMS_CTLR_NMBR = :p01 \r\n"
- " AND A.DSPL_DT = :p02 \r\n"
- " ORDER BY A.DSPL_PHASE_NUM \r\n";
- TcxDataController *pGDC = TvVmsMsg->DataController;
- try
- {
- int nRow;
- TvVmsMsg->BeginUpdate(lsimImmediate);
- pGDC->BeginUpdate();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", AVmsNmbr);
- ITSDb_SQLBind(pADO, "p02", ADsplDt);
- ITSDb_SQLOpen(pADO);
- EdMsgCnt->Text = "Forms: " + String(pADO->RecordCount);
- for( ; !pADO->Eof; pADO->Next())
- {
- String sData = pADO->FieldByName("VMS_DSPL_MSG_DATA")->AsString;
- //폼종류/표출시간/배경색상
- //sCont.printf("%02d%02X%02X|", pForm->FormKind, pForm->DisplayTime, pForm->BkColor);
- int nFormKind = StrToInt("0x" + sData.SubString(1,2));
- int nDispTime = StrToInt("0x" + sData.SubString(3,2));
- int nBkColor = StrToInt("0x" + sData.SubString(5,2));
- int nObjType, nObjLen;
- try
- {
- pImage = new TImage(NULL);
- pImage->Canvas->Lock();
- pImage->AutoSize = true;
- pImage->Picture->Bitmap->PixelFormat = pf24bit;
- pImage->Picture->Bitmap->Height = FHeight;
- pImage->Picture->Bitmap->Width = FWidth;
- pImage->Canvas->Brush->Color = CodeToColor(nBkColor);
- pImage->Canvas->FloodFill(0, 0, pImage->Picture->Bitmap->Canvas->Pixels[0][0], fsSurface);
- TStringList *pList = new TStringList;
- pList->Delimiter = '|';
- pList->StrictDelimiter = true;
- pList->DelimitedText = sData;
- int nObjCnt = pList->Count;
- if (nObjCnt > 1)
- {
- for (int ii = 1; ii < nObjCnt-1; ii++)
- {
- String sTmp = pList->Strings[ii];
- nObjType = StrToInt("0x" + sTmp.SubString(1, 2));
- nObjLen = StrToInt("0x" + sTmp.SubString(3, 2));
- int nBlink = StrToInt("0x" + sTmp.SubString( 5, 2));
- int nLeft = StrToInt("0x" + sTmp.SubString( 7, 4));
- int nTop = StrToInt("0x" + sTmp.SubString(11, 4));
- int nBkColor = StrToInt("0x" + sTmp.SubString(15, 2));
- if (nObjType == 1) //text
- {
- int nFontSize = StrToInt("0x" + sTmp.SubString(17, 2));
- int nFontColor = StrToInt("0x" + sTmp.SubString(19, 2));
- int nFontName = StrToInt("0x" + sTmp.SubString(21, 2));
- int nFontBold = StrToInt("0x" + sTmp.SubString(23, 2));
- int nTextSize = StrToInt("0x" + sTmp.SubString(25, 2));
- String sText = sTmp.SubString(27, nTextSize);
- pImage->Canvas->Brush->Color = CodeToColor(nBkColor);
- pImage->Canvas->Font->Color = CodeToColor(nFontColor);
- pImage->Canvas->Font->Name = CodeToFont(nFontName);
- pImage->Canvas->Font->Size = nFontSize;
- if (nFontBold)
- pImage->Canvas->Font->Style = TFontStyles() << fsBold;
- else
- pImage->Canvas->Font->Style = TFontStyles();
- pImage->Canvas->TextOut(nLeft, nTop, sText);
- }
- else
- if (nObjType == 2) //symbol id
- {
- String sBmpId = sTmp.SubString(17, sTmp.Length()-16);
- TImage *pTmpImage = GetSymbolImage(sBmpId);
- if (pImage)
- {
- pImage->Canvas->Draw(nLeft, nTop, pTmpImage->Picture->Graphic);
- pTmpImage->Picture->Assign(NULL);
- SAFE_DELETE(pTmpImage);
- }
- }
- else
- if (nObjType == 3) //draw traffic
- {
- TStringList *pTmpList = new TStringList;
- pTmpList->Delimiter = '+';
- pTmpList->StrictDelimiter = true;
- pTmpList->DelimitedText = sTmp;
- if (pTmpList->Count == 2)
- {
- sTmp = pTmpList->Strings[0];
- String sBmpId = sTmp.SubString(17, sTmp.Length()-16);
- TImage *pTmpImage = GetSymbolImage(sBmpId);
- if (pImage)
- {
- sTmp = pTmpList->Strings[1];
- if (sTmp != "X")
- {
- int nCellX, nCellY, nTraff;
- int nVertex = StrToInt("0x" + sTmp.SubString(1, 2));
- for (int jj = 0; jj < nVertex; jj++)
- {
- nCellX = sTmp.SubString((jj*7)+3,3).ToIntDef(0);
- nCellY = sTmp.SubString((jj*7)+6,3).ToIntDef(0);
- nTraff = sTmp.SubString((jj*7)+9,1).ToIntDef(0);
- pTmpImage->Picture->Bitmap->Canvas->Brush->Color = GradeToFillColor(nTraff);
- pTmpImage->Picture->Bitmap->Canvas->FloodFill(nCellX,
- nCellY,
- pTmpImage->Picture->Bitmap->Canvas->Pixels[nCellX][nCellY],
- fsSurface);
- }
- }
- pImage->Canvas->Draw(nLeft, nTop, pTmpImage->Picture->Graphic);
- pTmpImage->Picture->Assign(NULL);
- SAFE_DELETE(pTmpImage);
- }
- }
- SAFE_DELETE(pTmpList);
- }
- }
- }
- SAFE_DELETE(pList);
- Graphics::TBitmap *pBitmap = pImage->Picture->Bitmap;
- TStream *pImgStream = new TMemoryStream();
- try
- {
- nRow = pGDC->AppendRecord();
- pGDC->Values[nRow][ColSch01->Index] = String(nRow+1);
- pBitmap->SaveToStream(pImgStream);
- void *p;
- Variant v;
- int aBound[]={0, pImgStream->Size - 1};
- v = VarArrayCreate(aBound, 1, varByte);
- p = VarArrayLock(v);
- pImgStream->Position = 0;
- pImgStream->Read(p, pImgStream->Size);
- VarArrayUnlock(v);
- pGDC->Values[nRow][ColSch02->Index] = v;
- } catch(Exception &e) {}
- SAFE_DELETE(pImgStream);
- }
- __finally
- {
- pImage->Picture->Assign(NULL);
- pImage->Canvas->Unlock();
- SAFE_DELETE(pImage);
- }
- }
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("VMS Display History", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("VMS Display History", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- pGDC->EndUpdate();
- TvVmsMsg->EndUpdate();
- //TvVmsMsg->ApplyBestFit(NULL, false, false);
- }
- }
- //---------------------------------------------------------------------------
- TImage * __fastcall TFrmVmsLogMsgSub::GetSymbolImage(String ASymbolId)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- TImage *pImage = NULL;
- sQry = "SELECT IMAG_DATA \r\n"
- " FROM TB_VMS_SYMB_LIB \r\n"
- " WHERE SYMBLIB_NMBR = :p01 \r\n";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", ASymbolId);
- ITSDb_SQLOpen(pADO);
- pADO->First();
- if (!pADO->IsEmpty() || !pADO->Eof)
- {
- TStream *pStream = NULL;
- pStream = pADO->CreateBlobStream(pADO->FieldByName("IMAG_DATA"), bmRead);
- try
- {
- try {
- pImage = new TImage(NULL);
- pImage->Canvas->Lock();
- pStream->Position = 0;
- pImage->Picture->Bitmap->LoadFromStream(pStream);
- } catch(...) {}
- }__finally{
- pImage->Canvas->Unlock();
- if (pStream)
- delete pStream;
- }
- }
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("VMS Symbol Query", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("VMS Symbol Qeury", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- return pImage;
- }
- //---------------------------------------------------------------------------
|