1

I have an ArcMap AddIn that updates an attribute field called "ROTATION". That field is linked to the featureclasses' symbology (going to the Layer > Properties > Symbology tab > Advanced > Rotation... > Arithmetic option > OK.
If you are manually editing and change the field value, the point symbol will rotate based on your entered value (like 90 degrees or whatever) and redraw itself. My code worked fine and dandy on a file geodatabase, but when I tried to integrate it into the intended edit environment (a versioned SDE) I couldn't use the same operations. So after a bit of research I came across the following links:

Can I use an Update cursor with a versioned feature class which has attachments in ArcObjects .NET

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Editing_with_the_geodatabase_API/00010000010s000000/

However, none of the following statements are updating the value, or the symbol, EVEN THOUGH the new value is correctly recognized in the code:

RefreshAttributeTable(pSelectedTable);

pMXDocument.UpdateContents();

pMXDocument.ActiveView.Refresh();

I used a few out-of-the-box ESRI methods, so maybe I am just missing something obvious?

try
        {
            IWorkspace pEditWorkSpace = connectToAtlasEditSDE();
            IFeatureWorkspace pFeatureWorkSpace = (IFeatureWorkspace)pEditWorkSpace;
            IFeatureDataset pFeatureDataset = pFeatureWorkSpace.OpenFeatureDataset("EDIT.PUD.WATER");
            IEnumDataset enumDatasets = pFeatureDataset.Subsets;
            IDataset pDataset = enumDatasets.Next();
            IDataset selectedDataset;
            IPropertySet pPropertySet;
            bool found = false;
            while (pDataset != null || found != true)
            {
                if (pDataset.Type == esriDatasetType.esriDTFeatureClass)
                {
                    string sDatasetName = pDataset.Name;
                    if (sDatasetName.Contains("wFitting"))
                    {
                        selectedDataset = pDataset;
                        pSelectedTable = (Table)selectedDataset;
                        pSelectedFeatureClass = (IFeatureClass)selectedDataset;
                        found = true;
                    }
                }
                pDataset = enumDatasets.Next();
            }
            int rotationIndex = pSelectedTable.Fields.FindField("ROTATION");
            EditWithReconcile(pEditWorkSpace, pSelectedTable, pSelectedFeatureClass);
            IMxDocument pMXDocument = ArcMap.Document;
            IMap pMap = pMXDocument.FocusMap;
            RefreshAttributeTable(pSelectedTable);
            pMXDocument.UpdateContents();
            pMXDocument.ActiveView.Refresh();
        }
        catch (Exception e) { }...

    public void RefreshAttributeTable(ITable pTable)
    {
        ITableWindow3 pTableWindow3 = new TableWindow() as ITableWindow3;
        if (pTableWindow3.ActiveTableWindow == null)
        {
            //MessageBox.Show("no table open");
        }
        else
        {
            var pTableWindow2 = pTableWindow3.ActiveTableWindow as ITableWindow2;
            if (pTableWindow2.Layer != null)
            {
                var pLayer = pTableWindow2.Layer as ILayer;
                pTableWindow3.Layer = pLayer; // do I need to set the ISelectionSet?!
            }
            else
            {
                var pStandaloneTable = pTableWindow2.StandaloneTable as IStandaloneTable;
                pTableWindow3.StandaloneTable = pStandaloneTable;
            }
        }
        pTableWindow3.ActiveTableWindow.Refresh();
    }

public void EditWithReconcile(IWorkspace workspace, ITable table, IFeatureClass pFeatureClass)
    {
        // Cast the workspace to the IMultiuserWorkspaceEdit and IWorkspaceEdit2 interfaces.
        IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)workspace;
        IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

        // Start a versioned edit session and an edit operation.
        muWorkspaceEdit.StartMultiuserEditing
            (esriMultiuserEditSessionMode.esriMESMVersioned);
        workspaceEdit.StartEditOperation();

        // Perform edits here...

        IFeature pFeature = pFeatureClass.GetFeature(90); // hard coded values for simplicity
        // following already shows -264 from last run, but still shows -79 in attribute table and symbol doesnt change
        var rotation = pFeature.get_Value(10); 
        pFeature.set_Value(10, -264);
        var afterChange = pFeature.get_Value(10); // -264
        pFeature.Store();

        //also tried this 
        //IRow row = table.GetRow(90);
        //var value = row.get_Value(10);
        //row.set_Value(10, -264);
        //var value2 = row.get_Value(10);
        //row.Store();

        // Save the edit operation. To cancel an edit operation, the AbortEditOperation
        // method can be used.
        workspaceEdit.StopEditOperation();
        try
        {
            // Stop the edit session. The saveEdits parameter indicates the edit session
            // will be committed.
            workspaceEdit.StopEditing(true);
        }
        catch (COMException comExc)
        {
            if (comExc.ErrorCode == (int)fdoError.FDO_E_VERSION_REDEFINED)
            {
                // Get the version name.
                IVersion version = (IVersion)workspace;
                String versionName = version.VersionName;

                // Reconcile the version. Modify this code to reconcile and handle conflicts
                // appropriately for the specific application.
                IVersionEdit4 versionEdit4 = (IVersionEdit4)workspace;
                versionEdit4.Reconcile4(versionName, true, false, true, true);

                // Stop the edit session.
                workspaceEdit.StopEditing(true);
            }
            else
            {
                // A different error has occurred. Handle appropriately for the application.
                workspaceEdit.StopEditing(false);
            }
        }
    }
  • Did you try using IEditor.EditWorkspace to get a reference to the current edit workspace? I think IEditor notifies arcmap when something might need to be refreshed. – Kirk Kuykendall Nov 15 '16 at 20:41
1

it seems that you are opening the SDE connection / dataset from code, updating it, then reading the content (table and symbol) that is currently displayed. If the two (i.e. the code and the loaded content) are not using the same connection, then you won't see right away edits made using the other connection. Once the edition is done (saved), you would need to do a Refresh Version in ArcMap (or by code) to propagate the modifications. If however you use the exact same connection, then changes will be see right away, most certainly when you save the edits. Connections are considered the same if, for Oracle at least (and presumably for other DB type) the same Instance, DB, login, (pws), are all equal. Let's put a big emphasis on the Instance, because the documentation is inaccurate.

  • It looks like the feature is updating straight into default, and the version doesn't know anything about it - thus not updating. Both connections are definitely OSA – Susan Madruga Nov 29 '16 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.