Find task timing out - only a few features

632
3
07-05-2013 06:52 AM
KarenEllett
Occasional Contributor
I have a find task set to search one layer, one field, but it takes 60+ seconds to run, or completely times out.  There are only 115 total features in the layer, and only 11 that actually match the query.  Anyone know why it's taking so long or how to speed it up?  It's a line feature.  Here's the code:

public void RunFindTask()
        {
            busyIndicator1.IsBusy = true;
            GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            FindTask cgtFindTask = new FindTask("http://myserver/ArcGIS/rest/services/CGT/MainLayers/MapServer");
            cgtFindTask.ExecuteCompleted += cgtFindTask_ExecuteCompleted;
            cgtFindTask.Failed += FindTask_Failed;
            FindParameters cgtFindParameters = new FindParameters();
            cgtFindParameters.ReturnGeometry = true;
            cgtFindParameters.SpatialReference = MapApplication.Current.Map.SpatialReference;

          
           
                cgtFindParameters.LayerIds.AddRange(new int[] { 10 });
                cgtFindParameters.SearchFields.AddRange(new string[] { "SUBSYSTEM", "SYSTEM_NM" });
                cgtFindParameters.SearchText = Subsystem.Text;
           

            cgtFindTask.ExecuteAsync(cgtFindParameters);
           
        }
0 Kudos
3 Replies
KarenEllett
Occasional Contributor
Also, just realized that actually shows it searching two fields, not one.  That was a change I just now made to test something; originally it was running against only one field, same results.
0 Kudos
KarenEllett
Occasional Contributor
Since I'm only looking at one layer for this, I've also tried it as a query task.  However it returns 0 features every time, even though it should be returning 8-10.  Here's the code.

QueryTask queryTask = new QueryTask("http://myserver/ArcGIS/rest/services/CGT/MainLayers/MapServer/10");
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;
            Query query = new Query();
            query.ReturnGeometry = true;
            query.OutFields.AddRange(new string[] { "SUBSYSTEM" });
            query.Where = Subsystem.Text;
           
          
            queryTask.ExecuteAsync(query);
0 Kudos
KarenEllett
Occasional Contributor
It actually was a problem with the case sensitivity of the where clause, and I've got that part fixed.  Now, however, none of the features will draw. 


        private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
            FeatureSet featureSet = args.FeatureSet;
            if (featureSet.Features.Count > 0)
            {
                foreach (Graphic resultFeature in featureSet.Features)
                {
                    resultFeature.Symbol = YellowLine;
                    graphicsLayer.Graphics.Add(resultFeature);

                }
                MessageBox.Show(featureSet.Features.Count.ToString() + " lines found");
            }
}
0 Kudos