private void SingleConduitPlaced(SingleConduitInfo singleConduitInfo, SingleConduitPlaced @event) { singleConduitInfo.Id = @event.SingleConduitId; singleConduitInfo.Kind = ConduitKindEnum.SingleConduit; singleConduitInfo.AssetInfo = @event.AssetInfo; singleConduitInfo.WalkOfInterestId = @event.WalkOfInterestId; singleConduitInfo.Color = @event.ConduitInfo.Color; singleConduitInfo.Shape = @event.ConduitInfo.Shape; singleConduitInfo.ColorMarking = @event.ConduitInfo.ColorMarking; singleConduitInfo.TextMarking = @event.ConduitInfo.TextMarking; singleConduitInfo.Name = @event.ConduitInfo.Name; singleConduitInfo.InnerDiameter = @event.ConduitInfo.InnerDiameter; singleConduitInfo.OuterDiameter = @event.ConduitInfo.OuterDiameter; // Create segment info (as is looks before any cuts or connections) var segment = new SingleConduitSegmentInfo(); segment.Id = Guid.NewGuid(); segment.ConduitId = @event.SingleConduitId; segment.SequenceNumber = 1; segment.FromRouteNodeId = routeNetworkQueryService.GetWalkOfInterestInfo(singleConduitInfo.WalkOfInterestId).StartNodeId; segment.ToRouteNodeId = routeNetworkQueryService.GetWalkOfInterestInfo(singleConduitInfo.WalkOfInterestId).EndNodeId; singleConduitInfo.Segments = new List <ISegment>() { segment }; conduitNetworkQueryService.UpdateSingleConduitInfo(singleConduitInfo); }
public static void CutConduit(ConduitInfo conduitInfo, WalkOfInterestInfo walkOfInterest, RouteNodeInfo nodeWhereToCut) { ConduitSegmentInfo newSegment = null; List <ISegment> newSegmentList = new List <ISegment>(); int newSequenceNumber = 1; var fromNodeId = conduitInfo.Segments[0].FromRouteNodeId; foreach (var existingSegment in conduitInfo.Segments) { List <Guid> segmentWalk = walkOfInterest.SubWalk(existingSegment.FromRouteNodeId, existingSegment.ToRouteNodeId); newSegmentList.Add(existingSegment); existingSegment.SequenceNumber = newSequenceNumber; existingSegment.FromRouteNodeId = fromNodeId; // If the segment is cut by point of interest, divide it if (segmentWalk.Contains(nodeWhereToCut.Id)) { // Create the segment newSequenceNumber++; if (conduitInfo.Kind != ConduitKindEnum.MultiConduit) { newSegment = new SingleConduitSegmentInfo(); } else { newSegment = new MultiConduitSegmentInfo(); } newSegment.Id = Guid.NewGuid(); newSegment.ConduitId = ((ConduitSegmentInfo)existingSegment).ConduitId; newSegment.SequenceNumber = newSequenceNumber; newSegment.FromRouteNodeId = nodeWhereToCut.Id; newSegment.ToRouteNodeId = existingSegment.ToRouteNodeId; // we need copy to side info newSegment.ToNodeId = existingSegment.ToNodeId; // we need copy to side info newSegment.ToNode = existingSegment.ToNode; // we need copy to side info // Update the existing segment existingSegment.ToRouteNodeId = nodeWhereToCut.Id; existingSegment.ToNodeId = Guid.Empty; // cannot possible have to junction anymore if it had so (transfered to new segment) existingSegment.ToNode = null; // cannot possible have to junction anymore if it had so (transfered to new segment) // Set from node on next segment to from node on inserted segment fromNodeId = newSegment.ToRouteNodeId; newSegmentList.Add(newSegment); } else { // set from node to this one to node fromNodeId = existingSegment.ToRouteNodeId; } newSequenceNumber++; } conduitInfo.Segments = newSegmentList; // Needed to wake up Marten conduitInfo.Name = conduitInfo.Name; }