From 95e7fe3b1dc1c1bc6bb8e48425f0bac2080e3568 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期二, 07 一月 2025 17:44:26 +0800 Subject: [PATCH] 匹配增加状态判断 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs | 1287 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 1,030 insertions(+), 257 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 ca67a33..9e48ccf 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,5 +1,6 @@ 锘縰sing DevExpress.XtraSpreadsheet.Model.CopyOperation; using System.Windows.Media.Imaging; +using Yw.Ahart; using Yw.DAL.Basic; using Yw.EPAnet; using Yw.Hydro; @@ -684,7 +685,13 @@ /// <summary> /// 搴旂敤鑷姩鍖归厤ViewModel /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, HydroMatchingViewModel matchingInfo) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + HydroMatchingViewModel matchingInfo, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -707,7 +714,7 @@ allTanks.ForEach(x => { var matching = matchingInfo.Tanks.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -727,7 +734,7 @@ hydroInfo.Bluntheads.ForEach(x => { var matching = matchingInfo.Bluntheads.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -746,7 +753,7 @@ hydroInfo.Elbows.ForEach(x => { var matching = matchingInfo.Elbows.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -765,7 +772,7 @@ hydroInfo.Threelinks.ForEach(x => { var matching = matchingInfo.Threelinks.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -784,7 +791,7 @@ hydroInfo.Fourlinks.ForEach(x => { var matching = matchingInfo.Fourlinks.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -803,7 +810,7 @@ hydroInfo.Nozzles.ForEach(x => { var matching = matchingInfo.Nozzles.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -822,7 +829,7 @@ hydroInfo.Hydrants.ForEach(x => { var matching = matchingInfo.Hydrants.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -841,7 +848,7 @@ hydroInfo.Coolings.ForEach(x => { var matching = matchingInfo.Coolings.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -860,7 +867,7 @@ hydroInfo.Meters.ForEach(x => { var matching = matchingInfo.Meters.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -879,7 +886,7 @@ hydroInfo.Flowmeters.ForEach(x => { var matching = matchingInfo.Flowmeters.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -898,7 +905,7 @@ hydroInfo.Pressmeters.ForEach(x => { var matching = matchingInfo.Pressmeters.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -917,7 +924,7 @@ hydroInfo.Pipes.ForEach(x => { var matching = matchingInfo.Pipes.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -936,7 +943,7 @@ hydroInfo.Translations.ForEach(x => { var matching = matchingInfo.Translations.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -955,7 +962,7 @@ hydroInfo.Pumps.ForEach(x => { var matching = matchingInfo.Pumps.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -974,7 +981,7 @@ hydroInfo.Valves.ForEach(x => { var matching = matchingInfo.Valves.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -993,7 +1000,7 @@ hydroInfo.Exchangers.ForEach(x => { var matching = matchingInfo.Exchangers.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -1012,7 +1019,7 @@ hydroInfo.Compressors.ForEach(x => { var matching = matchingInfo.Compressors.Find(t => t.Code == x.Code); - if (Apply(hydroInfo, x, matching)) + if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper)) { result = true; } @@ -1030,9 +1037,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroTankViewModel visualViewModel, HydroTankMatchingViewModel matching) + public static bool Apply + ( + HydroTankViewModel visualViewModel, + HydroTankMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1040,7 +1053,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroTankInfo visual, HydroTankMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroTankInfo visual, + HydroTankMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1054,58 +1074,86 @@ { 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; + //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)) { - visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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)) { - visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.MinLevel), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.MaxLevel), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.DN), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.MinVol), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.OverFlow), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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; } @@ -1129,6 +1177,7 @@ } hydroInfo.Curves.Add(curvevol); visual.VolCurve = curvevol.Code; + changeHelper?.Append(curvevol, eChangeType.Add); result = true; } else @@ -1137,7 +1186,22 @@ { 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); } } } @@ -1152,9 +1216,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroBluntheadViewModel visualViewModel, HydroBluntheadMatchingViewModel matching) + public static bool Apply + ( + HydroBluntheadViewModel visualViewModel, + HydroBluntheadMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1162,7 +1232,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroBluntheadInfo visual, HydroBluntheadMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroBluntheadInfo visual, + HydroBluntheadMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1176,39 +1253,64 @@ { 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.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; } @@ -1223,9 +1325,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroElbowViewModel visualViewModel, HydroElbowMatchingViewModel matching) + public static bool Apply + ( + HydroElbowViewModel visualViewModel, + HydroElbowMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1233,7 +1341,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroElbowInfo visual, HydroElbowMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroElbowInfo visual, + HydroElbowMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1247,55 +1362,91 @@ { 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); - } + //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) { - visual.ElbowType = HydroElbowTypeEnumHelper.GetElbowTypeName(matching.MatchingElbowType.Value); + 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; } } @@ -1309,9 +1460,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroThreelinkViewModel visualViewModel, HydroThreelinkMatchingViewModel matching) + public static bool Apply + ( + HydroThreelinkViewModel visualViewModel, + HydroThreelinkMatchingViewModel matching, + HydroChangeHelper changeHelper, + HydroPropStatusHelper propStatusHelper + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1319,7 +1476,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroThreelinkInfo visual, HydroThreelinkMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroThreelinkInfo visual, + HydroThreelinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1333,51 +1497,86 @@ { 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; + //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; } @@ -1392,9 +1591,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroFourlinkViewModel visualViewModel, HydroFourlinkMatchingViewModel matching) + public static bool Apply + ( + HydroFourlinkViewModel visualViewModel, + HydroFourlinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1402,7 +1607,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFourlinkInfo visual, HydroFourlinkMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroFourlinkInfo visual, + HydroFourlinkMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1416,39 +1628,64 @@ { 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.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; } @@ -1463,9 +1700,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroNozzleViewModel visualViewModel, HydroNozzleMatchingViewModel matching) + public static bool Apply + ( + HydroNozzleViewModel visualViewModel, + HydroNozzleMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1473,7 +1716,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroNozzleInfo visual, HydroNozzleMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroNozzleInfo visual, + HydroNozzleMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1487,45 +1737,75 @@ { 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.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; } @@ -1540,9 +1820,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroHydrantViewModel visualViewModel, HydroHydrantMatchingViewModel matching) + public static bool Apply + ( + HydroHydrantViewModel visualViewModel, + HydroHydrantMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1550,7 +1836,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroHydrantInfo visual, HydroHydrantMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroHydrantInfo visual, + HydroHydrantMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1564,45 +1857,75 @@ { 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.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; } @@ -1617,9 +1940,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroCoolingViewModel visualViewModel, HydroCoolingMatchingViewModel matching) + public static bool Apply + ( + HydroCoolingViewModel visualViewModel, + HydroCoolingMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1627,7 +1956,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCoolingInfo visual, HydroCoolingMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroCoolingInfo visual, + HydroCoolingMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1641,58 +1977,86 @@ { 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; + //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)) { - visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.ModelType}"); + 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)) { - visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.DbId}"); + 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) { - visual.UpdatePropStatus(nameof(visual.Caliber), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.Caliber}"); + 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)) { - visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.Material}"); + 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) { - visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.MinorLoss}"); + 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) { - visual.UpdatePropStatus(nameof(visual.Coefficient), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.Coefficient}"); + 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) { - visual.UpdatePropStatus(nameof(visual.LowerLimit), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師鏁版嵁:{visual.LowerLimit}"); + 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; } @@ -1707,9 +2071,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroMeterViewModel visualViewModel, HydroMeterMatchingViewModel matching) + public static bool Apply + ( + HydroMeterViewModel visualViewModel, + HydroMeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1717,7 +2087,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroMeterInfo visual, HydroMeterMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroMeterInfo visual, + HydroMeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1731,27 +2108,42 @@ { return false; } - visual.Name = matching.Name; - visual.DbLocked = matching.DbLocked; - visual.DbId = matching.DbId; - visual.ModelType = matching.ModelType; - visual.MinorLoss = matching.MinorLoss; + //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; } @@ -1766,9 +2158,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroFlowmeterViewModel visualViewModel, HydroFlowmeterMatchingViewModel matching) + public static bool Apply + ( + HydroFlowmeterViewModel visualViewModel, + HydroFlowmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1776,7 +2174,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFlowmeterInfo visual, HydroFlowmeterMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroFlowmeterInfo visual, + HydroFlowmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1790,27 +2195,42 @@ { return false; } - visual.Name = matching.Name; - visual.DbLocked = matching.DbLocked; - visual.DbId = matching.DbId; - visual.ModelType = matching.ModelType; - visual.MinorLoss = matching.MinorLoss; + //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; } @@ -1825,9 +2245,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroPressmeterViewModel visualViewModel, HydroPressmeterMatchingViewModel matching) + public static bool Apply + ( + HydroPressmeterViewModel visualViewModel, + HydroPressmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1835,7 +2261,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPressmeterInfo visual, HydroPressmeterMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPressmeterInfo visual, + HydroPressmeterMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1849,27 +2282,42 @@ { return false; } - visual.Name = matching.Name; - visual.DbLocked = matching.DbLocked; - visual.DbId = matching.DbId; - visual.ModelType = matching.ModelType; - visual.MinorLoss = matching.MinorLoss; + //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; } @@ -1884,9 +2332,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroPipeViewModel visualViewModel, HydroPipeMatchingViewModel matching) + public static bool Apply + ( + HydroPipeViewModel visualViewModel, + HydroPipeMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1894,7 +2348,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPipeInfo visual, HydroPipeMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPipeInfo visual, + HydroPipeMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1909,14 +2370,14 @@ 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; + //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; @@ -1924,31 +2385,61 @@ { 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; } @@ -1963,9 +2454,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroTranslationViewModel visualViewModel, HydroTranslationMatchingViewModel matching) + public static bool Apply + ( + HydroTranslationViewModel visualViewModel, + HydroTranslationMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -1973,7 +2470,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroTranslationInfo visual, HydroTranslationMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroTranslationInfo visual, + HydroTranslationMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -1988,16 +2492,16 @@ 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; + //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; @@ -2005,42 +2509,82 @@ { 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.MatchingStartDiameter.HasValue) - { - visual.StartDiameter = matching.MatchingStartDiameter.Value; - result = true; - } - if (matching.MatchingEndDiameter.HasValue) - { - visual.EndDiameter = matching.MatchingEndDiameter.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; } } @@ -2054,9 +2598,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroPumpViewModel visualViewModel, HydroPumpMatchingViewModel matching) + public static bool Apply + ( + HydroPumpViewModel visualViewModel, + HydroPumpMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -2064,7 +2614,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPumpInfo visual, HydroPumpMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroPumpInfo visual, + HydroPumpMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -2079,66 +2636,99 @@ return false; } - 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; + //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; bool result = false; if (!visual.DbLocked) { if (!string.IsNullOrEmpty(matching.MatchingModelType)) { - visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.ModelType}"); + 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)) { - visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.DbId}"); + 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) { - visual.UpdatePropStatus(nameof(visual.RatedQ), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.RatedQ}"); + 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) { - visual.UpdatePropStatus(nameof(visual.RatedH), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.RatedH}"); + 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) { - visual.UpdatePropStatus(nameof(visual.RatedP), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.RatedP}"); + 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) { - visual.UpdatePropStatus(nameof(visual.RatedN), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.RatedN}"); + 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) { - visual.UpdatePropStatus(nameof(visual.RatedHz), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.RatedHz}"); + 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) { - visual.UpdatePropStatus(nameof(visual.SpeedRatio), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇锛屽師濮嬫暟鎹�:{visual.SpeedRatio}"); - visual.SpeedRatio = matching.MatchingCurrentHz.Value / visual.RatedHz; + 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; } @@ -2162,8 +2752,9 @@ hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); } hydroInfo.Curves.Add(curveqh); - visual.UpdatePropStatus(nameof(visual.CurveQH), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.CurveQH = curveqh.Code; + changeHelper?.Append(curveqh, eChangeType.Add); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } else @@ -2172,6 +2763,8 @@ { 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); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } } @@ -2194,8 +2787,9 @@ hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); } hydroInfo.Curves.Add(curveqp); - visual.UpdatePropStatus(nameof(visual.CurveQP), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.CurveQP = curveqp.Code; + changeHelper?.Append(curveqp, eChangeType.Add); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } else @@ -2204,6 +2798,8 @@ { 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); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } } @@ -2226,8 +2822,9 @@ hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); } hydroInfo.Curves.Add(curveqe); - visual.UpdatePropStatus(nameof(visual.CurveQE), ePropStatus.Matching, $"閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.CurveQE = curveqe.Code; + changeHelper?.Append(curveqe, eChangeType.Add); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQE), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } else @@ -2236,7 +2833,42 @@ { 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); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQE), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; + } + } + } + else + { + if (!string.IsNullOrEmpty(visual.CurveQH)) + { + var curveQH = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQH); + if (curveQH != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQH); + visual.CurveQH = string.Empty; + changeHelper?.Append(curveQH, eChangeType.Remove); + } + } + if (!string.IsNullOrEmpty(visual.CurveQP)) + { + var curveQP = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQP); + if (curveQP != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQP); + visual.CurveQP = string.Empty; + changeHelper?.Append(curveQP, eChangeType.Remove); + } + } + if (!string.IsNullOrEmpty(visual.CurveQE)) + { + var curveQE = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQE); + if (curveQE != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQE); + visual.CurveQE = string.Empty; + changeHelper?.Append(curveQE, eChangeType.Remove); } } } @@ -2252,9 +2884,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroValveViewModel visualViewModel, HydroValveMatchingViewModel matching) + public static bool Apply + ( + HydroValveViewModel visualViewModel, + HydroValveMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -2262,7 +2900,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo visual, HydroValveMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroValveInfo visual, + HydroValveMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -2277,15 +2922,15 @@ 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; - visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.ValveType); - visual.ValveSetting = matching.ValveSetting; + // 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; bool result = false; @@ -2293,38 +2938,63 @@ { if (!string.IsNullOrEmpty(matching.MatchingModelType)) { - visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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)) { - visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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)) { - visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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) { - visual.UpdatePropStatus(nameof(visual.Diameter), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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.MatchingMinorLoss.HasValue) { - visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); + 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.MatchingValveType.HasValue) { - visual.UpdatePropStatus(nameof(visual.ValveType), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); - visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value); + var valveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value); + if (visual.ValveType != valveType) + { + changeHelper?.Append(visual, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ValveType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); + } + visual.ValveType = valveType; result = true; } switch (visual.ValveType) @@ -2333,7 +3003,6 @@ { if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) { - visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.ValveSetting = matching.MatchingValveSetting; result = true; } @@ -2343,7 +3012,6 @@ { if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) { - visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.ValveSetting = matching.MatchingValveSetting; result = true; } @@ -2353,7 +3021,6 @@ { if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) { - visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.ValveSetting = matching.MatchingValveSetting; result = true; } @@ -2363,7 +3030,6 @@ { if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) { - visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); visual.ValveSetting = matching.MatchingValveSetting; result = true; } @@ -2399,6 +3065,7 @@ 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; } @@ -2436,6 +3103,7 @@ 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; } @@ -2460,9 +3128,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroExchangerViewModel visualViewModel, HydroExchangerMatchingViewModel matching) + public static bool Apply + ( + HydroExchangerViewModel visualViewModel, + HydroExchangerMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -2470,7 +3144,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroExchangerInfo visual, HydroExchangerMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroExchangerInfo visual, + HydroExchangerMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -2484,39 +3165,64 @@ { 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; + //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; 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.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; } @@ -2541,6 +3247,8 @@ } hydroInfo.Curves.Add(curvevql); visual.CurveQL = curvevql.Code; + changeHelper?.Append(curvevql, eChangeType.Add); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } else @@ -2549,7 +3257,22 @@ { curvevql.DbId = matching.MatchingCurveDbId; curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curvevql, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; + } + } + } + else + { + if (!string.IsNullOrEmpty(visual.CurveQL)) + { + var curveql = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQL); + if (curveql != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQL); + visual.CurveQL = string.Empty; + changeHelper?.Append(curveql, eChangeType.Remove); } } } @@ -2564,9 +3287,15 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(HydroCompressorViewModel visualViewModel, HydroCompressorMatchingViewModel matching) + public static bool Apply + ( + HydroCompressorViewModel visualViewModel, + HydroCompressorMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); + var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); visualViewModel.UpdateProperty(); return bol; } @@ -2574,7 +3303,14 @@ /// <summary> /// 搴旂敤 /// </summary> - public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCompressorInfo visual, HydroCompressorMatchingViewModel matching) + public static bool Apply + ( + Yw.Model.HydroModelInfo hydroInfo, + Yw.Model.HydroCompressorInfo visual, + HydroCompressorMatchingViewModel matching, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { if (hydroInfo == null) { @@ -2588,45 +3324,65 @@ { 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; + //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; 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; - visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); 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; - visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); 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; - visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); 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; - visual.UpdatePropStatus(nameof(visual.Diameter), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); 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; - visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, "閫氳繃鍩虹鏁版嵁鍖归厤淇"); result = true; } @@ -2650,6 +3406,8 @@ } hydroInfo.Curves.Add(curvevql); visual.CurveQL = curvevql.Code; + changeHelper?.Append(curvevql, eChangeType.Add); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } else @@ -2658,10 +3416,25 @@ { curvevql.DbId = matching.MatchingCurveDbId; curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); + changeHelper?.Append(curvevql, eChangeType.Update); + propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼"); result = true; } } } + else + { + if (!string.IsNullOrEmpty(visual.CurveQL)) + { + var curveql = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQL); + if (curveql != null) + { + hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQL); + visual.CurveQL = string.Empty; + changeHelper?.Append(curveql, eChangeType.Remove); + } + } + } } return result; } -- Gitblit v1.9.3