Select to view content in your preferred language

Serious issues for feature layers, data is getting deleted from ArcSDE.

2735
10
02-24-2011 08:04 PM
SanajyJadhav
Deactivated User
Guys,

I am in serious trouble. I am adding featurelayers to the my application. These feature layers come from the featureservice.

The layers are getting added fine, they can be viewed in the application. But, when I use any task like Identify on any of the layers in the application, the data used in featureservice is getting deleted from the SDE Feature Dataset. This is driving me crazy.

Below are the steps I am taking to add the featurelayer.

1.  Create new instance of ArcGISDynamicLayer and initialize it.

 
ArcGISDynamicMapServiceLayer otherFeatBaseMapSrvc = new ArcGISDynamicMapServiceLayer();
            otherFeatBaseMapSrvc.Url = currentApps.WebconfigVrbls.OtherFeaturesBaseMapSrvc;
            otherFeatBaseMapSrvc.ID = "Other Features Map Service";
            otherFeatBaseMapSrvc.Initialized += new EventHandler<EventArgs>(BaseMapSrvc_Initialized);
            otherFeatBaseMapSrvc.InitializationFailed += new EventHandler<EventArgs>(BaseMapSrvc_InitializationFailed);

            //if this map service is not initialized, then manually initialize it.
            if (otherFeatBaseMapSrvc.IsInitialized == false)
            {
                otherFeatBaseMapSrvc.Initialize();    
        }


2. In the initialized event, access the layer info object and create FeatureLayer object

void BaseMapSrvc_Initialized(object sender, EventArgs e)
        {
            ArcGISDynamicMapServiceLayer lyr = sender as ArcGISDynamicMapServiceLayer;

            //get layer info array
            LayerInfo[] lyrInfoArray = lyr.Layers;

            if (lyrInfoArray != null)
            {
                //iterate thru each layer info and create feature service url for each of the layer by taking it's ID
                for (int i = 0; i < lyrInfoArray.Length; i++)
                {
                    LayerInfo lyrInfo = lyrInfoArray;
                    string featureLyrURL = lyr.Url.Replace("MapServer", "FeatureServer") + "/" + lyrInfo.ID;

                    //set  feature layer using above url  
                    FeatureLayer featLyr = new FeatureLayer();
                    featLyr.ID = lyrInfo.Name;
                    featLyr.Mode = FeatureLayer.QueryMode.OnDemand;
                    featLyr.Url = featureLyrURL;
                    featLyr.InitializationFailed += new EventHandler<EventArgs>(EditFeatLyr_InitializationFailed);
                    featLyr.Initialized += new EventHandler<EventArgs>(EditFeatLyr_Initialized);

                    if (featLyr.IsInitialized == false)
                    {
                        featLyr.Initialize();
                    }
                }
            }           
        }


3. In the initialized event of the feature layer, add it to the map.

void EditFeatLyr_Initialized(object sender, EventArgs e)
        {
            //get reference to the feature layer that raised the event 
            FeatureLayer fl = sender as FeatureLayer;

            //add this feature layer to the map.
            currentApps.MapXaml.MyMap.Layers.Add(fl);

            //add this feature layer to application level collection object
            currentApps.AllMapServicesCollection.Add(fl); 
        }


This is very serious issue for us. I am not getting how to fix it. If I add the normal map services in the code behind, everything works normal.Whenever, this featureservice comes into picture, problem rises.

Please help me on this issue.

Thanks,
Sanjay.
0 Kudos
10 Replies
JenniferNery
Esri Regular Contributor
Oh right. Glad you fixed it. : ) You can also wire up to FeatureLayer.BeginSaveEdits and/or FeatureLayer.EndSaveEdits to check when updates get pushed back to the server.
0 Kudos