public void ExportSubnetwork(UtilityNetwork utilityNetwork, string subnetworkName, Uri exportResultJsonPath)
{
using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
using (SubnetworkManager subnetworkManager = utilityNetwork.GetSubnetworkManager())
{
Subnetwork subnetwork = subnetworkManager.GetSubnetwork(subnetworkName);
IReadOnlyList<NetworkAttribute> networkAttributes = utilityNetworkDefinition.GetNetworkAttributes();
IReadOnlyList<NetworkSource> networkSources = utilityNetworkDefinition.GetNetworkSources();
// Export options
SubnetworkExportOptions subnetworkExportOptions = new SubnetworkExportOptions()
{
SetAcknowledged = false,
IncludeDomainDescriptions = true,
IncludeGeometry = true,
ServiceSynchronizationType = ServiceSynchronizationType.Asynchronous,
SubnetworkExportResultTypes = new List<SubnetworkExportResultType>()
{
SubnetworkExportResultType.Connectivity,
SubnetworkExportResultType.Features
},
ResultNetworkAttributes = new List<NetworkAttribute>(networkAttributes),
ResultFieldsByNetworkSourceID = new Dictionary<int, List<string>>()
{ { networkSources[0].ID, new List<string>() { "OBJECTID" } } }
};
subnetwork.Export(exportResultJsonPath, subnetworkExportOptions);
}
}