Shuxia Ning
2024-11-19 a01861a95ede48fa4979a47b24f21616e362e534
WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs
@@ -1,9 +1,4 @@
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;
namespace HStation.WinFrmUI
{
@@ -42,7 +37,7 @@
            feedBackProgress?.Invoke(100, 5);
            #endregion 第一步 临时文件处理(进度5%)
            #endregion
            #region 第二步 创建项目(进度 10%)
@@ -78,7 +73,7 @@
            feedBackProgress?.Invoke(100, 10);
            #endregion 第二步 创建项目(进度 10%)
            #endregion
            #region 第三步 设置地图位置(进度 20%)
@@ -113,15 +108,24 @@
            feedBackProgress?.Invoke(100, 20);
            #endregion 第三步 设置地图位置(进度 20%)
            #endregion
            #region 第四步 压缩文件解析 (进度25%)
            msg = "正在解析模型文件...";
            feedBackMsg?.Invoke(msg, Color.Black);
            #region 第四步 压缩文件解析 (进度30%)
            var zipFilePwd = HStation.Settings.XhsParasHelper.Xhs.File.Password;
            var bol = Yw.FileFolderZipHelper.UnZip(vm.ZipFile, tempFolder, zipFilePwd);
            var localZipFile = vm.LocalZipFile;
            if (!vm.IsLocal)
            {
                if (vm.TransferRevitFile != null)
                {
                    feedBackMsg?.Invoke("正在下载模型文件...", Color.Black);
                    localZipFile = await BLLFactory<HStation.BLL.TransferRevitFile>.Instance.Download(vm.TransferRevitFile.StorageHouse, vm.TransferRevitFile.StorageCode);
                    feedBackMsg?.Invoke("模型文件下载完成!!!", Color.Green);
                }
            }
            msg = "正在解析模型文件...";
            feedBackMsg?.Invoke(msg, Color.Black);
            var bol = Yw.FileFolderZipHelper.UnZip(localZipFile, tempFolder, zipFilePwd);
            if (!bol)
            {
                feedBackMsg?.Invoke("模型文件解析失败!!!", Color.Red);
@@ -142,11 +146,11 @@
            feedBackMsg?.Invoke("模型文件解析成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 25);
            feedBackProgress?.Invoke(100, 30);
            #endregion 第四步 压缩文件解析 (进度25%)
            #endregion
            #region 第五步 解析水力结构文件 (进度30%)
            #region 第五步 解析水力结构文件 (进度40%)
            feedBackMsg?.Invoke("正在解析水力结构文件...", Color.Black);
            var structFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.StructFileName);
@@ -184,19 +188,22 @@
                            {
                                case Revit.ePropStatus.Error:
                                    {
                                        feedBackMsg?.Invoke($"构件类型:{revitParter.Catalog},构件编码:{revitParter.Code},构件属性:{revitParterPropStatus.PropName},错误:{revitParterPropStatus.StatusInfo} ", Color.Red);
                                        feedBackMsg?.Invoke($"构件类型:{revitParter.Catalog},构件编码:{revitParter.Id},构件属性:{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;
                            }
                        }
@@ -222,18 +229,7 @@
                return true;
            }
            var hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            if (hydroId < 1)
            {
                feedBackMsg?.Invoke("水力结构信息保存失败!!!", Color.Red);
                feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue);
                feedBackProgress?.Invoke(100, 100);
                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))
            {
@@ -250,15 +246,24 @@
            {
                feedBackMsg?.Invoke("产品匹配失败!!!", Color.Red);
            }
            hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            feedBackMsg?.Invoke("正在保存水力结构信息...", Color.Black);
            var hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo);
            if (hydroId < 1)
            {
                feedBackMsg?.Invoke("水力结构信息保存失败!!!", Color.Red);
                feedBackMsg?.Invoke("项目导入结束。。。", Color.Blue);
                feedBackProgress?.Invoke(100, 100);
                return true;
            }
            feedBackMsg?.Invoke("水力结构信息保存成功。。。", Color.Green);
            feedBackMsg?.Invoke("水力结构文件解析成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 30);
            feedBackProgress?.Invoke(100, 40);
            vm.HydroID = hydroId;
            #endregion 第五步 解析水力结构文件 (进度30%)
            #endregion
            #region 第六步 关联水力结构模型(进度 40%)
            #region 第六步 关联水力结构模型(进度 50%)
            var projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(projectId);
            if (projectSite == null)
@@ -293,11 +298,11 @@
            vm.HydroRelationID = hydroRelationId;
            feedBackMsg?.Invoke("关联水力结构模型成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 40);
            feedBackProgress?.Invoke(100, 50);
            #endregion 第六步 关联水力结构模型(进度 40%)
            #endregion
            #region 第七步 上传Revit模型文件(进度 45%)
            #region 第七步 上传Revit模型文件(进度 60%)
            feedBackMsg?.Invoke("正在解析Revit模型文件...", Color.Black);
            var rvtFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.RvtFileName);
@@ -310,7 +315,7 @@
            }
            //var bimfaceId = await Yw.WinFrmUI.BimfaceHelper.UploadFile(rvtFileInfo.FullName);//上传
            var bimfaceId = 10000884362886; //测试用例 10000878572231 10000882826621  10000884283372 10000884362886
            var bimfaceId = 10000884893369; //测试用例 10000878572231 10000882826621  10000884283372 10000884362886 10000884702464 10000884893369
            if (bimfaceId < 1)
            {
                feedBackMsg?.Invoke("Revit模型文件上传失败!!!", Color.Red);
@@ -321,11 +326,11 @@
            vm.BimfaceId = bimfaceId;
            feedBackMsg?.Invoke("解析Revit模型文件成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 45);
            feedBackProgress?.Invoke(100, 60);
            #endregion 第七步 上传Revit模型文件(进度 45%)
            #endregion
            #region 第八步 保存Bimface文件 (进度 50%)
            #region 第八步 保存Bimface文件 (进度 65%)
            feedBackMsg?.Invoke("正在保存Bimface文件...", Color.Black);
@@ -349,11 +354,11 @@
            vm.BimfaceFileID = bimfaceFileId;
            feedBackMsg?.Invoke("Bimface文件保存成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 50);
            feedBackProgress?.Invoke(100, 65);
            #endregion 第八步 保存Bimface文件 (进度 50%)
            #endregion
            #region 第九步 关联Bimface文件(进度 55%)
            #region 第九步 关联Bimface文件(进度 70%)
            feedBackMsg?.Invoke("正在关联Bimface文件...", Color.Black);
@@ -374,11 +379,11 @@
            }
            vm.BimfaceFileRelationID = bimfaceRelationId;
            feedBackMsg?.Invoke("Bimface文件关联成功。。。", Color.Green);
            feedBackProgress?.Invoke(100, 55);
            feedBackProgress?.Invoke(100, 70);
            #endregion 第九步 关联Bimface文件(进度 55%)
            #endregion
            #region 第十步 发起bimface转换(进度 80%)
            #region 第十步 发起bimface转换(进度 90%)
            feedBackMsg?.Invoke("正在进行Bimface模型轻量化...", Color.Black);
            //var bimfaceTranslateStatus = await Yw.WinFrmUI.BimfaceHelper.TranslateRvtFile(bimfaceId);//发起转换
@@ -407,9 +412,9 @@
                feedBackMsg?.Invoke("Bimface模型轻量化完成。。。", Color.Green);
            }
            feedBackProgress?.Invoke(100, 80);
            feedBackProgress?.Invoke(100, 90);
            #endregion 第十步 发起bimface转换(进度 80%)
            #endregion
            #region 第十一步 更新Bimface文件状态(进度 100%)
@@ -430,7 +435,7 @@
            feedBackMsg?.Invoke("项目导入完成。。。", Color.Green);
            return true;
            #endregion 第十一步 更新Bimface文件状态(进度 100%)
            #endregion
        }
    }
}