Hi Harrison,
I am implementing the same thing in JAVA. I have implemented same code you quoted above both JAVA and .NET. I could able to get correct results in .NET. However, I am not getting any results in JAVA. Below is my code in JAVA. Could you please help me out.
IVersionedWorkspace versionedWorkspace = new VersionedWorkspace(workspace);
IVersion childVersion = versionedWorkspace.findVersion("SDE.Test");
IVersion parentVersion = versionedWorkspace.getDefaultVersion();
// Cast to the IVersion2 interface to find the common ancestor.
IVersion2 childVersion2 = new IVersion2Proxy(childVersion);
commonAncestorVersion = childVersion2.getCommonAncestor(parentVersion);
// Cast the child version to IFeatureWorkspace and open the table.
IFeatureWorkspace childFWS = new IFeatureWorkspaceProxy(childVersion);
ITable childTable = childFWS.openTable(tableName);
// Cast the common ancestor version to IFeatureWorkspace and open the table.
commonAncestorFWS = new IFeatureWorkspaceProxy(commonAncestorVersion);
commonAncestorTable = commonAncestorFWS.openTable(tableName);
// Cast to the IVersionedTable interface to create a difference cursor.
IVersionedTable versionedTable = new IVersionedTableProxy(childTable);
differenceCursor = versionedTable.differences(commonAncestorTable, esriDifferenceType.esriDifferenceTypeInsert, null);
int countChildRecords = childTable.rowCount(null);
int countParentRecords = commonAncestorTable.rowCount(null);
// Create output variables for the IDifferenceCursor.Next method and a FID set.
IFIDSet fidSet = new FIDSet();
IRow[] differenceRow = null;
int[] objectID = null;
// Step through the cursor, showing the ID of each modified row.
differenceCursor.next(objectID, differenceRow);
Thanks & Regards,
Vara Prasad.
public void FindDifferences(IWorkspace ws, List<string> tableNames) { try { // Searching for insert differences foreach (string tableName in tableNames) FindDiff(ws, tableName); } catch (Exception ex) { //Logging } } public void FindDiff(IWorkspace workspace, string tabName) { IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace; IVersion childVersion = versionedWorkspace.DefaultVersion; IVersion parentVersion = versionedWorkspace.FindVersion("MY_VERSION"); // 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(tabName); // Cast the common ancestor version to IFeatureWorkspace and open the table. IFeatureWorkspace commonAncestorFWS = (IFeatureWorkspace)commonAncestorVersion; ITable commonAncestorTable = commonAncestorFWS.OpenTable(tabName); IVersionedTable versionedTable = (IVersionedTable)childTable; IDifferenceCursor differenceCursor = versionedTable.Differences(commonAncestorTable, esriDifferenceType.esriDifferenceTypeInsert, null); // Create output variables for the IDifferenceCursor.Next method. IRow differenceRow = null; int objectID = -1; // Step through the cursor, showing the ID of each modified row. differenceCursor.Next(out objectID, out differenceRow); while (objectID != -1) { differenceCursor.Next(out objectID, out differenceRow); ReleaseObject(differenceRow); } ReleaseObject(differenceCursor); ReleaseObject(commonAncestorTable); ReleaseObject(versionedTable); } public static void ReleaseObject(object comObj) { try { if (comObj != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj); } } catch { } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.