| | |
| | | /// 上传文件 |
| | | /// </summary> |
| | | /// <param name="fullFilePath">文件全路径</param> |
| | | /// <param name="fileName">文件名称</param> |
| | | /// <returns>BimfaceId</returns> |
| | | public static async Task<long> UploadFile(string fullFilePath) |
| | | public static async Task<long> UploadFile(string fullFilePath, string fileName = null) |
| | | { |
| | | if (!File.Exists(fullFilePath)) |
| | | { |
| | | return default; |
| | | } |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | var bimfaceId = await bimfaceClient.UploadFileExByPolicy(fullFilePath); |
| | | var bimfaceId = await bimfaceClient.UploadFileExByPolicy(fullFilePath, fileName); |
| | | return bimfaceId; |
| | | } |
| | | |
| | |
| | | { |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | var fileStatus = await bimfaceClient.TranslateRvtFileReturnStatus(bimfaceId.ToString(), translateStyle); |
| | | return fileStatus; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转换rvt文件 |
| | | /// </summary> |
| | | /// <param name="bimfaceId">bimfaceId</param> |
| | | /// <param name="translateStyle">转换样式</param> |
| | | /// <returns>转换状态</returns> |
| | | public static async Task<eTranslateStatus> TranslateRvtFile(string bimfaceId, eRvtTranslateStyle translateStyle = eRvtTranslateStyle.Real) |
| | | { |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | var fileStatus = await bimfaceClient.TranslateRvtFileReturnStatus(bimfaceId, translateStyle); |
| | | return fileStatus; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 等待文件转换状态直到成功 |
| | | /// </summary> |
| | | /// <param name="bimfaceId">bimfaceId</param> |
| | | /// <param name="polling">轮询毫秒</param> |
| | | /// <returns></returns> |
| | | public static async Task WaitFileTranslateStatusUntilSuccess(string bimfaceId, int polling) |
| | | { |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | var fileStatus = await bimfaceClient.GetFileTranslateStatusReturnStatus(bimfaceId); |
| | | if (fileStatus == eTranslateStatus.Processing) |
| | | { |
| | | await Task.Run(async () => |
| | | { |
| | | while (fileStatus == eTranslateStatus.Processing) |
| | | { |
| | | Thread.Sleep(polling); |
| | | fileStatus = await bimfaceClient.GetFileTranslateStatusReturnStatus(bimfaceId); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除 |
| | | /// </summary> |
| | | /// <param name="bimfaceId">bimfaceId</param> |
| | | /// <param name="modelIdType">模型类型</param> |
| | | /// <returns></returns> |
| | | public static async Task<bool> Delete(long bimfaceId, Yw.BIMFace.eModelIdType modelIdType = eModelIdType.fileId) |
| | | { |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | return await bimfaceClient.Delete(bimfaceId.ToString(), modelIdType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除 |
| | | /// </summary> |
| | | /// <param name="bimfaceId">bimfaceId</param> |
| | | /// <param name="modelIdType">模型类型</param> |
| | | /// <returns></returns> |
| | | public static async Task<bool> Delete(string bimfaceId, Yw.BIMFace.eModelIdType modelIdType = eModelIdType.fileId) |
| | | { |
| | | var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); |
| | | return await bimfaceClient.Delete(bimfaceId, modelIdType); |
| | | } |
| | | |
| | | } |
| | | } |