diff --git a/Content/MetadataBrowserControl/MetadataBrowserControl.xml b/Content/MetadataBrowserControl/MetadataBrowserControl.xml index 7a5e7c3c..283913f4 100644 --- a/Content/MetadataBrowserControl/MetadataBrowserControl.xml +++ b/Content/MetadataBrowserControl/MetadataBrowserControl.xml @@ -161,35 +161,5 @@ Represents the stylesheet picked to apply the transform with - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/CoreHost/CoreHostGDB/CoreHostGDB.xml b/CoreHost/CoreHostGDB/CoreHostGDB.xml index 9359fafb..1c183812 100644 --- a/CoreHost/CoreHostGDB/CoreHostGDB.xml +++ b/CoreHost/CoreHostGDB/CoreHostGDB.xml @@ -146,35 +146,5 @@ Gets the rows from the selected table - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Framework/ConfigWithMap/ConfigWithMap.xml b/Framework/ConfigWithMap/ConfigWithMap.xml index 9b995d37..5b3f4d3c 100644 --- a/Framework/ConfigWithMap/ConfigWithMap.xml +++ b/Framework/ConfigWithMap/ConfigWithMap.xml @@ -171,35 +171,5 @@ Business logic for the StartPage - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Framework/CustomStyling/CustomStyling.xml b/Framework/CustomStyling/CustomStyling.xml index f7aac8e8..4b1f4624 100644 --- a/Framework/CustomStyling/CustomStyling.xml +++ b/Framework/CustomStyling/CustomStyling.xml @@ -75,35 +75,5 @@ InitializeComponent - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Geometry/CoordinateSystemDialog/CoordinateSystemPicker.xml b/Geometry/CoordinateSystemDialog/CoordinateSystemPicker.xml index f1cb848d..6288ec9f 100644 --- a/Geometry/CoordinateSystemDialog/CoordinateSystemPicker.xml +++ b/Geometry/CoordinateSystemDialog/CoordinateSystemPicker.xml @@ -109,35 +109,5 @@ InitializeComponent - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Map-Authoring/Symbology/Symbology.xml b/Map-Authoring/Symbology/Symbology.xml index 9f193347..7081457e 100644 --- a/Map-Authoring/Symbology/Symbology.xml +++ b/Map-Authoring/Symbology/Symbology.xml @@ -229,35 +229,5 @@ Button implementation to show the DockPane. - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Map-Authoring/TextSymbols/TextSymbols.xml b/Map-Authoring/TextSymbols/TextSymbols.xml index 0f63b2c2..27357a35 100644 --- a/Map-Authoring/TextSymbols/TextSymbols.xml +++ b/Map-Authoring/TextSymbols/TextSymbols.xml @@ -161,35 +161,5 @@ - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/Map-Exploration/CustomAnimation/CustomAnimation.xml b/Map-Exploration/CustomAnimation/CustomAnimation.xml index e527133f..3b68ceb2 100644 --- a/Map-Exploration/CustomAnimation/CustomAnimation.xml +++ b/Map-Exploration/CustomAnimation/CustomAnimation.xml @@ -142,35 +142,5 @@ ViewModel for the timing options control. - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - diff --git a/README.md b/README.md index a43367eb..7f3b87a4 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Read the [ProGuide: Installation and Upgrade](https://github.com/Esri/arcgis-pro ## ArcGIS Pro Add-In Community Sample List -Below is the list of 193 ArcGIS Pro samples that are included in this repository. +Below is the list of 194 ArcGIS Pro samples that are included in this repository. #### Content @@ -316,6 +316,7 @@ Below is the list of 193 ArcGIS Pro samples that are included in this repository * [CategoriesUsage (c#)](../../tree/master/UtilityNetwork/CategoriesUsage) * [CreateTransformerBank (c#)](../../tree/master/UtilityNetwork/CreateTransformerBank) * [LoadReportSample (c#)](../../tree/master/UtilityNetwork/LoadReportSample) +* [ValidateChanges (c#)](../../tree/master/UtilityNetwork/ValidateChanges) #### Workflow diff --git a/Samples.sln b/Samples.sln index 42bbaa7e..8423c5a9 100644 --- a/Samples.sln +++ b/Samples.sln @@ -414,6 +414,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DisplayFilters", "Map-Autho EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphicsLayers", "Map-Authoring\GraphicsLayers\GraphicsLayers.csproj", "{3711865A-D5D9-4607-8A1B-659019D6C148}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValidateChanges", "UtilityNetwork\ValidateChanges\ValidateChanges.csproj", "{0A907E31-89CA-439F-855C-81FC9375EEEF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -2038,6 +2040,14 @@ Global {3711865A-D5D9-4607-8A1B-659019D6C148}.Release|Any CPU.Build.0 = Release|Any CPU {3711865A-D5D9-4607-8A1B-659019D6C148}.Release|x64.ActiveCfg = Release|Any CPU {3711865A-D5D9-4607-8A1B-659019D6C148}.Release|x64.Build.0 = Release|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|x64.ActiveCfg = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|x64.Build.0 = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|Any CPU.Build.0 = Release|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|x64.ActiveCfg = Release|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/UtilityNetwork/README.md b/UtilityNetwork/README.md index c4e5443a..717196a0 100644 --- a/UtilityNetwork/README.md +++ b/UtilityNetwork/README.md @@ -16,6 +16,7 @@ This folder contains ArcGIS Pro Add-In Samples that fall under the 'Utility Netw * [CategoriesUsage (c#)](../../../tree/master/UtilityNetwork/CategoriesUsage) * [CreateTransformerBank (c#)](../../../tree/master/UtilityNetwork/CreateTransformerBank) * [LoadReportSample (c#)](../../../tree/master/UtilityNetwork/LoadReportSample) +* [ValidateChanges (c#)](../../../tree/master/UtilityNetwork/ValidateChanges) ## Instructions diff --git a/UtilityNetwork/ValidateChanges/Config.daml b/UtilityNetwork/ValidateChanges/Config.daml new file mode 100644 index 00000000..814e0541 --- /dev/null +++ b/UtilityNetwork/ValidateChanges/Config.daml @@ -0,0 +1,56 @@ + + + + + ValidateChanges + ValidateChanges description + Images\AddinDesktop32.png + ArcGIS Pro SDK Team, arcgisprosdk@esri.com + esri, http://www.esri.com + 7/24/2020 1:46:58 PM, 2020 + UtilityNetwork + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop16.png b/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop16.png new file mode 100644 index 00000000..0118942a Binary files /dev/null and b/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop16.png differ diff --git a/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop32.png b/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop32.png new file mode 100644 index 00000000..9713e3b1 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/DarkImages/AddInDesktop32.png differ diff --git a/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue16.png b/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue16.png new file mode 100644 index 00000000..20b11875 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue16.png differ diff --git a/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue32.png b/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue32.png new file mode 100644 index 00000000..e3b26ab9 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/DarkImages/GenericButtonBlue32.png differ diff --git a/UtilityNetwork/ValidateChanges/Images/AddInDesktop16.png b/UtilityNetwork/ValidateChanges/Images/AddInDesktop16.png new file mode 100644 index 00000000..5910bbf3 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/Images/AddInDesktop16.png differ diff --git a/UtilityNetwork/ValidateChanges/Images/AddInDesktop32.png b/UtilityNetwork/ValidateChanges/Images/AddInDesktop32.png new file mode 100644 index 00000000..1d19084a Binary files /dev/null and b/UtilityNetwork/ValidateChanges/Images/AddInDesktop32.png differ diff --git a/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue16.png b/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue16.png new file mode 100644 index 00000000..ab6cad35 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue16.png differ diff --git a/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue32.png b/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue32.png new file mode 100644 index 00000000..4a573fd6 Binary files /dev/null and b/UtilityNetwork/ValidateChanges/Images/GenericButtonBlue32.png differ diff --git a/UtilityNetwork/ValidateChanges/Module1.cs b/UtilityNetwork/ValidateChanges/Module1.cs new file mode 100644 index 00000000..4a315794 --- /dev/null +++ b/UtilityNetwork/ValidateChanges/Module1.cs @@ -0,0 +1,87 @@ +/* + + Copyright 2020 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Threading.Tasks; +using ArcGIS.Core.CIM; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Catalog; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Editing; +using ArcGIS.Desktop.Extensions; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; +using ArcGIS.Desktop.Framework.Dialogs; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; + +namespace ValidateChanges +{ + /// + /// This add-in demonstrates running Validate Network Topology on data changes. When used on a file geodatabase or on the default version of a branch-versioned feature service, it runs Validate Network Topology on the entire network. + /// If used on a named version of a branch-versioned feature service, it does a version differences on the dirty areas table, and uses the resulting extent for the Validate Network Topology operation. + /// + /// Community Sample data(see under the "Resources" section for downloading sample data) has a UtilityNetworkSamples.aprx project that contains a utility network that can be used with this sample.This project can be found under the + /// C:\Data\UtilityNetwork folder. However, to demonstrate the version differences functionality, a utility network should be published to a feature service. + /// + /// + /// 1. In Visual Studio click the Build menu. Then select Build Solution. + /// 1. Click Start button to open ArcGIS Pro. + /// 1. ArcGIS Pro will open. + /// 1. Open a project and map view that references a utility network. + /// 1. Switch to a branch version that contains edits to utility network features. + /// 1. Select a feature layer or subtype group layer that participates in a utility network or a utility network layer. + /// 1. Click on the Add-in tab on the ribbon. + /// 1. Click on the Validate Changes button. + /// + internal class Module1 : Module + { + private static Module1 _this = null; + + /// + /// Retrieve the singleton instance to this module here + /// + public static Module1 Current + { + get + { + return _this ?? (_this = (Module1)FrameworkApplication.FindModule("ValidateChanges_Module")); + } + } + + #region Overrides + /// + /// Called by Framework when ArcGIS Pro is closing + /// + /// False to prevent Pro from closing, otherwise True + protected override bool CanUnload() + { + //TODO - add your business logic + //return false to ~cancel~ Application close + return true; + } + + #endregion Overrides + + } +} diff --git a/UtilityNetwork/ValidateChanges/Properties/AssemblyInfo.cs b/UtilityNetwork/ValidateChanges/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a72f3043 --- /dev/null +++ b/UtilityNetwork/ValidateChanges/Properties/AssemblyInfo.cs @@ -0,0 +1,54 @@ +/* + + Copyright 2020 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ValidateChanges")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Acme")] +[assembly: AssemblyProduct("ValidateChanges")] +[assembly: AssemblyCopyright("Copyright © Acme 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0a907e31-89ca-439f-855c-81fc9375eeef")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UtilityNetwork/ValidateChanges/ReadMe.md b/UtilityNetwork/ValidateChanges/ReadMe.md new file mode 100644 index 00000000..0c44d58a --- /dev/null +++ b/UtilityNetwork/ValidateChanges/ReadMe.md @@ -0,0 +1,58 @@ +## ValidateChanges + + + This add-in demonstrates running Validate Network Topology on data changes. When used on a file geodatabase or on the default version of a branch-versioned feature service, it runs Validate Network Topology on the entire network. + If used on a named version of a branch-versioned feature service, it does a version differences on the dirty areas table, and uses the resulting extent for the Validate Network Topology operation. + + Community Sample data(see under the "Resources" section for downloading sample data) has a UtilityNetworkSamples.aprx project that contains a utility network that can be used with this sample.This project can be found under the + C:\Data\UtilityNetwork folder. However, to demonstrate the version differences functionality, a utility network should be published to a feature service. + + + +View it live + + +``` +Language: C# +Subject: UtilityNetwork +Contributor: ArcGIS Pro SDK Team +Organization: Esri, http://www.esri.com +Date: 7/01/2020 +ArcGIS Pro: 2.6 +Visual Studio: 2019 +.NET Target Framework: 4.8 +``` + +## Resources + +* [API Reference online](https://pro.arcgis.com/en/pro-app/sdk/api-reference) +* ArcGIS Pro SDK for .NET (pro.arcgis.com) +* [arcgis-pro-sdk-community-samples](https://github.com/Esri/arcgis-pro-sdk-community-samples) +* [ArcGIS Pro DAML ID Reference](https://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference) +* [FAQ](https://github.com/Esri/arcgis-pro-sdk/wiki/FAQ) +* [ArcGIS Pro SDK icons](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.4.0.19948) + +![ArcGIS Pro SDK for .NET Icons](https://Esri.github.io/arcgis-pro-sdk/images/Home/Image-of-icons.png "ArcGIS Pro SDK Icons") + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [repo releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + + 1. In Visual Studio click the Build menu. Then select Build Solution. + 1. Click Start button to open ArcGIS Pro. + 1. ArcGIS Pro will open. + 1. Open a project and map view that references a utility network. + 1. Switch to a branch version that contains edits to utility network features. + 1. Select a feature layer or subtype group layer that participates in a utility network or a utility network layer. + 1. Click on the Add-in tab on the ribbon. + 1. Click on the Validate Changes button. + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/UtilityNetwork/ValidateChanges/UtilityNetworkUtils.cs b/UtilityNetwork/ValidateChanges/UtilityNetworkUtils.cs new file mode 100644 index 00000000..f39e0daa --- /dev/null +++ b/UtilityNetwork/ValidateChanges/UtilityNetworkUtils.cs @@ -0,0 +1,117 @@ +// Copyright 2019 Esri +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.UtilityNetwork; +using ArcGIS.Desktop.Mapping; + +namespace UtilityNetworkSamples +{ + class UtilityNetworkUtils + { + + /// + /// GetUtilityNetworkFromFeatureClass - gets a utility network from a layer + /// + /// + /// a UtilityNetwork object, or null if the layer does not reference a utility network + public static UtilityNetwork GetUtilityNetworkFromLayer(Layer layer) + { + + UtilityNetwork utilityNetwork = null; + + if (layer is UtilityNetworkLayer) + { + UtilityNetworkLayer utilityNetworkLayer = layer as UtilityNetworkLayer; + utilityNetwork = utilityNetworkLayer.GetUtilityNetwork(); + } + + else if (layer is SubtypeGroupLayer) + { + CompositeLayer compositeLayer = layer as CompositeLayer; + utilityNetwork = GetUtilityNetworkFromLayer(compositeLayer.Layers.First()); + } + + else if (layer is FeatureLayer) + { + FeatureLayer featureLayer = layer as FeatureLayer; + using (FeatureClass featureClass = featureLayer.GetFeatureClass()) + { + if (featureClass.IsControllerDatasetSupported()) + { + IReadOnlyList controllerDatasets = new List(); + controllerDatasets = featureClass.GetControllerDatasets(); + foreach (Dataset controllerDataset in controllerDatasets) + { + if (controllerDataset is UtilityNetwork) + { + utilityNetwork = controllerDataset as UtilityNetwork; + } + else + { + controllerDataset.Dispose(); + } + } + } + } + } + + else if (layer is GroupLayer) + { + CompositeLayer compositeLayer = layer as CompositeLayer; + foreach (Layer childLayer in compositeLayer.Layers) + { + utilityNetwork = GetUtilityNetworkFromLayer(childLayer); + // Break at the first layer inside a group layer that belongs to a utility network + if (utilityNetwork != null) break; + } + } + + return utilityNetwork; + } + + /// + /// Fetches a Row from an Element + /// + /// The utility network to which the element belongs + /// An element in a utility network + /// The Row corresponding to the Element (if any) + public static Row FetchRowFromElement(UtilityNetwork utilityNetwork, Element element) + { + // Get the table from the element + using (Table table = utilityNetwork.GetTable(element.NetworkSource)) + { + // Create a query filter to fetch the appropriate row + QueryFilter queryFilter = new QueryFilter() + { + ObjectIDs = new List() { element.ObjectID } + }; + + // Fetch and return the row + using (RowCursor rowCursor = table.Search(queryFilter)) + { + if (rowCursor.MoveNext()) + { + return rowCursor.Current; + } + } + return null; + } + + } + + } +} diff --git a/UtilityNetwork/ValidateChanges/ValidateChanges (C#).md b/UtilityNetwork/ValidateChanges/ValidateChanges (C#).md new file mode 100644 index 00000000..0c44d58a --- /dev/null +++ b/UtilityNetwork/ValidateChanges/ValidateChanges (C#).md @@ -0,0 +1,58 @@ +## ValidateChanges + + + This add-in demonstrates running Validate Network Topology on data changes. When used on a file geodatabase or on the default version of a branch-versioned feature service, it runs Validate Network Topology on the entire network. + If used on a named version of a branch-versioned feature service, it does a version differences on the dirty areas table, and uses the resulting extent for the Validate Network Topology operation. + + Community Sample data(see under the "Resources" section for downloading sample data) has a UtilityNetworkSamples.aprx project that contains a utility network that can be used with this sample.This project can be found under the + C:\Data\UtilityNetwork folder. However, to demonstrate the version differences functionality, a utility network should be published to a feature service. + + + +View it live + + +``` +Language: C# +Subject: UtilityNetwork +Contributor: ArcGIS Pro SDK Team +Organization: Esri, http://www.esri.com +Date: 7/01/2020 +ArcGIS Pro: 2.6 +Visual Studio: 2019 +.NET Target Framework: 4.8 +``` + +## Resources + +* [API Reference online](https://pro.arcgis.com/en/pro-app/sdk/api-reference) +* ArcGIS Pro SDK for .NET (pro.arcgis.com) +* [arcgis-pro-sdk-community-samples](https://github.com/Esri/arcgis-pro-sdk-community-samples) +* [ArcGIS Pro DAML ID Reference](https://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference) +* [FAQ](https://github.com/Esri/arcgis-pro-sdk/wiki/FAQ) +* [ArcGIS Pro SDK icons](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.4.0.19948) + +![ArcGIS Pro SDK for .NET Icons](https://Esri.github.io/arcgis-pro-sdk/images/Home/Image-of-icons.png "ArcGIS Pro SDK Icons") + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [repo releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + + 1. In Visual Studio click the Build menu. Then select Build Solution. + 1. Click Start button to open ArcGIS Pro. + 1. ArcGIS Pro will open. + 1. Open a project and map view that references a utility network. + 1. Switch to a branch version that contains edits to utility network features. + 1. Select a feature layer or subtype group layer that participates in a utility network or a utility network layer. + 1. Click on the Add-in tab on the ribbon. + 1. Click on the Validate Changes button. + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/UtilityNetwork/ValidateChanges/ValidateChanges.cs b/UtilityNetwork/ValidateChanges/ValidateChanges.cs new file mode 100644 index 00000000..d12e21de --- /dev/null +++ b/UtilityNetwork/ValidateChanges/ValidateChanges.cs @@ -0,0 +1,219 @@ +/* + + Copyright 2020 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Core.CIM; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; +using ArcGIS.Core.Data.UtilityNetwork; +using ArcGIS.Desktop.Catalog; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Editing; +using ArcGIS.Desktop.Extensions; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; +using ArcGIS.Desktop.Framework.Dialogs; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Desktop.Mapping.Events; +using UtilityNetworkSamples; +using ArcGIS.Core.Data.UtilityNetwork.Extensions; + +using Version = ArcGIS.Core.Data.Version; + +namespace ValidateChanges +{ + internal class ValidateChanges : Button + { + protected async override void OnClick() + { + // Start by checking to make sure we have a single feature layer selected + + if (MapView.Active == null) + { + MessageBox.Show("Please select a utility network layer.", "Validate Changes"); + return; + } + + MapViewEventArgs mapViewEventArgs = new MapViewEventArgs(MapView.Active); + if (mapViewEventArgs.MapView.GetSelectedLayers().Count != 1) + { + MessageBox.Show("Please select a utility network layer.", "Validate Changes"); + return; + } + + Layer selectionLayer = mapViewEventArgs.MapView.GetSelectedLayers()[0]; + if (!(selectionLayer is UtilityNetworkLayer) && !(selectionLayer is FeatureLayer) && !(selectionLayer is SubtypeGroupLayer)) + { + MessageBox.Show("Please select a utility network layer.", "Validate Changes"); + return; + } + + string message = ""; + // Generate our report. The LoadTraceResults class is used to pass back results from the worker thread to the UI thread that we're currently executing. + + await QueuedTask.Run( () => + { + message = ValidateChangedFeatures(selectionLayer); + }); + + MessageBox.Show(message); + } + + private string ValidateChangedFeatures(Layer layer) + { + StringBuilder resultString = new StringBuilder(); + + // Get utility network and geodatabase + using (UtilityNetwork utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(layer)) + using (Geodatabase geodatabase = utilityNetwork.GetDatastore() as Geodatabase) + { + + // Determine what to validate + // File geodatabase - validate everything, synchronously + // Default version - validate everything, asynchronously + // Branch version - validate changes only, synchronously + + bool shouldValidateEverything; + bool runAsync; + + if (!geodatabase.IsVersioningSupported()) + { + shouldValidateEverything = true; + runAsync = false; + } + else + { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + using (Version currentVersion = versionManager.GetCurrentVersion()) + { + if (IsDefaultVersion(currentVersion)) + { + shouldValidateEverything = true; + runAsync = true; + } + else + { + shouldValidateEverything = false; + runAsync = false; + } + } + } + + // If we validating everything, get an envelope from the dirty areas table + EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(layer.GetSpatialReference()); + + if (shouldValidateEverything) + { + using (Table dirtyAreaTable = utilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) + using (RowCursor rowCursor = dirtyAreaTable.Search()) + { + envelopeBuilder = GetExtentFromRowCursor(envelopeBuilder, rowCursor); + } + } + + // else get an envelope using version differences + else + { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + using (Version currentVersion = versionManager.GetCurrentVersion()) + using (Version defaultVersion = currentVersion.GetParent()) + using (Geodatabase defaultGeodatabase = defaultVersion.Connect()) + using (UtilityNetwork defaultUtilityNetwork = defaultGeodatabase.OpenDataset(utilityNetwork.GetName())) + using (Table dirtyAreaTable = utilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) + using (Table defaultDirtyAreaTable = defaultUtilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) + using (DifferenceCursor inserts = dirtyAreaTable.Differences(defaultDirtyAreaTable, DifferenceType.Insert)) + { + envelopeBuilder = GetExtentFromDifferenceCursor(envelopeBuilder, inserts); + } + } + + // Run validate topology on our envelope + Envelope extent = envelopeBuilder.ToGeometry(); + ValidationResult result = utilityNetwork.ValidateNetworkTopologyInEditOperation(extent, runAsync ? InvocationTarget.AsynchronousService : InvocationTarget.SynchronousService); + if (result.HasErrors) + { + resultString.AppendLine("Errors found."); + } + else + { + resultString.AppendLine("No errors found."); + } + } + + return resultString.ToString(); + } + + public bool IsDefaultVersion(Version version) + { + Version parentVersion = version.GetParent(); + if (parentVersion == null) + { + return true; + } + parentVersion.Dispose(); + return false; + } + + private EnvelopeBuilder GetExtentFromRowCursor(EnvelopeBuilder envelopeBuilder, RowCursor rowCursor) + { + while (rowCursor.MoveNext()) + { + using (Feature feature = rowCursor.Current as Feature) + { + Envelope newEnvelope = feature.GetShape().Extent; + envelopeBuilder = Union(envelopeBuilder, newEnvelope); + } + } + return envelopeBuilder; + } + + private EnvelopeBuilder GetExtentFromDifferenceCursor(EnvelopeBuilder envelopeBuilder, DifferenceCursor differenceCursor) + { + while (differenceCursor.MoveNext()) + { + using (Feature differenceFeature = differenceCursor.Current as Feature) + { + Envelope newEnvelope = differenceFeature.GetShape().Extent; + envelopeBuilder = Union(envelopeBuilder, newEnvelope); + } + } + return envelopeBuilder; + } + + private EnvelopeBuilder Union(EnvelopeBuilder envelopeBuilder, Envelope newEnvelope) + { + if (envelopeBuilder.IsEmpty) + { + return new EnvelopeBuilder(newEnvelope); + } + else + { + envelopeBuilder.Union(newEnvelope); + return envelopeBuilder; + } + } + + + + } +} diff --git a/UtilityNetwork/ValidateChanges/ValidateChanges.csproj b/UtilityNetwork/ValidateChanges/ValidateChanges.csproj new file mode 100644 index 00000000..dec7e112 --- /dev/null +++ b/UtilityNetwork/ValidateChanges/ValidateChanges.csproj @@ -0,0 +1,172 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {0A907E31-89CA-439F-855C-81FC9375EEEF} + Library + Properties + ValidateChanges + ValidateChanges + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + Program + C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + Program + C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe + AnyCPU + + + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\ArcGISPro', 'InstallDir', null, RegistryView.Registry64)) + $(registry:HKEY_CURRENT_USER\SOFTWARE\ESRI\ArcGISPro@InstallDir) + + + + + + + + + + + + + + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Ribbon.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.DataGrid.Contrib.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ESRI.ArcGIS.ItemIndex.dll + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BuildDefault + bin\Debug\ValidateChanges.xml + + + BuildDefault + + + + + + + + + \ No newline at end of file diff --git a/UtilityNetwork/ValidateChanges/ValidateChanges.sln b/UtilityNetwork/ValidateChanges/ValidateChanges.sln new file mode 100644 index 00000000..23829afb --- /dev/null +++ b/UtilityNetwork/ValidateChanges/ValidateChanges.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30128.74 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValidateChanges", "ValidateChanges.csproj", "{0A907E31-89CA-439F-855C-81FC9375EEEF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A907E31-89CA-439F-855C-81FC9375EEEF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FA3DCA79-8184-4736-AE2B-33017D151C64} + EndGlobalSection +EndGlobal