Hi,
I have some code I'm trying to troubleshoot. It does some editing of attributes to a point and the intersecting line feature. A user can select multiple points, and then click the tool to run the code on each selected point. I get no error messages, but the results are not as expected when selecting more than one feature.
The weird thing is that if I step through the code, line by line, everything works fine. The only time I have problems is when running the code in real-time. For some reason, only the first feature selected gets updated, and all the other features keep their original attributes.
I will post the code below, but here is the main logic behind it:
1. select one or more hydrant features and click on the tool
2. the tool work through each selected hydrant one at a time
3. it finds the intersecting water service connected to the hydrant and updates the SUBTYPE attribute of the water service
4. it then finds the intersecting water main of the water service, and updates the WATERMAINSIZE and WATERMAINID on the hydrant feature
5. goes to the next selected hydrant and repeats steps 2 through 4
If anyone has any ideas as to why this code will not work in real-time, please let me know.
Thanks!
<SPAN class="keyword token">internal</SPAN> <SPAN class="keyword token">class</SPAN> <SPAN class="token class-name">FittingsButton</SPAN> <SPAN class="punctuation token">:</SPAN> Button
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">string</SPAN> <SPAN class="token function">GetIntersectingFeature</SPAN><SPAN class="punctuation token">(</SPAN>MapPoint point<SPAN class="punctuation token">,</SPAN> FeatureLayer intersectLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">string</SPAN> fieldName<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(point.X.ToString() + " : " + point.Y.ToString());</SPAN>
<SPAN class="comment token">//Create a Spatial Query using the supplied point, layer and fieldname</SPAN>
SpatialQueryFilter spatialFilter <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">SpatialQueryFilter</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
spatialFilter<SPAN class="punctuation token">.</SPAN>FilterGeometry <SPAN class="operator token">=</SPAN> point<SPAN class="punctuation token">;</SPAN>
spatialFilter<SPAN class="punctuation token">.</SPAN>SpatialRelationship <SPAN class="operator token">=</SPAN> SpatialRelationship<SPAN class="punctuation token">.</SPAN>Intersects<SPAN class="punctuation token">;</SPAN>
spatialFilter<SPAN class="punctuation token">.</SPAN>SubFields <SPAN class="operator token">=</SPAN> fieldName<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Gets the intersecting feature</SPAN>
<SPAN class="keyword token">string</SPAN> fieldValue <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
RowCursor featureCursor <SPAN class="operator token">=</SPAN> intersectLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN>spatialFilter<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
Feature feature<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Gets the value using the fieldName</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN>featureCursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MoveNext</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN>feature <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>Feature<SPAN class="punctuation token">)</SPAN>featureCursor<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">int</SPAN> fieldPosition <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN>fieldName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">[</SPAN>fieldPosition<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
fieldValue <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">[</SPAN>fieldPosition<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">else</SPAN>
fieldValue <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">return</SPAN> fieldValue<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">Exception</SPAN> ex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Framework<SPAN class="punctuation token">.</SPAN>Dialogs<SPAN class="punctuation token">.</SPAN>MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"An error occured while finding the intersecting feature."</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="operator token">+</SPAN> ex<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"GetIntersecingFeature"</SPAN><SPAN class="punctuation token">,</SPAN> System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>MessageBoxButton<SPAN class="punctuation token">.</SPAN>OK<SPAN class="punctuation token">,</SPAN> System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>MessageBoxImage<SPAN class="punctuation token">.</SPAN>Error<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">protected</SPAN> <SPAN class="keyword token">async</SPAN> <SPAN class="keyword token">override</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnClick</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Start the edit operation, and place on the UNDO stack</SPAN>
<SPAN class="keyword token">var</SPAN> editOperation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Editing<SPAN class="punctuation token">.</SPAN>EditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Update Fittings Diameters on Selected Features"</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>EditOperationType <SPAN class="operator token">=</SPAN> ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Editing<SPAN class="punctuation token">.</SPAN>EditOperationType<SPAN class="punctuation token">.</SPAN>Long<SPAN class="punctuation token">;</SPAN>
Map map <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">;</SPAN>
FeatureLayer waterMainLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WaterMain"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer waterServiceLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WaterService"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer hydrantLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WAT_Hydrant"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer controlValveLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WAT_ControlValve"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer waterFittingsLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WAT_Fitting"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer reliefValveLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WAT_ReliefValve"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureLayer pressureZoneLayer <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GISWRKS1.WORKS.WAT_PressureZone"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token preprocessor">#region Check for hydrants; Update the </SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>hydrantLayer <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>hydrantLayer<SPAN class="punctuation token">.</SPAN>SelectionCount <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> hydrantSelection <SPAN class="operator token">=</SPAN> hydrantLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetSelection</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IReadOnlyList<SPAN class="operator token"><</SPAN><SPAN class="keyword token">long</SPAN><SPAN class="operator token">></SPAN> selectedOIDs <SPAN class="operator token">=</SPAN> hydrantSelection<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetObjectIDs</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">foreach</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> oid <SPAN class="keyword token">in</SPAN> selectedOIDs<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> insp <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Editing<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">.</SPAN>Inspector</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
insp<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Load</SPAN><SPAN class="punctuation token">(</SPAN>hydrantLayer<SPAN class="punctuation token">,</SPAN> oid<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> thePoint <SPAN class="operator token">=</SPAN> insp<SPAN class="punctuation token">.</SPAN>Shape<SPAN class="punctuation token">;</SPAN>
MapPoint hydrantPoint <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>MapPoint<SPAN class="punctuation token">)</SPAN>insp<SPAN class="punctuation token">.</SPAN>Shape<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Update the subtype of the water service to 2 - HydrantLateral</SPAN>
<SPAN class="keyword token">var</SPAN> wsInspector <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Editing<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">.</SPAN>Inspector</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wsInspector<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Load</SPAN><SPAN class="punctuation token">(</SPAN>waterServiceLayer<SPAN class="punctuation token">,</SPAN> Convert<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToInt64</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">GetIntersectingFeature</SPAN><SPAN class="punctuation token">(</SPAN>hydrantPoint<SPAN class="punctuation token">,</SPAN> waterServiceLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wsInspector<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"SubTypeCD"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Modify</SPAN><SPAN class="punctuation token">(</SPAN>wsInspector<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Now get the watermain that intersect the From point of the HydrantLateral.</SPAN>
<SPAN class="comment token">//Get the To and From point of the currently selected HydrantLateral</SPAN>
<SPAN class="keyword token">var</SPAN> pointCollection <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>Multipart<SPAN class="punctuation token">)</SPAN>wsInspector<SPAN class="punctuation token">.</SPAN>Shape<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Points<SPAN class="punctuation token">;</SPAN>
MapPoint fromPoint <SPAN class="operator token">=</SPAN> pointCollection<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
MapPoint toPoint <SPAN class="operator token">=</SPAN> pointCollection<SPAN class="punctuation token">[</SPAN>pointCollection<SPAN class="punctuation token">.</SPAN>Count <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> watermainID <SPAN class="operator token">=</SPAN> <SPAN class="token function">GetIntersectingFeature</SPAN><SPAN class="punctuation token">(</SPAN>fromPoint<SPAN class="punctuation token">,</SPAN> waterMainLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//The HydrantLateral could be digitized backwards, so use the toPoint if the fromPoint returns NULL</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>watermainID <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
watermainID <SPAN class="operator token">=</SPAN> <SPAN class="token function">GetIntersectingFeature</SPAN><SPAN class="punctuation token">(</SPAN>toPoint<SPAN class="punctuation token">,</SPAN> waterMainLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>watermainID <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> wmInspector <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGIS<SPAN class="punctuation token">.</SPAN>Desktop<SPAN class="punctuation token">.</SPAN>Editing<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">.</SPAN>Inspector</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wmInspector<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Load</SPAN><SPAN class="punctuation token">(</SPAN>waterMainLayer<SPAN class="punctuation token">,</SPAN> Convert<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToInt64</SPAN><SPAN class="punctuation token">(</SPAN>watermainID<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
insp<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"WaterMainSize"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> wmInspector<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Diameter"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
insp<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"WATERMAINID"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> wmInspector<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"FACILITYID"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Modify</SPAN><SPAN class="punctuation token">(</SPAN>insp<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="token preprocessor">#endregion</SPAN>
<SPAN class="token preprocessor">#region Check for Control Valves</SPAN>
<SPAN class="token preprocessor">#endregion</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Execute</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">finally</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>