TemplatePicker adds two features

921
6
05-04-2011 02:16 PM
RickThiel
Occasional Contributor
Has anyone experienced this problem with the TemplatePicker control?:  I have discovered that when I try to add a new feature and also try to update some of the attributes for that feature (then click apply), it actually adds two records in the database at the same exact point.

I have been troubleshooting this with Fiddler and this appears to be the sequence of events:
1. Click on the feature in the template picker pallette
2. Click a point on the map (at this point in Fiddler I see a call to my FeatureService with ../FeatureServer/0/ApplyEdits)
3. Then the dialog box opens on the map so I can edit the attributes for the feature I just placed on the map.  When I click 'apply' to persist the attribute values I see another call to my feature service ../FeatureServer/0/ApplyEdits.
4. now when I go to review the results in the database I see one record with only an objectID, and a second record with the next sequential ObjectID plus all the attribute values I just entered.

For example:
ObjectID: 6849585
Company:
CU:

ObjectID: 6849586
Company: WPL
CU: X4000

I have been able to repeat scenario this several times.  Has anyone else experienced this same problem?
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
Can you reproduce with sampleserver service? If yes, can you provide us some code like how FeatureLayer and TemplatePicker are setup.

Thanks.
0 Kudos
RickThiel
Occasional Contributor
Hi Jennifer,

Thanks.  I just tried the following sample service:  http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0

It seemed to work just fine.  No double entries.  

When I view the network activity through Fiddler, the sequence of events seemed to match what I saw when I was using my feature service.  For example in Fiddler I could still see the two "/applyEdits": once when I clicked the point on the map; and the second time when I clicked "Apply" in the attribute window.  The biggest difference I saw: with my feature service it seems to take 17 seconds for the /applyEdits to complete and I do not get an object id immediately;  with the ESRI sample service the /applyEdits happen immediately and I see the object ID immediately.

One note:  for our services, we have security enabled.  We are using Windows authentication.
0 Kudos
JenniferNery
Esri Regular Contributor
I have tested secured services too but have not seen this behavior.

So the same code with different service did not produce the same outcome? With AutoSave=False can you try to add one feature and copy-paste the parameters from Fiddler then create the /applyEdits web request using your web browser and check if you still get one extra feature added to your service? You can also monitor the graphics.Count after FeatureLayer.Update() if this number increases by 2 every time you add 1.

Please share some code. Thanks.
0 Kudos
RickThiel
Occasional Contributor
Hi Jennifer,

When I set the AutoSave to False, it does nothing.  I do not see any /applyEdits.  Would it be helpful to send you the Fiddler session (.saz) file?  I thought about posting it here, but I wasn't so sure that was a good idea.  I'm not sure what information I might be exposing.

Sorry about not including the code earlier.  I am following the ESRI samples very closely. But here is my xaml and xaml.cs if you want to take a look.

<esri:Map x:Name="MapControl" Background="White" IsLogoVisible="False">
<esri:FeatureLayer ID="Poles"
     Url="http://msnwingisd1/ArcGIS/rest/services/Test1_PoleUpdates/FeatureServer/0"
     DisableClientCaching="True"
     AutoSave="True"
     Mode="OnDemand"
     MaximumResolution="43.4028"
     OutFields="OBJECTID,COMPANY,CU">
    <esri:FeatureLayer.Clusterer>
 <esri:FlareClusterer FlareBackground="Orange"
        FlareForeground="Black"
        MaximumFlareCount="9" />
    </esri:FeatureLayer.Clusterer>
    <esri:FeatureLayer.MapTip>
 <Border CornerRadius="10"
  BorderBrush="#FF222957"
  BorderThickness="3"
  Margin="0,0,15,15">
     <Border.Background>
  <LinearGradientBrush EndPoint="1.038,1.136"
         StartPoint="0.015,0.188">
      <GradientStop Color="#FFD1DFF2" />
      <GradientStop Color="#FF0088FF"
      Offset="0.946" />
  </LinearGradientBrush>
     </Border.Background>
     <Border.Effect>
  <DropShadowEffect ShadowDepth="10"
      BlurRadius="14"
      Direction="300" />
     </Border.Effect>
     <StackPanel Margin="7">
  <StackPanel Orientation="Horizontal">
      <TextBlock Text="Pole: "
          Foreground="Black" />
      <TextBlock Text="{Binding [OBJECTID]}"
          FontWeight="Bold"
          Foreground="Black" />
  </StackPanel>
  <StackPanel Orientation="Horizontal">
      <TextBlock Text="Company: "
          Foreground="Black" />
      <TextBlock Text="{Binding [COMPANY]}"
          FontWeight="Bold"
          Foreground="Black" />
  </StackPanel>
  <StackPanel Orientation="Horizontal">
      <TextBlock Text="CU: "
          Foreground="Black" />
      <TextBlock Text="{Binding [CU]}"
          FontWeight="Bold"
          Foreground="Black" />
  </StackPanel>
     </StackPanel>
 </Border>
    </esri:FeatureLayer.MapTip>
</esri:FeatureLayer>
</esri:Map>


<esri:TemplatePicker x:Name="MyTemplatePicker"
       Continuous="False"
       Loaded="MyTemplatePicker_Loaded"
       Map="{Binding ElementName=MapControl}"
       ShowAttributesOnAdd="True" />


private void MyTemplatePicker_Loaded(object sender, RoutedEventArgs e)
{
    string[] myLayerIDs = { "Poles" };
    MyTemplatePicker.LayerIDs = myLayerIDs;
}
0 Kudos
JenniferNery
Esri Regular Contributor
Hi Rick, Thank you for reporting this. It was very difficult to reproduce the issue with the sampleservers until we force to introduce a delay in code. We are trying to get this bug fixed.

If you have AutoSave=True (default), please try AutoSave=False so that edit to the same feature are submitted to the server at the same time.
0 Kudos
RickThiel
Occasional Contributor
Hi Jennifer,  Thanks.  Turning the AutoSave="False" on the feature layer seemed to fix the problem.  We will go with that. 

But I do have another question.  I am a little new to the GIS area in our company... can you tell me how I could begin troubleshooting why I am experiencing a 17 second delay on the updates to our feature layer?

Thanks again.  --Rick
0 Kudos