Created
September 6, 2021 09:50
-
-
Save bjoerntx/b7c8cceea32df29b6e2b92128a2d76c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<SmartFormField> GetFormFields(byte[] data) { | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
tx.Load(data, BinaryStreamType.InternalUnicodeFormat); | |
List<SmartFormField> smartFormFields = new List<SmartFormField>(); | |
foreach (FormField field in tx.FormFields) { | |
switch (field.GetType().Name) { | |
case "TextFormField": | |
smartFormFields.Add(new SmartTextFormField() { | |
Name = field.Name, | |
Text = field.Text | |
}); | |
break; | |
case "CheckFormField": | |
smartFormFields.Add(new SmartCheckboxField() { | |
Name = field.Name, | |
Text = field.Text, | |
Checked = ((CheckFormField)field).Checked | |
}); | |
break; | |
case "SelectionFormField": | |
smartFormFields.Add(new SmartDropdownField() { | |
Name = field.Name, | |
Text = field.Text, | |
Items = ((SelectionFormField)field).Items | |
}); | |
break; | |
case "DateFormField": | |
SmartDateField smartDateField = new SmartDateField() { | |
Name = field.Name, | |
Text = field.Text, | |
Date = "" | |
}; | |
if (((DateFormField)field).Date != null) | |
smartDateField.Date = ((DateFormField)field).Date.Value.ToString("yyyy-MM-dd"); | |
smartFormFields.Add(smartDateField); | |
break; | |
} | |
} | |
return smartFormFields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment