天天看点

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

BIMFACE二次开发

BIMFACE二次开发系列目录     【已更新最新开发文章,点击查看详细】

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

  在《C#开发BIMFACE系列31 服务端API之模型对比2:获取模型对比状态》中介绍了根据对比ID,获取一笔记录的对比状态。由于模型对比是在BIMFACE云端进行的,通常需要5~10分钟,在等待对比的过程中还可以发起更多的模型对比,最后通过接口一次性批量获取模型对比状态 。

  该功能与BIMFACE控制台中“图模对比”功能相同。

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

请求地址:POST https://api.bimface.com/compares

说明:应用发起对比以后,可以根据筛选条件,通过该接口批量查询对比状态

参数:

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态
 其中 ModelCompareQueryRequest 类如下
C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态
C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

1 /// <summary>
 2 ///  批量获取模型对比状态的请求参数类
 3 /// </summary>
 4 public class ModelCompareQueryRequest
 5 {
 6     /// <summary>
 7     /// 【必填项】应用的 appKey
 8     /// </summary>
 9     [JsonProperty("appKey")]
10     public string AppKey { get; set; }
11 
12     /// <summary>
13     /// 【非必填项】对比后返回的ID,用于获取对比状态或者结果等信息
14     /// </summary>
15     [JsonProperty("compareId", NullValueHandling = NullValueHandling.Ignore)]
16     public long? CompareId { get; set; }
17 
18     /// <summary>
19     ///  【非必填项】模型对比的类型 rvt(或者igms…​)
20     /// </summary>
21     [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
22     public string Type { get; set; }
23 
24     /// <summary>
25     /// 【非必填项】文件名称
26     /// </summary>
27     [JsonProperty("fileName", NullValueHandling = NullValueHandling.Ignore)]
28     public string FileName { get; set; }
29 
30     /// <summary>
31     ///  【非必填项】模型对应的sourceId。例如:389c28de59ee62e66a7d87ec12692a76
32     /// </summary>
33     [JsonProperty("sourceId", NullValueHandling = NullValueHandling.Ignore)]
34     public string SourceId { get; set; }
35 
36     /// <summary>
37     /// 【非必填项】(分页)当前页码
38     /// </summary>
39     [JsonProperty("pageNo", NullValueHandling = NullValueHandling.Ignore)]
40     public int? PageNo { get; set; }
41 
42     /// <summary>
43     /// 【非必填项】(分页)每页记录数
44     /// </summary>
45     [JsonProperty("pageSize", NullValueHandling = NullValueHandling.Ignore)]
46     public int? PageSize { get; set; }
47 
48     /// <summary>
49     ///  【非必填项】模型状态码。0(所有) 1(处理中) 99(成功) -1(失败)
50     /// </summary>
51     [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
52     public short? Status { get; set; }
53 
54     /// <summary>
55     /// 【非必填项】筛选类型。例如:create_time desc
56     /// </summary>
57     [JsonProperty("sortType", NullValueHandling = NullValueHandling.Ignore)]
58     public string SortType { get; set; }
59 
60     /// <summary>
61     /// 【非必填项】对比开始时间,格式:yyyy-MM-dd hh:mm:ss
62     /// </summary>
63     [JsonProperty("startDate", NullValueHandling = NullValueHandling.Ignore)]
64     public string StartDate { get; set; }
65 
66     /// <summary>
67     /// 【非必填项】对比结束时间,格式:yyyy-MM-dd hh:mm:ss
68     /// </summary>
69     [JsonProperty("endDate", NullValueHandling = NullValueHandling.Ignore)]
70     public string EndDate { get; set; }
71 }      

View Code

请求 path(示例):https://api.bimface.com/compares

请求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"

请求 body(示例):

1 {
 2   "appKey" : "appKey",
 3   "compareId" : 0,
 4   "endDate" : "string",
 5   "fileName" : "fileName",
 6   "pageNo" : 0,
 7   "pageSize" : 0,
 8   "sortType" : "sortType",
 9   "sourceId" : "23be51b7e1eb4228bd896ac1a4640c62",
10   "startDate" : "string",
11   "status" : 0,
12   "type" : "type"
13 }      

HTTP响应示例(200):

1 {
 2   "code" : "success",
 3   "data" : {
 4     "list" : [ {
 5       "compareId" : 1248756572307264,
 6       "cost" : 0,
 7       "createTime" : "2017-12-25 16:17:27",
 8       "name" : "compare0001",
 9       "offlineDatabagStatus" : "offlineDatabagStatus",
10       "priority" : 2,
11       "reason" : "reason",
12       "sourceId" : "123223223212",
13       "status" : "succcess",
14       "thumbnail" : [ "https://m.bimface.com/9b711803a43b92d871cde346b63e5019/thumbnail/96.png" ],
15       "type" : "type",
16       "workerType" : "workerType"
17     } ],
18     "page" : {
19       "htmlDisplay" : "string",
20       "nextPage" : 0,
21       "pageNo" : 0,
22       "pageSize" : 0,
23       "prePage" : 0,
24       "startIndex" : 0,
25       "totalCount" : 0,
26       "totalPages" : 0
27     }
28   },
29   "message" : ""
30 }      

返回体参数说明请参考 ModelCompareBean 类

1 public class ModelCompareBean
 2 {
 3     /// <summary>
 4     /// 对比后返回的ID,用于获取对比状态或者结果等信息
 5     /// </summary>
 6     [JsonProperty("compareId", NullValueHandling = NullValueHandling.Ignore)]
 7     public long? CompareId { get; set; }
 8 
 9     /// <summary>
10     ///  对比完成的消耗时间,单位是秒
11     /// </summary>
12     [JsonProperty("cost", NullValueHandling = NullValueHandling.Ignore)]
13     public int? Cost { get; set; }
14 
15     /// <summary>
16     /// 对比开始时间,格式:yyyy-MM-dd hh:mm:ss
17     /// </summary>
18     [JsonProperty("createTime", NullValueHandling = NullValueHandling.Ignore)]
19     public string CreateTime { get; set; }
20 
21     /// <summary>
22     /// 用户指定对比后的模型的名字
23     /// </summary>
24     [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
25     public string Name { get; set; }
26 
27     /// <summary>
28     ///  离线数据包生成状态。prepare(未生成); processing(生成中); success(生成成功); failed(生成失败)
29     /// </summary>
30     [JsonProperty("offlineDatabagStatus", NullValueHandling = NullValueHandling.Ignore)]
31     public string OfflineDatabagStatus { get; set; }
32 
33     /// <summary>
34     /// 对比优先级。取值 1、2、3。数字越大,优先级越低。默认为2
35     /// </summary>
36     [JsonProperty("priority", NullValueHandling = NullValueHandling.Ignore)]
37     public int? Priority { get; set; }
38 
39     /// <summary>
40     ///  若对比失败,返回失败原因
41     /// </summary>
42     [JsonProperty("reason", NullValueHandling = NullValueHandling.Ignore)]
43     public string Reason { get; set; }
44 
45     /// <summary>
46     ///  第三方应用自己的ID
47     /// </summary>
48     [JsonProperty("sourceId", NullValueHandling = NullValueHandling.Ignore)]
49     public string SourceId { get; set; }
50 
51     /// <summary>
52     ///  对比状态:prepare(待对比)、processing(对比中)、success(对比成功)、failed(对比失败)
53     /// </summary>
54     [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
55     public string Status { get; set; }
56 
57     /// <summary>
58     ///  对比几个缩略图
59     /// </summary>
60     [JsonProperty("thumbnail", NullValueHandling = NullValueHandling.Ignore)]
61     public string[] Thumbnails { get; set; }
62 
63     /// <summary>
64     /// 模型对比的类型 rvt(或者igms…​)
65     /// </summary>
66     [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
67     public string Type { get; set; }
68 
69     /// <summary>
70     /// 处理对比任务的worker类型。model-compare(或者drawing-compare…​)
71     /// </summary>
72     [JsonProperty("workerType", NullValueHandling = NullValueHandling.Ignore)]
73     public string WorkerType { get; set; }
74 
75     /// <summary>返回表示当前对象的字符串。</summary>
76     /// <returns>表示当前对象的字符串。</returns>
77     public override string ToString()
78     {
79         return this.SerializeToJson();
80     }      

C#实现方法:

1 /// <summary>
 2 ///  批量获取模型对比状态
 3 /// </summary>
 4 /// <param name="accessToken">【必填】令牌</param>
 5 /// <param name="request">【必填】批量获取模型对比状态的请求参数</param>
 6 /// <returns></returns>
 7 public virtual ModelCompareQueryResponse GetCompareStatusList(string accessToken, ModelCompareQueryRequest request)
 8 {
 9     //POST https://api.bimface.com/compares
10     string url = BimfaceConstants.API_HOST + "/compares";
11     string data = request.SerializeToJson();
12     BimFaceHttpHeaders headers = new BimFaceHttpHeaders();
13     headers.AddOAuth2Header(accessToken);
14 
15     try
16     {
17         ModelCompareQueryResponse response;
18 
19         HttpManager httpManager = new HttpManager(headers);
20         HttpResult httpResult = httpManager.Post(url, data);
21         if (httpResult.Status == HttpResult.STATUS_SUCCESS)
22         {
23             response = httpResult.Text.DeserializeJsonToObject<ModelCompareQueryResponse>();
24         }
25         else
26         {
27             response = new ModelCompareQueryResponse
28             {
29                 Message = httpResult.RefText
30             };
31         }
32 
33         return response;
34     }
35     catch (Exception ex)
36     {
37         throw new Exception("[批量获取模型对比状态]发生异常!", ex);
38     }
39 }      
C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

成在管理,败在经验;嬴在选择,输在不学!  贵在坚持!

欢迎关注作者头条号 张传宁IT讲堂,获取更多IT文章、视频等优质内容。

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

个人作品

1、BIMFace.Community.SDK.NET

     开源地址:https://gitee.com/NAlps/BIMFace.SDK

     系列博客:https://www.cnblogs.com/SavionZhang/p/11424431.html

     系列视频:https://www.cnblogs.com/SavionZhang/p/14258393.html

2、ZCN.NET.Common

     开源地址:https://gitee.com/NAlps/zcn.net.common

C#开发BIMFACE系列32 服务端API之模型对比3:批量获取模型对比状态

技术栈

 1、Visual Studio、.C#/.NET、.NET Core、MVC、Web API、RESTful API、gRPC、SignalR、Python

 2、jQuery、Vue.js、Bootstrap

 3、数据库:SQLServer、MySQL、PostgreSQL、Oracle、SQLite、Redis、MongoDB、ElasticSearch、TiDB、达梦DM、人大金仓、 神通、南大通用 GBase、华为 GaussDB 、腾讯 TDSQL 、阿里 PolarDB、蚂蚁金服 OceanBase、东软 OpenBASE、浪潮云溪数据库 ZNBase

 4、ORM:Dapper、Entity Framework、FreeSql、SqlSugar、分库分表、读写分离

 5、架构:领域驱动设计 DDD、ABP

 6、环境:跨平台、Windows、Linux(CentOS、麒麟、统信UOS、深度Linux)、maxOS、IIS、Nginx、Apach

 7、移动App:Android、IOS、HarmonyOS、微信、小程序、快应用、Xamarin、uni-app、MUI、Flutter、Framework7、Cordova、Ionic、React Native、Taro、NutUI、Smobiler

 云原生、微服务、Docker、CI/CD、DevOps、K8S;

 Dapr、RabbitMQ、Kafka、分布式、大数据、高并发、负载均衡、中间件、RPC、ELK;

 .NET + Docker + jenkins + Github + Harbor + K8S;

出处:www.cnblogs.com/SavionZhang

作者:张传宁   微软MCP、系统架构设计师、系统集成项目管理工程师、科技部创新工程师。

          专注于微软.NET技术(.NET Core、Web、MVC、WinForm、WPF)、通用权限管理系统、工作流引擎、自动化项目(代码)生成器、SOA 、DDD、 云原生(Docker、微服务、DevOps、CI/CD);PDF、CAD、BIM 审图等研究与应用。

          多次参与电子政务、图书教育、生产制造等企业级大型项目研发与管理工作。

          熟悉中小企业软件开发过程:需求分析、架构设计、编码测试、实施部署、项目管理。通过技术与管理帮助中小企业快速化实现互联网技术全流程解决方案。

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

如有问题,可以通过邮件[email protected]联系。共同交流、互相学习。

如果您觉得文章对您有帮助,请点击文章右下角【推荐】。您的鼓励是作者持续创作的最大动力!

继续阅读