EditOperation.Execution caused by DB Corruption?

297
2
12-05-2018 06:38 AM
DanH1
by
New Contributor II

I have a couple of routines that generate anywhere from 30-40 polygons with approximate 800+ points each.  I call each routine from two different ArcGIS Pro SDK Button Add-In Controls as part of my custom ArcGIS Pro Add-In.  After each routine I take the Polygons that were created add them to the map using the code below (sorry couldn't figure out how to format the coding correctly).  It was working for both buttons consistently until yesterday when only one button would work.  Meaning that I would click one button this routine would run and I'd see my polygons on the map and then I'd push the second button and the second time the routine would get stuck on the

bool l_created = l_createFeatures.Execute();

line of code (i.e. Execute() never returned).  After trying several different things I decided that maybe the problem was my database so I shutdown ArcGIS and I deleted the DefaultGeodatabase folder for my project.  I reran and it started working normally again.  Any thoughts on what happened and how I can prevent this from happening again?  See anything wrong with the code below?  Is there a problem with polygons with that many points?  My add-in is in beta release now but would like to know the root of the problem before final release.  Thank you.

// First obtain the FeatureLayer based on the name of the layer (l_featureClassName)
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
         var l_mapLayers = l_mapView.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
         foreach (FeatureLayer l_featureClassLayer in l_mapLayers)
         {
               if (l_featureClassLayer.Name == l_featureClassName)
               {
                     l_featureLayer = l_featureClassLayer;
                     break;
               }
         }
});

//Second Set the Opacity for the Polygons so I can overlapping Polygons
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
    //Create polygon outline.
    CIMStroke l_outline = SymbolFactory.Instance.ConstructStroke(
                                 ColorFactory.Instance.BlackRGB,
                                                            1.0,
                                           SimpleLineStyle.Solid);

    //Create polygon fill with outline.
    CIMPolygonSymbol l_fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
    ColorFactory.Instance.CreateRGBColor(0.0, 0.0, 0.0, 0.0),
                              SimpleFillStyle.Solid,
                                          l_outline);

    //Get layer's current renderer.
    CIMSimpleRenderer l_renderer = l_featureLayer.GetRenderer() as CIMSimpleRenderer;

    //Update current renderer's symbol.
    l_renderer.Symbol = l_fillWithOutline.MakeSymbolReference();

    //Update layer's renderer.
    l_featureLayer.SetRenderer(l_renderer);
});

//Third Perform EditOperation to add polygons to layer
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{

      var l_createFeatures = new EditOperation();
      l_createFeatures.CancelMessage = "Operation Cancelled";
      l_createFeatures.ErrorMessage = "Error creating polygon";
      l_createFeatures.ShowProgressor = true;


      // l_arcGISPolygons is List<Polygon>
      for (int i = 0; i < l_arcGISResults.Count; i++)
      {
            l_createFeatures.Name = $"Create Result Polygon #{i}";
            l_createFeatures.ProgressMessage = $"Adding Result Polygon #{i} to the Map.....";
            //Create a feature with a polygon.
            l_createFeatures.Create(l_featureLayer, l_arcGISResults[i]);
      }

      //Execute the operation. Must be called within QueuedTask.Run.
      bool l_created = l_createFeatures.Execute();
});

// Finally Save Edits to Layer

await Project.Current.SaveEditsAsync();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
2 Replies
DanH1
by
New Contributor II

Would be glad to update the code formatting if someone could tell me how to do that withing the body of the question...:-) 

0 Kudos
by Anonymous User
Not applicable

The syntax highlighter can be found on the expanded toolbar (three dots), then under the More dropdown. In the syntax highlighter, choose your language and paste your code into the window.

The hanging problem might be harder to solve without a repro case (data). The code looks ok. You shouldn't have await all those calls though, depends what the rest of the code is doing.

0 Kudos