示例#1
0
        private RouteSegment CreateRouteSegmentClone(RouteSegment routeSegment)
        {
            var routeSegmentClone = _routeSegmentFactory.Create(routeSegment.GetLineString());

            routeSegmentClone.WorkTaskMrid     = routeSegment.WorkTaskMrid;
            routeSegmentClone.ApplicationInfo  = routeSegment.ApplicationInfo;
            routeSegmentClone.MappingInfo      = routeSegment.MappingInfo;
            routeSegmentClone.LifeCycleInfo    = routeSegment.LifeCycleInfo;
            routeSegmentClone.NamingInfo       = routeSegment.NamingInfo;
            routeSegmentClone.RouteSegmentInfo = routeSegment.RouteSegmentInfo;
            routeSegmentClone.SafetyInfo       = routeSegment.SafetyInfo;
            routeSegmentClone.Username         = routeSegment.Username;

            return(routeSegmentClone);
        }
示例#2
0
        public async Task Handle(ExistingRouteSegmentSplitted request, CancellationToken token)
        {
            _logger.LogInformation($"Starting {nameof(ExistingRouteSegmentSplittedHandler)}");

            var domainEvents = new List <RouteNetworkEvent>();

            if (request.InsertNode)
            {
                await _geoDatabase.InsertRouteNode(request.RouteNode);

                var routeNodeAddedEvent = _routeNodeEventFactory.CreateAdded(request.RouteNode);
                domainEvents.Add(routeNodeAddedEvent);
            }

            if (request.CreateNodeAddedEvent && !request.InsertNode)
            {
                var routeNodeAddedEvent = _routeNodeEventFactory.CreateAdded(request.RouteNode);
                domainEvents.Add(routeNodeAddedEvent);
            }

            var intersectingRouteSegment = await GetIntersectingRouteSegment(request.RouteSegmentDigitizedByUser, request.RouteNode);

            var routeSegmentsWkt = await _geoDatabase.GetRouteSegmentsSplittedByRouteNode(request.RouteNode, intersectingRouteSegment);

            var routeSegments = _routeSegmentFactory.Create(routeSegmentsWkt);

            SetSplittedRouteSegmentValuesToNewRouteSegments(routeSegments, intersectingRouteSegment);

            var routeSegmentAddedEvents = await InsertReplacementRouteSegments(routeSegments);

            domainEvents.AddRange(routeSegmentAddedEvents);

            var routeSegmentMarkedForDeletionEvent = await DeleteRouteSegment(intersectingRouteSegment, routeSegments);

            domainEvents.Add(routeSegmentMarkedForDeletionEvent);

            var cmdId = Guid.NewGuid();
            var routeNetworkCommand = new RouteNetworkCommand(nameof(ExistingRouteSegmentSplitted), cmdId, domainEvents.ToArray());

            _eventStore.Insert(routeNetworkCommand);
        }