Shuxia Ning
2024-10-24 0711485ecb4fe66fbe820478d92eb9f04b77c042
WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs
@@ -1,5 +1,6 @@
using Castle.Core.Internal;
using DevExpress.XtraEditors;
using HStation.Model;
using HStation.Vmo;
using static DevExpress.XtraEditors.XtraInputBox;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
@@ -41,7 +42,7 @@
            feedBackProgress?.Invoke(100, 5);
            #endregion
            #endregion 第一步 临时文件处理(进度5%)
            #region 第二步 创建项目(进度 10%)
@@ -77,7 +78,7 @@
            feedBackProgress?.Invoke(100, 10);
            #endregion
            #endregion 第二步 创建项目(进度 10%)
            #region 第三步 设置地图位置(进度 20%)
@@ -112,7 +113,7 @@
            feedBackProgress?.Invoke(100, 20);
            #endregion
            #endregion 第三步 设置地图位置(进度 20%)
            #region 第四步 压缩文件解析 (进度25%)
@@ -139,12 +140,11 @@
                return true;
            }
            feedBackMsg?.Invoke("模型文件解析成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 25);
            #endregion
            #endregion 第四步 压缩文件解析 (进度25%)
            #region 第五步 解析水力结构文件 (进度30%)
@@ -157,15 +157,64 @@
                feedBackProgress?.Invoke(100, 100);
                return true;
            }
            var structRevitModel = HStation.Service.RevitParseHelper.FromJsonFile(structFileInfo.FullName, out msg);
            if (structRevitModel == null)
            var structOthersFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.StructOthersFileName);
            var structRevitModel = HStation.Service.RevitParseHelper.FromJsonFile
                (structFileInfo.FullName, structOthersFileInfo?.FullName, out bool structFileResult, out List<string> structFileMsgList);
            //解析结果判断
            if (!structFileResult)
            {
                feedBackMsg?.Invoke($"{msg}!!!", Color.Red);
                structFileMsgList?.ForEach(x => feedBackMsg?.Invoke(x, Color.Red));
            }
            //Revit属性错误处理
            var hasRevitPropError = false;
            if (structRevitModel != null)
            {
                var allRevitParterList = structRevitModel.GetAllParters();
                foreach (var revitParter in allRevitParterList)
                {
                    if (revitParter.PropStatusList != null && revitParter.PropStatusList.Count > 0)
                    {
                        foreach (var revitParterPropStatus in revitParter.PropStatusList)
                        {
                            if (revitParterPropStatus.PropStatus == HStation.Revit.ePropStatus.Error)
                            {
                                hasRevitPropError = true;
                            }
                            switch (revitParterPropStatus.PropStatus)
                            {
                                case Revit.ePropStatus.Error:
                                    {
                                        feedBackMsg?.Invoke($"构件类型:{revitParter.Catalog},构件编码:{revitParter.Code},构件属性:{revitParterPropStatus.PropName},错误:{revitParterPropStatus.StatusInfo} ", Color.Red);
                                    }
                                    break;
                                case Revit.ePropStatus.Lack:
                                    {
                                        //feedBackMsg?.Invoke($"构件编码:{revitParter.Id},构件属性:{revitParterPropStatus.PropName},缺省:{revitParterPropStatus.StatusInfo} ", Color.Gray);
                                    }
                                    break;
                                case Revit.ePropStatus.Abnormal:
                                    {
                                        //feedBackMsg?.Invoke($"构件编码:{revitParter.Id},构件属性:{revitParterPropStatus.PropName},异常:{revitParterPropStatus.StatusInfo} ", Color.Orange);
                                    }
                                    break;
                                default: break;
                            }
                        }
                    }
                }
            }
            if (hasRevitPropError || !structFileResult)
            {
                feedBackMsg?.Invoke($"水力结构文件解析错误!!!", Color.Red);
                feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue);
                feedBackProgress?.Invoke(100, 100);
                return true;
            }
            vm.RevitModel = structRevitModel;
            var hydroInfo = HStation.Hydro.TransferHelper.FromRevit(structRevitModel, out msg);
            if (hydroInfo == null)
@@ -185,11 +234,31 @@
                return true;
            }
            feedBackMsg?.Invoke("正在进行产品匹配...", Color.Black);
            hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroId);
            var matchingParas = AssetsMatchingParasHelper.Create(hydroInfo, null);
            if (AssetsMatchingHelper.Matching(matchingParas, out string error))
            {
                if (AssetsMatchingParasHelper.Apply(hydroInfo, matchingParas))
                {
                    feedBackMsg?.Invoke("产品匹配完成。。。", Color.Green);
                }
                else
                {
                    feedBackMsg?.Invoke("产品匹配失败!!!", Color.Red);
                }
            }
            else
            {
                feedBackMsg?.Invoke("产品匹配失败!!!", Color.Red);
            }
            hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            feedBackMsg?.Invoke("水力结构文件解析成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 30);
            vm.HydroID = hydroId;
            #endregion
            #endregion 第五步 解析水力结构文件 (进度30%)
            #region 第六步 关联水力结构模型(进度 40%)
@@ -224,12 +293,11 @@
                return true;
            }
            vm.HydroRelationID = hydroRelationId;
            feedBackMsg?.Invoke("关联水力结构模型成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 40);
            #endregion
            #endregion 第六步 关联水力结构模型(进度 40%)
            #region 第七步 上传Revit模型文件(进度 45%)
@@ -243,8 +311,8 @@
                return true;
            }
            // var bimfaceId = await Yw.WinFrmUI.BimfaceHelper.UploadFile(rvtFileInfo.FullName);//上传
            var bimfaceId = 10000878332030; //测试用例
            //var bimfaceId = await Yw.WinFrmUI.BimfaceHelper.UploadFile(rvtFileInfo.FullName);//上传
            var bimfaceId = 10000884702464; //测试用例 10000878572231 10000882826621  10000884283372 10000884362886 10000884702464
            if (bimfaceId < 1)
            {
                feedBackMsg?.Invoke("Revit模型文件上传失败!!!", Color.Red);
@@ -257,7 +325,7 @@
            feedBackMsg?.Invoke("解析Revit模型文件成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 45);
            #endregion
            #endregion 第七步 上传Revit模型文件(进度 45%)
            #region 第八步 保存Bimface文件 (进度 50%)
@@ -285,7 +353,7 @@
            feedBackMsg?.Invoke("Bimface文件保存成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 50);
            #endregion
            #endregion 第八步 保存Bimface文件 (进度 50%)
            #region 第九步 关联Bimface文件(进度 55%)
@@ -310,7 +378,7 @@
            feedBackMsg?.Invoke("Bimface文件关联成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 55);
            #endregion
            #endregion 第九步 关联Bimface文件(进度 55%)
            #region 第十步 发起bimface转换(进度 80%)
@@ -343,7 +411,7 @@
            feedBackProgress?.Invoke(100, 80);
            #endregion
            #endregion 第十步 发起bimface转换(进度 80%)
            #region 第十一步 更新Bimface文件状态(进度 100%)
@@ -364,10 +432,7 @@
            feedBackMsg?.Invoke("项目导入完成。。。", Color.Green);
            return true;
            #endregion
            #endregion 第十一步 更新Bimface文件状态(进度 100%)
        }
    }
}