Disable subnetwork controller in utility network, ArcGIS Pro sdk

294
5
04-04-2024 06:40 AM
robertoquartarone
New Contributor

Hi, I need to develop an add-In to work with utility network. After clicking a button, programmatically disable all subnetwork controllers that have a certain globalId within my device layer in map. For testing purposes, I tried to operate with only one subnetwork controller, in order: create an element, get subnetworkManager from un, disable controller in edit operation, save the project and then do subnetwork update. Sequential operations as in the documentation example
https://pro.arcgis.com/en/pro-app/3.0/sdk/api-reference/topic76342.html

What I notice is that no Dirty Area is created, as if the editing is not being done. I tried as well the DisableController method without editing operation and did not get the desired result.
I am currently using version 3.2.2 of Pro and Geodatabase File.
What am I doing wrong?

CODE SNIPPET:

globalIdSBC.Clear();
globalIdSBC.Add("{77725B0F-B758-4D54-B1D9-4A927CC14F01}");

// globalId string list
string globalIdStringList = string.Join(",", globalIdSBC.Select(id => $"'{id}'"));


QueryFilter filter = new QueryFilter
{
    WhereClause = $"GLOBALID IN ({globalIdStringList})"
};
// filter.SubFields = "GLOBALID, OBJECTID";

// Count
int rowCount = GetFilteredFeatureCount(deviceLayer, filter);

Debug.WriteLine($"Count: {rowCount}");

var tierD = domainNetwork.GetTier("Distribuzione Primo Salto");
if (tierD == null)
{
    Debug.WriteLine($"Tier: {tierD}");
    return;
}

var subnetworks = utilityNetwork.GetSubnetworkManager().GetSubnetworks(tierD, SubnetworkStates.All);
var subnetwork = subnetworks.FirstOrDefault(x => x.Name == "R_GorlaMaggiore");


using (var cur = deviceLayer.Search(filter))
{
    ArcGIS.Core.Data.UtilityNetwork.Element element = null;
    while (cur.MoveNext())
    {                    
        var currentRow = cur.Current;

        // Element from row
        element = utilityNetwork.CreateElement(currentRow);
        // Disable snc 
        utilityNetwork.GetSubnetworkManager().DisableControllerInEditOperation(element);

        // Tried also validate network topology first
        UtilityNetworkExtensions.ValidateNetworkTopologyInEditOperation(utilityNetwork);

        // Save edits and update subnetwork
        await Project.Current.SaveEditsAsync();
        subnetwork.Update();
    }
}

// Save edits
// await Project.Current.SaveEditsAsync();

// I tried update both ways 
//foreach (Tier tier in domainNetwork.Tiers)
//{
//    utilityNetwork.GetSubnetworkManager().UpdateAllSubnetworks(tier, true);
//}

//foreach (Tier tier in domainNetwork.Tiers)
//{
//    var subnetworks = utilityNetwork.GetSubnetworkManager().GetSubnetworks(tier, SubnetworkStates.Dirty);
//    foreach (Subnetwork subnetwork in subnetworks)
//    {
//        subnetwork.Update();
//    }
//}

// subnetwork.Update();
mapView.Redraw(true);

 

0 Kudos
5 Replies
Aashis
by Esri Contributor
Esri Contributor

The DisableControllerWithEditOperation should create a dirty area, and calling ValidateNetworkTopologyInEditOperation should clean it so you don't see it.

0 Kudos
robertoquartarone
New Contributor

Hello Aashis,
I thank you for your kind reply. I had not used the ValidateNetworkTopology initially and still the result was the same.
The dirty area is not generated at all because the subnetwork controller remains as such even after disabling, so it is not disabled

DanieleChiara
New Contributor II

@RichRuh sorry for the mention but i think you are the right person to ask 😀 

it's possible the method DisableControllerInEditOperation works only with the UN on service and not with UN in the gdb file?

0 Kudos
RichRuh
Esri Regular Contributor

Ciao Daniele,

No, the DisableControllerInEditOperation works equally well with feature services, file geodatabases, and mobile geodatabases.

Are you sure the feature that you are passing to DisableControllerInEditOperation is, in fact, a subnetwork controller?

--Rich

0 Kudos
DanieleChiara
New Contributor II

Hi Rich. Thanks for the fast reply.

Yes we are sure that the feature is a subnetwork controller (we pass directly the Global ID and the method)

the strange thing is that the save and discard buttons are enable but no dirty areas are created and no error was return in the whole process. 

A screen on what i see in the PRO (Before and after the process)

DanieleChiara_0-1712939481489.png

the snippet of the code.


string  globalIdStringList = "'{597AD203-0637-4ABB-B628-6497D3CB74EA}'";
QueryFilter filter = new QueryFilter
{
WhereClause = $"GLOBALID IN ({globalIdStringList})"
};
filter.SubFields = "GLOBALID, OBJECTID";

using (var cur = deviceLayer.Search(filter))
{
ArcGIS.Core.Data.UtilityNetwork.Element element = null;
while (cur.MoveNext())
{
element = utilityNetwork.CreateElement(cur.Current);
utilityNetwork.GetSubnetworkManager().DisableControllerInEditOperation(element);

}
}



We miss something?

We try with pro 3.1.3 and 3.2.2 and enterprise 11.1

 

 

0 Kudos