From 9eb94e9eec2e2e164698e34d0481d66093c8655b Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期三, 15 一月 2025 17:40:55 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs | 3393 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 2,669 insertions(+), 724 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs index 1c5fb5a..4158f0a 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs @@ -1,4 +1,5 @@ -锘縰sing Yw.Model; +锘縰sing Yw.Hydro; +using Yw.Model; namespace Yw.WinFrmUI { @@ -11,22 +12,9 @@ #region 鍒涘缓 /// <summary> - /// 鍒涘缓鑷姩鍖归厤ViewModel - /// </summary> - public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultVisualList = null) - { - if (hydroInfo == null) - { - return default; - } - var allCalcuResultVisualDict = allCalcuResultVisualList?.ToDictionary(x => x.Code); - return Create(hydroInfo, allCalcuResultVisualDict); - } - - /// <summary> /// 鍒涘缓 /// </summary> - public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict = null) + public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo) { if (hydroInfo == null) { @@ -38,97 +26,103 @@ #region 姘存睜 var tanks = hydroInfo.GetAllTanks(); - vm.Tanks = tanks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Tanks = tanks?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 闂峰ご - vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 寮ご - vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 涓夐�� - vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 鍥涢�� - vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 鍠峰槾 - vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 娑堢伀鏍� - vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo)).ToList(); + + #endregion + + #region 鍐峰嵈濉� + + vm.Coolings = hydroInfo.Coolings?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 姘磋〃 - vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 娴侀噺璁� - vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuFlowmeterResult)).ToList(); + vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 鍘嬪姏琛� - vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuPressmeterResult)).ToList(); + vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 绠¢亾 - vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 杩囨浮浠� - vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 姘存车 - vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuPumpResult)).ToList(); + vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 闃�闂� - vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 鎹㈢儹鍣� - vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo)).ToList(); #endregion #region 鍘嬬缉鏈� - vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo)).ToList(); #endregion @@ -140,9 +134,9 @@ /// <summary> /// 鍒涘缓姘存睜鑷姩鍖归厤ViewModel /// </summary> - public static HydroTankMatchingViewModel Create(HydroTankInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroTankMatchingViewModel Create(HydroTankInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -150,19 +144,19 @@ { return default; } - return new HydroTankMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroTankMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓姘存睜鑷姩鍖归厤ViewModel /// </summary> - public static HydroTankMatchingViewModel Create(HydroTankViewModel parterViewModel) + public static HydroTankMatchingViewModel Create(HydroTankViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroTankMatchingViewModel(parterViewModel); + return new HydroTankMatchingViewModel(visualViewModel); } #endregion @@ -172,9 +166,9 @@ /// <summary> /// 鍒涘缓闂峰ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroBluntheadMatchingViewModel Create(HydroBluntheadInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroBluntheadMatchingViewModel Create(HydroBluntheadInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -182,19 +176,19 @@ { return default; } - return new HydroBluntheadMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroBluntheadMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓闂峰ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroBluntheadMatchingViewModel Create(HydroBluntheadViewModel parterViewModel) + public static HydroBluntheadMatchingViewModel Create(HydroBluntheadViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroBluntheadMatchingViewModel(parterViewModel); + return new HydroBluntheadMatchingViewModel(visualViewModel); } #endregion @@ -204,9 +198,9 @@ /// <summary> /// 鍒涘缓寮ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroElbowMatchingViewModel Create(HydroElbowInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroElbowMatchingViewModel Create(HydroElbowInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -214,19 +208,19 @@ { return default; } - return new HydroElbowMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroElbowMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓寮ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroElbowMatchingViewModel Create(HydroElbowViewModel parterViewModel) + public static HydroElbowMatchingViewModel Create(HydroElbowViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroElbowMatchingViewModel(parterViewModel); + return new HydroElbowMatchingViewModel(visualViewModel); } #endregion @@ -236,9 +230,9 @@ /// <summary> /// 鍒涘缓涓夐�氳嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroThreelinkMatchingViewModel Create(HydroThreelinkInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroThreelinkMatchingViewModel Create(HydroThreelinkInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -246,19 +240,19 @@ { return default; } - return new HydroThreelinkMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroThreelinkMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓涓夐�氳嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroThreelinkMatchingViewModel Create(HydroThreelinkViewModel parterViewModel) + public static HydroThreelinkMatchingViewModel Create(HydroThreelinkViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroThreelinkMatchingViewModel(parterViewModel); + return new HydroThreelinkMatchingViewModel(visualViewModel); } #endregion @@ -268,9 +262,9 @@ /// <summary> /// 鍒涘缓鍥涢�氳嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroFourlinkMatchingViewModel Create(HydroFourlinkInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroFourlinkMatchingViewModel Create(HydroFourlinkInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -278,19 +272,19 @@ { return default; } - return new HydroFourlinkMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroFourlinkMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓鍥涢�氳嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroFourlinkMatchingViewModel Create(HydroFourlinkViewModel parterViewModel) + public static HydroFourlinkMatchingViewModel Create(HydroFourlinkViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroFourlinkMatchingViewModel(parterViewModel); + return new HydroFourlinkMatchingViewModel(visualViewModel); } #endregion @@ -300,9 +294,9 @@ /// <summary> /// 鍒涘缓鍠峰ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroNozzleMatchingViewModel Create(HydroNozzleInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroNozzleMatchingViewModel Create(HydroNozzleInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -310,19 +304,19 @@ { return default; } - return new HydroNozzleMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroNozzleMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓鍠峰ご鑷姩鍖归厤ViewModel /// </summary> - public static HydroNozzleMatchingViewModel Create(HydroNozzleViewModel parterViewModel) + public static HydroNozzleMatchingViewModel Create(HydroNozzleViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroNozzleMatchingViewModel(parterViewModel); + return new HydroNozzleMatchingViewModel(visualViewModel); } #endregion @@ -332,9 +326,9 @@ /// <summary> /// 鍒涘缓娑堢伀鏍撹嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroHydrantMatchingViewModel Create(HydroHydrantInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroHydrantMatchingViewModel Create(HydroHydrantInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -342,19 +336,51 @@ { return default; } - return new HydroHydrantMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroHydrantMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓娑堢伀鏍撹嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroHydrantMatchingViewModel Create(HydroHydrantViewModel parterViewModel) + public static HydroHydrantMatchingViewModel Create(HydroHydrantViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroHydrantMatchingViewModel(parterViewModel); + return new HydroHydrantMatchingViewModel(visualViewModel); + } + + #endregion + + #region 鍐峰嵈濉� + + /// <summary> + /// 鍒涘缓鍐峰嵈濉旇嚜鍔ㄥ尮閰峍iewModel + /// </summary> + public static HydroCoolingMatchingViewModel Create(HydroCoolingInfo visualInfo, HydroModelInfo hydroInfo) + { + if (visualInfo == null) + { + return default; + } + if (hydroInfo == null) + { + return default; + } + return new HydroCoolingMatchingViewModel(visualInfo, hydroInfo); + } + + /// <summary> + /// 鍒涘缓鍐峰嵈濉旇嚜鍔ㄥ尮閰峍iewModel + /// </summary> + public static HydroCoolingMatchingViewModel Create(HydroCoolingViewModel visualViewModel) + { + if (visualViewModel == null) + { + return default; + } + return new HydroCoolingMatchingViewModel(visualViewModel); } #endregion @@ -364,9 +390,9 @@ /// <summary> /// 鍒涘缓姘磋〃鑷姩鍖归厤ViewModel /// </summary> - public static HydroMeterMatchingViewModel Create(HydroMeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null) + public static HydroMeterMatchingViewModel Create(HydroMeterInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -374,19 +400,19 @@ { return default; } - return new HydroMeterMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroMeterMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓姘磋〃鑷姩鍖归厤ViewModel /// </summary> - public static HydroMeterMatchingViewModel Create(HydroMeterViewModel parterViewModel) + public static HydroMeterMatchingViewModel Create(HydroMeterViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroMeterMatchingViewModel(parterViewModel); + return new HydroMeterMatchingViewModel(visualViewModel); } #endregion @@ -396,9 +422,9 @@ /// <summary> /// 鍒涘缓娴侀噺璁¤嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuFlowmeterResult calcuResult = null) + public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -406,19 +432,19 @@ { return default; } - return new HydroFlowmeterMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroFlowmeterMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓娴侀噺璁¤嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterViewModel parterViewModel) + public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroFlowmeterMatchingViewModel(parterViewModel); + return new HydroFlowmeterMatchingViewModel(visualViewModel); } #endregion @@ -428,9 +454,9 @@ /// <summary> /// 鍒涘缓鍘嬪姏琛ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroPressmeterMatchingViewModel Create(HydroPressmeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuPressmeterResult calcuResult = null) + public static HydroPressmeterMatchingViewModel Create(HydroPressmeterInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -438,19 +464,19 @@ { return default; } - return new HydroPressmeterMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroPressmeterMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓鍘嬪姏琛ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroPressmeterMatchingViewModel Create(HydroPressmeterViewModel parterViewModel) + public static HydroPressmeterMatchingViewModel Create(HydroPressmeterViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroPressmeterMatchingViewModel(parterViewModel); + return new HydroPressmeterMatchingViewModel(visualViewModel); } #endregion @@ -460,9 +486,9 @@ /// <summary> /// 鍒涘缓绠¢亾鑷姩鍖归厤ViewModel /// </summary> - public static HydroPipeMatchingViewModel Create(HydroPipeInfo pipeInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null) + public static HydroPipeMatchingViewModel Create(HydroPipeInfo visualInfo, HydroModelInfo hydroInfo) { - if (pipeInfo == null) + if (visualInfo == null) { return default; } @@ -470,19 +496,19 @@ { return default; } - return new HydroPipeMatchingViewModel(pipeInfo, hydroInfo, calcuResult); + return new HydroPipeMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓绠¢亾鑷姩鍖归厤ViewModel /// </summary> - public static HydroPipeMatchingViewModel Create(HydroPipeViewModel pipeViewModel) + public static HydroPipeMatchingViewModel Create(HydroPipeViewModel visualViewModel) { - if (pipeViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroPipeMatchingViewModel(pipeViewModel); + return new HydroPipeMatchingViewModel(visualViewModel); } #endregion @@ -492,9 +518,9 @@ /// <summary> /// 鍒涘缓杩囨浮浠惰嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroTranslationMatchingViewModel Create(HydroTranslationInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null) + public static HydroTranslationMatchingViewModel Create(HydroTranslationInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -502,19 +528,19 @@ { return default; } - return new HydroTranslationMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroTranslationMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓杩囨浮浠惰嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroTranslationMatchingViewModel Create(HydroTranslationViewModel parterViewModel) + public static HydroTranslationMatchingViewModel Create(HydroTranslationViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroTranslationMatchingViewModel(parterViewModel); + return new HydroTranslationMatchingViewModel(visualViewModel); } #endregion @@ -524,9 +550,9 @@ /// <summary> /// 鍒涘缓姘存车鑷姩鍖归厤ViewModel /// </summary> - public static HydroPumpMatchingViewModel Create(HydroPumpInfo pumpInfo, HydroModelInfo hydroInfo, HydroCalcuPumpResult calcuResult = null) + public static HydroPumpMatchingViewModel Create(HydroPumpInfo visualInfo, HydroModelInfo hydroInfo) { - if (pumpInfo == null) + if (visualInfo == null) { return default; } @@ -534,19 +560,19 @@ { return default; } - return new HydroPumpMatchingViewModel(pumpInfo, hydroInfo, calcuResult); + return new HydroPumpMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓姘存车鑷姩鍖归厤ViewModel /// </summary> - public static HydroPumpMatchingViewModel Create(HydroPumpViewModel pumpViewModel) + public static HydroPumpMatchingViewModel Create(HydroPumpViewModel visualViewModel) { - if (pumpViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroPumpMatchingViewModel(pumpViewModel); + return new HydroPumpMatchingViewModel(visualViewModel); } #endregion @@ -556,9 +582,9 @@ /// <summary> /// 鍒涘缓闃�闂ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroValveMatchingViewModel Create(HydroValveInfo valveInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null) + public static HydroValveMatchingViewModel Create(HydroValveInfo visualInfo, HydroModelInfo hydroInfo) { - if (valveInfo == null) + if (visualInfo == null) { return default; } @@ -566,19 +592,19 @@ { return default; } - return new HydroValveMatchingViewModel(valveInfo, hydroInfo, calcuResult); + return new HydroValveMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓闃�闂ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroValveMatchingViewModel Create(HydroValveViewModel valveViewModel) + public static HydroValveMatchingViewModel Create(HydroValveViewModel visualViewModel) { - if (valveViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroValveMatchingViewModel(valveViewModel); + return new HydroValveMatchingViewModel(visualViewModel); } #endregion @@ -588,9 +614,9 @@ /// <summary> /// 鍒涘缓鎹㈢儹鍣ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroExchangerMatchingViewModel Create(HydroExchangerInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null) + public static HydroExchangerMatchingViewModel Create(HydroExchangerInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -598,19 +624,19 @@ { return default; } - return new HydroExchangerMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroExchangerMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓鎹㈢儹鍣ㄨ嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroExchangerMatchingViewModel Create(HydroExchangerViewModel parterViewModel) + public static HydroExchangerMatchingViewModel Create(HydroExchangerViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroExchangerMatchingViewModel(parterViewModel); + return new HydroExchangerMatchingViewModel(visualViewModel); } #endregion @@ -620,9 +646,9 @@ /// <summary> /// 鍒涘缓鍘嬬缉鏈鸿嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroCompressorMatchingViewModel Create(HydroCompressorInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null) + public static HydroCompressorMatchingViewModel Create(HydroCompressorInfo visualInfo, HydroModelInfo hydroInfo) { - if (parterInfo == null) + if (visualInfo == null) { return default; } @@ -630,19 +656,19 @@ { return default; } - return new HydroCompressorMatchingViewModel(parterInfo, hydroInfo, calcuResult); + return new HydroCompressorMatchingViewModel(visualInfo, hydroInfo); } /// <summary> /// 鍒涘缓鍘嬬缉鏈鸿嚜鍔ㄥ尮閰峍iewModel /// </summary> - public static HydroCompressorMatchingViewModel Create(HydroCompressorViewModel parterViewModel) + public static HydroCompressorMatchingViewModel Create(HydroCompressorViewModel visualViewModel) { - if (parterViewModel == null) + if (visualViewModel == null) { return default; } - return new HydroCompressorMatchingViewModel(parterViewModel); + return new HydroCompressorMatchingViewModel(visualViewModel); } #endregion @@ -651,82 +677,1908 @@ #region 搴旂敤 - ///// <summary> - ///// 搴旂敤璧勪骇鑷姩鍖归厤ViewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, AssetsMatchingViewModel output) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (output == null) - // { - // return false; - // } + /// <summary> + /// 搴旂敤鑷姩鍖归厤ViewModel + /// </summary> + public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, HydroMatchingViewModel matchingInfo) + { + if (hydroInfo == null) + { + return false; + } + if (matchingInfo == null) + { + return false; + } - // bool result = false; + bool result = false; - // //姘存车 - // output.PumpMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + #region 姘存睜 - // //闃�闂� - // output.ValveMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + var allTanks = hydroInfo.GetAllTanks(); + if (allTanks != null && allTanks.Count > 0) + { + if (matchingInfo.Tanks != null && matchingInfo.Tanks.Count > 0) + { + allTanks.ForEach(x => + { + var matching = matchingInfo.Tanks.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } - // //绠¢亾 - // output.PipeMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + } - // //寮ご - // output.ElbowMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + #endregion - // //涓夐�� - // output.ThreelinkMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + #region 闂峰ご - // //鍥涢�� - // output.FourlinkMatchingList?.ForEach(x => - // { - // if (Apply(hydroInfo, x)) - // { - // result = true; - // } - // }); + if (hydroInfo.Bluntheads != null && hydroInfo.Bluntheads.Count > 0) + { + if (matchingInfo.Bluntheads != null && matchingInfo.Bluntheads.Count > 0) + { + hydroInfo.Bluntheads.ForEach(x => + { + var matching = matchingInfo.Bluntheads.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } - // return result; - //} + #endregion + + #region 寮ご + + if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0) + { + if (matchingInfo.Elbows != null && matchingInfo.Elbows.Count > 0) + { + hydroInfo.Elbows.ForEach(x => + { + var matching = matchingInfo.Elbows.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 涓夐�� + + if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0) + { + if (matchingInfo.Threelinks != null && matchingInfo.Threelinks.Count > 0) + { + hydroInfo.Threelinks.ForEach(x => + { + var matching = matchingInfo.Threelinks.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 鍥涢�� + + if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0) + { + if (matchingInfo.Fourlinks != null && matchingInfo.Fourlinks.Count > 0) + { + hydroInfo.Fourlinks.ForEach(x => + { + var matching = matchingInfo.Fourlinks.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 鍠峰ご + + if (hydroInfo.Nozzles != null && hydroInfo.Nozzles.Count > 0) + { + if (matchingInfo.Nozzles != null && matchingInfo.Nozzles.Count > 0) + { + hydroInfo.Nozzles.ForEach(x => + { + var matching = matchingInfo.Nozzles.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 娑堢伀鏍� + + if (hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0) + { + if (matchingInfo.Hydrants != null && matchingInfo.Hydrants.Count > 0) + { + hydroInfo.Hydrants.ForEach(x => + { + var matching = matchingInfo.Hydrants.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 娑堢伀鏍� + + if (hydroInfo.Coolings != null && hydroInfo.Coolings.Count > 0) + { + if (matchingInfo.Coolings != null && matchingInfo.Coolings.Count > 0) + { + hydroInfo.Coolings.ForEach(x => + { + var matching = matchingInfo.Coolings.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 姘磋〃 + + if (hydroInfo.Meters != null && hydroInfo.Meters.Count > 0) + { + if (matchingInfo.Meters != null && matchingInfo.Meters.Count > 0) + { + hydroInfo.Meters.ForEach(x => + { + var matching = matchingInfo.Meters.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 娴侀噺璁� + + if (hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0) + { + if (matchingInfo.Flowmeters != null && matchingInfo.Flowmeters.Count > 0) + { + hydroInfo.Flowmeters.ForEach(x => + { + var matching = matchingInfo.Flowmeters.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 鍘嬪姏琛� + + if (hydroInfo.Pressmeters != null && hydroInfo.Pressmeters.Count > 0) + { + if (matchingInfo.Pressmeters != null && matchingInfo.Pressmeters.Count > 0) + { + hydroInfo.Pressmeters.ForEach(x => + { + var matching = matchingInfo.Pressmeters.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 绠¢亾 + + if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0) + { + if (matchingInfo.Pipes != null && matchingInfo.Pipes.Count > 0) + { + hydroInfo.Pipes.ForEach(x => + { + var matching = matchingInfo.Pipes.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 杩囨浮浠� + + if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0) + { + if (matchingInfo.Translations != null && matchingInfo.Translations.Count > 0) + { + hydroInfo.Translations.ForEach(x => + { + var matching = matchingInfo.Translations.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 姘存车 + + if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0) + { + if (matchingInfo.Pumps != null && matchingInfo.Pumps.Count > 0) + { + hydroInfo.Pumps.ForEach(x => + { + var matching = matchingInfo.Pumps.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 闃�闂� + + if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0) + { + if (matchingInfo.Valves != null && matchingInfo.Valves.Count > 0) + { + hydroInfo.Valves.ForEach(x => + { + var matching = matchingInfo.Valves.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 鎹㈢儹鍣� + + if (hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0) + { + if (matchingInfo.Exchangers != null && matchingInfo.Exchangers.Count > 0) + { + hydroInfo.Exchangers.ForEach(x => + { + var matching = matchingInfo.Exchangers.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + #region 绌哄帇鏈� + + if (hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0) + { + if (matchingInfo.Compressors != null && matchingInfo.Compressors.Count > 0) + { + hydroInfo.Compressors.ForEach(x => + { + var matching = matchingInfo.Compressors.Find(t => t.Code == x.Code); + if (Apply(hydroInfo, x, matching)) + { + result = true; + } + }); + } + } + + #endregion + + return result; + } #region 姘存睜 + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroTankViewModel visualViewModel, + HydroTankMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroTankInfo visual, + HydroTankMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.MinLevel = matching.MinLevel; + //visual.MaxLevel = matching.MaxLevel; + //visual.DN = matching.DN; + //visual.MinVol = matching.MinVol; + //visual.OverFlow = matching.OverFlow; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingMinLevel.HasValue) + { + if (visual.MinLevel != matching.MatchingMinLevel.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinLevel), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinLevel = matching.MatchingMinLevel.Value; + result = true; + } + if (matching.MatchingMaxLevel.HasValue) + { + if (visual.MaxLevel != matching.MatchingMaxLevel.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MaxLevel), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MaxLevel = matching.MatchingMaxLevel.Value; + result = true; + } + if (matching.MatchingDN.HasValue) + { + if (visual.DN != matching.MatchingDN.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DN), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DN = matching.MatchingDN.Value; + result = true; + } + if (matching.MatchingMinVol.HasValue) + { + if (visual.MinVol != matching.MatchingMinVol.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinVol), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinVol = matching.MatchingMinVol.Value; + result = true; + } + if (matching.MatchingOverFlow.HasValue) + { + if (visual.OverFlow != matching.MatchingOverFlow.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.OverFlow), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.OverFlow = matching.MatchingOverFlow.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + var curvevol = hydroInfo.Curves?.Find(x => x.Code == visual.VolCurve); + if (curvevol == null) + { + curvevol = new Yw.Model.HydroCurveInfo(); + curvevol.Catalog = Yw.Hydro.ParterCatalog.Curve; + curvevol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curvevol.Name = "鍖归厤"; + curvevol.ModelType = string.Empty; + curvevol.DbLocked = false; + curvevol.DbId = matching.MatchingCurveDbId; + curvevol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveVol; + curvevol.CurveData = matching.MatchingVolCurve?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curvevol); + visual.VolCurve = curvevol.Code; + changeHelper?.Append(curvevol, eChangeType.Add); + result = true; + } + else + { + if (!curvevol.DbLocked) + { + curvevol.DbId = matching.MatchingCurveDbId; + curvevol.CurveData = matching.MatchingVolCurve?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curvevol, eChangeType.Update); + result = true; + } + } + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.VolCurve), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇"); + } + else + { + if (!string.IsNullOrEmpty(visual.VolCurve)) + { + var volCurve = hydroInfo?.Curves?.Find(x => x.Code == visual.VolCurve); + if (volCurve != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.VolCurve); + visual.VolCurve = string.Empty; + changeHelper?.Append(volCurve, eChangeType.Remove); + } + } + } + } + return result; + } + + #endregion + + #region 闂峰ご + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroBluntheadViewModel visualViewModel, + HydroBluntheadMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroBluntheadInfo visual, + HydroBluntheadMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Caliber = matching.Caliber; + //visual.Material = matching.Material; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 寮ご + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroElbowViewModel visualViewModel, + HydroElbowMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroElbowInfo visual, + HydroElbowMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Caliber = matching.Caliber; + //visual.Material = matching.Material; + //visual.MinorLoss = matching.MinorLoss; + //visual.BendingAngle = matching.BendingAngle; + //if (matching.ElbowType.HasValue) + //{ + // visual.ElbowType = HydroElbowTypeEnumHelper.GetElbowTypeName(matching.ElbowType.Value); + //} + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingBendingAngle.HasValue) + { + if (visual.BendingAngle != matching.MatchingBendingAngle.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.BendingAngle), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.BendingAngle = matching.MatchingBendingAngle.Value; + result = true; + } + if (matching.MatchingElbowType.HasValue) + { + var elbowType = HydroElbowTypeEnumHelper.GetElbowTypeName(matching.MatchingElbowType.Value); + if (visual.ElbowType != elbowType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ElbowType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ElbowType = elbowType; + result = true; + } + } + return result; + } + + #endregion + + #region 涓夐�� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroThreelinkViewModel visualViewModel, + HydroThreelinkMatchingViewModel matching, + HydroChangeHelper changeHelper, + HydroPropStatusHelper propStatusHelper + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroThreelinkInfo visual, + HydroThreelinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Caliber = matching.Caliber; + //visual.Material = matching.Material; + //visual.MinorLoss = matching.MinorLoss; + //visual.RunningThroughLoss = matching.RunningThroughLoss; + //visual.BranchThroughLoss = matching.BranchThroughLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingRunningThroughLoss.HasValue) + { + if (visual.RunningThroughLoss != matching.MatchingRunningThroughLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RunningThroughLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RunningThroughLoss = matching.MatchingRunningThroughLoss.Value; + result = true; + } + if (matching.MatchingBranchThroughLoss.HasValue) + { + if (visual.BranchThroughLoss != matching.MatchingBranchThroughLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.BranchThroughLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.BranchThroughLoss = matching.MatchingBranchThroughLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 鍥涢�� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroFourlinkViewModel visualViewModel, + HydroFourlinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroFourlinkInfo visual, + HydroFourlinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Caliber = matching.Caliber; + //visual.Material = matching.Material; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 鍠峰ご + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroNozzleViewModel visualViewModel, + HydroNozzleMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroNozzleInfo visual, + HydroNozzleMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Material = matching.Material; + //visual.Caliber = matching.Caliber; + //visual.MinorLoss = matching.MinorLoss; + //visual.Coefficient = matching.Coefficient; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingCoefficient.HasValue) + { + if (visual.Coefficient != matching.MatchingCoefficient.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Coefficient), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Coefficient = matching.MatchingCoefficient.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 娑堢伀鏍� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroHydrantViewModel visualViewModel, + HydroHydrantMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroHydrantInfo visual, + HydroHydrantMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Material = matching.Material; + //visual.Caliber = matching.Caliber; + // visual.MinorLoss = matching.MinorLoss; + // visual.Coefficient = matching.Coefficient; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingCoefficient.HasValue) + { + if (visual.Coefficient != matching.MatchingCoefficient.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Coefficient), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Coefficient = matching.MatchingCoefficient.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 鍐峰嵈濉� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroCoolingViewModel visualViewModel, + HydroCoolingMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroCoolingInfo visual, + HydroCoolingMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Material = matching.Material; + //visual.Caliber = matching.Caliber; + //visual.MinorLoss = matching.MinorLoss; + //visual.Coefficient = matching.Coefficient; + //visual.LowerLimit = matching.LowerLimit; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingCaliber.HasValue) + { + if (visual.Caliber != matching.MatchingCaliber.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Caliber), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Caliber = matching.MatchingCaliber.Value; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingCoefficient.HasValue) + { + if (visual.Coefficient != matching.MatchingCoefficient.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Coefficient), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Coefficient = matching.MatchingCoefficient.Value; + result = true; + } + if (matching.MatchingLowerLimit.HasValue) + { + if (visual.LowerLimit != matching.MatchingLowerLimit.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.LowerLimit), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.LowerLimit = matching.MatchingLowerLimit.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 姘磋〃 + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroMeterViewModel visualViewModel, + HydroMeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroMeterInfo visual, + HydroMeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 娴侀噺璁� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroFlowmeterViewModel visualViewModel, + HydroFlowmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroFlowmeterInfo visual, + HydroFlowmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + // visual.ModelType = matching.ModelType; + // visual.MinorLoss = matching.MinorLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 鍘嬪姏琛� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroPressmeterViewModel visualViewModel, + HydroPressmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPressmeterInfo visual, + HydroPressmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 绠¢亾 + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroPipeViewModel visualViewModel, + HydroPipeMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPipeInfo visual, + HydroPipeMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Material = matching.Material; + //visual.Diameter = matching.Diameter; + //visual.Roughness = matching.Roughness; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingDiameter.HasValue) + { + if (visual.Diameter != matching.MatchingDiameter.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Diameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Diameter = matching.MatchingDiameter.Value; + result = true; + } + if (matching.MatchingRoughness.HasValue) + { + if (visual.Roughness != matching.MatchingRoughness.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Roughness), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Roughness = matching.MatchingRoughness.Value; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + } + return result; + } + + #endregion + + #region 杩囨浮浠� + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + HydroTranslationViewModel visualViewModel, + HydroTranslationMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } + + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroTranslationInfo visual, + HydroTranslationMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.Material = matching.Material; + //visual.Diameter = matching.Diameter; + //visual.StartDiameter = matching.StartDiameter; + //visual.EndDiameter = matching.EndDiameter; + //visual.Roughness = matching.Roughness; + //visual.MinorLoss = matching.MinorLoss; + + bool result = false; + + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + if (visual.Material != matching.MatchingMaterial) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingDiameter.HasValue) + { + if (visual.Diameter != matching.MatchingDiameter.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Diameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Diameter = matching.MatchingDiameter.Value; + result = true; + } + if (matching.MatchingRoughness.HasValue) + { + if (visual.Roughness != matching.MatchingRoughness.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Roughness), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.Roughness = matching.MatchingRoughness.Value; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + if (visual.MinorLoss != matching.MatchingMinorLoss.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingStartDiameter.HasValue) + { + if (visual.StartDiameter != matching.MatchingStartDiameter.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.StartDiameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.StartDiameter = matching.MatchingStartDiameter.Value; + result = true; + } + if (matching.MatchingEndDiameter.HasValue) + { + if (visual.EndDiameter != matching.MatchingEndDiameter.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.EndDiameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.EndDiameter = matching.MatchingEndDiameter.Value; + result = true; + } + } + return result; + } #endregion @@ -735,568 +2587,661 @@ /// <summary> /// 搴旂敤 /// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PumpMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } + public static bool Apply + ( + HydroPumpViewModel visualViewModel, + HydroPumpMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); + visualViewModel.UpdateProperty(); + return bol; + } - // bool result = false; + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPumpInfo visual, + HydroPumpMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } - // var pump = hydroInfo.Pumps?.Find(x => x.Code == matching.Code); - // if (pump != null) - // { - // pump.DbLocked = matching.DbLocked; - // pump.ModelType = matching.ModelType; - // pump.RatedP = matching.RatedP; - // pump.RatedQ = matching.RatedQ; - // pump.RatedH = matching.RatedH; - // pump.RatedN = matching.RatedN; - // pump.RatedHz = matching.RatedHz; - // pump.SpeedRatio = Math.Round(matching.CurrentHz / matching.RatedHz, 1); + //visual.Name = matching.Name; + //visual.DbLocked = matching.DbLocked; + //visual.DbId = matching.DbId; + //visual.ModelType = matching.ModelType; + //visual.RatedQ = matching.RatedQ; + //visual.RatedH = matching.RatedH; + //visual.RatedP = matching.RatedP; + //visual.RatedN = matching.RatedN; + //visual.RatedHz = matching.RatedHz; + //visual.SpeedRatio = matching.CurrentHz / visual.RatedHz; - // if (!pump.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // pump.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // pump.DbId = matching.MatchingDbId; - // } - // if (matching.MatchingRatedP.HasValue) - // { - // pump.RatedP = matching.MatchingRatedP.Value; - // } - // if (matching.MatchingRatedQ.HasValue) - // { - // pump.RatedQ = matching.MatchingRatedQ.Value; - // } - // if (matching.MatchingRatedH.HasValue) - // { - // pump.RatedH = matching.MatchingRatedH.Value; - // } - // if (matching.MatchingRatedN.HasValue) - // { - // pump.RatedN = matching.MatchingRatedN.Value; - // } + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + if (visual.ModelType != matching.MatchingModelType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + if (visual.DbId != matching.MatchingDbId) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.DbId = matching.MatchingDbId; + result = true; + } + if (matching.MatchingRatedQ.HasValue) + { + if (visual.RatedQ != matching.MatchingRatedQ.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RatedQ), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RatedQ = matching.MatchingRatedQ.Value; + result = true; + } + if (matching.MatchingRatedH.HasValue) + { + if (visual.RatedH != matching.MatchingRatedH.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RatedH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RatedH = matching.MatchingRatedH.Value; + result = true; + } + if (matching.MatchingRatedP.HasValue) + { + if (visual.RatedP != matching.MatchingRatedP.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RatedP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RatedP = matching.MatchingRatedP.Value; + result = true; + } + if (matching.MatchingRatedN.HasValue) + { + if (visual.RatedN != matching.MatchingRatedN.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RatedN), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RatedN = matching.MatchingRatedN.Value; + result = true; + } + if (matching.MatchingRatedHz.HasValue) + { + if (visual.RatedHz != matching.MatchingRatedHz.Value) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.RatedHz), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.RatedHz = matching.MatchingRatedHz.Value; + result = true; + } + if (matching.MatchingCurrentHz.HasValue) + { + var speedRatio = matching.MatchingCurrentHz.Value / visual.RatedHz; + if (visual.SpeedRatio != speedRatio) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.SpeedRatio), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.SpeedRatio = speedRatio; + result = true; + } - // if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) - // { - // //娴侀噺鎵▼鏇茬嚎 - // var curveqh = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH); - // if (curveqh == null) - // { - // curveqh = new Yw.Model.HydroCurveInfo(); - // curveqh.Catalog = Yw.Hydro.ParterCatalog.Curve; - // curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); - // curveqh.Name = "鍖归厤"; - // curveqh.ModelType = string.Empty; - // curveqh.DbLocked = false; - // curveqh.DbId = matching.MatchingCurveDbId; - // curveqh.CurveType = Yw.WinFrmUI.HydroCurve.PumpQH; - // curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // if (hydroInfo.Curves == null) - // { - // hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); - // } - // hydroInfo.Curves.Add(curveqh); - // pump.CurveQH = curveqh.Code; - // } - // else - // { - // if (!curveqh.DbLocked) - // { - // curveqh.DbId = matching.MatchingCurveDbId; - // curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // } - // } + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + //娴侀噺鎵▼鏇茬嚎 + var curveqh = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQH); + if (curveqh == null) + { + curveqh = new Yw.Model.HydroCurveInfo(); + curveqh.Catalog = Yw.Hydro.ParterCatalog.Curve; + curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curveqh.Name = "鍖归厤"; + curveqh.ModelType = string.Empty; + curveqh.DbLocked = false; + curveqh.DbId = matching.MatchingCurveDbId; + curveqh.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQH; + curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curveqh); + visual.CurveQH = curveqh.Code; + changeHelper?.Append(curveqh, eChangeType.Add); + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + result = true; + } + else + { + if (!curveqh.DbLocked) + { + curveqh.DbId = matching.MatchingCurveDbId; + curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curveqh, eChangeType.Update); + result = true; + } + } - // //娴侀噺鍔熺巼鏇茬嚎 - // var curveqp = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP); - // if (curveqp == null) - // { - // curveqp = new Yw.Model.HydroCurveInfo(); - // curveqp.Catalog = Yw.Hydro.ParterCatalog.Curve; - // curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); - // curveqp.Name = "鍖归厤"; - // curveqp.ModelType = string.Empty; - // curveqp.DbLocked = false; - // curveqp.DbId = matching.MatchingCurveDbId; - // curveqp.CurveType = Yw.WinFrmUI.HydroCurve.PumpQP; - // curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // if (hydroInfo.Curves == null) - // { - // hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); - // } - // hydroInfo.Curves.Add(curveqp); - // pump.CurveQP = curveqp.Code; - // } - // else - // { - // if (!curveqp.DbLocked) - // { - // curveqp.DbId = matching.MatchingCurveDbId; - // curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // } - // } + //娴侀噺鍔熺巼鏇茬嚎 + var curveqp = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQP); + if (curveqp == null) + { + curveqp = new Yw.Model.HydroCurveInfo(); + curveqp.Catalog = Yw.Hydro.ParterCatalog.Curve; + curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curveqp.Name = "鍖归厤"; + curveqp.ModelType = string.Empty; + curveqp.DbLocked = false; + curveqp.DbId = matching.MatchingCurveDbId; + curveqp.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQP; + curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curveqp); + visual.CurveQP = curveqp.Code; + changeHelper?.Append(curveqp, eChangeType.Add); + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + result = true; + } + else + { + if (!curveqp.DbLocked) + { + curveqp.DbId = matching.MatchingCurveDbId; + curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curveqp, eChangeType.Update); + result = true; + } + } - // //娴侀噺鏁堢巼鏇茬嚎 - // var curveqe = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQE); - // if (curveqe == null) - // { - // curveqe = new Yw.Model.HydroCurveInfo(); - // curveqe.Catalog = Yw.Hydro.ParterCatalog.Curve; - // curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); - // curveqe.Name = "鍖归厤"; - // curveqe.ModelType = string.Empty; - // curveqe.DbLocked = false; - // curveqe.DbId = matching.MatchingCurveDbId; - // curveqe.CurveType = Yw.WinFrmUI.HydroCurve.PumpQE; - // curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // if (hydroInfo.Curves == null) - // { - // hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); - // } - // hydroInfo.Curves.Add(curveqe); - // pump.CurveQE = curveqe.Code; - // } - // else - // { - // if (!curveqe.DbLocked) - // { - // curveqe.DbId = matching.MatchingCurveDbId; - // curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // } - // } + //娴侀噺鏁堢巼鏇茬嚎 + var curveqe = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQE); + if (curveqe == null) + { + curveqe = new Yw.Model.HydroCurveInfo(); + curveqe.Catalog = Yw.Hydro.ParterCatalog.Curve; + curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curveqe.Name = "鍖归厤"; + curveqe.ModelType = string.Empty; + curveqe.DbLocked = false; + curveqe.DbId = matching.MatchingCurveDbId; + curveqe.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQE; + curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curveqe); + visual.CurveQE = curveqe.Code; + changeHelper?.Append(curveqe, eChangeType.Add); + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQE), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + result = true; + } + else + { + if (!curveqe.DbLocked) + { + curveqe.DbId = matching.MatchingCurveDbId; + curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curveqe, eChangeType.Update); + result = true; + } + } + } + } - // } - - // result = true; - // } - // } - - // return result; - //} + return result; + } #endregion - ///// <summary> - ///// 搴旂敤闃�闂ㄨ嚜鍔ㄥ尮閰峍iewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ValveMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } + #region 闃�闂� - // bool result = false; + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(HydroValveViewModel visualViewModel, HydroValveMatchingViewModel matching) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + visualViewModel.UpdateProperty(); + return bol; + } - // var valve = hydroInfo.Valves?.Find(x => x.Code == matching.Code); - // if (valve != null) - // { - // valve.DbLocked = matching.DbLocked; - // valve.ModelType = matching.ModelType; - // valve.Material = matching.Material; - // valve.Diameter = matching.Diameter; - // valve.MinorLoss = matching.MinorLoss; - // switch (matching.ValveType) - // { - // case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break; - // case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break; - // case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break; - // case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break; - // case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break; - // case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break; - // case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break; - // default: break; - // } - // valve.ValveSetting = matching.ValveSetting; + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo visual, HydroValveMatchingViewModel matching) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } - // if (!valve.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // valve.DbId = matching.MatchingDbId; - // } - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // valve.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingMaterial)) - // { - // valve.Material = matching.MatchingMaterial; - // } - // if (matching.MatchingDiameter.HasValue) - // { - // valve.Diameter = matching.MatchingDiameter.Value; - // } - // if (matching.MatchingMinorLoss.HasValue) - // { - // valve.MinorLoss = matching.MatchingMinorLoss.Value; - // } - // if (matching.MatchingValveType.HasValue) - // { - // switch (matching.MatchingValveType.Value) - // { - // case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break; - // case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break; - // case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break; - // case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break; - // case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break; - // case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break; - // case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break; - // default: break; - // } - // } - // switch (valve.ValveType) - // { - // case Yw.Hydro.ValveType.PSV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) - // { - // valve.ValveSetting = matching.MatchingValveSetting; - // } - // } - // break; - // case Yw.Hydro.ValveType.PBV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) - // { - // valve.ValveSetting = matching.MatchingValveSetting; - // } - // } - // break; - // case Yw.Hydro.ValveType.PRV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) - // { - // valve.ValveSetting = matching.MatchingValveSetting; - // } - // } - // break; - // case Yw.Hydro.ValveType.FCV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) - // { - // valve.ValveSetting = matching.MatchingValveSetting; - // } - // } - // break; - // case Yw.Hydro.ValveType.TCV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) - // { - // //闃�闂ㄥ紑搴︽崯澶辩郴鏁版洸绾� - // var curveol = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting); - // if (curveol == null) - // { - // curveol = new Yw.Model.HydroCurveInfo(); - // curveol.Catalog = Yw.Hydro.ParterCatalog.Curve; - // curveol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); - // curveol.Name = "鍖归厤"; - // curveol.ModelType = valve.ModelType; - // curveol.DbLocked = false; - // curveol.DbId = matching.MatchingCurveDbId; - // curveol.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL; - // curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // if (hydroInfo.Curves == null) - // { - // hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); - // } - // hydroInfo.Curves.Add(curveol); - // valve.ValveSetting = curveol.Code; - // } - // else - // { - // if (!curveol.DbLocked) - // { - // curveol.DbId = matching.MatchingCurveDbId; - // curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // } - // } - // } - // } - // break; - // case Yw.Hydro.ValveType.GPV: - // { - // if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) - // { - // //闃�闂ㄥ紑搴︽崯澶辩郴鏁版洸绾� - // var curveql = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting); - // if (curveql == null) - // { - // curveql = new Yw.Model.HydroCurveInfo(); - // curveql.Catalog = Yw.Hydro.ParterCatalog.Curve; - // curveql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); - // curveql.Name = "鍖归厤"; - // curveql.ModelType = valve.ModelType; - // curveql.DbLocked = false; - // curveql.DbId = matching.MatchingCurveDbId; - // curveql.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL; - // curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // if (hydroInfo.Curves == null) - // { - // hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); - // } - // hydroInfo.Curves.Add(curveql); - // valve.ValveSetting = curveql.Code; - // } - // else - // { - // if (!curveql.DbLocked) - // { - // curveql.DbId = matching.MatchingCurveDbId; - // curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); - // } - // } - // } - // } - // break; - // case Yw.Hydro.ValveType.CV: - // { + visual.Name = matching.Name; + visual.DbLocked = matching.DbLocked; + visual.DbId = matching.DbId; + visual.ModelType = matching.ModelType; + visual.Material = matching.Material; + visual.Diameter = matching.Diameter; + visual.MinorLoss = matching.MinorLoss; + visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.ValveType); + visual.ValveSetting = matching.ValveSetting; - // } - // break; - // } + bool result = false; - // result = true; - // } - // } - // return result; - //} + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + visual.DbId = matching.MatchingDbId; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingDiameter.HasValue) + { + visual.Diameter = matching.MatchingDiameter.Value; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } + if (matching.MatchingValveType.HasValue) + { + visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value); + result = true; + } + switch (visual.ValveType) + { + case Yw.Hydro.ValveType.PSV: + { + if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) + { + visual.ValveSetting = matching.MatchingValveSetting; + result = true; + } + } + break; + case Yw.Hydro.ValveType.PBV: + { + if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) + { + visual.ValveSetting = matching.MatchingValveSetting; + result = true; + } + } + break; + case Yw.Hydro.ValveType.PRV: + { + if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) + { + visual.ValveSetting = matching.MatchingValveSetting; + result = true; + } + } + break; + case Yw.Hydro.ValveType.FCV: + { + if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) + { + visual.ValveSetting = matching.MatchingValveSetting; + result = true; + } + } + break; + case Yw.Hydro.ValveType.TCV: + { + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + //闃�闂ㄥ紑搴︽崯澶辩郴鏁版洸绾� + var curveol = hydroInfo.Curves?.Find(x => x.Code == visual.ValveSetting); + if (curveol == null) + { + curveol = new Yw.Model.HydroCurveInfo(); + curveol.Catalog = Yw.Hydro.ParterCatalog.Curve; + curveol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curveol.Name = "鍖归厤"; + curveol.ModelType = visual.ModelType; + curveol.DbLocked = false; + curveol.DbId = matching.MatchingCurveDbId; + curveol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveOL; + curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curveol); + visual.ValveSetting = curveol.Code; + result = true; + } + else + { + if (!curveol.DbLocked) + { + curveol.DbId = matching.MatchingCurveDbId; + curveol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveOL; + curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + result = true; + } + } + } + } + break; + case Yw.Hydro.ValveType.GPV: + { + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + //姘村ご鎹熷け鏇茬嚎 + var curveql = hydroInfo.Curves?.Find(x => x.Code == visual.ValveSetting); + if (curveql == null) + { + curveql = new Yw.Model.HydroCurveInfo(); + curveql.Catalog = Yw.Hydro.ParterCatalog.Curve; + curveql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curveql.Name = "鍖归厤"; + curveql.ModelType = visual.ModelType; + curveql.DbLocked = false; + curveql.DbId = matching.MatchingCurveDbId; + curveql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; + curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curveql); + visual.ValveSetting = curveql.Code; + result = true; + } + else + { + if (!curveql.DbLocked) + { + curveql.DbId = matching.MatchingCurveDbId; + curveql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; + curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + result = true; + } + } + } + } + break; + case Yw.Hydro.ValveType.CV: + { - ///// <summary> - ///// 搴旂敤绠¢亾鑷姩鍖归厤ViewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PipeMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } + } + break; + } + } + return result; + } - // bool result = false; + #endregion - // var pipe = hydroInfo.Pipes?.Find(x => x.Code == matching.Code); - // if (pipe != null) - // { - // pipe.DbLocked = matching.DbLocked; - // pipe.ModelType = matching.ModelType; - // pipe.Diameter = matching.Diameter; - // pipe.Material = matching.Material; - // pipe.Roughness = matching.Roughness; - // pipe.MinorLoss = matching.MinorLoss; + #region 鎹㈢儹鍣� - // if (!pipe.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // pipe.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // pipe.DbId = matching.MatchingDbId; - // } - // if (matching.MatchingDiameter.HasValue) - // { - // pipe.Diameter = matching.MatchingDiameter.Value; - // } - // if (!string.IsNullOrEmpty(matching.MatchingMaterial)) - // { - // pipe.Material = matching.MatchingMaterial; - // } - // if (matching.MatchingRoughness.HasValue) - // { - // pipe.Roughness = matching.MatchingRoughness.Value; - // } - // if (matching.MatchingMinorLoss.HasValue) - // { - // pipe.MinorLoss = matching.MatchingMinorLoss.Value; - // } + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(HydroExchangerViewModel visualViewModel, HydroExchangerMatchingViewModel matching) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + visualViewModel.UpdateProperty(); + return bol; + } - // result = true; - // } - // } - // return result; - //} + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroExchangerInfo visual, HydroExchangerMatchingViewModel matching) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + visual.Name = matching.Name; + visual.DbLocked = matching.DbLocked; + visual.DbId = matching.DbId; + visual.ModelType = matching.ModelType; + visual.Material = matching.Material; + visual.Diameter = matching.Diameter; + visual.MinorLoss = matching.MinorLoss; - ///// <summary> - ///// 搴旂敤寮ご鑷姩鍖归厤ViewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ElbowMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + visual.DbId = matching.MatchingDbId; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingDiameter.HasValue) + { + visual.Diameter = matching.MatchingDiameter.Value; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } - // bool result = false; + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + var curvevql = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQL); + if (curvevql == null) + { + curvevql = new Yw.Model.HydroCurveInfo(); + curvevql.Catalog = Yw.Hydro.ParterCatalog.Curve; + curvevql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curvevql.Name = "鍖归厤"; + curvevql.ModelType = string.Empty; + curvevql.DbLocked = false; + curvevql.DbId = matching.MatchingCurveDbId; + curvevql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; + curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curvevql); + visual.CurveQL = curvevql.Code; + result = true; + } + else + { + if (!curvevql.DbLocked) + { + curvevql.DbId = matching.MatchingCurveDbId; + curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + result = true; + } + } + } + } + return result; + } - // var elbow = hydroInfo.Elbows?.Find(x => x.Code == matching.Code); - // if (elbow != null) - // { - // elbow.DbLocked = matching.DbLocked; - // elbow.ModelType = matching.ModelType; - // elbow.Caliber = matching.Caliber; - // elbow.Material = matching.Material; - // elbow.MinorLoss = matching.MinorLoss; + #endregion - // if (!elbow.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // elbow.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // elbow.DbId = matching.MatchingDbId; - // } - // if (matching.MatchingCaliber.HasValue) - // { - // elbow.Caliber = matching.MatchingCaliber.Value; - // } - // if (!string.IsNullOrEmpty(matching.MatchingMaterial)) - // { - // elbow.Material = matching.MatchingMaterial; - // } - // if (matching.MatchingMinorLoss.HasValue) - // { - // elbow.MinorLoss = matching.MatchingMinorLoss.Value; - // } + #region 绌哄帇鏈� - // result = true; - // } - // } - // return result; - //} + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(HydroCompressorViewModel visualViewModel, HydroCompressorMatchingViewModel matching) + { + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + visualViewModel.UpdateProperty(); + return bol; + } - ///// <summary> - ///// 搴旂敤涓夐�氳嚜鍔ㄥ尮閰峍iewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ThreelinkMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } + /// <summary> + /// 搴旂敤 + /// </summary> + public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCompressorInfo visual, HydroCompressorMatchingViewModel matching) + { + if (hydroInfo == null) + { + return false; + } + if (visual == null) + { + return false; + } + if (matching == null) + { + return false; + } + visual.Name = matching.Name; + visual.DbLocked = matching.DbLocked; + visual.DbId = matching.DbId; + visual.ModelType = matching.ModelType; + visual.Material = matching.Material; + visual.Diameter = matching.Diameter; + visual.MinorLoss = matching.MinorLoss; - // bool result = false; + bool result = false; + if (!visual.DbLocked) + { + if (!string.IsNullOrEmpty(matching.MatchingModelType)) + { + visual.ModelType = matching.MatchingModelType; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingDbId)) + { + visual.DbId = matching.MatchingDbId; + result = true; + } + if (!string.IsNullOrEmpty(matching.MatchingMaterial)) + { + visual.Material = matching.MatchingMaterial; + result = true; + } + if (matching.MatchingDiameter.HasValue) + { + visual.Diameter = matching.MatchingDiameter.Value; + result = true; + } + if (matching.MatchingMinorLoss.HasValue) + { + visual.MinorLoss = matching.MatchingMinorLoss.Value; + result = true; + } - // var threelink = hydroInfo.Threelinks?.Find(x => x.Code == matching.Code); - // if (threelink != null) - // { - // threelink.DbLocked = matching.DbLocked; - // threelink.ModelType = matching.ModelType; - // threelink.Caliber = matching.Caliber; - // threelink.Material = matching.Material; - // threelink.MinorLoss = matching.MinorLoss; + if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) + { + var curvevql = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQL); + if (curvevql == null) + { + curvevql = new Yw.Model.HydroCurveInfo(); + curvevql.Catalog = Yw.Hydro.ParterCatalog.Curve; + curvevql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes()); + curvevql.Name = "鍖归厤"; + curvevql.ModelType = string.Empty; + curvevql.DbLocked = false; + curvevql.DbId = matching.MatchingCurveDbId; + curvevql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; + curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + if (hydroInfo.Curves == null) + { + hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); + } + hydroInfo.Curves.Add(curvevql); + visual.CurveQL = curvevql.Code; + result = true; + } + else + { + if (!curvevql.DbLocked) + { + curvevql.DbId = matching.MatchingCurveDbId; + curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + result = true; + } + } + } + } + return result; + } - // if (!threelink.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // threelink.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // threelink.DbId = matching.MatchingDbId; - // } - // if (matching.MatchingCaliber.HasValue) - // { - // threelink.Caliber = matching.MatchingCaliber.Value; - // } - // if (!string.IsNullOrEmpty(matching.MatchingMaterial)) - // { - // threelink.Material = matching.MatchingMaterial; - // } - // if (matching.MatchingMinorLoss.HasValue) - // { - // threelink.MinorLoss = matching.MatchingMinorLoss.Value; - // } - - // result = true; - // } - // } - // return result; - //} - - ///// <summary> - ///// 搴旂敤鍥涢�氳嚜鍔ㄥ尮閰峍iewModel - ///// </summary> - //public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, FourlinkMatchingViewModel matching) - //{ - // if (hydroInfo == null) - // { - // return false; - // } - // if (matching == null) - // { - // return false; - // } - - // bool result = false; - - // var fourlink = hydroInfo.Fourlinks?.Find(x => x.Code == matching.Code); - // if (fourlink != null) - // { - // fourlink.DbLocked = matching.DbLocked; - // fourlink.ModelType = matching.ModelType; - // fourlink.Caliber = matching.Caliber; - // fourlink.Material = matching.Material; - // fourlink.MinorLoss = matching.MinorLoss; - - // if (!fourlink.DbLocked) - // { - // if (!string.IsNullOrEmpty(matching.MatchingModelType)) - // { - // fourlink.ModelType = matching.MatchingModelType; - // } - // if (!string.IsNullOrEmpty(matching.MatchingDbId)) - // { - // fourlink.DbId = matching.MatchingDbId; - // } - // if (matching.MatchingCaliber.HasValue) - // { - // fourlink.Caliber = matching.MatchingCaliber.Value; - // } - // if (!string.IsNullOrEmpty(matching.MatchingMaterial)) - // { - // fourlink.Material = matching.MatchingMaterial; - // } - // if (matching.MatchingMinorLoss.HasValue) - // { - // fourlink.MinorLoss = matching.MatchingMinorLoss.Value; - // } - - // result = true; - // } - // } - // return result; - //} + #endregion #endregion -- Gitblit v1.9.3