public static Result <NodeContainer> GetNodeContainer(IQueryDispatcher queryDispatcher, Guid nodeContainerId)
        {
            var equipmentIdList = new EquipmentIdList();

            equipmentIdList.Add(nodeContainerId);

            // Query all the equipments related to the route network element
            var equipmentQueryResult = queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(equipmentIdList)
            {
                EquipmentDetailsFilter = new EquipmentDetailsFilterOptions()
                {
                    IncludeRouteNetworkTrace = false
                }
            }
                ).Result;

            if (equipmentQueryResult.IsFailed)
            {
                return(Result.Fail(equipmentQueryResult.Errors.First()));
            }

            if (equipmentQueryResult.Value.NodeContainers != null && equipmentQueryResult.Value.NodeContainers.Count > 0)
            {
                return(Result.Ok(equipmentQueryResult.Value.NodeContainers.First()));
            }


            return(Result.Fail(new Error($"Failed to find node container with id: {nodeContainerId}")));
        }
示例#2
0
        private Guid?GetSingleSpanSegmentTraceOnlyIdIfSpecificed(EquipmentIdList equipmentIdsToQuery)
        {
            if (equipmentIdsToQuery.Count == 1)
            {
                var spanEquipmentOrSegmentId = equipmentIdsToQuery[0];

                if (_utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphSegmentRef>(spanEquipmentOrSegmentId, out var _))
                {
                    return(spanEquipmentOrSegmentId);
                }
            }

            return(null);
        }
示例#3
0
        private Result <List <SpanEquipmentWithRelatedInfo> > GetSpanEquipmentsById(EquipmentIdList equipmentIdsToFetch)
        {
            List <SpanEquipmentWithRelatedInfo> result = new List <SpanEquipmentWithRelatedInfo>();

            foreach (var equipmentId in equipmentIdsToFetch)
            {
                if (!_utilityNetwork.TryGetEquipment <SpanEquipment>(equipmentId, out var spanEquipment))
                {
                    return(Result.Fail(new GetEquipmentDetailsError(GetEquipmentDetailsErrorCodes.INVALID_QUERY_ARGUMENT_ERROR_LOOKING_UP_SPECIFIED_EQUIPMENT_BY_EQUIPMENT_ID, $"Cannot find equipment with equipment id: {equipmentId}")));
                }

                result.Add(new SpanEquipmentWithRelatedInfo(spanEquipment));
            }

            return(Result.Ok <List <SpanEquipmentWithRelatedInfo> >(result));
        }