/// <summary> /// Gets the rows that pertain to the data change type. /// </summary> /// <param name="dataChangeTypes">Type of the data changes.</param> /// <returns>Retursn a <see cref="DeltaRowCollection" /> representing the delta rows for the data change type.</returns> public DeltaRowCollection GetRows(params esriDataChangeType[] dataChangeTypes) { var rows = this.Where(deltaRow => dataChangeTypes.Contains(deltaRow.DataChangeType)); var collection = new DeltaRowCollection(this.ModifiedClassInfo, this.SourceVersion, this.TargetVersion); collection.AddRange(rows); return(collection); }
/// <summary> /// Combines the rows from the collections in into a single collection /// </summary> /// <param name="collections">The collections.</param> /// <returns> /// Retursn a <see cref="DeltaRowCollection" /> representing the delta rows for the data change type. /// </returns> public DeltaRowCollection GetRows(params DeltaRowCollection[] collections) { var collection = new DeltaRowCollection(this.ModifiedClassInfo, this.SourceVersion, this.TargetVersion); foreach (var rows in collections) { collection.AddRange(rows); } return(collection); }
/// <summary> /// Gets the differences between the <paramref name="source" /> and <paramref name="target" /> versions that need to be /// checked-in or exported. /// </summary> /// <param name="source">The source (or child) version.</param> /// <param name="target">The target (or parent) version.</param> /// <param name="predicate"> /// The predicate that defines a set of criteria and determines whether the specified differences /// will be loaded. /// </param> /// <param name="dataChangeTypes">The data change types.</param> /// <returns> /// Returns a <see cref="Dictionary{String, DeltaRow}" /> representing the differences for the table (or /// key). /// </returns> /// <exception cref="System.ArgumentNullException"> /// target /// or /// predicate /// or /// dataChangeTypes /// </exception> public static Dictionary <string, DeltaRowCollection> GetDataChanges(this IVersion source, IVersion target, Func <IModifiedClassInfo, bool> predicate, params esriDataChangeType[] dataChangeTypes) { if (source == null) { return(null); } if (target == null) { throw new ArgumentNullException("target"); } if (predicate == null) { throw new ArgumentNullException("predicate"); } if (dataChangeTypes == null) { throw new ArgumentNullException("dataChangeTypes"); } var list = new Dictionary <string, DeltaRowCollection>(StringComparer.Create(CultureInfo.InvariantCulture, true)); IVersionDataChangesInit vdci = new VersionDataChangesClass(); IWorkspaceName wsNameSource = (IWorkspaceName)((IDataset)source).FullName; IWorkspaceName wsNameTarget = (IWorkspaceName)((IDataset)target).FullName; vdci.Init(wsNameSource, wsNameTarget); IDataChanges dataChanges = (IDataChanges)vdci; IDataChangesInfo dci = (IDataChangesInfo)vdci; var tasks = new List <Action>(); IEnumModifiedClassInfo enumMci = dataChanges.GetModifiedClassesInfo(); foreach (var mci in enumMci.AsEnumerable()) { // Validate that the table needs to be loaded. if (predicate(mci)) { string tableName = mci.ChildClassName; tasks.Add(() => { var rows = new DeltaRowCollection(mci, source, target); var actions = new List <Action>(); // Determines if the table represents a feature class. bool isFeatureClass = mci.DatasetType == esriDatasetType.esriDTFeatureClass; // Iterate through all of the data change types. foreach (var dataChangeType in dataChangeTypes) { actions.Add(() => { // IRow objects returned from a difference cursor are meant to be a read only. Thus, only the OIDs are being loaded and // the rows are hydrated from the struct. IFIDSet set = dci.ChangedIDs[tableName, dataChangeType]; set.Reset(); int oid; set.Next(out oid); while (oid != -1) { var row = new DeltaRow(dataChangeType, oid, tableName, isFeatureClass); rows.Add(row); set.Next(out oid); } }); } if (actions.Any()) { Task.WaitAll(actions); } list.Add(tableName, rows); }); } } if (tasks.Any()) { Task.WaitAll(tasks); } return(list); }