Finding differences between 2 SDE child versions

3094
3
05-16-2016 01:41 PM
JoseSanchez
Occasional Contributor III

Hello everyone,

How can I find differences between 2 SDE child versions using C# or VB.net. Both versions (version 1 and version 2) that have the same parent, Default.

How can I identify the features that changed from a specific feature class from version 2 and copy these changes to version 1?

Can I change the parent for version 2 from Default to version 1 and then apply a reconcile and post?

Please advise

0 Kudos
3 Replies
RebeccaStrauch__GISP
MVP Emeritus

Can you access the "version compare" tool from the versioning tool box?  I do arcpy vs .net, so can't help with any arcobjects stuff anymore.  You may have to compare each one separately against the parent and then see if there are differences.  ??

Manually it looks like this:

Maybe not the most efficient way, but depending on how many changes you have.  (by the way, mine is fully reconciled right now, so nothing to show).

Not sure that this is still all relevant (or what year it is from) but here is an article about versioning concepts, including a little about the about the stateid, which I don't think they teach anymore.  But might be of interest.  Versioning 101

0 Kudos
Vara_PrasadM_S
Occasional Contributor II

Hi Jose,

I am also looking for any solution to exactly the same problem. Could you please let me know if you got any solution for this. Please reply.

Thanks in advance!

With Regards,

Vara Prasad.

0 Kudos
nicogis
MVP Frequent Contributor

In arcobjects you can see the difference between two transactional versions with this code:

-list of oids : update in Versione A and no change in Default   (no conflits …)

List<int> f1 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName, esriDifferenceType.esriDifferenceTypeUpdateNoChange);

-list of oids : delete in Versione A and no change in Default (no conflits …)

List<int> f2 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName, esriDifferenceType.esriDifferenceTypeDeleteNoChange);

-list of oids : insert in Versione A (no conflits)

List<int> f3 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName, esriDifferenceType.esriDifferenceTypeInsert);

-list of oids : update in Versione A and update in Default (conflits)

List<int> f4 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName,

esriDifferenceType.esriDifferenceTypeUpdateUpdate);

-list of oids : update in Versione A and delete in Default (conflits)

List<int> f5 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName, esriDifferenceType.esriDifferenceTypeUpdateDelete);

-list of oids : delete in Versione A and update in Default (conflits)

List<int> f6 = FindVersionDifferences(aWorkspace, "Version A", "DEFAULT", featureClassName, esriDifferenceType.esriDifferenceTypeDeleteUpdate);

you also get 6 lists between Version B and Default and compare lists for see difference between Version A and B

for example change in A and in change B and no change in Default:

var c = f1_VersionA_Default.Intersect(f1_VersionB_Deafult);
c is list of oids changed in A and changed in B but not in Default

and so on …

 

public List<int> FindVersionDifferences(IWorkspace workspace, String childVersionName, String parentVersionName, String tableName, esriDifferenceType differenceType)
        {
            // Get references to the child and parent versions.
            IVersionedWorkspace versionedWorkspace=(IVersionedWorkspace)workspace;
            IVersion childVersion=versionedWorkspace.FindVersion(childVersionName);
            IVersion parentVersion=versionedWorkspace.FindVersion(parentVersionName);

            // Cast to the IVersion2 interface to find the common ancestor.
            //IVersion2 childVersion2=(IVersion2)childVersion;
            //IVersion commonAncestorVersion=childVersion2.GetCommonAncestor(parentVersion);

            // Cast the child version to IFeatureWorkspace and open the table.
            IFeatureWorkspace childFWS=(IFeatureWorkspace)childVersion;
            ITable childTable=childFWS.OpenTable(tableName);

            // Cast the common ancestor version to IFeatureWorkspace and open the table.
            //IFeatureWorkspace commonAncestorFWS=(IFeatureWorkspace)commonAncestorVersion;
            //ITable commonAncestorTable=commonAncestorFWS.OpenTable(tableName);

            IFeatureWorkspace commonAncestorFWS = (IFeatureWorkspace)parentVersion;
            ITable commonAncestorTable=commonAncestorFWS.OpenTable(tableName);

            // Cast to the IVersionedTable interface to create a difference cursor.
            IVersionedTable versionedTable=(IVersionedTable)childTable;
            IDifferenceCursor differenceCursor=versionedTable.Differences
                (commonAncestorTable, differenceType, null);

            // Create output variables for the IDifferenceCursor.Next method and a FID set.
            //IFIDSet fidSet=new FIDSetClass();
            IRow differenceRow=null;
            int objectID= - 1;
            List<int> l = new List<int>();
            // Step through the cursor, showing the ID of each modified row.
            differenceCursor.Next(out objectID, out differenceRow);
            while (objectID !=  - 1)
            {
                l.Add(objectID);
                differenceCursor.Next(out objectID, out differenceRow);
            }

           // fidSet.Reset();
           // return fidSet;
            return l;
        }
0 Kudos