FRAME_VdsStateListF.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITS_OPLibF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "CDSCodeF.h"
  8. #include "CDSVdsCtlrF.h"
  9. #pragma hdrstop
  10. #include "FRAME_VdsStateListF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxDropDownEdit"
  23. #pragma link "cxEdit"
  24. #pragma link "cxFilter"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGrid"
  27. #pragma link "cxGridCustomTableView"
  28. #pragma link "cxGridCustomView"
  29. #pragma link "cxGridLevel"
  30. #pragma link "cxGridTableView"
  31. #pragma link "cxLabel"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxMaskEdit"
  35. #pragma link "cxStyles"
  36. #pragma link "cxTextEdit"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma link "dxSkinBlack"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma resource "*.dfm"
  43. //TFRAMEVdsStateList *FRAMEVdsStateList;
  44. //---------------------------------------------------------------------------
  45. __fastcall TFRAMEVdsStateList::TFRAMEVdsStateList(TComponent* Owner)
  46. : TFrame(Owner)
  47. {
  48. LangTrans->Translate(this, ITSDb_GetConnection());
  49. m_pGDC = TvList->DataController;
  50. //TvList->OptionsView->NoDataToDisplayInfoText = "<VDS 정보가 없습니다>";
  51. APP_FillCode(CbType, "VDST");
  52. FTitle = lblTitle->Caption;
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TFRAMEVdsStateList::UpdateList()
  56. {
  57. CMM_ClearGridTableView(TvList);
  58. int nRow = 0;
  59. TvList->BeginUpdate();
  60. try
  61. {
  62. VdsCtlrManager->FLists.Lock();
  63. try
  64. {
  65. FOR_STL(TVdsCtlr*, pObj, VdsCtlrManager->FLists)
  66. {
  67. if (pObj->DEL_YN == "Y") continue;
  68. nRow = m_pGDC->AppendRecord();
  69. m_pGDC->Values[nRow][ColumnSel->Index] = false;
  70. m_pGDC->Values[nRow][Column00->Index] = "-";
  71. m_pGDC->Values[nRow][Column01->Index] = pObj->CTLR_NMBR;
  72. m_pGDC->Values[nRow][Column02->Index] = pObj->CTLR_ID;
  73. m_pGDC->Values[nRow][Column03->Index] = pObj->NAME;
  74. m_pGDC->Values[nRow][Column04->Index] = APP_GetCodeName(CbType, pObj->TYPE_CD);
  75. m_pGDC->Values[nRow][Column05->Index] = pObj->CTLR_IP;
  76. m_pGDC->Values[nRow][Column06->Index] = pObj->CTLR_PORT;
  77. m_pGDC->Values[nRow][Column07->Index] = String(pObj->GROUP_NO);
  78. m_pGDC->Values[nRow][Column08->Index] = String(pObj->CTLR_LOCAL_NO);
  79. m_pGDC->Values[nRow][Column09->Index] = String(pObj->TRAF_CLCT_CYCL);
  80. m_pGDC->Values[nRow][Column10->Index] = String(pObj->STTS_CLCT_CYCL);
  81. if (pObj->STATE.Comm == vds_normal) m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblComm0->Caption;//"정상";
  82. else if (pObj->STATE.Comm == vds_error ) m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  83. else m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblUnknown->Caption;
  84. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  85. }
  86. }
  87. __finally
  88. {
  89. VdsCtlrManager->FLists.UnLock();
  90. }
  91. }
  92. __finally
  93. {
  94. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  95. TvList->EndUpdate();
  96. Column01->SortIndex = Column01->Index;
  97. Column01->SortOrder = soAscending;
  98. TvList->DataController->GotoFirst();
  99. TvList->DataController->FocusedRecordIndex = 0;
  100. }
  101. }
  102. //---------------------------------------------------------------------------
  103. void __fastcall TFRAMEVdsStateList::RefreshStatus()
  104. {
  105. TcxDataController *pGDC = TvList->DataController;
  106. try
  107. {
  108. TvList->BeginUpdate();
  109. pGDC->BeginUpdate();
  110. int nRows = pGDC->RecordCount;
  111. for(int nRow = 0; nRow < nRows; nRow++)
  112. {
  113. int nMemPtr = TvList->DataController->Values[nRow][Column99->Index];
  114. TVdsCtlr *pObj = (TVdsCtlr*)nMemPtr;
  115. if (!pObj) continue;
  116. if (pObj->STATE.Comm == vds_normal) m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblComm0->Caption;//"정상";
  117. else if (pObj->STATE.Comm == vds_error ) m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  118. else m_pGDC->Values[nRow][Column11->Index] = FrmLang->lblUnknown->Caption;
  119. }
  120. }
  121. __finally
  122. {
  123. pGDC->EndUpdate();
  124. TvList->EndUpdate();
  125. //CxList->LayoutChanged();
  126. }
  127. }
  128. //---------------------------------------------------------------------------
  129. void __fastcall TFRAMEVdsStateList::BtnAllSelectClick(TObject *Sender)
  130. {
  131. TcxButton *pBtn = (TcxButton*)Sender;
  132. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  133. }
  134. //---------------------------------------------------------------------------
  135. int __fastcall TFRAMEVdsStateList::GetSelIds(String &ALinkIds)
  136. {
  137. ALinkIds = "";
  138. if (TvList->ViewData->RecordCount <= 0) return 0;
  139. int nIndex = m_pGDC->FocusedRecordIndex;
  140. if( nIndex < 0 )
  141. return 0;
  142. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  143. ALinkIds = sLinkId;
  144. return 1;
  145. }
  146. //---------------------------------------------------------------------------
  147. int __fastcall TFRAMEVdsStateList::GetSelIds(TStringList *AStringList)
  148. {
  149. int nSelCnt = 0;
  150. try
  151. {
  152. TvList->BeginUpdate();
  153. int nRowCnt = TvList->ViewData->RecordCount;
  154. for (int ii = 0; ii < nRowCnt; ii++)
  155. {
  156. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  157. if (((bool)ARow->Values[ColumnSel->Index]))
  158. {
  159. AStringList->Add(ARow->Values[Column01->Index]);
  160. nSelCnt++;
  161. }
  162. }
  163. }
  164. __finally
  165. {
  166. TvList->EndUpdate();
  167. }
  168. return nSelCnt;
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TFRAMEVdsStateList::TvListDataControllerFilterChanged(TObject *Sender)
  172. {
  173. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  174. }
  175. //---------------------------------------------------------------------------
  176. void __fastcall TFRAMEVdsStateList::BtnExlSaveClick(TObject *Sender)
  177. {
  178. TcxGrid *pGrid = CxList;
  179. TcxGridTableView *pView = TvList;
  180. String sTitle= FTitle;//"Vds정보";
  181. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  182. }
  183. //---------------------------------------------------------------------------
  184. void __fastcall TFRAMEVdsStateList::OnCloseQuery(bool &CanClose)
  185. {
  186. }
  187. //---------------------------------------------------------------------------
  188. void __fastcall TFRAMEVdsStateList::Column11CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  189. bool &ADone)
  190. {
  191. try
  192. {
  193. TColor tColor = ACanvas->Brush->Color;
  194. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column11->Index]))
  195. {
  196. String sCode = AViewInfo->GridRecord->DisplayTexts[Column11->Index];
  197. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  198. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  199. else tColor = clGray;
  200. }
  201. ACanvas->SetBrushColor(tColor);
  202. ACanvas->Font->Color = clBlack;
  203. }
  204. catch(Exception &e)
  205. {
  206. }
  207. }
  208. //---------------------------------------------------------------------------