From d9b8c4b8639e5239cea8fbb88fa2ae6fa1ac706b Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期一, 23 九月 2024 09:48:29 +0800 Subject: [PATCH] 提交修改 --- WinFrmUI/Yw.WinFrmUI.Bimface.Core/00-core/BimfaceHelper.cs | 101 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 99 insertions(+), 2 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Bimface.Core/00-core/BimfaceHelper.cs b/WinFrmUI/Yw.WinFrmUI.Bimface.Core/00-core/BimfaceHelper.cs index 24f3492..7f541d3 100644 --- a/WinFrmUI/Yw.WinFrmUI.Bimface.Core/00-core/BimfaceHelper.cs +++ b/WinFrmUI/Yw.WinFrmUI.Bimface.Core/00-core/BimfaceHelper.cs @@ -5,6 +5,8 @@ /// </summary> public class BimfaceHelper { + #region 鏂囦欢Token + /// <summary> /// 鑾峰彇ViewToken /// </summary> @@ -17,21 +19,30 @@ return await bimfaceClient.GetViewToken(bimfaceId, modelIdType); } + #endregion + + #region 涓婁紶鏂囦欢 + /// <summary> /// 涓婁紶鏂囦欢 /// </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; } + + #endregion + + #region 鏂囦欢杞崲 /// <summary> /// 杞崲rvt鏂囦欢 @@ -43,6 +54,19 @@ { 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; } @@ -81,6 +105,79 @@ } } + /// <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); + } + }); + } + } + + #endregion + + #region 鏂囦欢鍒犻櫎 + + /// <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); + } + + #endregion + + #region 鏂囦欢鑾峰彇 + + /// <summary> + /// 鑾峰彇鏂囦欢鏋勪欢id鍒楄〃 + /// </summary> + public static async Task<List<string>> GetFileComponentIds(string bimfaceId) + { + var bimfaceClient = Yw.BIMFaceClient.Instance(ConfigHelper.AppKey, ConfigHelper.AppSecret); + return await bimfaceClient.GetFileComponentIds(bimfaceId); + } + + /// <summary> + /// 鑾峰彇鏂囦欢鏋勪欢id鍒楄〃 + /// </summary> + public static async Task<List<string>> GetFileComponentIds(long bimfaceId) + { + return await GetFileComponentIds(bimfaceId.ToString()); + } + + #endregion } -- Gitblit v1.9.3