123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "AppGlobalF.h"
- #pragma hdrstop
- #include "FrmVmsFormEditF.h"
- #include "VMSM500MSRCF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- String __fastcall TFrmVmsFormEdit::GetVmsSizeTypeDesc(String AType)
- {
- TVmsSizeType *Obj = VmsSizeTypeManager->Find(AType);
- if (Obj) {
- return Obj->NAME;
- }
- return "";
- }
- //---------------------------------------------------------------------------
- String __fastcall TFrmVmsFormEdit::GetVmsFormTypeDesc(String AType)
- {
- TVmsCode *Obj = VmsFormTypeManager->Find(AType.ToIntDef(-1));
- if (Obj) {
- return Obj->NAME;
- }
- return "";
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsFormEdit::FillVmsSizeType(TcxComboBox *cboBox)
- {
- String sQry;
- TStrings *pStrItems;
- pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
- ((TcxComboBox *)cboBox)->Properties->Items->Clear();
- FOR_STL(TVmsSizeType*, pObj, VmsSizeTypeManager->FLists)
- {
- if (!pObj->IsUse) continue;
- pStrItems->AddObject(" [" + pObj->CODE + "] " + pObj->NAME + " (" + String(pObj->WDTH) + "x" + String(pObj->HGHT) + ")", (TObject*)pObj);
- }
- cboBox->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
- TVmsSizeType* __fastcall TFrmVmsFormEdit::GetVmsSizeTypeObject(TcxComboBox *cboBox)
- {
- TStrings *pStrItems;
- TVmsSizeType *Ov = NULL;
- int nItemIndex;
- pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
- nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
- if (nItemIndex < 0)
- {
- return Ov;
- }
- Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
- if (Ov == NULL)
- {
- Ov = NULL;
- }
- return Ov;
- }
- //---------------------------------------------------------------------------
- //폼유형
- void __fastcall TFrmVmsFormEdit::FillVmsFormType(TcxComboBox *ACombo)
- {
- ACombo->Properties->Items->Clear();
- try {
- FOR_STL(TVmsCode*, pObj, VmsFormTypeManager->FLists) {
- if (!pObj->IsUse) continue;
- ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
- }
- } __finally {
- ACombo->ItemIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- //표출방법
- void __fastcall TFrmVmsFormEdit::FillVmsFormDispMthd(TcxComboBox *ACombo)
- {
- ACombo->Properties->Items->Clear();
- try {
- FOR_STL(TVmsCode*, pObj, VmsDsplMthdManager->FLists) {
- if (!pObj->IsUse) continue;
- ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
- }
- } __finally {
- ACombo->ItemIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- //표출방향
- void __fastcall TFrmVmsFormEdit::FillVmsFormDispDrct(TcxComboBox *ACombo)
- {
- ACombo->Properties->Items->Clear();
- try {
- FOR_STL(TVmsCode*, pObj, VmsDsplDrctManager->FLists) {
- if (!pObj->IsUse) continue;
- ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
- }
- } __finally {
- ACombo->ItemIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- //VMS Font
- void __fastcall TFrmVmsFormEdit::FillVmsFont(TcxComboBox *ACombo)
- {
- ACombo->Properties->Items->Clear();
- try {
- FOR_STL(TVmsCode*, pObj, VmsFontNameManager->FLists) {
- if (!pObj->IsUse) continue;
- ACombo->Properties->Items->Add(" [" + String(pObj->CODE) + "] " + pObj->NAME);
- }
- } __finally {
- ACombo->ItemIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- String __fastcall TFrmVmsFormEdit::BitmapToBase64String(Graphics::TBitmap *ABitmap)
- {
- String result = "";
- TIdEncoderMIME *Encodeur = new TIdEncoderMIME(NULL);
- TMemoryStream *TempMem = new TMemoryStream();
- void *buffer = NULL;
- try {
- try {
- ABitmap->SaveToStream(TempMem);
- TBytes bytes;
- TempMem->Position = 0;
- int size = TempMem->Size;
- buffer = malloc(size);
- bytes.Length = size;
- TempMem->ReadBuffer(buffer, TempMem->Size);
- ZeroMemory(&bytes[0], TempMem->Size);
- CopyMemory(&bytes[0], buffer, TempMem->Size);
- result = Encodeur->EncodeBytes(bytes);
- }
- catch(Exception &e) {
- }
- }
- __finally {
- if (Encodeur) delete Encodeur;
- if (TempMem) delete TempMem;
- if (buffer) free(buffer);
- }
- return result;
- }
- //---------------------------------------------------------------------------
- Graphics::TBitmap * __fastcall TFrmVmsFormEdit::Base64StringToBitmap(String AImageString)
- {
- TIdDecoderMIME *Decodeur = new TIdDecoderMIME(NULL);
- TMemoryStream *TempMem = new TMemoryStream();
- Graphics::TBitmap *result = new Graphics::TBitmap();
- try {
- try {
- Decodeur->DecodeBegin(TempMem);
- Decodeur->Decode(AImageString);
- Decodeur->DecodeEnd();
- TempMem->Position = 0;
- result->LoadFromStream(TempMem);
- }
- catch(Exception &e) {
- }
- }
- __finally {
- if (Decodeur) delete Decodeur;
- if (TempMem) delete TempMem;
- }
- return result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsFormEdit::LoadFormObjectInfo(String AFormId, TVmsFormDesigner *ADesigner, String AFormType)
- {
- ADesigner->Clear();
- //String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/object/" + AFormId;
- String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/form/detail/" + AFormId;
- TMcJsonItem *ObjList = NULL;
- try
- {
- ObjList = TRestObjectManager::RequestGet(apiUri);
- if (ObjList == NULL) {
- return;
- }
- try
- {
- int nDrawType;
- String sObjKind;
- if (ObjList->Count < 2) {
- return;
- }
- //TMcJsonItem *formInfo = ObjList->Items[0];
- TMcJsonItem *formInfo = ObjList->Values["form"];
- if (formInfo) {
- String formImageString = TRestObjectManager::GetValue(formInfo, "vms_form_imag");
- Graphics::TBitmap *formBitmap = Base64StringToBitmap(formImageString);
- try {
- ImgForm->Picture->Bitmap->Assign(formBitmap);
- } catch(Exception &e) {
- }
- SAFE_DELETE(formBitmap);
- }
- //TMcJsonItem *objects = ObjList->Items[1];
- TMcJsonItem *objects = ObjList->Values["objects"];
- if (objects) {
- for (int ii = 0; ii < objects->Count; ii++)
- {
- int nFormId = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_id").ToIntDef(0);
- int nObjId = TRestObjectManager::GetValue(objects->Items[ii], "form_object_id").ToIntDef(0);
- int nObjType = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_object_type_cd").ToIntDef(-1);
- if (nObjType == 1 || //이미지 심볼
- nObjType == 2 || //파일이미지
- nObjType == 3 || //소통정보이미지
- nObjType == 17 || //소통이미지1
- nObjType == 27 || //소통이미지2
- nObjType == 37 || //소통이미지3
- nObjType == 47 || //소통이미지4
- nObjType == 200 || //동영상
- nObjType == 300 || //스트리밍영상
- nObjType == 406 || //@통합대기등급 이미지
- nObjType == 407 || //@미세먼지등급 이미지
- nObjType == 408 || //@초미세먼지등급 이미지
- nObjType == 413 //@오존등급이미지
- )
- {
- if (nObjType == 3) sObjKind = OBJKIND_IMAGE;
- else sObjKind = OBJKIND_IMAGEID;
- nDrawType = 1; //이미지그리기
- }
- else
- {
- sObjKind = OBJKIND_TEXT; //문자열
- nDrawType = 0; //문자열그리기
- }
- int nBlinking = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_blinking").ToIntDef(0);
- int nPosX = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_xcrdn").ToIntDef(0);
- int nPosY = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_ycrdn").ToIntDef(0);
- int nWidth = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_width").ToIntDef(0);
- int nHeight = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_height").ToIntDef(0);
- TVmsFormObject *pObj = ADesigner->AddObject((VmsObjectDrawType)nDrawType);
- if (!pObj) continue;
- if (nObjType == 200 || nObjType == 300)
- {
- pObj->EditMode = false;
- }
- String sIfscId = TRestObjectManager::GetValue(objects->Items[ii], "vms_ifsc_id");
- String sFillCd = TRestObjectManager::GetValue(objects->Items[ii], "trfc_fill_cd");
- pObj->ObjSeq = nObjId;
- pObj->ObjId = nObjId;
- pObj->ObjKind = sObjKind;
- pObj->Tag = sIfscId;
- if (AFormType == "15")
- {
- if (nObjType == 0 || nObjType == 1 || nObjType == 2)
- {
- pObj->Tag = sFillCd;
- }
- }
- pObj->ObjType = TRestObjectManager::GetValue(objects->Items[ii], "vms_form_object_type_cd");
- pObj->ObjSize = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_size").ToIntDef(0);
- pObj->BkColorCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_bkcolor");
- pObj->Blink = nBlinking == 1 ? true : false;
- pObj->ImageId = TRestObjectManager::GetValue(objects->Items[ii], "symb_lib_nmbr");
- pObj->Text = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_txt");
- pObj->RunText = pObj->Text;
- pObj->SetPos(nPosX, nPosY);
- if (pObj->ObjKind == OBJKIND_TEXT) // 문자열
- {
- int nFontBold = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_bold").ToIntDef(0);
- // TODO
- pObj->FontName = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_name");
- pObj->FontNameCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_name_cd");
- pObj->FontColorCode = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_colr_cd");
- pObj->FontSize = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_size").ToIntDef(0);
- pObj->FontBold = nFontBold == 1 ? true : false;
- pObj->TextAlign = TRestObjectManager::GetValue(objects->Items[ii], "vms_font_align").ToIntDef(0);
- //pObj->SetPos(nPosX, nPosY);
- //pObj->SetSize(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);
- }
- else //if (sObjKind == "1" || sObjKind == "2") // 이미지(1), 이미지 ID(2)
- {
- if (pObj->ObjKind == OBJKIND_IMAGEID)
- {
- if (pObj->Text.Trim() == "")
- {
- pObj->Text = pObj->ImageId;
- }
- }
- String imageString = TRestObjectManager::GetValue(objects->Items[ii], "vms_dspl_figr");
- Graphics::TBitmap *bitmap = Base64StringToBitmap(imageString);
- TStream *pStream = new TMemoryStream();
- try {
- bitmap->SaveToStream(pStream);
- } catch(Exception &e) {}
- try
- {
- if (pStream && pStream->Size > 0)
- {
- Graphics::TBitmap *Bitmap = pObj->GetBitmap();
- pStream->Position = 0;
- Bitmap->LoadFromStream(pStream);
- #ifdef IMAGE_RESIZE
- #if 0
- if (nObjType == 1 || nObjType == 2)
- {
- pObj->GetImage()->AutoSize= false;
- pObj->GetImage()->Stretch = true;
- pObj->GetImage()->Width = nWidth;
- pObj->GetImage()->Height = nHeight;
- pObj->SetSize(nWidth, nHeight);
- pObj->SetPos(nPosX, nPosY);
- }
- else
- {
- pObj->SetSize(Bitmap->Width, Bitmap->Height);
- }
- #else
- switch(nObjType)
- {
- case 1: //심볼
- case 2: //이미지
- case 3: //소통정보배경이미지
- case 17: //소통정보이미지1
- case 27: //소통정보이미지2
- case 37: //소통정보이미지3
- case 47: //소통정보이미지4
- case 167: //@우회소통정보이미지
- case 200: //동영상이미지
- case 300: //스트리밍영상이미지
- case 406: //@통합대기등급 이미지
- case 407: //@미세먼지등급 이미지
- case 408: //@초미세먼지등급 이미지
- case 413: //@오존등급이미지
- pObj->GetImage()->AutoSize= false;
- pObj->GetImage()->Stretch = true;
- pObj->GetImage()->Width = nWidth;
- pObj->GetImage()->Height = nHeight;
- pObj->SetSize(nWidth, nHeight);
- pObj->SetPos(nPosX, nPosY);
- break;
- default:
- pObj->SetSize(Bitmap->Width, Bitmap->Height);
- pObj->SetPos(nPosX, nPosY); //TODO
- break;
- }
- #endif
- #else
- pObj->SetSize(Bitmap->Width, Bitmap->Height);
- pObj->SetPos(nPosX, nPosY);
- #endif
- }
- }
- __finally
- {
- SAFE_DELETE(pStream);
- SAFE_DELETE(bitmap);
- }
- }
- //pObj->SetPos(nPosX, nPosY);
- //if (pObj->Left < 0) pObj->Left = 0;
- //if (pObj->Top < 0) pObj->Top = 0;
- pObj->Show();
- pObj->BringToFront();
- }
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (ObjList) delete ObjList;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsFormEdit::LoadVmsForm()
- {
- FormClear();
- int nFocusedIdx = TvList->DataController->FocusedRecordIndex;
- CMM_ClearGridTableView(TvList);
- ClearSymbloList();
- TVmsSizeType *pVmsSizeType = GetVmsSizeTypeObject(CbSizeType);
- if (pVmsSizeType == NULL) return;
- String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage";
- TMcJsonItem *ObjList = NULL;
- if (pVmsSizeType->CODE != "ALL")
- {
- apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/form/" + pVmsSizeType->CODE;
- }
- FVmsTypeCd = pVmsSizeType->CODE;
- FVmsWidth = pVmsSizeType->WDTH;
- FVmsHeight = pVmsSizeType->HGHT;
- FVmsCols = pVmsSizeType->COLS;
- FVmsRows = pVmsSizeType->ROWS;
- ImgForm->Width = FVmsWidth;
- ImgForm->Height = FVmsHeight;
- ImgForm->Picture->Bitmap->Width = FVmsWidth;
- ImgForm->Picture->Bitmap->Height = FVmsHeight;
- {
- PnlBack->Left = 5;
- PnlBack->Top = 5;
- PnlBack->Width = FVmsWidth+4;
- PnlBack->Height= FVmsHeight+4;
- }
- {
- PnlEdtBack->Width = FVmsWidth+4;
- PnlEdtBack->Height= FVmsHeight+4;
- PnlRePreview->Width = FVmsWidth+4;
- PnlRePreview->Height= FVmsHeight+4;
- PnlRePreview->Color = clWhite;
- ImgEdtPreview->Left = 2;
- ImgEdtPreview->Top = 2;
- ImgEdtPreview->Width = FVmsWidth;
- ImgEdtPreview->Height= FVmsHeight;
- ImgEdtPreview->Picture->Bitmap->Width = FVmsWidth;
- ImgEdtPreview->Picture->Bitmap->Height = FVmsHeight;
- m_pEdtDesigner->DrawPreviewModuleBack(ImgEdtPreview, clBlack, FVmsRows, FVmsCols);
- #if 0
- #if 0
- ReForm->Width = FVmsWidth+22+4;
- ReForm->Height= FVmsHeight+22+4;
- #else
- ReForm->Width = FVmsWidth+4;
- ReForm->Height= FVmsHeight+4;
- #endif
- #endif
- ReForm->Color = clBlack;
- m_pEdtDesigner->Clear();
- m_pEdtDesigner->SizeType = FVmsTypeCd;
- m_pEdtDesigner->SetSize(FVmsWidth, FVmsHeight);
- m_pEdtDesigner->SetPos(0, 0);
- m_pEdtDesigner->BkColorCode = "0";
- m_pEdtDesigner->EditMode = true;
- m_pEdtDesigner->Show();
- }
- String sVmsSizeNm = pVmsSizeType->NAME;
- String sFirstFormId = "";
- try
- {
- int nRow;
- TcxDataController *pGDC = TvList->DataController;
- TvList->BeginUpdate();
- ObjList = TRestObjectManager::RequestGet(apiUri);
- if (ObjList == NULL) {
- return;
- }
- try
- {
- for (int ii = 0; ii < ObjList->Count; ii++)
- {
- nRow = pGDC->AppendRecord();
- String sFormId = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_id");
- if (sFirstFormId == "") sFirstFormId = sFormId;
- pGDC->Values[nRow][Col01->Index] = sFormId; //폼ID
- pGDC->Values[nRow][Col02->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_nm"); //폼명칭
- pGDC->Values[nRow][Col03->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_expl"); //폼설명
- pGDC->Values[nRow][Col04->Index] = GetVmsFormTypeDesc(TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_type_cd"));
- pGDC->Values[nRow][Col05->Index] = GetVmsSizeTypeDesc(TRestObjectManager::GetValue(ObjList->Items[ii], "vms_type_cd"));
- pGDC->Values[nRow][Col06->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_dspl_mthd_cd");
- pGDC->Values[nRow][Col07->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_dspl_drct_cd");
- pGDC->Values[nRow][Col08->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_colr_cd");
- pGDC->Values[nRow][Col09->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_form_type_cd");
- pGDC->Values[nRow][Col10->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_type_cd");
- pGDC->Values[nRow][Col12->Index] = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_dspl_txt");
- }
- }
- catch(Exception &e)
- {
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (ObjList) delete ObjList;
- TvList->EndUpdate();
- if (TvList->DataController->RecordCount > 0)
- {
- //CMM_SetGridRow(CxList, TvList, sFirstFormId, Col01->Index);
- //DisplayInfo();
- }
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmVmsFormEdit::SaveVmsForm(String AVALID_YN)
- {
- bool result = false;
- int nFormId = EdFormId->Text.Trim().ToIntDef(0);
- String sVmsType = FVmsTypeCd;
- String sFormType = APP_GetCode(CbFormKind);
- String sName = EdFormName->Text.Trim();
- String sExpl = EdFormDesc->Text.Trim();
- String sFormColor = String(CbFormColor->ItemIndex);
- String sDispDir = APP_GetCode(CbFormDsplDrct);
- String sDispMode = APP_GetCode(CbFormDsplMthd);
- String sUpdtDt = Now().FormatString("yyyymmddhhnnss");
- String resultVal;
- String key = "abcdefg1234567890x";
- String apiUri = g_AppCfg.sRestApiUri + "/cs-api/vms/form/manage/merge/" + key + "/" + String(nFormId);
- TMcJsonItem *ObjList = new TMcJsonItem();
- try
- {
- ObjList->Add("vms_form_id")->AsInteger = nFormId;
- ObjList->Add("vms_form_nm")->AsString = sName;
- ObjList->Add("vms_form_expl")->AsString = sExpl;
- ObjList->Add("vms_type_cd")->AsString = sVmsType;
- ObjList->Add("vms_form_type_cd")->AsInteger = sFormType.ToIntDef(0);
- ObjList->Add("vms_form_colr_cd")->AsInteger = sFormColor.ToIntDef(0);
- ObjList->Add("vms_form_dspl_drct_cd")->AsInteger = sDispDir.ToIntDef(0);
- ObjList->Add("vms_form_dspl_mthd_cd")->AsInteger = sDispMode.ToIntDef(0);
- ObjList->Add("vms_form_imag")->AsString = BitmapToBase64String(ImgForm->Picture->Bitmap);
- //ObjList->Add("symb_lib_nmbr")->AsInteger = jvtNull;
- ObjList->Add("updt_dt")->AsString = sUpdtDt;
- ObjList->Add("valid_yn")->AsString = AVALID_YN;
- TMcJsonItem *objects = ObjList->Add("objects", jitArray);
- TVmsFormObject *pObj;
- TcxGridDataController *pGDC = TvObjList->DataController;
- int nObjType;
- int nObjCnt = pGDC->RecordCount;
- for (int ii = 0; ii < nObjCnt; ii++)
- {
- TMcJsonItem *object = new TMcJsonItem();
- String sObjSeq = VarToStr(pGDC->Values[ii][ColSeq->Index]);
- pObj = m_pEdtDesigner->FindObject(sObjSeq.ToInt());
- if (!pObj) continue;
- nObjType = pObj->ObjType.ToIntDef(0);
- object->Add("vms_form_object_id")->AsInteger = ii+1;
- object->Add("vms_form_id")->AsInteger = nFormId;
- object->Add("vms_form_dspl_row")->AsInteger = 0;
- object->Add("vms_form_dspl_clmn")->AsInteger = 0;
- object->Add("vms_form_object_type_cd")->AsInteger = nObjType;
- object->Add("vms_font_name_cd")->AsInteger = pObj->FontNameCode.ToIntDef(0);
- object->Add("vms_font_colr_cd")->AsInteger = pObj->FontColorCode.ToIntDef(0);
- object->Add("vms_font_bold")->AsInteger = pObj->FontBold ? 1 : 0;
- object->Add("vms_font_size")->AsInteger = pObj->FontSize;
- object->Add("vms_font_align")->AsInteger = pObj->TextAlign;
- object->Add("vms_dspl_txt")->AsString = pObj->Text;
- TImage *pImg = pObj->GetImage();
- if (!pImg) {
- object->Add("vms_dspl_figr")->AsString = BitmapToBase64String(ImgNull->Picture->Bitmap);
- }
- else {
- object->Add("vms_dspl_figr")->AsString = BitmapToBase64String(pImg->Picture->Bitmap);
- }
- object->Add("vms_dspl_xcrdn")->AsInteger = pObj->GetLeft();
- object->Add("vms_dspl_ycrdn")->AsInteger = pObj->GetTop();
- object->Add("vms_dspl_width")->AsInteger = pObj->GetWidth();
- object->Add("vms_dspl_height")->AsInteger = pObj->GetHeight();
- object->Add("vms_dspl_blinking")->AsInteger = pObj->Blink ? 1 : 0;
- object->Add("vms_dspl_bkcolor")->AsInteger = pObj->BkColorCode.ToIntDef(0);
- object->Add("vms_dspl_size")->AsInteger = pObj->ObjSize;
- String sFillIn = "N";
- if (sFormType == "15")
- {
- if (nObjType == 0 || nObjType == 1 || nObjType == 2)
- {
- sFillIn = pObj->Tag;
- }
- }
- object->Add("trfc_fill_cd")->AsString = sFillIn;
- int symbLibNmbr = pObj->ImageId.ToIntDef(0);
- if (symbLibNmbr > 0) {
- //object->Add("symb_lib_nmbr")->AsInteger = symbLibNmbr == 0 ? jvtNull : symbLibNmbr;
- object->Add("symb_lib_nmbr")->AsInteger = symbLibNmbr;
- }
- else {
- object->Add("symb_lib_nmbr")->AsInteger = 0; // NOT NULL
- }
- String sIfscId = "";
- if (nObjType == 91 || nObjType == 92)
- {
- sIfscId = pObj->Tag;
- }
- object->Add("vms_ifsc_id")->AsString = sIfscId;
- objects->Add(object);
- delete object;
- }
- result = TRestObjectManager::RequestPost(apiUri, ObjList->AsJSON, resultVal);
- if (!result) {
- return false;
- }
- }
- __finally
- {
- if (ObjList) delete ObjList;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmVmsFormEdit::CheckVmsFormUse(String AFormId)
- {
- String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/usage/" + AFormId;
- TMcJsonItem *ObjList = NULL;
- try {
- ObjList = TRestObjectManager::RequestGet(apiUri);
- if (ObjList == NULL) {
- return false;
- }
- if (ObjList->Count > 0) {
- String usages = TRestObjectManager::GetValue(ObjList, "count");
- if (usages.ToIntDef(-1) > 0) {
- Application->MessageBox(L"VMS 폼 사용확인\r\n삭제할 VMS 폼 정보가 VMS 스케쥴에 사용되고 있습니다.\r\n먼저 해당 정보를 삭제해주시기 바랍니다.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- }
- } __finally {
- if (ObjList) delete ObjList;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmVmsFormEdit::DelVmsForm(String AFormId)
- {
- bool result = false;
- String resultVal;
- String key = "abcdefg1234567890x";
- String apiUri = g_AppCfg.sRestApiUri + "/cs-api/vms/form/manage/delete/" + key + "/" + AFormId;
- try {
- result = TRestObjectManager::RequestPost(apiUri, "", resultVal);
- if (!result) {
- return false;
- }
- } __finally {
- }
- return result;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmVmsFormEdit::GetNextVmsFormId(int &AFormId)
- {
- AFormId = -1;
- String apiUri = g_AppCfg.sRestApiUri + "/api/vms/form/manage/new-id";
- TMcJsonItem *ObjList = NULL;
- try {
- ObjList = TRestObjectManager::RequestGet(apiUri);
- if (ObjList == NULL) {
- return false;
- }
- if (ObjList->Count > 0) {
- String newId = TRestObjectManager::GetValue(ObjList, "new_id");
- AFormId = newId.ToIntDef(-1);
- }
- } __finally {
- if (ObjList) delete ObjList;
- }
- if (AFormId == -1) return false;
- return true;
- }
- //---------------------------------------------------------------------------
|