| | |
| | | using System.Transactions; |
| | | |
| | | namespace HStation.Service |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// Revit Json辅助类 |
| | |
| | | /// <summary> |
| | | /// 从json字符串中解析 |
| | | /// </summary> |
| | | public static HStation.Model.RevitModel FromJsonString(string revitJsonString, out string msg) |
| | | public static HStation.Model.RevitModel FromJsonString |
| | | ( |
| | | string revitJsonString, |
| | | string revitOthersJsonString, |
| | | out string msg |
| | | ) |
| | | { |
| | | msg = string.Empty; |
| | | if (string.IsNullOrEmpty(revitJsonString)) |
| | |
| | | msg = "Revit json 字符串为空"; |
| | | return default; |
| | | } |
| | | try |
| | | { |
| | | //try |
| | | //{ |
| | | var model = new Model.RevitModel(); |
| | | |
| | | //解析结构json |
| | | var jarray = JArray.Parse(revitJsonString); |
| | | for (int i = 0; i < jarray.Count; i++) |
| | | { |
| | |
| | | { |
| | | case RevitJsonCatalog.Reservoir: |
| | | { |
| | | var reservoir = new Model.RevitReservoir(); |
| | | reservoir.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | reservoir.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(reservoir.Code)) |
| | | var reservoir = ParseReservoir(jobject); |
| | | if (reservoir != null) |
| | | { |
| | | reservoir.Code = reservoir.Id; |
| | | model.Reservoirs.Add(reservoir); |
| | | } |
| | | reservoir.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | reservoir.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | reservoir.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | reservoir.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | reservoir.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | reservoir.Quality = quality; |
| | | } |
| | | reservoir.Position = reservoir.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | reservoir.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.Head].MatchNumeric(out double head)) |
| | | { |
| | | reservoir.Head = head; |
| | | } |
| | | reservoir.HeadPattern = jobject[RevitJsonProp.HeadPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(reservoir.HeadPattern)) |
| | | { |
| | | reservoir.HeadPattern = string.Empty; |
| | | } |
| | | model.Reservoirs.Add(reservoir); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Tank: |
| | | { |
| | | var tank = new Model.RevitTank(); |
| | | tank.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | tank.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(tank.Code)) |
| | | var tank = ParseTank(jobject); |
| | | if (tank != null) |
| | | { |
| | | tank.Code = tank.Id; |
| | | model.Tanks.Add(tank); |
| | | } |
| | | tank.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | tank.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | tank.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | tank.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | tank.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | tank.Quality = quality; |
| | | } |
| | | tank.Position = tank.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | tank.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | tank.InitLevel = initLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | tank.MinLevel = minLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | tank.MaxLevel = maxLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | tank.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | tank.MinVol = minVol; |
| | | } |
| | | tank.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(tank.VolCurve)) |
| | | { |
| | | tank.VolCurve = string.Empty; |
| | | } |
| | | model.Tanks.Add(tank); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Waterbox: |
| | | { |
| | | var waterbox = new Model.RevitWaterbox(); |
| | | waterbox.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | waterbox.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(waterbox.Code)) |
| | | var waterbox = ParseWaterbox(jobject); |
| | | if (waterbox != null) |
| | | { |
| | | waterbox.Code = waterbox.Id; |
| | | model.Waterboxs.Add(waterbox); |
| | | } |
| | | waterbox.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | waterbox.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | waterbox.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | waterbox.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | waterbox.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | waterbox.Quality = quality; |
| | | } |
| | | waterbox.Position = waterbox.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | waterbox.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | waterbox.InitLevel = initLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | waterbox.MinLevel = minLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | waterbox.MaxLevel = maxLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | waterbox.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | waterbox.MinVol = minVol; |
| | | } |
| | | waterbox.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(waterbox.VolCurve)) |
| | | { |
| | | waterbox.VolCurve = string.Empty; |
| | | } |
| | | model.Waterboxs.Add(waterbox); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Junction: |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | junction.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(junction.Code)) |
| | | var junction = ParseJunction(jobject); |
| | | if (junction != null) |
| | | { |
| | | junction.Code = junction.Id; |
| | | model.Junctions.Add(junction); |
| | | } |
| | | junction.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | junction.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | junction.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | junction.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | junction.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | junction.Quality = quality; |
| | | } |
| | | junction.Position = junction.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | junction.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | junction.Demand = demand; |
| | | } |
| | | junction.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(junction.DemandPattern)) |
| | | { |
| | | junction.DemandPattern = string.Empty; |
| | | } |
| | | model.Junctions.Add(junction); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Elbow: |
| | | { |
| | | var elbow = new Model.RevitElbow(); |
| | | elbow.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | elbow.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(elbow.Code)) |
| | | { |
| | | elbow.Code = elbow.Id; |
| | | } |
| | | elbow.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | elbow.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | elbow.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | elbow.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | elbow.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | elbow.Quality = quality; |
| | | } |
| | | elbow.Position = elbow.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | elbow.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | elbow.Demand = demand; |
| | | } |
| | | elbow.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(elbow.DemandPattern)) |
| | | { |
| | | elbow.DemandPattern = string.Empty; |
| | | } |
| | | model.Elbows.Add(elbow); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Threelink: |
| | | { |
| | | var threelink = new Model.RevitThreelink(); |
| | | threelink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | threelink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(threelink.Code)) |
| | | { |
| | | threelink.Code = threelink.Id; |
| | | } |
| | | threelink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | threelink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | threelink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | threelink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | threelink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | threelink.Quality = quality; |
| | | } |
| | | threelink.Position = threelink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | threelink.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | threelink.Demand = demand; |
| | | } |
| | | threelink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(threelink.DemandPattern)) |
| | | { |
| | | threelink.DemandPattern = string.Empty; |
| | | } |
| | | model.Threelinks.Add(threelink); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Fourlink: |
| | | { |
| | | var fourlink = new Model.RevitFourlink(); |
| | | fourlink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | fourlink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(fourlink.Code)) |
| | | { |
| | | fourlink.Code = fourlink.Id; |
| | | } |
| | | fourlink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | fourlink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | fourlink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | fourlink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | fourlink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | fourlink.Quality = quality; |
| | | } |
| | | fourlink.Position = fourlink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | fourlink.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | fourlink.Demand = demand; |
| | | } |
| | | fourlink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(fourlink.DemandPattern)) |
| | | { |
| | | fourlink.DemandPattern = string.Empty; |
| | | } |
| | | model.Fourlinks.Add(fourlink); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Meter: |
| | | { |
| | | var meter = new Model.RevitMeter(); |
| | | meter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | meter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(meter.Code)) |
| | | { |
| | | meter.Code = meter.Id; |
| | | } |
| | | meter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | meter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | meter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | meter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | meter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | meter.Quality = quality; |
| | | } |
| | | meter.Position = meter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | meter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | meter.Demand = demand; |
| | | } |
| | | meter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(meter.DemandPattern)) |
| | | { |
| | | meter.DemandPattern = string.Empty; |
| | | } |
| | | model.Meters.Add(meter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Flowmeter: |
| | | { |
| | | var flowmeter = new Model.RevitFlowmeter(); |
| | | flowmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | flowmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(flowmeter.Code)) |
| | | { |
| | | flowmeter.Code = flowmeter.Id; |
| | | } |
| | | flowmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | flowmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | flowmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | flowmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | flowmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | flowmeter.Quality = quality; |
| | | } |
| | | flowmeter.Position = flowmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | flowmeter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | flowmeter.Demand = demand; |
| | | } |
| | | flowmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(flowmeter.DemandPattern)) |
| | | { |
| | | flowmeter.DemandPattern = string.Empty; |
| | | } |
| | | model.Flowmeters.Add(flowmeter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pressmeter: |
| | | { |
| | | var pressmeter = new Model.RevitPressmeter(); |
| | | pressmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pressmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pressmeter.Code)) |
| | | { |
| | | pressmeter.Code = pressmeter.Id; |
| | | } |
| | | pressmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pressmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pressmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pressmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pressmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | pressmeter.Quality = quality; |
| | | } |
| | | pressmeter.Position = pressmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | pressmeter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | pressmeter.Demand = demand; |
| | | } |
| | | pressmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pressmeter.DemandPattern)) |
| | | { |
| | | pressmeter.DemandPattern = string.Empty; |
| | | } |
| | | model.Pressmeters.Add(pressmeter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Blunthead: |
| | | { |
| | | var blunthead = new Model.RevitBlunthead(); |
| | | blunthead.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | blunthead.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(blunthead.Code)) |
| | | var blunthead = ParseBlunthead(jobject); |
| | | if (blunthead != null) |
| | | { |
| | | blunthead.Code = blunthead.Id; |
| | | model.Bluntheads.Add(blunthead); |
| | | } |
| | | blunthead.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | blunthead.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | blunthead.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | blunthead.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | blunthead.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Elbow: |
| | | { |
| | | var elbow = ParseElbow(jobject); |
| | | if (elbow != null) |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | blunthead.Quality = quality; |
| | | model.Elbows.Add(elbow); |
| | | } |
| | | blunthead.Position = blunthead.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Threelink: |
| | | { |
| | | var threelink = ParseThreelink(jobject); |
| | | if (threelink != null) |
| | | { |
| | | blunthead.Elev = elev; |
| | | model.Threelinks.Add(threelink); |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Fourlink: |
| | | { |
| | | var fourlink = ParseFourlink(jobject); |
| | | if (fourlink != null) |
| | | { |
| | | blunthead.Demand = demand; |
| | | model.Fourlinks.Add(fourlink); |
| | | } |
| | | blunthead.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(blunthead.DemandPattern)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Meter: |
| | | { |
| | | var meter = ParseMeter(jobject); |
| | | if (meter != null) |
| | | { |
| | | blunthead.DemandPattern = string.Empty; |
| | | model.Meters.Add(meter); |
| | | } |
| | | model.Bluntheads.Add(blunthead); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Flowmeter: |
| | | { |
| | | var flowmeter = ParseFlowmeter(jobject); |
| | | if (flowmeter != null) |
| | | { |
| | | model.Flowmeters.Add(flowmeter); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pressmeter: |
| | | { |
| | | var pressmeter = ParsePressmeter(jobject); |
| | | if (pressmeter != null) |
| | | { |
| | | model.Pressmeters.Add(pressmeter); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Nozzle: |
| | | { |
| | | var nozzle = new Model.RevitNozzle(); |
| | | nozzle.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | nozzle.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(nozzle.Code)) |
| | | var nozzle = ParseNozzle(jobject); |
| | | if (nozzle != null) |
| | | { |
| | | nozzle.Code = nozzle.Id; |
| | | model.Nozzles.Add(nozzle); |
| | | } |
| | | nozzle.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | nozzle.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | nozzle.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | nozzle.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | nozzle.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | nozzle.Quality = quality; |
| | | } |
| | | nozzle.Position = nozzle.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | nozzle.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | nozzle.Demand = demand; |
| | | } |
| | | nozzle.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(nozzle.DemandPattern)) |
| | | { |
| | | nozzle.DemandPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffient)) |
| | | { |
| | | nozzle.Coefficient = coeffient; |
| | | } |
| | | model.Nozzles.Add(nozzle); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Hydrant: |
| | | { |
| | | var hydrant = new Model.RevitHydrant(); |
| | | hydrant.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | hydrant.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(hydrant.Code)) |
| | | var hydrant = ParseHydrant(jobject); |
| | | if (hydrant != null) |
| | | { |
| | | hydrant.Code = hydrant.Id; |
| | | model.Hydrants.Add(hydrant); |
| | | } |
| | | hydrant.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | hydrant.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | hydrant.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | hydrant.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | hydrant.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | hydrant.Quality = quality; |
| | | } |
| | | hydrant.Position = hydrant.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | hydrant.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | hydrant.Demand = demand; |
| | | } |
| | | hydrant.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(hydrant.DemandPattern)) |
| | | { |
| | | hydrant.DemandPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffient)) |
| | | { |
| | | hydrant.Coefficient = coeffient; |
| | | } |
| | | model.Hydrants.Add(hydrant); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Exchanger: |
| | | case RevitJsonCatalog.Cooling: |
| | | { |
| | | var exchanger = new Model.RevitExchanger(); |
| | | exchanger.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | exchanger.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(exchanger.Code)) |
| | | var cooling = ParseCooling(jobject); |
| | | if (cooling != null) |
| | | { |
| | | exchanger.Code = exchanger.Id; |
| | | model.Coolings.Add(cooling); |
| | | } |
| | | exchanger.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | exchanger.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | exchanger.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | exchanger.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | exchanger.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = exchanger.ConnectList.GetStartConnect(); |
| | | var endConnect = exchanger.ConnectList.GetEndConnect(); |
| | | exchanger.StartCode = startConnect.Id; |
| | | exchanger.EndCode = endConnect.Id; |
| | | exchanger.StartPosition = startConnect.Position; |
| | | exchanger.EndPosition = endConnect.Position; |
| | | exchanger.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | exchanger.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | exchanger.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | exchanger.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | exchanger.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | exchanger.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | exchanger.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | exchanger.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | exchanger.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | exchanger.Roughness = roughness; |
| | | } |
| | | if (exchanger.Length <= 0) |
| | | { |
| | | exchanger.Length = exchanger.StartPosition.Distance(exchanger.EndPosition); |
| | | } |
| | | if (exchanger.Diameter < 0.1) |
| | | { |
| | | exchanger.Diameter = 0.1; |
| | | } |
| | | if (exchanger.Roughness < 0.1) |
| | | { |
| | | exchanger.Roughness = 0.1; |
| | | } |
| | | model.Exchangers.Add(exchanger); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pipe: |
| | | { |
| | | var pipe = new Model.RevitPipe(); |
| | | pipe.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pipe.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pipe.Code)) |
| | | var pipe = ParsePipe(jobject); |
| | | if (pipe != null) |
| | | { |
| | | pipe.Code = pipe.Id; |
| | | model.Pipes.Add(pipe); |
| | | } |
| | | pipe.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pipe.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pipe.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pipe.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pipe.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pipe.ConnectList.GetStartConnect(); |
| | | var endConnect = pipe.ConnectList.GetEndConnect(); |
| | | pipe.StartCode = startConnect.Id; |
| | | pipe.EndCode = endConnect.Id; |
| | | pipe.StartPosition = startConnect.Position; |
| | | pipe.EndPosition = endConnect.Position; |
| | | pipe.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pipe.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pipe.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pipe.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pipe.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | pipe.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | pipe.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | pipe.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | pipe.Roughness = roughness; |
| | | } |
| | | if (pipe.Length <= 0) |
| | | { |
| | | pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition); |
| | | } |
| | | if (pipe.Diameter < 0.1) |
| | | { |
| | | pipe.Diameter = 0.1; |
| | | } |
| | | if (pipe.Roughness < 0.1) |
| | | { |
| | | pipe.Roughness = 0.1; |
| | | } |
| | | model.Pipes.Add(pipe); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Translation: |
| | | { |
| | | var translation = new Model.RevitTranslation(); |
| | | translation.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | translation.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(translation.Code)) |
| | | var translation = ParseTranslation(jobject); |
| | | if (translation != null) |
| | | { |
| | | translation.Code = translation.Id; |
| | | model.Translations.Add(translation); |
| | | } |
| | | translation.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | translation.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | translation.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | translation.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | translation.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Exchanger: |
| | | { |
| | | var exchanger = ParseExchanger(jobject); |
| | | if (exchanger != null) |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = translation.ConnectList.GetStartConnect(); |
| | | var endConnect = translation.ConnectList.GetEndConnect(); |
| | | translation.StartCode = startConnect.Id; |
| | | translation.EndCode = endConnect.Id; |
| | | translation.StartPosition = startConnect.Position; |
| | | translation.EndPosition = endConnect.Position; |
| | | translation.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | translation.StartElev = startElev; |
| | | model.Exchangers.Add(exchanger); |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Compressor: |
| | | { |
| | | var compressor = ParseCompressor(jobject); |
| | | if (compressor != null) |
| | | { |
| | | translation.EndElev = endElev; |
| | | model.Compressors.Add(compressor); |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | translation.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | translation.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | translation.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | translation.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | translation.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | translation.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | translation.Roughness = roughness; |
| | | } |
| | | if (translation.Length <= 0) |
| | | { |
| | | translation.Length = translation.StartPosition.Distance(translation.EndPosition); |
| | | } |
| | | if (translation.Diameter < 0.1) |
| | | { |
| | | translation.Diameter = 0.1; |
| | | } |
| | | if (translation.Roughness < 0.1) |
| | | { |
| | | translation.Roughness = 0.1; |
| | | } |
| | | model.Translations.Add(translation); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pump: |
| | | { |
| | | var pump = new Model.RevitPump(); |
| | | pump.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pump.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pump.Code)) |
| | | var pump = ParsePump(jobject); |
| | | if (pump != null) |
| | | { |
| | | pump.Code = pump.Id; |
| | | model.Pumps.Add(pump); |
| | | } |
| | | pump.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pump.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pump.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pump.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pump.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pump.ConnectList.GetStartConnect(); |
| | | var endConnect = pump.ConnectList.GetEndConnect(); |
| | | pump.StartCode = startConnect.Id; |
| | | pump.EndCode = endConnect.Id; |
| | | pump.StartPosition = startConnect.Position; |
| | | pump.EndPosition = endConnect.Position; |
| | | pump.LinkStatus = jobject[RevitJsonProp.LinkStatusPump].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pump.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pump.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pump.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pump.EndQuality = endQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.RatedPower].MatchNumeric(out double ratedPower)) |
| | | { |
| | | pump.RatedPower = ratedPower; |
| | | } |
| | | pump.CurveQH = jobject[RevitJsonProp.CurveQH].ToString(); |
| | | pump.CurveQH = "PumpDefault"; |
| | | if (jobject[RevitJsonProp.SpeedRatio].MatchNumeric(out double speedRatio)) |
| | | { |
| | | pump.SpeedRatio = speedRatio; |
| | | } |
| | | pump.SpeedRatioPattern = jobject[RevitJsonProp.SpeedRatioPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.SpeedRatioPattern)) |
| | | { |
| | | pump.SpeedRatioPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.Price].MatchNumeric(out double price)) |
| | | { |
| | | pump.Price = price; |
| | | } |
| | | pump.PricePattern = jobject[RevitJsonProp.PricePattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.PricePattern)) |
| | | { |
| | | pump.PricePattern = string.Empty; |
| | | } |
| | | pump.CurveQE = jobject[RevitJsonProp.CurveQE].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.CurveQE)) |
| | | { |
| | | pump.CurveQE = string.Empty; |
| | | } |
| | | model.Pumps.Add(pump); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Valve: |
| | | { |
| | | var valve = new Model.RevitValve(); |
| | | valve.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | valve.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(valve.Code)) |
| | | var valve = ParseValve(jobject); |
| | | if (valve != null) |
| | | { |
| | | valve.Code = valve.Id; |
| | | model.Valves.Add(valve); |
| | | } |
| | | valve.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | valve.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | valve.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | valve.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | valve.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = valve.ConnectList.GetStartConnect(); |
| | | var endConnect = valve.ConnectList.GetEndConnect(); |
| | | valve.StartCode = startConnect.Id; |
| | | valve.EndCode = endConnect.Id; |
| | | valve.StartPosition = startConnect.Position; |
| | | valve.EndPosition = endConnect.Position; |
| | | valve.LinkStatus = jobject[RevitJsonProp.LinkStatusValve].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | valve.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | valve.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | valve.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | valve.EndQuality = endQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | valve.MinorLoss = minorLoss; |
| | | } |
| | | |
| | | valve.ValveType = jobject[RevitJsonProp.ValveType].ToString(); |
| | | valve.ValveSetting = jobject[RevitJsonProp.ValveSetting].ToString(); |
| | | model.Valves.Add(valve); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Other: |
| | | { |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | decorator.Name = string.Empty; |
| | | decorator.Category = jobject[RevitJsonProp.ClanAndType][RevitJsonProp.ClanName].ToString(); |
| | | decorator.Decoration = string.Empty; |
| | | decorator.Decoration = string.Empty; |
| | | model.Decorators.Add(decorator); |
| | | var decorator = ParseDecorator(jobject); |
| | | if (decorator != null) |
| | | { |
| | | if (!string.IsNullOrEmpty(decorator.Id)) |
| | | { |
| | | model.Decorators.Add(decorator); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | |
| | | //解析其他json |
| | | var jothersArray = JArray.Parse(revitOthersJsonString); |
| | | if (jothersArray != null && jothersArray.Count > 0) |
| | | { |
| | | var allParterList = model.GetAllParters(); |
| | | for (int i = 0; i < jothersArray.Count; i++) |
| | | { |
| | | var jobject = jothersArray[i]; |
| | | var id = jobject[RevitOthersJsonProp.Id]?.ToString(); |
| | | if (string.IsNullOrEmpty(id)) |
| | | { |
| | | continue; |
| | | } |
| | | if (allParterList.Exists(x => x.Id == id)) |
| | | { |
| | | continue; |
| | | } |
| | | if (model.Decorators.Exists(x => x.Id == id)) |
| | | { |
| | | continue; |
| | | } |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = id; |
| | | decorator.Name = jobject[RevitOthersJsonProp.Name]?.ToString(); |
| | | decorator.Category = jobject[RevitOthersJsonProp.CategoryName]?.ToString(); |
| | | decorator.Decoration = jobject[RevitOthersJsonProp.CategoryID]?.ToString(); |
| | | model.Decorators.Add(decorator); |
| | | } |
| | | } |
| | | |
| | | return model; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | return default; |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // msg = ex.Message; |
| | | // return default; |
| | | //} |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 从json文件中解析 |
| | | /// </summary> |
| | | public static Model.RevitModel FromJsonFile(string revitJsonFile, out string msg) |
| | | public static Model.RevitModel FromJsonFile |
| | | ( |
| | | string revitJsonFile, |
| | | string revitOthersJsonFile, |
| | | out string msg |
| | | ) |
| | | { |
| | | if (!File.Exists(revitJsonFile)) |
| | | { |
| | |
| | | return default; |
| | | } |
| | | var revitJson = File.ReadAllText(revitJsonFile); |
| | | var revitModel = FromJsonString(revitJson, out msg); |
| | | var revitOthersJson = string.Empty; |
| | | if (File.Exists(revitOthersJsonFile)) |
| | | { |
| | | revitOthersJson = File.ReadAllText(revitOthersJsonFile); |
| | | } |
| | | var revitModel = FromJsonString(revitJson, revitOthersJson, out msg); |
| | | if (revitModel == null) |
| | | { |
| | | return default; |
| | |
| | | return revitModel; |
| | | } |
| | | |
| | | //解析水库 |
| | | private static HStation.Model.RevitReservoir ParseReservoir(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var reservoir = new Model.RevitReservoir(); |
| | | reservoir.Catalog = RevitJsonCatalog.Reservoir; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | reservoir.Id = id; |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | reservoir.Name = name; |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | reservoir.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(reservoir.ModelType)) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | reservoir.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (reservoir.Flags == null || reservoir.Flags.Count < 1) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | if (reservoir.Flags == null) |
| | | { |
| | | reservoir.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | reservoir.Description = description; |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | reservoir.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (reservoir.ConnectList == null || reservoir.ConnectList.Count < 1) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | reservoir.Position = reservoir.ConnectList?.GetCenterPosition(); |
| | | if (reservoir.Position == null) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region PoolElev |
| | | |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | reservoir.PoolElev = poolElev; |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.PoolElev), ePropStatus.Abnormal, "[池底标高]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (reservoir.PoolElev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | reservoir.PoolElev = elevOfElevation / 1000f; |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.PoolElev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (reservoir.PoolElev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (reservoir.Position == null) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.PoolElev), ePropStatus.Lack, "[池底标高]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | reservoir.PoolElev = reservoir.Position.Z; |
| | | reservoir.UpdatePropStatus(nameof(reservoir.PoolElev), ePropStatus.Lack, "[池底标高]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Head |
| | | |
| | | if (jobject[RevitJsonProp.Head].MatchNumeric(out double head)) |
| | | { |
| | | reservoir.Head = head; |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.Head), ePropStatus.Abnormal, "[总水头]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region HeadPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.HeadPattern, out string headPattern)) |
| | | { |
| | | reservoir.HeadPattern = headPattern; |
| | | if (string.IsNullOrEmpty(reservoir.HeadPattern)) |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.HeadPattern), ePropStatus.Lack, "[水头模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | reservoir.UpdatePropStatus(nameof(reservoir.HeadPattern), ePropStatus.Abnormal, "缺少[水头模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return reservoir; |
| | | } |
| | | |
| | | //解析水池 |
| | | private static HStation.Model.RevitTank ParseTank(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var tank = new Model.RevitTank(); |
| | | tank.Catalog = RevitJsonCatalog.Tank; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | tank.Id = id; |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | tank.Name = name; |
| | | tank.UpdatePropStatus(nameof(tank.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | tank.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(tank.ModelType)) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | tank.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (tank.Flags == null || tank.Flags.Count < 1) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (tank.Flags == null) |
| | | { |
| | | tank.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | tank.Description = description; |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | tank.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (tank.ConnectList == null || tank.ConnectList.Count < 1) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | tank.Position = tank.ConnectList?.GetCenterPosition(); |
| | | if (tank.Position == null) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region PoolElev |
| | | |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | tank.PoolElev = poolElev; |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.PoolElev), ePropStatus.Abnormal, "[池底标高]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (tank.PoolElev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | tank.PoolElev = elevOfElevation / 1000f; |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.PoolElev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (tank.PoolElev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (tank.Position == null) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.PoolElev), ePropStatus.Lack, "[池底标高]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | tank.PoolElev = tank.Position.Z; |
| | | tank.UpdatePropStatus(nameof(tank.PoolElev), ePropStatus.Lack, "[池底标高]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region InitLevel |
| | | |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | tank.InitLevel = initLevel; |
| | | tank.UpdatePropStatus(nameof(tank.InitLevel), ePropStatus.Lack, "[初始水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.InitLevel), ePropStatus.Abnormal, "[初始水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinLevel |
| | | |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | tank.MinLevel = minLevel; |
| | | tank.UpdatePropStatus(nameof(tank.MinLevel), ePropStatus.Lack, "[最低水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.MinLevel), ePropStatus.Abnormal, "[最低水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MaxLevel |
| | | |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | tank.MaxLevel = maxLevel; |
| | | tank.UpdatePropStatus(nameof(tank.MaxLevel), ePropStatus.Lack, "[最高水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.MaxLevel), ePropStatus.Abnormal, "[最高水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DN |
| | | |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | tank.DN = dn / 1000f; |
| | | tank.UpdatePropStatus(nameof(tank.DN), ePropStatus.Lack, "[公称直径]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.DN), ePropStatus.Abnormal, "[公称直径]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinVol |
| | | |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | tank.MinVol = minVol; |
| | | tank.UpdatePropStatus(nameof(tank.MinVol), ePropStatus.Lack, "[最小容积]缺省"); |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.MinVol), ePropStatus.Abnormal, "[最小容积]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region VolCurve |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.VolCurve, out string volCurve)) |
| | | { |
| | | tank.VolCurve = volCurve; |
| | | if (string.IsNullOrEmpty(tank.VolCurve)) |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.VolCurve), ePropStatus.Lack, "[容积曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.VolCurve), ePropStatus.Abnormal, "缺少[容积曲线]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region OverFlow |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.OverFlow, out string overFlow)) |
| | | { |
| | | if (!string.IsNullOrEmpty(overFlow)) |
| | | { |
| | | if (overFlow.Contains("0") || overFlow.ToLower().Contains("false") || overFlow.Contains("是") || overFlow.Contains("允许")) |
| | | { |
| | | tank.OverFlow = true; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tank.UpdatePropStatus(nameof(tank.OverFlow), ePropStatus.Error, "缺少[允许溢流]"); |
| | | } |
| | | #endregion |
| | | |
| | | return tank; |
| | | } |
| | | |
| | | //解析水箱 |
| | | private static HStation.Model.RevitWaterbox ParseWaterbox(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var waterbox = new Model.RevitWaterbox(); |
| | | waterbox.Catalog = RevitJsonCatalog.Waterbox; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | waterbox.Id = id; |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | waterbox.Name = name; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | waterbox.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(waterbox.ModelType)) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | waterbox.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (waterbox.Flags == null || waterbox.Flags.Count < 1) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (waterbox.Flags == null) |
| | | { |
| | | waterbox.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | waterbox.Description = description; |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | waterbox.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (waterbox.ConnectList == null || waterbox.ConnectList.Count < 1) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | waterbox.Position = waterbox.ConnectList?.GetCenterPosition(); |
| | | if (waterbox.Position == null) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region PoolElev |
| | | |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | waterbox.PoolElev = poolElev; |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.PoolElev), ePropStatus.Abnormal, "[池底标高]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (waterbox.PoolElev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | waterbox.PoolElev = elevOfElevation / 1000f; |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.PoolElev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (waterbox.PoolElev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (waterbox.Position == null) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.PoolElev), ePropStatus.Lack, "[池底标高]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.PoolElev = waterbox.Position.Z; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.PoolElev), ePropStatus.Lack, "[池底标高]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region InitLevel |
| | | |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | waterbox.InitLevel = initLevel; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.InitLevel), ePropStatus.Lack, "[初始水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.InitLevel), ePropStatus.Abnormal, "[初始水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinLevel |
| | | |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | waterbox.MinLevel = minLevel; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MinLevel), ePropStatus.Lack, "[最低水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MinLevel), ePropStatus.Abnormal, "[最低水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MaxLevel |
| | | |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | waterbox.MaxLevel = maxLevel; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MaxLevel), ePropStatus.Lack, "[最高水位]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MaxLevel), ePropStatus.Abnormal, "[最高水位]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DN |
| | | |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | waterbox.DN = dn / 1000f; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.DN), ePropStatus.Lack, "[公称直径]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.DN), ePropStatus.Abnormal, "[公称直径]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinVol |
| | | |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | waterbox.MinVol = minVol; |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MinVol), ePropStatus.Lack, "[最小容积]缺省"); |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.MinVol), ePropStatus.Abnormal, "[最小容积]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region VolCurve |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.VolCurve, out string volCurve)) |
| | | { |
| | | waterbox.VolCurve = volCurve; |
| | | if (string.IsNullOrEmpty(waterbox.VolCurve)) |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.VolCurve), ePropStatus.Lack, "[容积曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.VolCurve), ePropStatus.Abnormal, "缺少[容积曲线]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region OverFlow |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.OverFlow, out string overFlow)) |
| | | { |
| | | if (!string.IsNullOrEmpty(overFlow)) |
| | | { |
| | | if (overFlow.Contains("0") || overFlow.ToLower().Contains("false") || overFlow.Contains("是") || overFlow.Contains("允许")) |
| | | { |
| | | waterbox.OverFlow = true; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | waterbox.UpdatePropStatus(nameof(waterbox.OverFlow), ePropStatus.Error, "缺少[允许溢流]"); |
| | | } |
| | | #endregion |
| | | |
| | | return waterbox; |
| | | } |
| | | |
| | | //解析连接节点 |
| | | private static HStation.Model.RevitJunction ParseJunction(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Catalog = RevitJsonCatalog.Junction; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | junction.Id = id; |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | junction.Name = name; |
| | | junction.UpdatePropStatus(nameof(junction.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | junction.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(junction.ModelType)) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | junction.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (junction.Flags == null || junction.Flags.Count < 1) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (junction.Flags == null) |
| | | { |
| | | junction.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | junction.Description = description; |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | junction.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (junction.ConnectList == null || junction.ConnectList.Count < 1) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | junction.Position = junction.ConnectList?.GetCenterPosition(); |
| | | if (junction.Position == null) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | junction.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (junction.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | junction.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | junction.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (junction.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (junction.Position == null) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | junction.Elev = junction.Position.Z; |
| | | junction.UpdatePropStatus(nameof(junction.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | junction.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | junction.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(junction.DemandPattern)) |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | junction.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | junction.UpdatePropStatus(nameof(junction.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return junction; |
| | | } |
| | | |
| | | //解析闷头 |
| | | private static HStation.Model.RevitBlunthead ParseBlunthead(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var blunthead = new Model.RevitBlunthead(); |
| | | blunthead.Catalog = RevitJsonCatalog.Blunthead; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | blunthead.Id = id; |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | blunthead.Name = name; |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | blunthead.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(blunthead.ModelType)) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | blunthead.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (blunthead.Flags == null || blunthead.Flags.Count < 1) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (blunthead.Flags == null) |
| | | { |
| | | blunthead.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | blunthead.Description = description; |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | blunthead.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (blunthead.ConnectList == null || blunthead.ConnectList.Count < 1) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | blunthead.Position = blunthead.ConnectList?.GetCenterPosition(); |
| | | if (blunthead.Position == null) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | blunthead.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (blunthead.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | blunthead.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | blunthead.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (blunthead.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (blunthead.Position == null) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | blunthead.Elev = blunthead.Position.Z; |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | blunthead.Material = material; |
| | | if (string.IsNullOrEmpty(blunthead.Material)) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | blunthead.Caliber = caliber; |
| | | } |
| | | if (blunthead.Caliber <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out caliber)) |
| | | { |
| | | blunthead.Caliber = caliber; |
| | | } |
| | | } |
| | | if (blunthead.Caliber <= 0) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | blunthead.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | blunthead.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(blunthead.DemandPattern)) |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | blunthead.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | blunthead.UpdatePropStatus(nameof(blunthead.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return blunthead; |
| | | |
| | | } |
| | | |
| | | //解析弯头 |
| | | private static HStation.Model.RevitElbow ParseElbow(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var elbow = new Model.RevitElbow(); |
| | | elbow.Catalog = RevitJsonCatalog.Elbow; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | elbow.Id = id; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | elbow.Name = name; |
| | | elbow.UpdatePropStatus(nameof(elbow.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | elbow.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(elbow.ModelType)) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | elbow.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (elbow.Flags == null || elbow.Flags.Count < 1) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (elbow.Flags == null) |
| | | { |
| | | elbow.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | elbow.Description = description; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | elbow.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (elbow.ConnectList == null || elbow.ConnectList.Count < 1) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | elbow.Position = elbow.ConnectList?.GetCenterPosition(); |
| | | if (elbow.Position == null) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | elbow.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (elbow.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | elbow.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | elbow.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (elbow.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (elbow.Position == null) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | elbow.Elev = elbow.Position.Z; |
| | | elbow.UpdatePropStatus(nameof(elbow.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | elbow.Material = material; |
| | | if (string.IsNullOrEmpty(elbow.Material)) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | elbow.Caliber = caliber; |
| | | } |
| | | if (elbow.Caliber <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out caliber)) |
| | | { |
| | | elbow.Caliber = caliber; |
| | | } |
| | | } |
| | | if (elbow.Caliber <= 0) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | elbow.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | elbow.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(elbow.DemandPattern)) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | elbow.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region BendingAngle |
| | | |
| | | if (jobject[RevitJsonProp.BendingAngle].MatchNumeric(out double bendingAngle)) |
| | | { |
| | | elbow.BendingAngle = (int)bendingAngle; |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.BendingAngle), ePropStatus.Abnormal, "[弯曲角度]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ElbowType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ElbowType, out string elbowType)) |
| | | { |
| | | elbow.ElbowType = elbowType; |
| | | if (string.IsNullOrEmpty(elbow.ElbowType)) |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ElbowType), ePropStatus.Lack, "[弯头类型]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | elbow.UpdatePropStatus(nameof(elbow.ElbowType), ePropStatus.Abnormal, "缺少[弯头类型]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return elbow; |
| | | } |
| | | |
| | | //解析三通 |
| | | private static HStation.Model.RevitThreelink ParseThreelink(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var threelink = new Model.RevitThreelink(); |
| | | threelink.Catalog = RevitJsonCatalog.Threelink; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | threelink.Id = id; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | threelink.Name = name; |
| | | threelink.UpdatePropStatus(nameof(threelink.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | threelink.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(threelink.ModelType)) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | threelink.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (threelink.Flags == null || threelink.Flags.Count < 1) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (threelink.Flags == null) |
| | | { |
| | | threelink.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | threelink.Description = description; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | threelink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (threelink.ConnectList == null || threelink.ConnectList.Count < 1) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | threelink.Position = threelink.ConnectList?.GetCenterPosition(); |
| | | if (threelink.Position == null) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | threelink.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (threelink.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | threelink.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | threelink.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (threelink.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (threelink.Position == null) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | threelink.Elev = threelink.Position.Z; |
| | | threelink.UpdatePropStatus(nameof(threelink.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | threelink.Material = material; |
| | | if (string.IsNullOrEmpty(threelink.Material)) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | threelink.Caliber = caliber; |
| | | } |
| | | if (threelink.Caliber <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out caliber)) |
| | | { |
| | | threelink.Caliber = caliber; |
| | | } |
| | | } |
| | | if (threelink.Caliber <= 0) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | threelink.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | threelink.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(threelink.DemandPattern)) |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | threelink.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RunningThroughLoss |
| | | |
| | | if (jobject[RevitJsonProp.RunningThroughLoss].MatchNumeric(out double runningThroughLoss)) |
| | | { |
| | | threelink.RunningThroughLoss = runningThroughLoss; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.RunningThroughLoss), ePropStatus.Abnormal, "[运行损失系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region BranchThroughLoss |
| | | |
| | | if (jobject[RevitJsonProp.BranchThroughLoss].MatchNumeric(out double branchThroughLoss)) |
| | | { |
| | | threelink.BranchThroughLoss = branchThroughLoss; |
| | | } |
| | | else |
| | | { |
| | | threelink.UpdatePropStatus(nameof(threelink.BranchThroughLoss), ePropStatus.Abnormal, "[支管损失系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return threelink; |
| | | } |
| | | |
| | | //解析四通 |
| | | private static HStation.Model.RevitFourlink ParseFourlink(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var fourlink = new Model.RevitFourlink(); |
| | | fourlink.Catalog = RevitJsonCatalog.Fourlink; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | fourlink.Id = id; |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | fourlink.Name = name; |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | fourlink.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(fourlink.ModelType)) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | fourlink.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (fourlink.Flags == null || fourlink.Flags.Count < 1) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (fourlink.Flags == null) |
| | | { |
| | | fourlink.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | fourlink.Description = description; |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | fourlink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (fourlink.ConnectList == null || fourlink.ConnectList.Count < 1) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | fourlink.Position = fourlink.ConnectList?.GetCenterPosition(); |
| | | if (fourlink.Position == null) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | fourlink.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (fourlink.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | fourlink.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | fourlink.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (fourlink.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (fourlink.Position == null) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | fourlink.Elev = fourlink.Position.Z; |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | fourlink.Material = material; |
| | | if (string.IsNullOrEmpty(fourlink.Material)) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | fourlink.Caliber = caliber; |
| | | } |
| | | if (fourlink.Caliber <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out caliber)) |
| | | { |
| | | fourlink.Caliber = caliber; |
| | | } |
| | | } |
| | | if (fourlink.Caliber <= 0) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | fourlink.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | fourlink.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(fourlink.DemandPattern)) |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | fourlink.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | fourlink.UpdatePropStatus(nameof(fourlink.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return fourlink; |
| | | } |
| | | |
| | | //解析喷头 |
| | | private static HStation.Model.RevitNozzle ParseNozzle(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var nozzle = new Model.RevitNozzle(); |
| | | nozzle.Catalog = RevitJsonCatalog.Nozzle; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | nozzle.Id = id; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | nozzle.Name = name; |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | nozzle.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(nozzle.ModelType)) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | nozzle.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (nozzle.Flags == null || nozzle.Flags.Count < 1) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (nozzle.Flags == null) |
| | | { |
| | | nozzle.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | nozzle.Description = description; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | nozzle.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (nozzle.ConnectList == null || nozzle.ConnectList.Count < 1) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | nozzle.Position = nozzle.ConnectList?.GetCenterPosition(); |
| | | if (nozzle.Position == null) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | nozzle.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (nozzle.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | nozzle.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | nozzle.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (nozzle.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (nozzle.Position == null) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | nozzle.Elev = nozzle.Position.Z; |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | nozzle.Material = material; |
| | | if (string.IsNullOrEmpty(nozzle.Material)) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | nozzle.Caliber = caliber; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | nozzle.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | nozzle.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(nozzle.DemandPattern)) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | nozzle.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Coefficient |
| | | |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffientp)) |
| | | { |
| | | nozzle.Coefficient = coeffientp; |
| | | if (nozzle.Coefficient <= 0) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Coefficient), ePropStatus.Lack, "[喷射系数]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Coefficient), ePropStatus.Abnormal, "[喷射系数]缺少或者格式错误"); |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffientf)) |
| | | { |
| | | nozzle.Coefficient = coeffientf; |
| | | if (nozzle.Coefficient <= 0) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Coefficient), ePropStatus.Lack, "[流量系数]缺省"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nozzle.Coefficient < 1) |
| | | { |
| | | nozzle.UpdatePropStatus(nameof(nozzle.Coefficient), ePropStatus.Lack, "[喷射系数]缺省,使用默认值(163)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return nozzle; |
| | | } |
| | | |
| | | //解析消火栓 |
| | | private static HStation.Model.RevitHydrant ParseHydrant(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var hydrant = new Model.RevitHydrant(); |
| | | hydrant.Catalog = RevitJsonCatalog.Hydrant; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | hydrant.Id = id; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | hydrant.Name = name; |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | hydrant.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(hydrant.ModelType)) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | hydrant.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (hydrant.Flags == null || hydrant.Flags.Count < 1) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (hydrant.Flags == null) |
| | | { |
| | | hydrant.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | hydrant.Description = description; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | hydrant.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (hydrant.ConnectList == null || hydrant.ConnectList.Count < 1) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | hydrant.Position = hydrant.ConnectList?.GetCenterPosition(); |
| | | if (hydrant.Position == null) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | hydrant.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (hydrant.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | hydrant.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | hydrant.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (hydrant.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (hydrant.Position == null) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | hydrant.Elev = hydrant.Position.Z; |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | hydrant.Material = material; |
| | | if (string.IsNullOrEmpty(hydrant.Material)) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | hydrant.Caliber = caliber; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | hydrant.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | hydrant.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(hydrant.DemandPattern)) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | hydrant.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Coefficient |
| | | |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffientp)) |
| | | { |
| | | hydrant.Coefficient = coeffientp; |
| | | if (hydrant.Coefficient <= 0) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Coefficient), ePropStatus.Lack, "[喷射系数]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Coefficient), ePropStatus.Abnormal, "[喷射系数]缺少或者格式错误"); |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffientf)) |
| | | { |
| | | hydrant.Coefficient = coeffientf; |
| | | if (hydrant.Coefficient <= 0) |
| | | { |
| | | hydrant.UpdatePropStatus(nameof(hydrant.Coefficient), ePropStatus.Lack, "[流量系数]缺省"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return hydrant; |
| | | } |
| | | |
| | | //解析冷却塔 |
| | | private static HStation.Model.RevitCooling ParseCooling(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var cooling = new Model.RevitCooling(); |
| | | cooling.Catalog = RevitJsonCatalog.Cooling; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | cooling.Id = id; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | cooling.Name = name; |
| | | cooling.UpdatePropStatus(nameof(cooling.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | cooling.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(cooling.ModelType)) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | cooling.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (cooling.Flags == null || cooling.Flags.Count < 1) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (cooling.Flags == null) |
| | | { |
| | | cooling.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | cooling.Description = description; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | cooling.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (cooling.ConnectList == null || cooling.ConnectList.Count < 1) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | cooling.Position = cooling.ConnectList?.GetCenterPosition(); |
| | | if (cooling.Position == null) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | cooling.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (cooling.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | cooling.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | cooling.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (cooling.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (cooling.Position == null) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | cooling.Elev = cooling.Position.Z; |
| | | cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | cooling.Material = material; |
| | | if (string.IsNullOrEmpty(cooling.Material)) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Caliber |
| | | |
| | | if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) |
| | | { |
| | | cooling.Caliber = caliber; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Caliber), ePropStatus.Abnormal, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | cooling.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | cooling.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(cooling.DemandPattern)) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | cooling.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Coefficient |
| | | |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffientp)) |
| | | { |
| | | cooling.Coefficient = coeffientp; |
| | | if (cooling.Coefficient <= 0) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Lack, "[喷射系数]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Abnormal, "[喷射系数]缺少或者格式错误"); |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffientf)) |
| | | { |
| | | cooling.Coefficient = coeffientf; |
| | | if (cooling.Coefficient <= 0) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Lack, "[流量系数]缺省"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LowerLimit |
| | | |
| | | if (jobject[RevitJsonProp.LowerLimit].MatchNumeric(out double lowerLimit)) |
| | | { |
| | | cooling.LowerLimit = lowerLimit; |
| | | if (cooling.LowerLimit <= 0) |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.LowerLimit), ePropStatus.Lack, "[最小压力]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | cooling.UpdatePropStatus(nameof(cooling.LowerLimit), ePropStatus.Abnormal, "[最小压力]缺少或者格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return cooling; |
| | | } |
| | | |
| | | //解析水表 |
| | | private static HStation.Model.RevitMeter ParseMeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var meter = new Model.RevitMeter(); |
| | | meter.Catalog = RevitJsonCatalog.Meter; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | meter.Id = id; |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | meter.Name = name; |
| | | meter.UpdatePropStatus(nameof(meter.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | meter.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(meter.ModelType)) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | meter.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (meter.Flags == null || meter.Flags.Count < 1) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (meter.Flags == null) |
| | | { |
| | | meter.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | meter.Description = description; |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | meter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (meter.ConnectList == null || meter.ConnectList.Count < 1) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | meter.Position = meter.ConnectList?.GetCenterPosition(); |
| | | if (meter.Position == null) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | meter.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (meter.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | meter.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | meter.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (meter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (meter.Position == null) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | meter.Elev = meter.Position.Z; |
| | | meter.UpdatePropStatus(nameof(meter.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | meter.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | meter.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(meter.DemandPattern)) |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | meter.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | meter.UpdatePropStatus(nameof(meter.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return meter; |
| | | } |
| | | |
| | | //解析流量计 |
| | | private static HStation.Model.RevitFlowmeter ParseFlowmeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var flowmeter = new Model.RevitFlowmeter(); |
| | | flowmeter.Catalog = RevitJsonCatalog.Flowmeter; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | flowmeter.Id = id; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | flowmeter.Name = name; |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | flowmeter.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(flowmeter.ModelType)) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | flowmeter.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (flowmeter.Flags == null || flowmeter.Flags.Count < 1) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (flowmeter.Flags == null) |
| | | { |
| | | flowmeter.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | flowmeter.Description = description; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | flowmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (flowmeter.ConnectList == null || flowmeter.ConnectList.Count < 1) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | flowmeter.Position = flowmeter.ConnectList?.GetCenterPosition(); |
| | | if (flowmeter.Position == null) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | flowmeter.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (flowmeter.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | flowmeter.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | flowmeter.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (flowmeter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (flowmeter.Position == null) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | flowmeter.Elev = flowmeter.Position.Z; |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | flowmeter.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | flowmeter.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(flowmeter.DemandPattern)) |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | flowmeter.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurrentFlow |
| | | |
| | | if (jobject[RevitJsonProp.CurrentFlow].MatchNumeric(out double currentFlow)) |
| | | { |
| | | flowmeter.CurrentFlow = currentFlow; |
| | | } |
| | | else |
| | | { |
| | | flowmeter.UpdatePropStatus(nameof(flowmeter.CurrentFlow), ePropStatus.Abnormal, "[流量信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return flowmeter; |
| | | } |
| | | |
| | | //解析压力表 |
| | | private static HStation.Model.RevitPressmeter ParsePressmeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var pressmeter = new Model.RevitPressmeter(); |
| | | pressmeter.Catalog = RevitJsonCatalog.Pressmeter; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | pressmeter.Id = id; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | pressmeter.Name = name; |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Name), ePropStatus.Error, "缺少 [构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | pressmeter.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(pressmeter.ModelType)) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | pressmeter.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (pressmeter.Flags == null || pressmeter.Flags.Count < 1) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (pressmeter.Flags == null) |
| | | { |
| | | pressmeter.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | pressmeter.Description = description; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | pressmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (pressmeter.ConnectList == null || pressmeter.ConnectList.Count < 1) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Position |
| | | |
| | | pressmeter.Position = pressmeter.ConnectList?.GetCenterPosition(); |
| | | if (pressmeter.Position == null) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Position), ePropStatus.Lack, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | pressmeter.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (pressmeter.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | pressmeter.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | pressmeter.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (pressmeter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (pressmeter.Position == null) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | pressmeter.Elev = pressmeter.Position.Z; |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Demand |
| | | |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | pressmeter.Demand = demand; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.Demand), ePropStatus.Abnormal, "[需水量]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region DemandPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) |
| | | { |
| | | pressmeter.DemandPattern = demandPattern; |
| | | if (string.IsNullOrEmpty(pressmeter.DemandPattern)) |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.DemandPattern), ePropStatus.Lack, "[需水模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.DemandPattern), ePropStatus.Abnormal, "缺少[需水模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | pressmeter.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurrentPress |
| | | |
| | | if (jobject[RevitJsonProp.CurrentPress].MatchNumeric(out double currentPress)) |
| | | { |
| | | pressmeter.CurrentPress = currentPress; |
| | | } |
| | | else |
| | | { |
| | | pressmeter.UpdatePropStatus(nameof(pressmeter.CurrentPress), ePropStatus.Abnormal, "[压力信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return pressmeter; |
| | | } |
| | | |
| | | //解析管道 |
| | | private static HStation.Model.RevitPipe ParsePipe(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var pipe = new Model.RevitPipe(); |
| | | pipe.Catalog = RevitJsonCatalog.Pipe; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | pipe.Id = id; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | pipe.Name = name; |
| | | if (string.IsNullOrEmpty(pipe.Name)) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | pipe.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(pipe.ModelType)) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | pipe.Flags = RevitFlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (pipe.Flags == null || pipe.Flags.Count < 1) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (pipe.Flags == null) |
| | | { |
| | | pipe.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | pipe.Description = description; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | pipe.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (pipe.ConnectList == null || pipe.ConnectList.Count < 1) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = pipe.ConnectList?.GetStartConnect(); |
| | | pipe.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(pipe.StartCode)) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | pipe.StartPosition = startConnect?.Position; |
| | | if (pipe.StartPosition == null) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = pipe.ConnectList?.GetEndConnect(); |
| | | pipe.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(pipe.EndCode)) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | pipe.EndPosition = endConnect?.Position; |
| | | if (pipe.EndPosition == null) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusPipe, out string linkStatus)) |
| | | { |
| | | pipe.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(pipe.LinkStatus)) |
| | | { |
| | | pipe.LinkStatus = PipeStatus.Open; |
| | | pipe.UpdatePropStatus(nameof(pipe.LinkStatus), ePropStatus.Lack, "[管道状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!PipeStatus.Contains(pipe.LinkStatus)) |
| | | { |
| | | pipe.LinkStatus = PipeStatus.Open; |
| | | pipe.UpdatePropStatus(nameof(pipe.LinkStatus), ePropStatus.Abnormal, "[管道状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.LinkStatus = PipeStatus.Open; |
| | | pipe.UpdatePropStatus(nameof(pipe.LinkStatus), ePropStatus.Abnormal, "[管道状态]缺少或格式错误,使用默认值(Open)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | pipe.Material = material; |
| | | if (string.IsNullOrEmpty(pipe.Material)) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Diameter |
| | | |
| | | //直径信息 |
| | | if (jobject[RevitJsonProp.DiameterInfo].MatchNumeric(out double diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Abnormal, "[直径信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | //直径 |
| | | if (pipe.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Lack, "[直径信息]通过[直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | //内径 |
| | | if (pipe.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Lack, "[直径信息]通过[内径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[内径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | //公称直径 |
| | | if (pipe.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | pipe.Diameter = dn; |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Lack, "[直径信息]通过[公称直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[公称直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (pipe.Diameter < 1) |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Error, "[直径信息]解析错误,无法通过【直径】【内径】【公称直径】修复"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Length |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | pipe.Length = length; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Length), ePropStatus.Abnormal, "[长度信息]缺少或者格式错误"); |
| | | } |
| | | if (pipe.Length <= 0) |
| | | { |
| | | if (pipe.StartPosition != null && pipe.EndPosition != null) |
| | | { |
| | | pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition); |
| | | pipe.UpdatePropStatus(nameof(pipe.Length), ePropStatus.Lack, "[长度信息]缺省,通过位置信息自动计算"); |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Length), ePropStatus.Abnormal, "[长度信息]受[连接列表]影响无法自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Roughness |
| | | |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | pipe.Roughness = roughness; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.Roughness), ePropStatus.Abnormal, "[粗糙系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | if (pipe.Roughness < 0.1) |
| | | { |
| | | pipe.Roughness = 110; |
| | | pipe.UpdatePropStatus(nameof(pipe.Roughness), ePropStatus.Lack, "[粗糙系数]解析错误,通过默认值(110)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | pipe.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | pipe.UpdatePropStatus(nameof(pipe.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return pipe; |
| | | } |
| | | |
| | | //解析过渡件 |
| | | private static HStation.Model.RevitTranslation ParseTranslation(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var translation = new Model.RevitTranslation(); |
| | | translation.Catalog = RevitJsonCatalog.Translation; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | translation.Id = id; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | translation.Name = name; |
| | | translation.UpdatePropStatus(nameof(translation.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | translation.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(translation.ModelType)) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | translation.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (translation.Flags == null || translation.Flags.Count < 1) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (translation.Flags == null) |
| | | { |
| | | translation.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | translation.Description = description; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | translation.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (translation.ConnectList == null || translation.ConnectList.Count < 1) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = translation.ConnectList?.GetStartConnect(); |
| | | translation.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(translation.StartCode)) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | translation.StartPosition = startConnect?.Position; |
| | | if (translation.StartPosition == null) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = translation.ConnectList?.GetEndConnect(); |
| | | translation.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(translation.EndCode)) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | translation.EndPosition = endConnect?.Position; |
| | | if (translation.EndPosition == null) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatus, out string linkStatus)) |
| | | { |
| | | translation.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(translation.LinkStatus)) |
| | | { |
| | | translation.LinkStatus = PipeStatus.Open; |
| | | translation.UpdatePropStatus(nameof(translation.LinkStatus), ePropStatus.Lack, "[管段状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!PipeStatus.Contains(translation.LinkStatus)) |
| | | { |
| | | translation.LinkStatus = PipeStatus.Open; |
| | | translation.UpdatePropStatus(nameof(translation.LinkStatus), ePropStatus.Abnormal, "[管段状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.LinkStatus = PipeStatus.Open; |
| | | translation.UpdatePropStatus(nameof(translation.LinkStatus), ePropStatus.Abnormal, "[管段状态]缺少或格式错误,使用默认值(Open)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | translation.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (translation.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | translation.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | translation.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (translation.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (translation.StartPosition == null || translation.EndPosition == null) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置信息]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | var center = translation.ConnectList?.GetCenterPosition(); |
| | | if (center != null) |
| | | { |
| | | translation.Elev = center.Z; |
| | | translation.UpdatePropStatus(nameof(translation.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | translation.Material = material; |
| | | if (string.IsNullOrEmpty(translation.Material)) |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Diameter |
| | | |
| | | if (jobject[RevitJsonProp.DiameterInfo].MatchNumeric(out double diameter)) |
| | | { |
| | | translation.Diameter = diameter; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Abnormal, "[直径信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (translation.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | translation.Diameter = internalDiameter; |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Lack, "[直径信息]通过[内径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[内径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (translation.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | translation.Diameter = dn; |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Lack, "[直径信息]通过[公称直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[公称直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (translation.Diameter < 1) |
| | | { |
| | | translation.Diameter = 500; |
| | | translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Lack, "[直径信息][内径]解析错误,使用默认值(500mm)修正]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartDiameter |
| | | |
| | | if (jobject[RevitJsonProp.MaxSize].MatchNumeric(out double maxSize)) |
| | | { |
| | | translation.StartDiameter = maxSize; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndDiameter |
| | | |
| | | if (jobject[RevitJsonProp.MinSize].MatchNumeric(out double minSize)) |
| | | { |
| | | translation.EndDiameter = minSize; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Length |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | translation.Length = length; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Length), ePropStatus.Abnormal, "[长度信息]缺少或者格式错误"); |
| | | } |
| | | if (translation.Length <= 0) |
| | | { |
| | | if (translation.StartPosition != null && translation.EndPosition != null) |
| | | { |
| | | translation.Length = translation.StartPosition.Distance(translation.EndPosition); |
| | | translation.UpdatePropStatus(nameof(translation.Length), ePropStatus.Lack, "[长度信息]缺省,通过位置信息自动计算"); |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Length), ePropStatus.Abnormal, "[长度信息]受[连接列表]影响无法自动计算"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Roughness |
| | | |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | translation.Roughness = roughness; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.Roughness), ePropStatus.Abnormal, "[粗糙系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | if (translation.Roughness < 0.1) |
| | | { |
| | | translation.Roughness = 110; |
| | | translation.UpdatePropStatus(nameof(translation.Roughness), ePropStatus.Lack, "[粗糙系数]解析错误,通过默认值(110)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | translation.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | translation.UpdatePropStatus(nameof(translation.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return translation; |
| | | } |
| | | |
| | | //解析水泵 |
| | | private static HStation.Model.RevitPump ParsePump(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | var pump = new Model.RevitPump(); |
| | | pump.Catalog = RevitJsonCatalog.Pump; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | pump.Id = id; |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | pump.Name = name; |
| | | pump.UpdatePropStatus(nameof(pump.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | pump.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(pump.ModelType)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | pump.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (pump.Flags == null || pump.Flags.Count < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (pump.Flags == null) |
| | | { |
| | | pump.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | pump.Description = description; |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | pump.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (pump.ConnectList == null || pump.ConnectList.Count < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = pump.ConnectList?.GetStartConnect(); |
| | | pump.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(pump.StartCode)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | pump.StartPosition = startConnect?.Position; |
| | | if (pump.StartPosition == null) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = pump.ConnectList?.GetEndConnect(); |
| | | pump.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(pump.EndCode)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | pump.EndPosition = endConnect?.Position; |
| | | if (pump.EndPosition == null) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusPump, out string linkStatus)) |
| | | { |
| | | pump.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(pump.LinkStatus)) |
| | | { |
| | | pump.LinkStatus = PumpStatus.Open; |
| | | pump.UpdatePropStatus(nameof(pump.LinkStatus), ePropStatus.Lack, "[水泵状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!PumpStatus.Contains(pump.LinkStatus)) |
| | | { |
| | | pump.LinkStatus = PipeStatus.Open; |
| | | pump.UpdatePropStatus(nameof(pump.LinkStatus), ePropStatus.Abnormal, "[水泵状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.LinkStatus = PipeStatus.Open; |
| | | pump.UpdatePropStatus(nameof(pump.LinkStatus), ePropStatus.Abnormal, "[水泵状态]缺少或格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | pump.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (pump.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | pump.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | pump.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (pump.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (pump.StartPosition == null || pump.EndPosition == null) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置信息]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | var center = pump.ConnectList?.GetCenterPosition(); |
| | | if (center != null) |
| | | { |
| | | pump.Elev = center.Z; |
| | | pump.UpdatePropStatus(nameof(pump.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RatedQ |
| | | |
| | | if (jobject[RevitJsonProp.RatedQ].MatchNumeric(out double ratedQ)) |
| | | { |
| | | pump.RatedQ = ratedQ; |
| | | if (pump.RatedQ < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedQ), ePropStatus.Lack, "[额定流量]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedQ), ePropStatus.Abnormal, "[额定流量]缺少或者格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RatedH |
| | | |
| | | if (jobject[RevitJsonProp.RatedH].MatchNumeric(out double ratedH)) |
| | | { |
| | | pump.RatedH = ratedH; |
| | | if (pump.RatedH < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedH), ePropStatus.Lack, "[额定扬程]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedH), ePropStatus.Abnormal, "[额定扬程]缺少或者格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RatedP |
| | | |
| | | if (jobject[RevitJsonProp.RatedP].MatchNumeric(out double ratedP)) |
| | | { |
| | | pump.RatedP = ratedP; |
| | | if (pump.RatedP < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedP), ePropStatus.Lack, "[额定功率]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedP), ePropStatus.Abnormal, "[额定功率]缺少或者格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RatedN |
| | | |
| | | if (jobject[RevitJsonProp.RatedN].MatchNumeric(out double ratedN)) |
| | | { |
| | | pump.RatedN = ratedN; |
| | | if (pump.RatedN < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedN), ePropStatus.Lack, "[额定转速]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedN), ePropStatus.Abnormal, "[额定转速]缺少或者格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region RatedHz |
| | | |
| | | if (jobject[RevitJsonProp.RatedHz].MatchNumeric(out double ratedHz)) |
| | | { |
| | | pump.RatedHz = ratedHz; |
| | | if (pump.RatedHz < 1) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedHz), ePropStatus.Lack, "[额定频率]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.RatedHz), ePropStatus.Abnormal, "[额定频率]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (pump.RatedHz < 1) |
| | | { |
| | | pump.RatedHz = 50; |
| | | pump.UpdatePropStatus(nameof(pump.RatedHz), ePropStatus.Lack, "[额定频率]缺省,使用默认值(50Hz)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurveQH |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.CurveQH, out string curveqh)) |
| | | { |
| | | pump.CurveQH = curveqh; |
| | | if (string.IsNullOrEmpty(pump.CurveQH)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQH), ePropStatus.Lack, "[流量扬程曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQH), ePropStatus.Abnormal, "缺少[流量扬程曲线]"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(pump.CurveQH)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQH), ePropStatus.Lack, "[流量扬程曲线]缺省,使用默认值(PumpDefault)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurveQP |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.CurveQP, out string curveqp)) |
| | | { |
| | | pump.CurveQP = curveqp; |
| | | if (string.IsNullOrEmpty(pump.CurveQP)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQP), ePropStatus.Lack, "[流量功率曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQP), ePropStatus.Abnormal, "缺少[流量功率曲线]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurveQE |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.CurveQE, out string curveqe)) |
| | | { |
| | | pump.CurveQE = curveqe; |
| | | if (string.IsNullOrEmpty(pump.CurveQE)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQE), ePropStatus.Lack, "[流量效率曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.CurveQE), ePropStatus.Abnormal, "缺少[流量效率曲线]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region SpeedRatio |
| | | |
| | | if (jobject[RevitJsonProp.SpeedRatio].MatchNumeric(out double speedRatio)) |
| | | { |
| | | pump.SpeedRatio = speedRatio; |
| | | } |
| | | else |
| | | { |
| | | pump.SpeedRatio = 1; |
| | | pump.UpdatePropStatus(nameof(pump.SpeedRatio), ePropStatus.Abnormal, "[转速比]缺省,使用默认值(1)修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region SpeedRatioPattern |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.SpeedRatioPattern, out string speedRatioPattern)) |
| | | { |
| | | pump.SpeedRatioPattern = speedRatioPattern; |
| | | if (string.IsNullOrEmpty(pump.SpeedRatioPattern)) |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.SpeedRatioPattern), ePropStatus.Lack, "[转速比模式]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | pump.UpdatePropStatus(nameof(pump.SpeedRatioPattern), ePropStatus.Abnormal, "缺少[转速比模式]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return pump; |
| | | } |
| | | |
| | | //解析阀门 |
| | | private static HStation.Model.RevitValve ParseValve(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | var valve = new Model.RevitValve(); |
| | | valve.Catalog = RevitJsonCatalog.Valve; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | valve.Id = id; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | valve.Name = name; |
| | | valve.UpdatePropStatus(nameof(valve.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | valve.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(valve.ModelType)) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | valve.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (valve.Flags == null || valve.Flags.Count < 1) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (valve.Flags == null) |
| | | { |
| | | valve.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | valve.Description = description; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | valve.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (valve.ConnectList == null || valve.ConnectList.Count < 1) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = valve.ConnectList?.GetStartConnect(); |
| | | valve.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(valve.StartCode)) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | valve.StartPosition = startConnect?.Position; |
| | | if (valve.StartPosition == null) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = valve.ConnectList?.GetEndConnect(); |
| | | valve.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(valve.EndCode)) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | valve.EndPosition = endConnect?.Position; |
| | | if (valve.EndPosition == null) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | valve.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (valve.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | valve.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | valve.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (valve.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (valve.StartPosition == null || valve.EndPosition == null) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置信息]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | var center = valve.ConnectList?.GetCenterPosition(); |
| | | if (center != null) |
| | | { |
| | | valve.Elev = center.Z; |
| | | valve.UpdatePropStatus(nameof(valve.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusValve, out string linkStatus)) |
| | | { |
| | | valve.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(valve.LinkStatus)) |
| | | { |
| | | valve.LinkStatus = ValveStatus.Open; |
| | | valve.UpdatePropStatus(nameof(valve.LinkStatus), ePropStatus.Lack, "[阀门状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!ValveStatus.Contains(valve.LinkStatus)) |
| | | { |
| | | valve.LinkStatus = ValveStatus.Open; |
| | | valve.UpdatePropStatus(nameof(valve.LinkStatus), ePropStatus.Abnormal, "[阀门状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.LinkStatus = ValveStatus.Open; |
| | | valve.UpdatePropStatus(nameof(valve.LinkStatus), ePropStatus.Abnormal, "[阀门状态]缺少或格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | valve.Material = material; |
| | | if (string.IsNullOrEmpty(valve.Material)) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Diameter |
| | | |
| | | if (jobject[RevitJsonProp.DiameterInfo].MatchNumeric(out double diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Abnormal, "[直径信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (valve.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, "[直径信息]通过[内径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[内径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (valve.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, "[直径信息]通过[公称直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[公称直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (valve.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.MaxSize].MatchNumeric(out diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, "[直径信息]通过[最大尺寸]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[最大尺寸]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (valve.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.MinSize].MatchNumeric(out diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, "[直径信息]通过[最小尺寸]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[最小尺寸]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (valve.Diameter < 1) |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, "[直径信息]解析错误,无法通过[内径][公称直径][最大尺寸][最小尺寸]修复"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | valve.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Roughness |
| | | |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | valve.Roughness = roughness; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.Roughness), ePropStatus.Abnormal, "[粗糙系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | if (valve.Roughness < 0.1) |
| | | { |
| | | valve.Roughness = 110; |
| | | valve.UpdatePropStatus(nameof(valve.Roughness), ePropStatus.Lack, "[粗糙系数]解析错误,通过默认值(110)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ValveType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ValveType, out string valveType)) |
| | | { |
| | | valve.ValveType = valveType; |
| | | if (string.IsNullOrEmpty(valve.ValveType)) |
| | | { |
| | | valve.ValveType = ValveType.GPV; |
| | | valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Lack, "[阀门类型]缺省,使用默认值(GPV)进行修正"); |
| | | } |
| | | else |
| | | { |
| | | if (!ValveType.Contains(valve.ValveType)) |
| | | { |
| | | valve.ValveType = ValveType.GPV; |
| | | valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[阀门类型]设置错误,使用默认值(GPV)进行修正"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.ValveType = ValveType.GPV; |
| | | valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[阀门类型]缺少或格式错误,使用默认值(GPV)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region OpeningDegree |
| | | |
| | | if (jobject[RevitJsonProp.ValveOpeningDegree].MatchNumeric(out double openingDegree)) |
| | | { |
| | | valve.OpeningDegree = openingDegree; |
| | | } |
| | | else |
| | | { |
| | | valve.OpeningDegree = 100; |
| | | valve.UpdatePropStatus(nameof(valve.OpeningDegree), ePropStatus.Abnormal, "[阀门开度]缺少或者数据格式错误,使用默认值(100)进行修正"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ValveSetting |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ValveSetting, out string valveSetting)) |
| | | { |
| | | valve.ValveSetting = valveSetting; |
| | | } |
| | | else |
| | | { |
| | | valve.UpdatePropStatus(nameof(valve.ValveSetting), ePropStatus.Abnormal, "[阀门设置]缺少或格式错误"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(valve.ValveSetting)) |
| | | { |
| | | if (valve.ValveType == ValveType.GPV) |
| | | { |
| | | valve.ValveSetting = "GPVDefault"; |
| | | valve.UpdatePropStatus(nameof(valve.ValveSetting), ePropStatus.Lack, "[阀门设置]缺省,使用默认值(GPVDefault)进行修正"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return valve; |
| | | } |
| | | |
| | | //解析换热器 |
| | | private static HStation.Model.RevitExchanger ParseExchanger(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var exchanger = new Model.RevitExchanger(); |
| | | exchanger.Catalog = RevitJsonCatalog.Exchanger; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | exchanger.Id = id; |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | exchanger.Name = name; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | exchanger.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(exchanger.ModelType)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | exchanger.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (exchanger.Flags == null || exchanger.Flags.Count < 1) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (exchanger.Flags == null) |
| | | { |
| | | exchanger.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | exchanger.Description = description; |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | exchanger.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (exchanger.ConnectList == null || exchanger.ConnectList.Count < 1) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = exchanger.ConnectList?.GetStartConnect(); |
| | | exchanger.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(exchanger.StartCode)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | exchanger.StartPosition = startConnect?.Position; |
| | | if (exchanger.StartPosition == null) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = exchanger.ConnectList?.GetEndConnect(); |
| | | exchanger.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(exchanger.EndCode)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | exchanger.EndPosition = endConnect?.Position; |
| | | if (exchanger.EndPosition == null) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusSwitch, out string linkStatus)) |
| | | { |
| | | exchanger.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(exchanger.LinkStatus)) |
| | | { |
| | | exchanger.LinkStatus = ValveStatus.Open; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.LinkStatus), ePropStatus.Lack, "[开关状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!ValveStatus.Contains(exchanger.LinkStatus)) |
| | | { |
| | | exchanger.LinkStatus = ValveStatus.Open; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.LinkStatus), ePropStatus.Abnormal, "[开关状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.LinkStatus = ValveStatus.Open; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.LinkStatus), ePropStatus.Abnormal, "[开关状态]缺少或格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | exchanger.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (exchanger.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | exchanger.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | |
| | | if (!jre.HasValues) |
| | | { |
| | | |
| | | } |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | exchanger.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (exchanger.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (exchanger.StartPosition == null || exchanger.EndPosition == null) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置信息]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | var center = exchanger.ConnectList?.GetCenterPosition(); |
| | | if (center != null) |
| | | { |
| | | exchanger.Elev = center.Z; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | exchanger.Material = material; |
| | | if (string.IsNullOrEmpty(exchanger.Material)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Diameter |
| | | |
| | | if (jobject[RevitJsonProp.DiameterInfo].MatchNumeric(out double diameter)) |
| | | { |
| | | exchanger.Diameter = diameter; |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Abnormal, "[直径信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (exchanger.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | exchanger.Diameter = internalDiameter; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Lack, "[直径信息]通过[内径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[内径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (exchanger.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | exchanger.Diameter = dn; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Lack, "[直径信息]通过[公称直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[公称直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (exchanger.Diameter < 1) |
| | | { |
| | | exchanger.Diameter = 1000; |
| | | exchanger.UpdatePropStatus(nameof(exchanger.Diameter), ePropStatus.Lack, "[直径信息][内径]解析错误,使用默认值(1000mm)修正]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | exchanger.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurveQL |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.CurveQL, out string curveql)) |
| | | { |
| | | exchanger.CurveQL = curveql; |
| | | if (string.IsNullOrEmpty(exchanger.CurveQL)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.CurveQL), ePropStatus.Lack, "[水头损失曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.CurveQL), ePropStatus.Abnormal, "缺少[水头损失曲线]"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(exchanger.CurveQL)) |
| | | { |
| | | exchanger.UpdatePropStatus(nameof(exchanger.CurveQL), ePropStatus.Lack, "[水头损失曲线]缺省,期待产品匹配时修复"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return exchanger; |
| | | } |
| | | |
| | | //解析空压机 |
| | | private static HStation.Model.RevitCompressor ParseCompressor(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var compressor = new Model.RevitCompressor(); |
| | | compressor.Catalog = RevitJsonCatalog.Compressor; |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | compressor.Id = id; |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Id), ePropStatus.Error, "缺少[构件编码]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | compressor.Name = name; |
| | | compressor.UpdatePropStatus(nameof(compressor.Name), ePropStatus.Lack, "[构件名称]缺省"); |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Name), ePropStatus.Error, "缺少[构件名称]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | compressor.ModelType = modelType; |
| | | if (string.IsNullOrEmpty(compressor.ModelType)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.ModelType), ePropStatus.Lack, "[型号信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.ModelType), ePropStatus.Error, "缺少[型号信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | compressor.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | if (!string.IsNullOrEmpty(flags)) |
| | | { |
| | | if (compressor.Flags == null || compressor.Flags.Count < 1) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Flags), ePropStatus.Abnormal, "[标签信息]格式错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Flags), ePropStatus.Error, "缺少[标签信息]"); |
| | | } |
| | | |
| | | if (compressor.Flags == null) |
| | | { |
| | | compressor.Flags = new List<string>(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | compressor.Description = description; |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Description), ePropStatus.Error, "缺少[说明信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | compressor.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | if (compressor.ConnectList == null || compressor.ConnectList.Count < 1) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.ConnectList), ePropStatus.Error, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.ConnectList), ePropStatus.Error, "缺少[连接列表]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region StartCode/StartPosition |
| | | |
| | | var startConnect = compressor.ConnectList?.GetStartConnect(); |
| | | compressor.StartCode = startConnect?.Id; |
| | | if (string.IsNullOrEmpty(compressor.StartCode)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.StartCode), ePropStatus.Error, "[上游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | compressor.StartPosition = startConnect?.Position; |
| | | if (compressor.StartPosition == null) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.StartPosition), ePropStatus.Error, "[上游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EndCode/EndPosition |
| | | |
| | | var endConnect = compressor.ConnectList?.GetEndConnect(); |
| | | compressor.EndCode = endConnect?.Id; |
| | | if (string.IsNullOrEmpty(compressor.EndCode)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.EndCode), ePropStatus.Error, "[下游构件]受[连接列表]影响解析错误"); |
| | | } |
| | | compressor.EndPosition = endConnect?.Position; |
| | | if (compressor.EndPosition == null) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.EndPosition), ePropStatus.Error, "[下游构件位置]受[连接列表]影响解析错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusSwitch, out string linkStatus)) |
| | | { |
| | | compressor.LinkStatus = linkStatus; |
| | | if (string.IsNullOrEmpty(compressor.LinkStatus)) |
| | | { |
| | | compressor.LinkStatus = ValveStatus.Open; |
| | | compressor.UpdatePropStatus(nameof(compressor.LinkStatus), ePropStatus.Lack, "[开关状态]缺省"); |
| | | } |
| | | else |
| | | { |
| | | if (!ValveStatus.Contains(compressor.LinkStatus)) |
| | | { |
| | | compressor.LinkStatus = ValveStatus.Open; |
| | | compressor.UpdatePropStatus(nameof(compressor.LinkStatus), ePropStatus.Abnormal, "[开关状态]设置错误"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.LinkStatus = ValveStatus.Open; |
| | | compressor.UpdatePropStatus(nameof(compressor.LinkStatus), ePropStatus.Abnormal, "[开关状态]缺少或格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Elev |
| | | |
| | | if (jobject[RevitJsonProp.ElevInfo].MatchNumeric(out double elev)) |
| | | { |
| | | compressor.Elev = elev; |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Elev), ePropStatus.Abnormal, "[标高信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (compressor.Elev <= 0) |
| | | { |
| | | if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | compressor.Elev = elevOfElevation / 1000f; |
| | | var jre = jobject[RevitJsonProp.Elev]; |
| | | if (jre != null) |
| | | { |
| | | if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade)) |
| | | { |
| | | compressor.Elev += facade / 1000f; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Elev), ePropStatus.Abnormal, "[标高中的高程]缺少或者格式错误"); |
| | | } |
| | | } |
| | | |
| | | if (compressor.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | if (compressor.StartPosition == null || compressor.EndPosition == null) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Elev), ePropStatus.Lack, "[标高信息]缺省,受[位置信息]影响,无法通过Z轴自动计算"); |
| | | } |
| | | else |
| | | { |
| | | var center = compressor.ConnectList?.GetCenterPosition(); |
| | | if (center != null) |
| | | { |
| | | compressor.Elev = center.Z; |
| | | compressor.UpdatePropStatus(nameof(compressor.Elev), ePropStatus.Lack, "[标高信息]缺省,通过Z轴自动计算"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Material |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Material, out string material)) |
| | | { |
| | | compressor.Material = material; |
| | | if (string.IsNullOrEmpty(compressor.Material)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Material), ePropStatus.Lack, "[材质信息]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Material), ePropStatus.Abnormal, "缺少[材质信息]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Diameter |
| | | |
| | | if (jobject[RevitJsonProp.DiameterInfo].MatchNumeric(out double diameter)) |
| | | { |
| | | compressor.Diameter = diameter; |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Abnormal, "[直径信息]缺少或者格式错误"); |
| | | } |
| | | |
| | | if (compressor.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | compressor.Diameter = internalDiameter; |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Lack, "[直径信息]通过[内径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[内径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (compressor.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.DN].MatchNumeric(out double dn)) |
| | | { |
| | | compressor.Diameter = dn; |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Lack, "[直径信息]通过[公称直径]进行修复]"); |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Abnormal, "[直径信息]无法通过[公称直径]进行修复]"); |
| | | } |
| | | } |
| | | |
| | | if (compressor.Diameter < 1) |
| | | { |
| | | compressor.Diameter = 1000; |
| | | compressor.UpdatePropStatus(nameof(compressor.Diameter), ePropStatus.Lack, "[直径信息][内径]解析错误,使用默认值(1000mm)修正]"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region MinorLoss |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | compressor.MinorLoss = minorLoss; |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.MinorLoss), ePropStatus.Abnormal, "[局阻系数]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region CurveQL |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.CurveQL, out string curveql)) |
| | | { |
| | | compressor.CurveQL = curveql; |
| | | if (string.IsNullOrEmpty(compressor.CurveQL)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.CurveQL), ePropStatus.Lack, "[水头损失曲线]缺省"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.CurveQL), ePropStatus.Abnormal, "缺少[水头损失曲线]"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(compressor.CurveQL)) |
| | | { |
| | | compressor.UpdatePropStatus(nameof(compressor.CurveQL), ePropStatus.Lack, "[水头损失曲线]缺省,期待产品匹配时修复"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return compressor; |
| | | } |
| | | |
| | | //解析装饰件 |
| | | private static HStation.Model.RevitDecorator ParseDecorator(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var decorator = new Model.RevitDecorator(); |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | decorator.Id = id; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | decorator.Name = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | | #region Category |
| | | |
| | | var jobjectClanAndType = jobject[RevitJsonProp.ClanAndType]; |
| | | if (jobjectClanAndType != null) |
| | | { |
| | | var jobjectClanName = jobjectClanAndType[RevitJsonProp.ClanName]; |
| | | if (jobjectClanName != null) |
| | | { |
| | | decorator.Category = jobjectClanName.ToString(); |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty(decorator.Category)) |
| | | { |
| | | decorator.Category = "未知"; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Decoration |
| | | |
| | | decorator.Decoration = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | | return decorator; |
| | | } |
| | | |
| | | } |
| | | } |