Select to view content in your preferred language

EditOperation.Execute() didn't respond / stop

549
7
07-03-2024 10:09 AM
SailiTang_HW
Occasional Contributor

Hi,

I have a piece of code below to create new rows with some attribute values in a standalone table. Every step worked perfectly but stopped at Line43(var result = createOperation.Execute();). No error message popped up and my visual studio showed running, but my Pro was frozen. It looked like waiting for the "Execute()" finishing. I only added 3 rows and shouldn't be that long. I even waited it for 30 minutes but still didn't go to the next step. I am using Visual studio 2019 and Pro 2.9. Does anyone have any idea about this problem? Or how can I do to debug this problem?

Thanks,

Saili

public Task<string> CreateNewRowsInTable(string drawingNumber, string remarks)
{
  StandaloneTable lDrawingLinkTable = DETUtil.GetTableFromMap(mAssetDrawingInfo.AssetDrawingLinkTableName);

  if (null == lDrawingLinkTable)
     throw new AssignDrawingLogicException(Defs.ASSIGN_DRAWING_MSG_ERROR_NO_DRAW_LINK_TABLE + mAssetDrawingInfo.AssetDrawingLinkTableName);

  return QueuedTask.Run(() => {               

         var selectedLayers = MapView.Active.Map.GetSelection();
         string lAssetIDFieldName = mAssignDrawingConfig.GetAssetIDFieldForFeatureClass(selectedLayers.First().Key.Name);
         int lTotalFeatures = 0;

         var createOperation = new EditOperation();
         Table lnkTable = lDrawingLinkTable.GetTable();
         int lAssestNameCode = mAssignDrawingConfig.GetAssetNameCodeForFeatureClass(selectedLayers.First().Key.Name);

          foreach (long ObjectId in selectedLayers.First().Value)
          {
            var selectedInspector = new Inspector();
            selectedInspector.Load(selectedLayers.First().Key, ObjectId);
            string lAssetID = selectedInspector[lAssetIDFieldName].ToString();

             try
             {
              var attributes = new Dictionary<string, object>();                             attributes.Add(mAssetDrawingInfo.AssetDrawingLinkAssetIDFieldname, lAssetID);
                         attributes.Add(mAssetDrawingInfo.AssetDrawingLinkAssetNameFieldname, lAssestNameCode);
                        attributes.Add(mAssetDrawingInfo.AssetDrawingLinkDrawNumberFieldname, drawingNumber);
               if (!String.IsNullOrEmpty(remarks))
                            attributes.Add(mAssetDrawingInfo.AssetDrawingLinkRemarksFieldname, remarks);
                        
               createOperation.Create(lnkTable, attributes);
              }
               catch (Exception)
               {
                throw new AssignDrawingLogicException(Defs.ASSIGN_DRAWING_MSG_CANNOT_EDIT_LINK_TABLE + mAssetDrawingInfo.AssetDrawingLinkTableName);
                    }
                   
                }

                if (!createOperation.IsEmpty)
                {
                    var result = createOperation.Execute();
                    if (!result)
                    {
                        MessageBox.Show(String.Format("ERROR: AssignDrawing: Please check if you have Edit permission on the layer!", "Desktop Edit Tool Error", MessageBoxButtons.OK, MessageBoxIcon.Error));
                    }
                }

                return "Assigned Drawing to: " + lTotalFeatures.ToString() + $" feature(s).{Environment.NewLine}Assign Drawing Complete.";

            });
      
        }
0 Kudos
7 Replies
SailiTang_HW
Occasional Contributor

I changed my ArcGIS Pro license from "Standard" to "Advanced" just now and then it worked! Being able to run EditOperation.Execute() needs "Advanced" license, doesn't it?!

Thanks

0 Kudos
SailiTang_HW
Occasional Contributor

I did more tests and found that it was not license issue. It worked sometimes for Standard license. No matter "Standard" license or "Advanced" license, they were not stable. Sometimes worked, sometimes didn't. How could I find out what the problem is?

0 Kudos
MaxW
by
Emerging Contributor

Hi Sail

I seem to have encountered this problem before. It appears to be because when you first open Pro, the SDE has not yet started reading. Therefore, the first execution does not update or write. However, if you read the SDE afterward, the execution will perform the update or write.

0 Kudos
SailiTang_HW
Occasional Contributor

Thank you so much for your reply, MaxW.

I did lots of tests last night and occasionally noticed that the code ran without issue if the standalone table was not opened. The standalone table could be added to Contents panel in Pro but not be opened. And also, the standalone table had to use .getTable to convert it to Table. "Standalone" data type variable had the same issue no matter it was opened or not.

For feature classes and feature layers, they don't have this issue. Adding new rows code can run properly no matter they are opened or not. After EditOperation.Execute() was done, I could see my feature layer was redrawn in the Map area and its attribute table was reloaded.

We just started converting ArcMap addins to Pro and this is my first Pro addin development. I don't know this standalone table issue is a bug or ESRI just designed like that? For some reasons, our organization cannot upgrade Pro to version 3.x now and we are still using 2.9. Does 3.x have the same issue?

Thanks.

 

0 Kudos
SailiTang_HW
Occasional Contributor

There is another thing I forgot to mention. I tested the code using both SDE data (versioned) and local file geodatabase data, but both had the same issue.

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

Hi @SailiTang_HW, I could not reproduce the issue in our latest release, the Pro SDK 3.3. Is it possible to share sample data and code snippets for further investigation?

0 Kudos
AingeruArmendariz
New Contributor

Hi,

I have been struggling with the same problem with a custom addin development for ArcGIS Pro 3.3 with the .NET SDK. It performs some operations over features and sometimes it was working, other times no, in some of the computers of my colleagues worked, in others no... it looked quite random. Here is a example of one of the operations:

EditOperation editOperation = new EditOperation();
editOperation.Callback(context =>
{
    using (RowCursor cursor = featureClassObj.Search(query, false))
    {
        while (cursor.MoveNext())
        {
            using (Feature feature = (Feature)cursor.Current)
            {
                // Editions here
            }
        }
    }
}, featureClass);

deleted = editOperation.Execute();

 

The problem was that it wasn't getting into the callback function; after the line 16 (editOperation.Execute()) it was "getting lost" no stopping the execution nor throwing any error.

If it helps someone, in my case was the fact of having opened attribute tables in the map, if I close them everything goes OK but if I open them the execution gets "lost".

I have to say that it is a bulk edition process, I don't have the problem if I edit a single feature, but in that case the active attribute table gets like disabled: grey and not possible to interact with it. I cannot see a logic here because the execution "stops" before starting any operation (it should be the same for a feature or a bunch of them in my opinion).

Cheers