Select to view content in your preferred language

Feature Layer and multi-user concurrent editing

2607
7
06-06-2012 10:10 AM
DanielWalton
Frequent Contributor
We have a feature layer with QueryMode set to OnDemand and DisableClientCaching set to true. I also call .Update() on the layer from a DispatcherTimer every 30 seconds. When multiple users edit at the same time from different browsers, A few oddities occur:

1. When user 1 edits a feature, the edits don't appear in the other users' sessions unless they re-initialize the featurelayer. I have looked into the API and see that this is by design, to prevent the geometries from loading over and over again. But is there a way to disable this feature?

2. Often times when user 1 deletes a feature, the feature will reappear and need to be deleted 1 or 2 more times before finally being deleted for good. I cannot figure out why.


Any thoughts or ideas?

Thanks!
0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
Once you detect a change in the server, you can call FeatureLayer.Update() to re-query the service. This will solve both issues.
0 Kudos
DanielWalton
Frequent Contributor
Thanks for the reply Jennifer. I'm not sure I follow what you mean. How do I detect a change on the server? Also, I am calling Update() every 30 seconds, but the query includes a WHERE clause that excludes the OBJECTID's of graphics currently in the client. So no changes to those graphics are detected. I was wondering if there is a way to disable this functionality.
0 Kudos
JenniferNery
Esri Regular Contributor
Maybe you can create a WCF service that informs the applications when server has changed? Your FeatureLayer is probably set to Mode=OnDemand, this will exclude OBJECTIDs that are already on the client. If you don't want that filter, you can change to Mode=SnapShot.http://help.arcgis.com/en/webapi/silverlight/help/index.html#//016600000015000000
0 Kudos
DanielWalton
Frequent Contributor
I want the extent-driven query that OnDemand mode gives you, but without the caching. Is there a way to have both?
0 Kudos
JenniferNery
Esri Regular Contributor
0 Kudos
DanielWalton
Frequent Contributor
Unfortunately neither of those quite accomplish what I need. OnDemandCacheSize=0 simply limits the number of graphicslayer-cached graphics that are off-screen. DisableClientCaching=true just prevents the browser from caching http responses. Despite setting both of those I still see the query request having a '&WHERE=OBJECTID NOT IN (...)' parameter. I need to prevent the excludeCachedFeaturesFromQuery() routine from executing within the FeatureLayer.Update() method. It seems that currently this is impossible with OnDemand as the query mode. Can this be a feature in a future release perhaps?
0 Kudos
JenniferNery
Esri Regular Contributor
I tried the following sample:

   xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

 <Grid x:Name="LayoutRoot" Background="White">
  <esri:Map x:Name="MyMap" WrapAround="True" Extent="-19902659.740859,7433864.95979339,-13792567.5107708,10986668.962042">
   <esri:ArcGISTiledMapServiceLayer ID="BaseLayer" 
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />

   <esri:FeatureLayer ID="Points" 
          Mode="OnDemand"
          DisableClientCaching="True"                                
          OnDemandCacheSize="0"          
                               Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"
                               OutFields="*"/>
  </esri:Map>
  <Button Content="update" Click="Button_Click" 
    VerticalAlignment="Top" HorizontalAlignment="Center"/>
 </Grid>


  private void Button_Click(object sender, RoutedEventArgs e)
  {
   var l = MyMap.Layers["Points"] as FeatureLayer;
   l.Update();
  }


On Map.ExtentChanged, a query with where clause objectid NOT IN (<objectIDs in current extent>) is sent. If I click on button, features for current map extent is retrieved again (no NOT IN query). I assume you want to call FeatureLayer.Update()?
0 Kudos