Beispiel #1
0
        public Task <Unit> Handle(AttachConduitEndToClosureCommand request, CancellationToken cancellationToken)
        {
            // Id check
            if (request.ConduitClosureId == null || request.ConduitClosureId == Guid.Empty)
            {
                throw new ArgumentException("ConduitClosureId cannot be null or empty");
            }

            var conduitClosure = repo.Load <ConduitClosure>(request.ConduitClosureId);

            conduitClosure.AttachConduitEndToClosure(request.ConduitId, request.Side, request.PortPosition, request.TerminalPosition, routeNetworkQueryService, conduitNetworkQueryService, conduitClosureRepository);
            repo.Store(conduitClosure);

            return(Unit.Task);
        }
Beispiel #2
0
        public static void Run(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IMediator commandBus)
        {
            var conduitClosureId  = Guid.Parse("4ba4e2de-a06d-4168-b85b-a65490a9f313");
            var pointOfInterestId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000122");

            // Create conduit closure in J-1010
            var createConduitClosureCmd = new PlaceConduitClosureCommand()
            {
                ConduitClosureId  = conduitClosureId,
                PointOfInterestId = pointOfInterestId
            };

            commandBus.Send(createConduitClosureCmd).Wait();

            // Attached the two flex conduits from J-1010 to SP-1010 to conduit closure
            var attachFlexConduitCmd1 = new AttachConduitEndToClosureCommand()
            {
                ConduitClosureId = conduitClosureId,
                ConduitId        = Guid.Parse("9f779e83-9ffd-e5dd-2cfe-cb58197f74b0"),
                Side             = ConduitClosureInfoSide.Top
            };

            commandBus.Send(attachFlexConduitCmd1).Wait();

            var attachFlexConduitCmd2 = new AttachConduitEndToClosureCommand()
            {
                ConduitClosureId = conduitClosureId,
                ConduitId        = Guid.Parse("a7425e14-ba84-c958-c89f-6e00d84355a4"),
                Side             = ConduitClosureInfoSide.Top
            };

            commandBus.Send(attachFlexConduitCmd2).Wait();

            // Create 96 fiber cable from CO-BDAL to CO-BRED
            Guid startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000016");
            Guid endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000046");
            Guid cableId     = Guid.Parse("15960ab1-a6f8-46ca-964d-504354ec06b9");

            PlaceCable(routeNetworkQueryService, commandBus, cableId, 96, startNodeId, endNodeId);

            // Create 72 fiber cable from CO-BDAL to FP-1010
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000016");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            var fpCableId = Guid.Parse("3ebf7e5d-ebfe-4c06-b875-513c89b44ef0");

            PlaceCable(routeNetworkQueryService, commandBus, fpCableId, 72, startNodeId, endNodeId);

            // Create 48 fiber cable from FP-1010 to SP-1010
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000022");
            var spCableId1 = Guid.Parse("ba9e4da4-92df-4208-bd66-98e7ba659d9e");

            PlaceCable(routeNetworkQueryService, commandBus, spCableId1, 48, startNodeId, endNodeId);

            // Create 48 fiber cable from FP-1010 to SP-1020
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000059");
            var spCableId2 = Guid.Parse("5ee30eee-f9a5-4034-8d0e-871aa85cf6c7");

            PlaceCable(routeNetworkQueryService, commandBus, spCableId2, 48, startNodeId, endNodeId);
        }
