Esempio n. 1
0
        /// <summary>
        /// This routine takes a row from the starting (or barrier) point table and converts it to a [Network] Element that we can use for tracing
        /// </summary>
        /// <param name="pointRow">The Row (either starting point or barrier point)</param>
        /// <param name="utilityNetwork">Utility Network to be used</param>
        /// <param name="definition">Utility Network definition to be used</param>
        /// <returns>newly created element</returns>
        private static Element GetElementFromPointRow(Row pointRow,
                                                      UtilityNetwork utilityNetwork, UtilityNetworkDefinition definition)
        {
            // Fetch the SourceID, AssetGroupCode, AssetType, GlobalID, and TerminalID values from the starting point row
            int    sourceID     = (int)pointRow[PointsSourceIDFieldName];
            int    assetGroupID = (int)pointRow[PointsAssetGroupFieldName];
            int    assetTypeID  = (int)pointRow[PointsAssetTypeFieldName];
            Guid   globalID     = new Guid(pointRow[PointsGlobalIDFieldName].ToString());
            int    terminalID   = (int)pointRow[PointsTerminalFieldName];
            double percentAlong = (double)pointRow[PointsPercentAlong];

            // Fetch the NetworkSource, AssetGroup, and AssetType objects
            NetworkSource networkSource = definition.GetNetworkSources().First(x => x.ID == sourceID);
            AssetGroup    assetGroup    = networkSource.GetAssetGroups().First(x => x.Code == assetGroupID);
            AssetType     assetType     = assetGroup.GetAssetTypes().First(x => x.Code == assetTypeID);

            // Fetch the Terminal object from the ID
            Terminal terminal = null;

            if (assetType.IsTerminalConfigurationSupported())
            {
                TerminalConfiguration terminalConfiguration = assetType.GetTerminalConfiguration();
                terminal = terminalConfiguration.Terminals.First(x => x.ID == terminalID);
            }

            // Create and return a FeatureElement object
            // If we have an edge, set the PercentAlongEdge property; otherwise set the Terminal property
            if (networkSource.Type == SourceType.Edge)
            {
                Element element = utilityNetwork.CreateElement(assetType, globalID);
                element.PercentAlongEdge = percentAlong;
                return(element);
            }
            else
            {
                Element element = utilityNetwork.CreateElement(assetType, globalID, terminal);
                return(element);
            }
        }
        /// <summary>
        /// GetNetworkElementFromStartingPoint
        ///
        /// This routine takes a row from the starting point table and converts it to a NetworkElement that we can use for tracing
        ///
        /// </summary>
        ///

        private Element GetElementFromStartingPointRow(Row startingPointRow, UtilityNetwork utilityNetwork, UtilityNetworkDefinition definition)
        {
            // Fetch the SourceID, AssetGroupCode, AssetType, GlobalID, and TerminalID values from the starting point row

            object vSourceID = startingPointRow[StartingPointsSourceIDFieldName];
            int    sourceID  = (int)vSourceID;

            object vAssetGroupID = startingPointRow[StartingPointsAssetGroupFieldName];
            int    assetGroupID  = (int)vAssetGroupID;

            object vAssetTypeID = startingPointRow[StartingPointsAssetTypeFieldName];
            int    assetTypeID  = (int)vAssetTypeID;

            object vGlobalID = startingPointRow[StartingPointsGlobalIDFieldName];
            Guid   globalID  = new Guid(vGlobalID.ToString());

            object vTerminalID = startingPointRow[StartingPointsTerminalFieldName];
            int    terminalID  = (int)vTerminalID;

            // Fetch the NetworkSource, AssetGroup, and AssetType objects

            NetworkSource networkSource = definition.GetNetworkSources().First(x => x.ID == sourceID);
            AssetGroup    assetGroup    = networkSource.GetAssetGroups().First(x => x.Code == assetGroupID);
            AssetType     assetType     = assetGroup.GetAssetTypes().First(x => x.Code == assetTypeID);

            // Fetch the Terminal object from the ID
            Terminal terminal = null;

            if (assetType.IsTerminalConfigurationSupported())
            {
                TerminalConfiguration terminalConfiguration = assetType.GetTerminalConfiguration();
                terminal = terminalConfiguration.Terminals.First(x => x.ID == terminalID);
            }

            // Create and return a Element object

            return(utilityNetwork.CreateElement(assetType, globalID, terminal));
        }