Örnek: Custom Form Akışı¶
Bu örnekte panel'den gelen sipariş verisini bir Custom Form üzerinde gösterecek, alanlarına bağlayacak ve kontrol özelliklerini ayarlayacağız.
Hedef¶
OrderStartEvent tetiklendiğinde:
- Panel ekranında
OrderEntryFormadlı bir form açılsın. - Gelen sipariş bilgisi form alanlarına otomatik bağlansın.
- Buton görünürlüğü duruma göre ayarlansın.
- Akış sonunda panele cevap dönsün.
Önkoşullar¶
- Temel Akış örneğinin çalışıyor olması
- Form için XML tasarım hazır (aşağıda örnek var)
customFormDesigner.exe(opsiyonel, Designer kullanılacaksa)
Akış Şeması¶
flowchart LR
subgraph Kayit["Kayıt (bağımsız)"]
A[trex Subscriber]
end
subgraph Akis["Olay Akışı"]
B[Business Events<br/>OrderStartEvent] --> C[Custom Form<br/>OrderEntryForm]
C --> D[Form Bind Controls<br/>txt* → orderNo,...]
D --> E[Control Properties<br/>btnSave.Enabled=true]
E --> F[Responser]
end
style A fill:#58d68d,color:#000
style B fill:#ccffcc,color:#000
style C fill:#ccffcc,color:#000
style D fill:#ccffcc,color:#000
style E fill:#ccffcc,color:#000
style F fill:#ccffcc,color:#000
Form XML Tasarımı¶
Custom Form node'unun customformxml alanına yapıştıracağımız XML, trexForm.Designer tarafından üretilen WinForms formatındadır:
<Object name="CustomForm" type="trexForm.Designer.CustomForm, trexForm.Designer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" version="1">
<AutoValidate>EnablePreventFocusChange</AutoValidate>
<BackColor>Control</BackColor>
<ClientSize>600, 400</ClientSize>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<Name>CustomForm</Name>
<Object type="System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="lblOrderNo">
<Text>Sipariş No:</Text>
<Location>20, 20</Location>
<Size>100, 20</Size>
<TabIndex>0</TabIndex>
</Object>
<Object type="System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="txtOrderNo">
<Location>140, 20</Location>
<Size>200, 20</Size>
<TabIndex>1</TabIndex>
</Object>
<Object type="System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="lblCustomer">
<Text>Müşteri:</Text>
<Location>20, 60</Location>
<Size>100, 20</Size>
<TabIndex>2</TabIndex>
</Object>
<Object type="System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="txtCustomer">
<Location>140, 60</Location>
<Size>200, 20</Size>
<TabIndex>3</TabIndex>
</Object>
<Object type="System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="lblQty">
<Text>Miktar:</Text>
<Location>20, 100</Location>
<Size>100, 20</Size>
<TabIndex>4</TabIndex>
</Object>
<Object type="System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="txtQty">
<Minimum>1</Minimum>
<Maximum>9999</Maximum>
<Location>140, 100</Location>
<Size>100, 20</Size>
<TabIndex>5</TabIndex>
</Object>
<Object type="System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="lblWarning">
<Text></Text>
<ForeColor>Red</ForeColor>
<Location>20, 140</Location>
<Size>320, 20</Size>
<TabIndex>6</TabIndex>
</Object>
<Object type="System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="btnSave">
<Text>Kaydet</Text>
<Location>20, 200</Location>
<Size>120, 40</Size>
<TabIndex>7</TabIndex>
</Object>
<Object type="System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="btnCancel">
<Text>İptal</Text>
<Location>160, 200</Location>
<Size>120, 40</Size>
<TabIndex>8</TabIndex>
</Object>
</Object>
XML'i elle yazmayın
Yukarıdaki XML trexForm.Designer aracı ile görsel olarak tasarlanıp dışa aktarılabilir. Kontrol adları (txtOrderNo, btnSave vb.) Form Bind Controls ve Control Properties nodlarında kullanılacağından büyük/küçük harfe dikkat edin.
Adım Adım Yapılandırma¶
1. trex Subscriber (Bağımsız)¶
Temel Akış örneğindeki gibi varsayılan ayarlarla ekleyin.
2. Business Events¶
| Alan | Değer |
|---|---|
| Name | OrderStart |
| Method | get |
| Event | /OrderStartEvent |
| Is Handled | false |
3. Custom Form¶
| Alan | Değer |
|---|---|
| Name | OrderForm |
| Form Name | OrderEntryForm |
| Custom Form XML | (yukarıdaki XML) |
| Is Styled | true |
| Form In Main Form | false (modal dialog) |
| Design Form Name | (boş) |
4. Form Bind Controls¶
| Alan | Değer |
|---|---|
| Name | BindOrder |
| Form Name | OrderEntryForm |
| Form In Main Form | false |
| Data Type | msg |
| Data | payload |
| Props | (aşağıdaki tablo) |
props listesi:
p (Property) |
v (Value Field) |
|---|---|
txtOrderNo |
orderNo |
txtCustomer |
customer |
txtQty |
qty |
5. Control Properties¶
| Alan | Değer |
|---|---|
| Name | SetProperties |
| Form Name | OrderEntryForm |
| Form In Main Form | false |
| Props | (aşağıdaki tablo) |
props listesi:
p (Control) |
v (Property) |
d (Value) |
dt (Type) |
|---|---|---|---|
btnSave |
Enabled |
true |
bool |
lblWarning |
Visible |
false |
bool |
6. Responser¶
Tüm varsayılan değerlerle ekleyin.
Flow JSON¶
[
{
"id": "f2",
"type": "tab",
"label": "CustomFormOrnegi"
},
{
"id": "sub1",
"type": "trex Subscriber",
"z": "f2",
"name": "",
"method": "get",
"event": "/GetSubscribed",
"x": 200,
"y": 80,
"wires": [[]]
},
{
"id": "ev1",
"type": "Business Events",
"z": "f2",
"name": "OrderStart",
"event": "/OrderStartEvent",
"ishandled": false,
"x": 180,
"y": 180,
"wires": [["form1"]]
},
{
"id": "form1",
"type": "Custom Form",
"z": "f2",
"name": "OrderForm",
"formname": "OrderEntryForm",
"customformxml": "<form name='OrderEntryForm'>...</form>",
"isstyled": true,
"formainform": false,
"designformname": "",
"x": 360,
"y": 180,
"wires": [["bind1"]]
},
{
"id": "bind1",
"type": "Form Bind Controls",
"z": "f2",
"name": "BindOrder",
"formname": "OrderEntryForm",
"formainform": false,
"props": [
{ "p": "txtOrderNo", "v": "orderNo" },
{ "p": "txtCustomer", "v": "customer" },
{ "p": "txtQty", "v": "qty" }
],
"data": "payload",
"dataType": "msg",
"x": 560,
"y": 180,
"wires": [["props1"]]
},
{
"id": "props1",
"type": "Control Properties",
"z": "f2",
"name": "SetProperties",
"formname": "OrderEntryForm",
"formainform": false,
"props": [
{ "p": "btnSave", "v": "Enabled", "d": "true", "dt": "bool" },
{ "p": "lblWarning", "v": "Visible", "d": "false", "dt": "bool" }
],
"x": 760,
"y": 180,
"wires": [["resp1"]]
},
{
"id": "resp1",
"type": "Responser",
"z": "f2",
"name": "",
"statusCode": "",
"headers": {},
"x": 950,
"y": 180,
"wires": []
}
]
Beklenen Davranış¶
Panel'de OrderStartEvent tetiklendiğinde:
OrderEntryFormadlı modal pencere panel üzerinde açılır.- Form içindeki textbox'lar gelen sipariş verisiyle doldurulur:
txtOrderNo:ORD-2026-0042txtCustomer:ACME Ltd.txtQty:50
btnSavebutonu aktiftir,lblWarningetiketi gizlidir.- Operatör formu görür ve onaylayabilir.
msg.payload İncelemesi¶
Responser'a ulaştığında msg.payload array'i şuna benzer:
[
{
"operationtype": "CustomDialog",
"receiveddata": { "orderNo": "ORD-001", "customer": "ACME", "qty": 50 },
"name": "OrderEntryForm",
"continueevent": "Continue",
"customformxml": "<form ...>...</form>",
"isstyled": true
},
{
"operationtype": "BindControl",
"receiveddata": { ... },
"name": "OrderEntryForm",
"bindcontrols": [
{ "Name": "txtOrderNo", "FieldName": "orderNo" },
{ "Name": "txtCustomer", "FieldName": "customer" },
{ "Name": "txtQty", "FieldName": "qty" }
],
"value": { "orderNo": "ORD-001", "customer": "ACME", "qty": 50 }
},
{
"operationtype": "ControlProperties",
"receiveddata": { ... },
"name": "OrderEntryForm",
"value": [
{ "ControlName": "btnSave", "PropertyName": "Enabled", "Value": true },
{ "ControlName": "lblWarning", "PropertyName": "Visible", "Value": false }
]
}
]
Responser bu array'i tek HTTP cevabında panele gönderir, panel sırayla her operasyonu uygular.
Yaygın Sorunlar¶
Form açılıyor ama alanlar boş
Form Bind Controls'takidatavedataTypedoğru mu?propslistesindekipdeğerleri XML'deki kontrol isimleriyle birebir mi eşleşiyor? (büyük/küçük harf!)
Form hiç açılmıyor
customformxmlgeçerli XML mı? (Açıkta kalmış tag, eksik attribute)formnamedoğru?
btnSave hala disabled
Control Properties'te dt "bool", d ise düz "true" string olmalı.
Sonraki Adım¶
Buton Konfigürasyonu örneğinde butonları yapılandırıp tıklamaları yakalayacağız.