| | |
| | | /// <param name="feedBackMsg">信息反馈</param> |
| | | /// <param name="feedBackProgress">进度反馈</param> |
| | | /// <returns></returns> |
| | | public static async Task<bool> Import(ImportXhsProjectViewModel vm, Action<string> feedBackMsg, Action<int, int> feedBackProgress) |
| | | public static async Task<bool> Import(ImportXhsProjectViewModel vm, Action<string, Color> feedBackMsg, Action<int, int> feedBackProgress) |
| | | { |
| | | var msg = string.Empty; |
| | | |
| | | #region 第一步 临时文件处理(进度5%) |
| | | |
| | | msg = "开始导入项目..."; |
| | | feedBackMsg?.Invoke(msg); |
| | | feedBackMsg?.Invoke(msg, Color.Black); |
| | | |
| | | //临时文件夹路径 |
| | | var tempFolder = Path.Combine(Yw.Service.ConfigHelper.DataPath, HStation.Settings.XhsParasHelper.Xhs.DataFolder, _tempFolder); |
| | |
| | | |
| | | #region 第二步 创建项目(进度 10%) |
| | | |
| | | feedBackMsg?.Invoke("正在创建项目..."); |
| | | feedBackMsg?.Invoke("正在创建项目...", Color.Black); |
| | | |
| | | var bllXhsProjectExtensions = new Lazy<BLL.XhsProjectExtensions>(() => new BLL.XhsProjectExtensions()); |
| | | |
| | |
| | | var projectId = await bllXhsProjectExtensions.Value.Insert(project); |
| | | if (projectId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("项目创建失败!!!"); |
| | | feedBackMsg?.Invoke("项目创建失败!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | feedBackMsg?.Invoke("项目创建成功。。。"); |
| | | feedBackMsg?.Invoke("项目创建成功。。。", Color.Green); |
| | | |
| | | vm.ProjectID = projectId; |
| | | |
| | |
| | | |
| | | #region 第三步 设置地图位置(进度 20%) |
| | | |
| | | feedBackMsg?.Invoke("正在设置地图位置..."); |
| | | feedBackMsg?.Invoke("正在设置地图位置...", Color.Black); |
| | | |
| | | if (vm.Location != null) |
| | | { |
| | |
| | | var mapInfoId = await new Yw.BLL.MapInfo().Insert(mapInfo); |
| | | if (mapInfoId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("设置地图位置失败!!!"); |
| | | feedBackMsg?.Invoke("设置地图位置失败!!!", Color.Red); |
| | | } |
| | | else |
| | | { |
| | | vm.MapInfoID = mapInfoId; |
| | | feedBackMsg?.Invoke("设置地图位置成功。。。"); |
| | | feedBackMsg?.Invoke("设置地图位置成功。。。", Color.Green); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | feedBackMsg?.Invoke("未设置地图位置信息!!!"); |
| | | feedBackMsg?.Invoke("未设置地图位置信息!!!", Color.Red); |
| | | } |
| | | |
| | | feedBackProgress?.Invoke(100, 20); |
| | |
| | | #region 第四步 压缩文件解析 (进度25%) |
| | | |
| | | msg = "正在解析模型文件..."; |
| | | feedBackMsg?.Invoke(msg); |
| | | feedBackMsg?.Invoke(msg, Color.Black); |
| | | var bol = Yw.FileFolderZipHelper.UnZip(vm.ZipFile, tempFolder, null); |
| | | if (!bol) |
| | | { |
| | | feedBackMsg?.Invoke("模型文件解析失败!!!"); |
| | | feedBackMsg?.Invoke("模型文件解析失败!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | |
| | | var allFileInfoList = tempFolderInfo.GetFiles(); |
| | | if (allFileInfoList == null || allFileInfoList.Count() < 1) |
| | | { |
| | | feedBackMsg?.Invoke("模型文件格式错误!!!"); |
| | | feedBackMsg?.Invoke("模型文件格式错误!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | feedBackMsg?.Invoke("模型文件解析成功。。。"); |
| | | feedBackMsg?.Invoke("模型文件解析成功。。。", Color.Green); |
| | | |
| | | feedBackProgress?.Invoke(100, 25); |
| | | |
| | |
| | | |
| | | #region 第五步 解析水力结构文件 (进度30%) |
| | | |
| | | feedBackMsg?.Invoke("正在解析水力结构文件..."); |
| | | feedBackMsg?.Invoke("正在解析水力结构文件...", Color.Black); |
| | | var jsonFileInfo = allFileInfoList.Where(x => x.Extension == ".json").FirstOrDefault(); |
| | | if (jsonFileInfo == null) |
| | | { |
| | | feedBackMsg?.Invoke("水力结构文件格式错误!!!"); |
| | | feedBackMsg?.Invoke("水力结构文件格式错误!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | var revitModel = HStation.Service.RevitParseHelper.FromJsonFile(jsonFileInfo.FullName, out msg); |
| | | if (revitModel == null) |
| | | { |
| | | feedBackMsg?.Invoke($"{msg}!!!"); |
| | | feedBackMsg?.Invoke($"{msg}!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | var hydroInfo = HStation.Hydro.TransferHelper.FromRevit(revitModel, out msg); |
| | | if (hydroInfo == null) |
| | | { |
| | | feedBackMsg?.Invoke($"水力结构文件解析失败,{msg}!!!"); |
| | | feedBackMsg?.Invoke($"水力结构文件解析失败,{msg}!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | |
| | | var hydroId = await bllHydroInfo.Save(hydroInfo); |
| | | if (hydroId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("水力结构信息保存失败!!!"); |
| | | feedBackMsg?.Invoke("水力结构信息保存失败!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | feedBackMsg?.Invoke("水力结构文件解析成功。。。"); |
| | | feedBackMsg?.Invoke("水力结构文件解析成功。。。", Color.Green); |
| | | |
| | | feedBackProgress?.Invoke(100, 30); |
| | | |
| | |
| | | var projectSite = await bllXhsProjectSite.GetDefaultByProjectID(projectId); |
| | | if (projectSite == null) |
| | | { |
| | | feedBackMsg?.Invoke("项目站信息错误..."); |
| | | feedBackMsg?.Invoke("项目站信息错误...", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | var projectSiteId = projectSite.ID; |
| | | vm.ProjectSiteID = projectSite.ID; |
| | | |
| | | feedBackMsg?.Invoke("正在关联水力结构模型..."); |
| | | feedBackMsg?.Invoke("正在关联水力结构模型...", Color.Black); |
| | | |
| | | var hydroRelation = new Yw.Dto.AddHydroModelRelationInput(); |
| | | hydroRelation.ObjectType = HStation.Xhs.DataType.XhsProjectSite; |
| | |
| | | var hydroRelationId = await bllHydroRelation.Insert(hydroRelation); |
| | | if (hydroRelationId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("关联水力结构模型失败!!!"); |
| | | feedBackMsg?.Invoke("关联水力结构模型失败!!!", Color.Red); |
| | | return false; |
| | | } |
| | | |
| | | vm.HydroRelationID = hydroRelationId; |
| | | |
| | | feedBackMsg?.Invoke("关联水力结构模型成功。。。"); |
| | | feedBackMsg?.Invoke("关联水力结构模型成功。。。", Color.Green); |
| | | |
| | | feedBackProgress?.Invoke(100, 40); |
| | | |
| | |
| | | |
| | | #region 第七步 上传Revit模型文件(进度 45%) |
| | | |
| | | feedBackMsg?.Invoke("正在解析Revit模型文件..."); |
| | | feedBackMsg?.Invoke("正在解析Revit模型文件...", Color.Black); |
| | | var rvtFileInfo = allFileInfoList.Where(x => x.Extension == ".rvt").FirstOrDefault(); |
| | | if (rvtFileInfo == null) |
| | | { |
| | | feedBackMsg?.Invoke("Revit模型文件解析失败!!!"); |
| | | feedBackMsg?.Invoke("项目导入结束。。。"); |
| | | feedBackMsg?.Invoke("Revit模型文件解析失败!!!", Color.Red); |
| | | feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue); |
| | | return true; |
| | | } |
| | | |
| | |
| | | var bimfaceId = 10000872887098; //测试用例 |
| | | if (bimfaceId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("Revit模型文件上传失败!!!"); |
| | | feedBackMsg?.Invoke("项目导入结束。。。"); |
| | | feedBackMsg?.Invoke("Revit模型文件上传失败!!!", Color.Red); |
| | | feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue); |
| | | return true; |
| | | } |
| | | |
| | | vm.BimfaceId = bimfaceId; |
| | | |
| | | feedBackMsg?.Invoke("解析Revit模型文件成功。。。"); |
| | | feedBackMsg?.Invoke("解析Revit模型文件成功。。。", Color.Green); |
| | | |
| | | feedBackProgress?.Invoke(100, 45); |
| | | |
| | |
| | | |
| | | #region 第八步 保存Bimface文件 (进度 50%) |
| | | |
| | | feedBackMsg?.Invoke("正在保存Bimface文件..."); |
| | | feedBackMsg?.Invoke("正在保存Bimface文件...", Color.Black); |
| | | |
| | | var bimfaceFile = new Yw.Dto.AddBimfaceFileInput(); |
| | | bimfaceFile.BimfaceId = bimfaceId.ToString(); |
| | |
| | | var bimfaceFileId = await bllBimfaceFile.Insert(bimfaceFile); |
| | | if (bimfaceFileId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("Bimface文件保存失败!!!"); |
| | | feedBackMsg?.Invoke("项目导入结束。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件保存失败!!!", Color.Red); |
| | | feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue); |
| | | return true; |
| | | } |
| | | vm.BimfaceFileID = bimfaceFileId; |
| | | |
| | | feedBackMsg?.Invoke("Bimface文件保存成功。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件保存成功。。。", Color.Green); |
| | | |
| | | feedBackProgress?.Invoke(100, 50); |
| | | |
| | |
| | | |
| | | #region 第九步 关联Bimface文件(进度 55%) |
| | | |
| | | feedBackMsg?.Invoke("正在关联Bimface文件..."); |
| | | feedBackMsg?.Invoke("正在关联Bimface文件...", Color.Black); |
| | | |
| | | var bimfaceRelation = new Yw.Dto.AddBimfaceFileRelationInput(); |
| | | bimfaceRelation.ObjectType = HStation.Xhs.DataType.XhsProjectSite; |
| | |
| | | var bimfaceRelationId = await bllBimfaceRelation.Insert(bimfaceRelation); |
| | | if (bimfaceRelationId < 1) |
| | | { |
| | | feedBackMsg?.Invoke("Bimface文件关联失败!!!"); |
| | | feedBackMsg?.Invoke("项目导入结束。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件关联失败!!!", Color.Red); |
| | | feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue); |
| | | return true; |
| | | } |
| | | vm.BimfaceFileRelationID = bimfaceRelationId; |
| | | feedBackMsg?.Invoke("Bimface文件关联成功。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件关联成功。。。", Color.Green); |
| | | feedBackProgress?.Invoke(100, 55); |
| | | |
| | | #endregion 第九步 关联Bimface文件(进度 55%) |
| | | |
| | | #region 第十步 发起bimface转换(进度 80%) |
| | | |
| | | feedBackMsg?.Invoke("正在进行Bimface模型轻量化..."); |
| | | feedBackMsg?.Invoke("正在进行Bimface模型轻量化...", Color.Black); |
| | | //var bimfaceTranslateStatus = await Yw.WinFrmUI.BimfaceHelper.TranslateRvtFile(bimfaceId);//发起转换 |
| | | var bimfaceTranslateStatus = Yw.BIMFace.eTranslateStatus.Processing;//测试代码 |
| | | feedBackProgress?.Invoke(100, 60); |
| | |
| | | { |
| | | await Yw.WinFrmUI.BimfaceHelper.WaitFileTranslateStatusUntilSuccess(bimfaceId, 3000); |
| | | vm.BimfaceConverted = true; |
| | | feedBackMsg?.Invoke("Bimface模型轻量化完成。。。"); |
| | | feedBackMsg?.Invoke("Bimface模型轻量化完成。。。", Color.Green); |
| | | } |
| | | else |
| | | { |
| | | feedBackMsg?.Invoke("跳过Bimface模型轻量化等待。。。"); |
| | | feedBackMsg?.Invoke("跳过Bimface模型轻量化等待。。。", Color.Black); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | vm.BimfaceConverted = true; |
| | | feedBackMsg?.Invoke("Bimface模型轻量化完成。。。"); |
| | | feedBackMsg?.Invoke("Bimface模型轻量化完成。。。", Color.Green); |
| | | } |
| | | |
| | | feedBackProgress?.Invoke(100, 80); |
| | |
| | | |
| | | #region 第十一步 更新Bimface文件状态(进度 100%) |
| | | |
| | | feedBackMsg?.Invoke("正在更新Bimface文件状态..."); |
| | | feedBackMsg?.Invoke("正在更新Bimface文件状态...", Color.Black); |
| | | bol = await bllBimfaceFile.UpdateFileStatus(bimfaceFileId, (int)Yw.Bimface.eFileStatus.ConvertSucceed); |
| | | if (bol) |
| | | { |
| | | feedBackMsg?.Invoke("Bimface文件状态更新成功。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件状态更新成功。。。", Color.Green); |
| | | } |
| | | else |
| | | { |
| | | feedBackMsg?.Invoke("Bimface文件状态更新失败!!!"); |
| | | feedBackMsg?.Invoke("项目导入结束。。。"); |
| | | feedBackMsg?.Invoke("Bimface文件状态更新失败!!!", Color.Red); |
| | | feedBackMsg?.Invoke("项目导入结束。。。", Color.Black); |
| | | return true; |
| | | } |
| | | |