GET API 请求 - 表单数据类型

GET API Request - Form Data Types

我目前正在尝试使用 C# Web 从 Kentico 提取数据 API,我可以成功提取数据,但我还计划将其存储到数据库中。

使用这样的调用:/rest/bizformitem.bizform.contactus

我收到了表单中的所有数据,但由于我将这些值存储到数据库中,所以我想知道该表单的字段数据类型 name/value。

大多数 API 参考文献都有如下列表:ID:USER_ID | Type:int | Desc:User ID Form Field.

我正在尝试通过 API 或文档为表单中的这些值查找参考,因此我们将不胜感激。

您需要查看 CMS_Class 数据库 table。找到您的 class,然后是 ClassFormDefinition 字段,它有 XML 显示所有类型的字段。

将 XML 加载到 XmlDocument 中,然后为 //field[@column="YourColumnName"] 选择节点,下面是 XML

的示例
<field column="CultureName" visible="true" columntype="text" fieldtype="CustomUserControl" system="true" columnsize="200" publicfield="false" guid="7b7c2f84-da09-4874-aade-a4d3b77b975d">

现在请注意,列类型是 Kentico 特定的命名方式,因此您必须进行切换以将其转换为 .Net classes 或 SQL 数据库类型。

switch (fieldType)
        {
            case "longtext":
            case "text":
            default:
                dt.Columns.Add(fieldName, typeof(string));
                break;
            case "binary":
                dt.Columns.Add(fieldName, typeof(byte[]));
                break;
            case "boolean":
                dt.Columns.Add(fieldName, typeof(Boolean));
                break;
            case "date":
                dt.Columns.Add(fieldName, typeof(DateTime));
                break;
            case "datetime":
                dt.Columns.Add(fieldName, typeof(DateTime));
                break;
            case "decimal":
                dt.Columns.Add(fieldName, typeof(Decimal));
                break;
            case "double":
                dt.Columns.Add(fieldName, typeof(Double));
                break;
            case "integer":
                dt.Columns.Add(fieldName, typeof(Int32));
                break;
            case "longinteger":
                dt.Columns.Add(fieldName, typeof(Int64));
                break;
            case "timespan":
                dt.Columns.Add(fieldName, typeof(TimeSpan));
                break;
            case "guid":
                dt.Columns.Add(fieldName, typeof(Guid));
                break;
        }