2017-02-03 56 views
0

我目前正在尝试使用C#Web API从Kentico中提取数据,并且我可以成功提取数据,但我也计划将其存储到数据库中。GET API请求 - 表单数据类型

使用调用,比如:/rest/bizformitem.bizform.contactus

我收到回所有的表单中的数据,但由于我这些值存储到数据库中,我想知道这种形式的名称/值的字段的数据类型。

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

我想通过API或文档为表单中的这些值找到一个参考,所以任何援助将不胜感激。

回答

1

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

加载XML成的XmlDocument,则//字段[@柱= “YourColumnName”]的selectNodes,下面是XML

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

现在请注意的样本,所述columntype是那种Kentico特定的命名,所以你必须做一个开关将其转换为.Net类或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; 
     } 
+0

是否可以通过REST API访问CMS_Class数据库表? – confusedandamused

+0

是的,你可以通过'/ rest/cms.class/all'获取数据 – rocky

+0

@rocky当试图使用/rest/cms.form/all或者/ rest/cms.class/all时, 403错误? – confusedandamused