Remove an item from the selection with "RemoveFeatureFromSelection"
I need to select a parcel, buffer the parcel and select all those parcels in the buffer and then remove the original parcel from the selection set. I know there is a method to remove a parcel from a selection via the ParcelReportWorkflow_3_10.xaml you can download, but this is far too complex and requires user interaction. Does anyone know how to use the RemoveFeatureFromSelection command (Geocortex.Essentials.Client.Tasks.Feature) in a workflow to remove the initial selection? ( I'm referring to section 14.1.26 (SelectionCommands) in the Administrator and Developer Guide /Geocortex Viewer for Silverlight 1.7.
Tks!
-
That command is not really intended for use in Workflow. Fortunately there is another way to do this.
1. First, add a reference to System.Linq to your Workflow. Click on 'Imports' at the bottom of the screen and start typing 'System.Linq'. When it pops up, hit enter, and you have added a reference to this assembly. This provides some SQL-like methods for use in Visual Basic that will make our lives easier here.
2. You'll want to hang on to the OBJECTID of the original parcel. This is how you will tell the computer which one you want it to remove later. Put the OBJECTID in a string variable using an assign statement. Here I have called that variable 'objectid', and I have assumed that the objectid field is actually called 'OBJECTID':
objectid = parcel.Attributes("OBJECTID").ToString();
3.Then after buffering and performing a query task you will presumably have a FeatureSet that you'd like to remove the original parcel from. Add a RemoveFromCollection task to your workflow, and assuming your featureset variable is called 'selectedFeatures', fill out the parameters (look on the right hand side of the screen) as follows:
Collection: selectedFeatures.Features
Item: (From f In selectedFeatures.Features Where f.Attributes("OBJECTID").ToString() = objectid).FirstOrDefault()
TypeArguement: ESRI.ArcGIS.Client.Graphic
4. The code in the 'Item' box is where the magic happens. This uses the SQL-type syntax called Linq to look through your featureset for any features which match the OBJECTID you saved earlier. Since we know there is only one, and this task only operates on a single item at a time, you must then call .FirstOrDefault() to transform the resulting collection into a single item.
Hope this helps.
0 -
Thanks Jonathan, worked like a charm and just in time to keep the boss happy!
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare