Esempio n. 1
0
        private void method_11()
        {
            esriExportDataChangesOption esriExportToAccess = esriExportDataChangesOption.esriExportToAccess;

            if (Path.GetExtension(this.string_0).ToLower() == ".xml")
            {
                esriExportToAccess = esriExportDataChangesOption.esriExportToXML;
            }
            IExportDataChanges changes   = new DataChangesExporterClass();
            IName              name      = this.iworkspaceName_0 as IName;
            IWorkspace         workspace = name.Open() as IWorkspace;
            IWorkspaceReplicas replicas  = workspace as IWorkspaceReplicas;
            IEnumReplica       replica   = replicas.Replicas;

            replica.Reset();
            if (replica != null)
            {
                for (IReplica replica2 = replica.Next(); replica2 != null; replica2 = replica.Next())
                {
                    if (replica2.ReplicaRole == esriReplicaType.esriCheckOutTypeChild)
                    {
                        IReplicaDataChangesInit init = new CheckOutDataChangesClass();
                        init.Init(replica2, this.iworkspaceName_0);
                        IDataChanges dataChanges = init as IDataChanges;
                        changes.ExportDataChanges(this.string_0, esriExportToAccess, dataChanges, true);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets the differences between the <paramref name="source" /> and <paramref name="target" /> versions.
        /// </summary>
        /// <param name="source">The source (or child) version.</param>
        /// <param name="target">The target (or parent) version.</param>
        /// <param name="filter">The predicate to filter the results.</param>
        /// <param name="predicate">
        ///     The predicate that defines a set of criteria and determines whether the specified differences
        ///     will be loaded.
        /// </param>
        /// <param name="differenceTypes">The type of differences that will be determined.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{String, DifferenceRow}" /> representing the differences for the
        ///     table (or key).
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     target
        ///     or
        ///     differenceTypes
        /// </exception>
        public static Dictionary <string, IEnumerable <DifferenceRow> > GetDifferences(this IVersion source, IVersion target, IQueryFilter filter, Func <string, ITable, bool> predicate, params esriDifferenceType[] differenceTypes)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (differenceTypes == null)
            {
                throw new ArgumentNullException("differenceTypes");
            }

            var list = new Dictionary <string, IEnumerable <DifferenceRow> >();

            IVersionDataChangesInit vdci         = new VersionDataChangesClass();
            IWorkspaceName          wsNameSource = (IWorkspaceName)((IDataset)source).FullName;
            IWorkspaceName          wsNameTarget = (IWorkspaceName)((IDataset)target).FullName;

            vdci.Init(wsNameSource, wsNameTarget);

            IDataChanges           dataChanges = (IDataChanges)vdci;
            IEnumModifiedClassInfo enumMci     = dataChanges.GetModifiedClassesInfo();

            enumMci.Reset();
            IModifiedClassInfo mci;

            while ((mci = enumMci.Next()) != null)
            {
                // The table references are not disposed due to the enumerable return which would result in an RCW exception.
                string tableName   = mci.ChildClassName;
                ITable sourceTable = ((IFeatureWorkspace)source).OpenTable(tableName);
                if (predicate(tableName, sourceTable))
                {
                    IVersionedTable versionedTable = sourceTable as IVersionedTable;
                    ITable          table          = ((IFeatureWorkspace)target).OpenTable(tableName);
                    if (versionedTable != null && table != null)
                    {
                        var rows = versionedTable.GetDifferences(table, filter, differenceTypes);
                        list.Add(tableName, rows);
                    }
                }
            }

            return(list);
        }
Esempio n. 3
0
        private void btnSelectDelta_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter      = "*.mdb|*.mdb|*.xml|*.xml",
                Multiselect = false
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.bool_0 = false;
                this.lblCheckOutName.Text = "";
                this.txtDelta.Text        = "";
                string fileName = dialog.FileName;
                esriExportDataChangesOption esriExportToAccess = esriExportDataChangesOption.esriExportToAccess;
                if (dialog.FilterIndex == 2)
                {
                    esriExportToAccess = esriExportDataChangesOption.esriExportToXML;
                }
                IDeltaDataChangesInit init = new DeltaDataChangesClass();
                try
                {
                    init.Init(fileName, esriExportToAccess);
                    IDeltaDataChanges changes = init as IDeltaDataChanges;
                    this.txtDelta.Text = fileName;
                    this.txtDelta.Tag  = changes.Container;
                    IDataChanges changes2 = init as IDataChanges;
                    if (changes2.ParentWorkspaceName != null)
                    {
                        IWorkspace workspace = (changes2.ParentWorkspaceName as IName).Open() as IWorkspace;
                        IReplica   replica   = (workspace as IWorkspaceReplicas).get_ReplicaByID(changes2.ParentReplicaID);
                        if (replica != null)
                        {
                            this.lblCheckOutName.Text = replica.Name;
                            this.bool_0 = true;
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("检入空间中没有检出数据或检出数据无效!");
                }
            }
        }
Esempio n. 4
0
        /// <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);
        }