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();
NetworkSource electricDevice = networkSources.First(f => f.Name.Contains("ElectricDevice"));
// 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>>()
{ { electricDevice.ID, new List<string>() { "AssetID" } } }
};
subnetwork.Export(exportResultJsonPath, subnetworkExportOptions);
}
}