VMSM500MSRCF.cpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include <vcl.h>
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "FrmVmsFormEditF.h"
  9. #include "VMSM500MSRCF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. //---------------------------------------------------------------------------
  13. String __fastcall TFrmVmsFormEdit::GetVmsSizeTypeDesc(String AType)
  14. {
  15. TVmsSizeType *Obj = VmsSizeTypeManager->Find(AType);
  16. if (Obj) {
  17. return Obj->NAME;
  18. }
  19. return "";
  20. }
  21. //---------------------------------------------------------------------------
  22. String __fastcall TFrmVmsFormEdit::GetVmsFormTypeDesc(String AType)
  23. {
  24. TVmsCode *Obj = VmsFormTypeManager->Find(AType.ToIntDef(-1));
  25. if (Obj) {
  26. return Obj->NAME;
  27. }
  28. return "";
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TFrmVmsFormEdit::FillVmsSizeType(TcxComboBox *cboBox)
  32. {
  33. String sQry;
  34. TStrings *pStrItems;
  35. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  36. ((TcxComboBox *)cboBox)->Properties->Items->Clear();
  37. FOR_STL(TVmsSizeType*, pObj, VmsSizeTypeManager->FLists)
  38. {
  39. if (!pObj->IsUse) continue;
  40. pStrItems->AddObject(" [" + pObj->CODE + "] " + pObj->NAME + " (" + String(pObj->WDTH) + "x" + String(pObj->HGHT) + ")", (TObject*)pObj);
  41. }
  42. cboBox->ItemIndex = 0;
  43. }
  44. //---------------------------------------------------------------------------
  45. TVmsSizeType* __fastcall TFrmVmsFormEdit::GetVmsSizeTypeObject(TcxComboBox *cboBox)
  46. {
  47. TStrings *pStrItems;
  48. TVmsSizeType *Ov = NULL;
  49. int nItemIndex;
  50. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  51. nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
  52. if (nItemIndex < 0)
  53. {
  54. return Ov;
  55. }
  56. Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
  57. if (Ov == NULL)
  58. {
  59. Ov = NULL;
  60. }
  61. return Ov;
  62. }
  63. //---------------------------------------------------------------------------
  64. //폼유형
  65. void __fastcall TFrmVmsFormEdit::FillVmsFormType(TcxComboBox *ACombo)
  66. {
  67. ACombo->Properties->Items->Clear();
  68. try {
  69. FOR_STL(TVmsCode*, pObj, VmsFormTypeManager->FLists) {
  70. if (!pObj->IsUse) continue;
  71. ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
  72. }
  73. } __finally {
  74. ACombo->ItemIndex = 0;
  75. }
  76. }
  77. //---------------------------------------------------------------------------
  78. //표출방법
  79. void __fastcall TFrmVmsFormEdit::FillVmsFormDispMthd(TcxComboBox *ACombo)
  80. {
  81. ACombo->Properties->Items->Clear();
  82. try {
  83. FOR_STL(TVmsCode*, pObj, VmsDsplMthdManager->FLists) {
  84. if (!pObj->IsUse) continue;
  85. ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
  86. }
  87. } __finally {
  88. ACombo->ItemIndex = 0;
  89. }
  90. }
  91. //---------------------------------------------------------------------------
  92. //표출방향
  93. void __fastcall TFrmVmsFormEdit::FillVmsFormDispDrct(TcxComboBox *ACombo)
  94. {
  95. ACombo->Properties->Items->Clear();
  96. try {
  97. FOR_STL(TVmsCode*, pObj, VmsDsplDrctManager->FLists) {
  98. if (!pObj->IsUse) continue;
  99. ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
  100. }
  101. } __finally {
  102. ACombo->ItemIndex = 0;
  103. }
  104. }
  105. //---------------------------------------------------------------------------
  106. //VMS Font
  107. void __fastcall TFrmVmsFormEdit::FillVmsFont(TcxComboBox *ACombo)
  108. {
  109. ACombo->Properties->Items->Clear();
  110. try {
  111. FOR_STL(TVmsCode*, pObj, VmsFontNameManager->FLists) {
  112. if (!pObj->IsUse) continue;
  113. ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
  114. }
  115. } __finally {
  116. ACombo->ItemIndex = 0;
  117. }
  118. }
  119. //---------------------------------------------------------------------------
  120. String __fastcall TFrmVmsFormEdit::BitmapToBase64String(Graphics::TBitmap *ABitmap)
  121. {
  122. String result = "";
  123. TIdEncoderMIME *Encodeur = new TIdEncoderMIME(NULL);
  124. TMemoryStream *TempMem = new TMemoryStream();
  125. void *buffer = NULL;
  126. try {
  127. try {
  128. ABitmap->SaveToStream(TempMem);
  129. TBytes bytes;
  130. TempMem->Position = 0;
  131. int size = TempMem->Size;
  132. buffer = malloc(size);
  133. bytes.Length = size;
  134. TempMem->ReadBuffer(buffer, TempMem->Size);
  135. ZeroMemory(&bytes[0], TempMem->Size);
  136. CopyMemory(&bytes[0], buffer, TempMem->Size);
  137. result = Encodeur->EncodeBytes(bytes);
  138. }
  139. catch(Exception &e) {
  140. }
  141. }
  142. __finally {
  143. if (Encodeur) delete Encodeur;
  144. if (TempMem) delete TempMem;
  145. if (buffer) free(buffer);
  146. }
  147. return result;
  148. }
  149. //---------------------------------------------------------------------------
  150. Graphics::TBitmap * __fastcall TFrmVmsFormEdit::Base64StringToBitmap(String AImageString)
  151. {
  152. TIdDecoderMIME *Decodeur = new TIdDecoderMIME(NULL);
  153. TMemoryStream *TempMem = new TMemoryStream();
  154. Graphics::TBitmap *result = new Graphics::TBitmap();
  155. try {
  156. try {
  157. Decodeur->DecodeBegin(TempMem);
  158. Decodeur->Decode(AImageString);
  159. Decodeur->DecodeEnd();
  160. TempMem->Position = 0;
  161. result->LoadFromStream(TempMem);
  162. }
  163. catch(Exception &e) {
  164. }
  165. }
  166. __finally {
  167. if (Decodeur) delete Decodeur;
  168. if (TempMem) delete TempMem;
  169. }
  170. return result;
  171. }
  172. //---------------------------------------------------------------------------
  173. void __fastcall TFrmVmsFormEdit::LoadFormObjectInfo(String AFormId, TVmsFormDesigner *ADesigner, String AFormType)
  174. {
  175. ADesigner->Clear();
  176. //String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/object/" + AFormId;
  177. String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/form/detail/" + AFormId;
  178. TMcJsonItem *ObjList = NULL;
  179. try
  180. {
  181. ObjList = TRestObjectManager::RequestGet(apiUri);
  182. if (ObjList == NULL) {
  183. return;
  184. }
  185. try
  186. {
  187. int nDrawType;
  188. String sObjKind;
  189. if (ObjList->Count < 2) {
  190. return;
  191. }
  192. //TMcJsonItem *formInfo = ObjList->Items[0];
  193. TMcJsonItem *formInfo = ObjList->Values["form"];
  194. if (formInfo) {
  195. String formImageString = TRestObjectManager::GetValue(formInfo, "vms_form_imag");
  196. Graphics::TBitmap *formBitmap = Base64StringToBitmap(formImageString);
  197. try {
  198. ImgForm->Picture->Bitmap->Assign(formBitmap);
  199. } catch(Exception &e) {
  200. }
  201. SAFE_DELETE(formBitmap);
  202. }
  203. //TMcJsonItem *objects = ObjList->Items[1];
  204. TMcJsonItem *objects = ObjList->Values["objects"];
  205. if (objects) {
  206. for (int ii = 0; ii < objects->Count; ii++)
  207. {
  208. int nFormId = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_id").ToIntDef(0);
  209. int nObjId = TRestObjectManager::GetValue(objects->Items[ii], "form_object_id").ToIntDef(0);
  210. int nObjType = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_object_type_cd").ToIntDef(-1);
  211. if (nObjType == 1 || //이미지 심볼
  212. nObjType == 2 || //파일이미지
  213. nObjType == 3 || //소통정보이미지
  214. nObjType == 17 || //소통이미지1
  215. nObjType == 27 || //소통이미지2
  216. nObjType == 37 || //소통이미지3
  217. nObjType == 47 || //소통이미지4
  218. nObjType == 200 || //동영상
  219. nObjType == 300 || //스트리밍영상
  220. nObjType == 406 || //@통합대기등급 이미지
  221. nObjType == 407 || //@미세먼지등급 이미지
  222. nObjType == 408 || //@초미세먼지등급 이미지
  223. nObjType == 413 //@오존등급이미지
  224. )
  225. {
  226. if (nObjType == 3) sObjKind = OBJKIND_IMAGE;
  227. else sObjKind = OBJKIND_IMAGEID;
  228. nDrawType = 1; //이미지그리기
  229. }
  230. else
  231. {
  232. sObjKind = OBJKIND_TEXT; //문자열
  233. nDrawType = 0; //문자열그리기
  234. }
  235. int nBlinking = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_blinking").ToIntDef(0);
  236. int nPosX = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_xcrdn").ToIntDef(0);
  237. int nPosY = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_ycrdn").ToIntDef(0);
  238. int nWidth = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_width").ToIntDef(0);
  239. int nHeight = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_height").ToIntDef(0);
  240. TVmsFormObject *pObj = ADesigner->AddObject((VmsObjectDrawType)nDrawType);
  241. if (!pObj) continue;
  242. if (nObjType == 200 || nObjType == 300)
  243. {
  244. pObj->EditMode = false;
  245. }
  246. String sIfscId = TRestObjectManager::GetValue(objects->Items[ii], "vms_ifsc_id");
  247. String sFillCd = TRestObjectManager::GetValue(objects->Items[ii], "trfc_fill_cd");
  248. pObj->ObjSeq = nObjId;
  249. pObj->ObjId = nObjId;
  250. pObj->ObjKind = sObjKind;
  251. pObj->Tag = sIfscId;
  252. if (AFormType == "15")
  253. {
  254. if (nObjType == 0 || nObjType == 1 || nObjType == 2)
  255. {
  256. pObj->Tag = sFillCd;
  257. }
  258. }
  259. pObj->ObjType = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_object_type_cd");
  260. pObj->ObjSize = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_size").ToIntDef(0);
  261. pObj->BkColorCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_bkcolor");
  262. pObj->Blink = nBlinking == 1 ? true : false;
  263. pObj->ImageId = TRestObjectManager::GetValue(objects->Items[ii], "symb_lib_nmbr");
  264. pObj->Text = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_txt");
  265. pObj->RunText = pObj->Text;
  266. pObj->SetPos(nPosX, nPosY);
  267. if (pObj->ObjKind == OBJKIND_TEXT) // 문자열
  268. {
  269. int nFontBold = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_bold").ToIntDef(0);
  270. // TODO
  271. pObj->FontName = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_name");
  272. pObj->FontNameCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_name_cd");
  273. pObj->FontColorCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_colr_cd");
  274. pObj->FontSize = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_size").ToIntDef(0);
  275. pObj->FontBold = nFontBold == 1 ? true : false;
  276. pObj->TextAlign = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_align").ToIntDef(0);
  277. //pObj->SetPos(nPosX, nPosY);
  278. //pObj->SetSize(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);
  279. }
  280. else //if (sObjKind == "1" || sObjKind == "2") // 이미지(1), 이미지 ID(2)
  281. {
  282. if (pObj->ObjKind == OBJKIND_IMAGEID)
  283. {
  284. if (pObj->Text.Trim() == "")
  285. {
  286. pObj->Text = pObj->ImageId;
  287. }
  288. }
  289. String imageString = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_figr");
  290. Graphics::TBitmap *bitmap = Base64StringToBitmap(imageString);
  291. TStream *pStream = new TMemoryStream();
  292. try {
  293. bitmap->SaveToStream(pStream);
  294. } catch(Exception &e) {}
  295. try
  296. {
  297. if (pStream && pStream->Size > 0)
  298. {
  299. Graphics::TBitmap *Bitmap = pObj->GetBitmap();
  300. pStream->Position = 0;
  301. Bitmap->LoadFromStream(pStream);
  302. #ifdef IMAGE_RESIZE
  303. #if 0
  304. if (nObjType == 1 || nObjType == 2)
  305. {
  306. pObj->GetImage()->AutoSize= false;
  307. pObj->GetImage()->Stretch = true;
  308. pObj->GetImage()->Width = nWidth;
  309. pObj->GetImage()->Height = nHeight;
  310. pObj->SetSize(nWidth, nHeight);
  311. pObj->SetPos(nPosX, nPosY);
  312. }
  313. else
  314. {
  315. pObj->SetSize(Bitmap->Width, Bitmap->Height);
  316. }
  317. #else
  318. switch(nObjType)
  319. {
  320. case 1: //심볼
  321. case 2: //이미지
  322. case 3: //소통정보배경이미지
  323. case 17: //소통정보이미지1
  324. case 27: //소통정보이미지2
  325. case 37: //소통정보이미지3
  326. case 47: //소통정보이미지4
  327. case 167: //@우회소통정보이미지
  328. case 200: //동영상이미지
  329. case 300: //스트리밍영상이미지
  330. case 406: //@통합대기등급 이미지
  331. case 407: //@미세먼지등급 이미지
  332. case 408: //@초미세먼지등급 이미지
  333. case 413: //@오존등급이미지
  334. pObj->GetImage()->AutoSize= false;
  335. pObj->GetImage()->Stretch = true;
  336. pObj->GetImage()->Width = nWidth;
  337. pObj->GetImage()->Height = nHeight;
  338. pObj->SetSize(nWidth, nHeight);
  339. pObj->SetPos(nPosX, nPosY);
  340. break;
  341. default:
  342. pObj->SetSize(Bitmap->Width, Bitmap->Height);
  343. pObj->SetPos(nPosX, nPosY); //TODO
  344. break;
  345. }
  346. #endif
  347. #else
  348. pObj->SetSize(Bitmap->Width, Bitmap->Height);
  349. pObj->SetPos(nPosX, nPosY);
  350. #endif
  351. }
  352. }
  353. __finally
  354. {
  355. SAFE_DELETE(pStream);
  356. SAFE_DELETE(bitmap);
  357. }
  358. }
  359. //pObj->SetPos(nPosX, nPosY);
  360. //if (pObj->Left < 0) pObj->Left = 0;
  361. //if (pObj->Top < 0) pObj->Top = 0;
  362. pObj->Show();
  363. pObj->BringToFront();
  364. }
  365. }
  366. }
  367. catch(Exception &exception)
  368. {
  369. throw Exception(String(exception.ClassName()) + exception.Message);
  370. }
  371. }
  372. __finally
  373. {
  374. if (ObjList) delete ObjList;
  375. }
  376. }
  377. //---------------------------------------------------------------------------
  378. void __fastcall TFrmVmsFormEdit::LoadVmsForm()
  379. {
  380. FormClear();
  381. int nFocusedIdx = TvList->DataController->FocusedRecordIndex;
  382. CMM_ClearGridTableView(TvList);
  383. ClearSymbloList();
  384. TVmsSizeType *pVmsSizeType = GetVmsSizeTypeObject(CbSizeType);
  385. if (pVmsSizeType == NULL) return;
  386. String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage";
  387. TMcJsonItem *ObjList = NULL;
  388. if (pVmsSizeType->CODE != "ALL")
  389. {
  390. apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/form/" + pVmsSizeType->CODE;
  391. }
  392. FVmsTypeCd = pVmsSizeType->CODE;
  393. FVmsWidth = pVmsSizeType->WDTH;
  394. FVmsHeight = pVmsSizeType->HGHT;
  395. FVmsCols = pVmsSizeType->COLS;
  396. FVmsRows = pVmsSizeType->ROWS;
  397. ImgForm->Width = FVmsWidth;
  398. ImgForm->Height = FVmsHeight;
  399. ImgForm->Picture->Bitmap->Width = FVmsWidth;
  400. ImgForm->Picture->Bitmap->Height = FVmsHeight;
  401. {
  402. PnlBack->Left = 5;
  403. PnlBack->Top = 5;
  404. PnlBack->Width = FVmsWidth+4;
  405. PnlBack->Height= FVmsHeight+4;
  406. }
  407. {
  408. PnlEdtBack->Width = FVmsWidth+4;
  409. PnlEdtBack->Height= FVmsHeight+4;
  410. PnlRePreview->Width = FVmsWidth+4;
  411. PnlRePreview->Height= FVmsHeight+4;
  412. PnlRePreview->Color = clWhite;
  413. ImgEdtPreview->Left = 2;
  414. ImgEdtPreview->Top = 2;
  415. ImgEdtPreview->Width = FVmsWidth;
  416. ImgEdtPreview->Height= FVmsHeight;
  417. ImgEdtPreview->Picture->Bitmap->Width = FVmsWidth;
  418. ImgEdtPreview->Picture->Bitmap->Height = FVmsHeight;
  419. m_pEdtDesigner->DrawPreviewModuleBack(ImgEdtPreview, clBlack, FVmsRows, FVmsCols);
  420. #if 0
  421. #if 0
  422. ReForm->Width = FVmsWidth+22+4;
  423. ReForm->Height= FVmsHeight+22+4;
  424. #else
  425. ReForm->Width = FVmsWidth+4;
  426. ReForm->Height= FVmsHeight+4;
  427. #endif
  428. #endif
  429. ReForm->Color = clBlack;
  430. m_pEdtDesigner->Clear();
  431. m_pEdtDesigner->SizeType = FVmsTypeCd;
  432. m_pEdtDesigner->SetSize(FVmsWidth, FVmsHeight);
  433. m_pEdtDesigner->SetPos(0, 0);
  434. m_pEdtDesigner->BkColorCode = "0";
  435. m_pEdtDesigner->EditMode = true;
  436. m_pEdtDesigner->Show();
  437. }
  438. String sVmsSizeNm = pVmsSizeType->NAME;
  439. String sFirstFormId = "";
  440. try
  441. {
  442. int nRow;
  443. TcxDataController *pGDC = TvList->DataController;
  444. TvList->BeginUpdate();
  445. ObjList = TRestObjectManager::RequestGet(apiUri);
  446. if (ObjList == NULL) {
  447. return;
  448. }
  449. try
  450. {
  451. for (int ii = 0; ii < ObjList->Count; ii++)
  452. {
  453. nRow = pGDC->AppendRecord();
  454. String sFormId = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_id");
  455. if (sFirstFormId == "") sFirstFormId = sFormId;
  456. pGDC->Values[nRow][Col01->Index] = sFormId; //폼ID
  457. pGDC->Values[nRow][Col02->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_nm"); //폼명칭
  458. pGDC->Values[nRow][Col03->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_expl"); //폼설명
  459. pGDC->Values[nRow][Col04->Index] = GetVmsFormTypeDesc(TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_type_cd"));
  460. pGDC->Values[nRow][Col05->Index] = GetVmsSizeTypeDesc(TRestObjectManager::GetValue(ObjList->Items[ii], "vms_type_cd"));
  461. pGDC->Values[nRow][Col06->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_dspl_mthd_cd");
  462. pGDC->Values[nRow][Col07->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_dspl_drct_cd");
  463. pGDC->Values[nRow][Col08->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_colr_cd");
  464. pGDC->Values[nRow][Col09->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_type_cd");
  465. pGDC->Values[nRow][Col10->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_type_cd");
  466. pGDC->Values[nRow][Col12->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_dspl_txt");
  467. }
  468. }
  469. catch(Exception &e)
  470. {
  471. throw Exception(String(e.ClassName()) + e.Message);
  472. }
  473. }
  474. __finally
  475. {
  476. if (ObjList) delete ObjList;
  477. TvList->EndUpdate();
  478. if (TvList->DataController->RecordCount > 0)
  479. {
  480. //CMM_SetGridRow(CxList, TvList, sFirstFormId, Col01->Index);
  481. //DisplayInfo();
  482. }
  483. }
  484. }
  485. //---------------------------------------------------------------------------
  486. bool __fastcall TFrmVmsFormEdit::SaveVmsForm(String AVALID_YN)
  487. {
  488. bool result = false;
  489. int nFormId = EdFormId->Text.Trim().ToIntDef(0);
  490. String sVmsType = FVmsTypeCd;
  491. String sFormType = APP_GetCode(CbFormKind);
  492. String sName = EdFormName->Text.Trim();
  493. String sExpl = EdFormDesc->Text.Trim();
  494. String sFormColor = String(CbFormColor->ItemIndex);
  495. String sDispDir = APP_GetCode(CbFormDsplDrct);
  496. String sDispMode = APP_GetCode(CbFormDsplMthd);
  497. String sUpdtDt = Now().FormatString("yyyymmddhhnnss");
  498. String resultVal;
  499. String key = "abcdefg1234567890x";
  500. String apiUri = g_AppCfg.sRestApiUri + "/cs-api/vms/form/manage/merge/" + key + "/" + String(nFormId);
  501. TMcJsonItem *ObjList = new TMcJsonItem();
  502. try
  503. {
  504. ObjList->Add("vms_form_id")->AsInteger = nFormId;
  505. ObjList->Add("vms_form_nm")->AsString = sName;
  506. ObjList->Add("vms_form_expl")->AsString = sExpl;
  507. ObjList->Add("vms_type_cd")->AsString = sVmsType;
  508. ObjList->Add("vms_form_type_cd")->AsInteger = sFormType.ToIntDef(0);
  509. ObjList->Add("vms_form_colr_cd")->AsInteger = sFormColor.ToIntDef(0);
  510. ObjList->Add("vms_form_dspl_drct_cd")->AsInteger = sDispDir.ToIntDef(0);
  511. ObjList->Add("vms_form_dspl_mthd_cd")->AsInteger = sDispMode.ToIntDef(0);
  512. ObjList->Add("vms_form_imag")->AsString = BitmapToBase64String(ImgForm->Picture->Bitmap);
  513. //ObjList->Add("symb_lib_nmbr")->AsInteger = jvtNull;
  514. ObjList->Add("updt_dt")->AsString = sUpdtDt;
  515. ObjList->Add("valid_yn")->AsString = AVALID_YN;
  516. TMcJsonItem *objects = ObjList->Add("objects", jitArray);
  517. TVmsFormObject *pObj;
  518. TcxGridDataController *pGDC = TvObjList->DataController;
  519. int nObjType;
  520. int nObjCnt = pGDC->RecordCount;
  521. for (int ii = 0; ii < nObjCnt; ii++)
  522. {
  523. TMcJsonItem *object = new TMcJsonItem();
  524. String sObjSeq = VarToStr(pGDC->Values[ii][ColSeq->Index]);
  525. pObj = m_pEdtDesigner->FindObject(sObjSeq.ToInt());
  526. if (!pObj) continue;
  527. nObjType = pObj->ObjType.ToIntDef(0);
  528. object->Add("vms_form_object_id")->AsInteger = ii+1;
  529. object->Add("vms_form_id")->AsInteger = nFormId;
  530. object->Add("vms_form_dspl_row")->AsInteger = 0;
  531. object->Add("vms_form_dspl_clmn")->AsInteger = 0;
  532. object->Add("vms_form_object_type_cd")->AsInteger = nObjType;
  533. object->Add("vms_font_name_cd")->AsInteger = pObj->FontNameCode.ToIntDef(0);
  534. object->Add("vms_font_colr_cd")->AsInteger = pObj->FontColorCode.ToIntDef(0);
  535. object->Add("vms_font_bold")->AsInteger = pObj->FontBold ? 1 : 0;
  536. object->Add("vms_font_size")->AsInteger = pObj->FontSize;
  537. object->Add("vms_font_align")->AsInteger = pObj->TextAlign;
  538. object->Add("vms_dspl_txt")->AsString = pObj->Text;
  539. TImage *pImg = pObj->GetImage();
  540. if (!pImg) {
  541. object->Add("vms_dspl_figr")->AsString = BitmapToBase64String(ImgNull->Picture->Bitmap);
  542. }
  543. else {
  544. object->Add("vms_dspl_figr")->AsString = BitmapToBase64String(pImg->Picture->Bitmap);
  545. }
  546. object->Add("vms_dspl_xcrdn")->AsInteger = pObj->GetLeft();
  547. object->Add("vms_dspl_ycrdn")->AsInteger = pObj->GetTop();
  548. object->Add("vms_dspl_width")->AsInteger = pObj->GetWidth();
  549. object->Add("vms_dspl_height")->AsInteger = pObj->GetHeight();
  550. object->Add("vms_dspl_blinking")->AsInteger = pObj->Blink ? 1 : 0;
  551. object->Add("vms_dspl_bkcolor")->AsInteger = pObj->BkColorCode.ToIntDef(0);
  552. object->Add("vms_dspl_size")->AsInteger = pObj->ObjSize;
  553. String sFillIn = "N";
  554. if (sFormType == "15")
  555. {
  556. if (nObjType == 0 || nObjType == 1 || nObjType == 2)
  557. {
  558. sFillIn = pObj->Tag;
  559. }
  560. }
  561. object->Add("trfc_fill_cd")->AsString = sFillIn;
  562. int symbLibNmbr = pObj->ImageId.ToIntDef(0);
  563. if (symbLibNmbr > 0) {
  564. //object->Add("symb_lib_nmbr")->AsInteger = symbLibNmbr == 0 ? jvtNull : symbLibNmbr;
  565. object->Add("symb_lib_nmbr")->AsInteger = symbLibNmbr;
  566. }
  567. else {
  568. object->Add("symb_lib_nmbr")->AsInteger = 0; // NOT NULL
  569. }
  570. String sIfscId = "";
  571. if (nObjType == 91 || nObjType == 92)
  572. {
  573. sIfscId = pObj->Tag;
  574. }
  575. object->Add("vms_ifsc_id")->AsString = sIfscId;
  576. objects->Add(object);
  577. delete object;
  578. }
  579. result = TRestObjectManager::RequestPost(apiUri, ObjList->AsJSON, resultVal);
  580. if (!result) {
  581. return false;
  582. }
  583. }
  584. __finally
  585. {
  586. if (ObjList) delete ObjList;
  587. }
  588. return true;
  589. }
  590. //---------------------------------------------------------------------------
  591. bool __fastcall TFrmVmsFormEdit::CheckVmsFormUse(String AFormId)
  592. {
  593. String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/usage/" + AFormId;
  594. TMcJsonItem *ObjList = NULL;
  595. try {
  596. ObjList = TRestObjectManager::RequestGet(apiUri);
  597. if (ObjList == NULL) {
  598. return false;
  599. }
  600. if (ObjList->Count > 0) {
  601. String usages = TRestObjectManager::GetValue(ObjList, "count");
  602. if (usages.ToIntDef(-1) > 0) {
  603. Application->MessageBox(L"VMS 폼 사용확인\r\n삭제할 VMS 폼 정보가 VMS 스케쥴에 사용되고 있습니다.\r\n먼저 해당 정보를 삭제해주시기 바랍니다.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  604. return false;
  605. }
  606. }
  607. } __finally {
  608. if (ObjList) delete ObjList;
  609. }
  610. return true;
  611. }
  612. //---------------------------------------------------------------------------
  613. bool __fastcall TFrmVmsFormEdit::DelVmsForm(String AFormId)
  614. {
  615. bool result = false;
  616. String resultVal;
  617. String key = "abcdefg1234567890x";
  618. String apiUri = g_AppCfg.sRestApiUri + "/cs-api/vms/form/manage/delete/" + key + "/" + AFormId;
  619. try {
  620. result = TRestObjectManager::RequestPost(apiUri, "", resultVal);
  621. if (!result) {
  622. return false;
  623. }
  624. } __finally {
  625. }
  626. return result;
  627. }
  628. //---------------------------------------------------------------------------
  629. bool __fastcall TFrmVmsFormEdit::GetNextVmsFormId(int &AFormId)
  630. {
  631. AFormId = -1;
  632. String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/new-id";
  633. TMcJsonItem *ObjList = NULL;
  634. try {
  635. ObjList = TRestObjectManager::RequestGet(apiUri);
  636. if (ObjList == NULL) {
  637. return false;
  638. }
  639. if (ObjList->Count > 0) {
  640. String newId = TRestObjectManager::GetValue(ObjList, "new_id");
  641. AFormId = newId.ToIntDef(-1);
  642. }
  643. } __finally {
  644. if (ObjList) delete ObjList;
  645. }
  646. if (AFormId == -1) return false;
  647. return true;
  648. }
  649. //---------------------------------------------------------------------------