C # development BIMFACE 9 Series server-side API's acquisition applications supported file types

One of the most BIMFACE core competence is the project file format conversion. No need to install plug-ins, support for dozens of projects in the cloud file format conversion, intact original file information. Developers will bid farewell to the original file parsing troubles, data extraction all done automatically. BIMFACE currently able to resolve the 38 kinds of common engineering drawings and models, including: rvt, rfa, rte, skp , nwd, nwc, ifc, dwg, dxf, 3dm, stl, dgn, stp, 3ds, obj, dae, ply, fbx , dwf, gmp, gtj, gbq , gcl, ggj, gqi, gdq, gjg, igms, gpb, gpv, gsc, gbg, gsh, gtb, gzb.

The following details how to obtain the application of supported file types.

Request Address: GET https://file.bimface.com/support

Description: obtaining application support convert current file types, such as uploading a file format is not listed, BIMFACE does not support the conversion of its launch.

parameter:

Request path (Example): https://file.bimface.com/support

Request header (Example): "the Authorization: Bearer dc671840-BACC-4dc5-a134-97c1918d664b"

Example HTTP response (200):

{
  "code" : "success",
  "data" : {
    "length" : 1073741824,
    "types" : [ "rvt", "rfa", "dwg", "dxf", "skp", "ifc", "dgn", "obj", "stl", "3ds", "dae", "ply", "igms", "zip", "gtj", "bfcatzip" ]
  },
  "message" : ""
}

C#实现方法:

 1 /// <summary>
 2 ///  获取应用支持的文件类型
 3 /// </summary>
 4 /// <param name="accessToken">令牌</param>
 5 public virtual FileSupportResponse GetFileSupport(string accessToken)
 6 {
 7     //GET https://file.bimface.com/support
 8     string url = BimfaceConstants.FILE_HOST + "/support";
 9     BimFaceHttpHeaders headers = new BimFaceHttpHeaders();
10     headers.AddOAuth2Header(accessToken);
11 
12     try
13     {
14         FileSupportResponse response;
15 
16         HttpManager httpManager = new HttpManager(headers);
17         HttpResult httpResult = httpManager.Get(url);
18         if (httpResult.Status == HttpResult.STATUS_SUCCESS)
19         {
20             response = httpResult.Text.DeserializeJsonToObject<FileSupportResponse>();
21         }
22         else
23         {
24             response = new FileSupportResponse
25             {
26                 Message = httpResult.RefText
27             };
28         }
29 
30         return response;
31     }
32     catch (Exception ex)
33     {
34         throw new Exception("[获取应用支持的文件类型]发生异常!", ex);
35     }
36 }
其中引用的 httpManager.Get() 方法,请参考《C#开发BIMFACE系列6 服务端API之获取文件信息》,方法完全一样。
测试

可以看到获取应用支撑的文件类型成功,返回了以下信息:数据长度、支持的类型。

但是此处只返回了以下17种: rvt、rfa、dwg、dxf、skp、ifc、dgn、obj、stl、3ds、dae、ply、imgs、zip、fbx、dwf、nwd 格式。与官网介绍的38种相差很多,原因是我注册的账号只是一个开发者测试账号。所以默认只提供了17种。如果需要其他的格式,需要联系管理员增加其他的格式。

测试程序如下:

// 获取应用支持的文件类型
protected void btnGetFileSupport_Click(object sender, EventArgs e)
{
    txtFileInfo.Text = string.Empty;

    string token = txtAccessToken.Text;

    FileApi api = new FileApi();
    FileSupportResponse response = api.GetFileSupport(token);

    txtFileInfo.Text = response.Code
                     + Environment.NewLine
                     + response.Message
                     + Environment.NewLine
                     + response.Data.ToString();
}

 

Guess you like

Origin www.cnblogs.com/SavionZhang/p/11433982.html