Beispiel #3
0
        public ConduitClosureCommandHandler(IMediator commandBus, IConduitClosureRepository conduitClosureRepository, IRouteNetworkState routeNetwork, IConduitNetworkQueryService conduitNetwork)
        {
            Description = "API for sending commands to the conduit closure aggregate root";

            Field <ConduitClosureType>(
                "placeConduitClosure",
                description: "Place a new conduit clousure in a point of interest (route node)",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "pointOfInterestId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "conduitClosureId"
            }
                    ),
                resolve: context =>
            {
                var conduitClosureId = context.GetArgument <Guid>("conduitClosureId");

                var createConduitClosureCmd = new PlaceConduitClosureCommand()
                {
                    ConduitClosureId  = Guid.NewGuid(),
                    PointOfInterestId = context.GetArgument <Guid>("pointOfInterestId")
                };

                if (conduitClosureId != Guid.Empty)
                {
                    createConduitClosureCmd.ConduitClosureId = conduitClosureId;
                }

                try
                {
                    commandBus.Send(createConduitClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(createConduitClosureCmd.ConduitClosureId));
            }
                );

            Field <ConduitClosureType>(
                "removeConduitClosure",
                description: "Remove a new conduit clousure from its point of interest (route node)",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId"
            }
                    ),
                resolve: context =>
            {
                var removeConduitClosureCmd = new RemoveConduitClosureCommand()
                {
                    ConduitClosureId = context.GetArgument <Guid>("conduitClosureId")
                };

                try
                {
                    commandBus.Send(removeConduitClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(null);
            }
                );

            Field <ConduitClosureType>(
                "attachPassByConduitToClosure",
                description: "Attach a conduit that is passing by to the conduit closure",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId", Description = "Id of the conduit closure where the passing conduit should be attached to"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitId", Description = "Id of the conduit to be attached to the conduit closure"
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "incommingSide", Description = "The side where the conduit should enter the closure. This argument is mandatory."
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "outgoingSide", Description = "The side where the conduit should leav the closure. This argument is mandatory."
            },
                    new QueryArgument <IntGraphType> {
                Name = "incommingPortPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "outgoingPortPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "incommingTerminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            },
                    new QueryArgument <IntGraphType> {
                Name = "outgoingTerminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            }
                    ),
                resolve: context =>
            {
                var routeConduitThroughClosureCmd = new AttachPassByConduitToClosureCommand()
                {
                    ConduitClosureId          = context.GetArgument <Guid>("conduitClosureId"),
                    ConduitId                 = context.GetArgument <Guid>("conduitId"),
                    IncommingSide             = context.GetArgument <ConduitClosureInfoSide>("incommingSide"),
                    OutgoingSide              = context.GetArgument <ConduitClosureInfoSide>("outgoingSide"),
                    IncommingPortPosition     = context.GetArgument <int>("incommingPortPosition"),
                    OutgoingPortPosition      = context.GetArgument <int>("outgoingPortPosition"),
                    IncommingTerminalPosition = context.GetArgument <int>("incommingPortPosition"),
                    OutgoingTerminalPosition  = context.GetArgument <int>("outgoingPortPosition"),
                };

                try
                {
                    commandBus.Send(routeConduitThroughClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(routeConduitThroughClosureCmd.ConduitClosureId));
            }
                );


            Field <ConduitClosureType>(
                "attachConduitEndToClosure",
                description: "Attach a conduit to the conduit closure, that is ending in the point of interest (node) where the conduit closure is also located.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId", Description = "Id of the ending conduit that should be attached to the conduit closure."
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitId", Description = "Id of the conduit to be attached to the conduit closure"
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "side", Description = "The side where the conduit should enter the closure. This argument is mandatory."
            },
                    new QueryArgument <IntGraphType> {
                Name = "portPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "terminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            }
                    ),
                resolve: context =>
            {
                var attachConduitEndCmd = new AttachConduitEndToClosureCommand()
                {
                    ConduitClosureId = context.GetArgument <Guid>("conduitClosureId"),
                    ConduitId        = context.GetArgument <Guid>("conduitId"),
                    Side             = context.GetArgument <ConduitClosureInfoSide>("side"),
                    PortPosition     = context.GetArgument <int>("portPosition"),
                    TerminalPosition = context.GetArgument <int>("terminalPosition"),
                };

                try
                {
                    commandBus.Send(attachConduitEndCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(attachConduitEndCmd.ConduitClosureId));
            }
                );
        }