コード例 #1
0
ファイル: VersionHelper.cs プロジェクト: secondii/Yutai
        public IFIDSet FindHistoricalDifferences(IWorkspace workspace, string historicalMarkerName, string tableName,
                                                 esriDifferenceType differenceType)
        {
            IHistoricalWorkspace historicalWorkspace = (IHistoricalWorkspace)workspace;
            IHistoricalVersion   historicalVersion   =
                historicalWorkspace.FindHistoricalVersionByName(historicalWorkspace.DefaultMarkerName);
            IHistoricalVersion historicalVersion1 = historicalWorkspace.FindHistoricalVersionByName(historicalMarkerName);
            IFeatureWorkspace  featureWorkspace   = (IFeatureWorkspace)historicalVersion;
            IFeatureWorkspace  featureWorkspace1  = (IFeatureWorkspace)historicalVersion1;
            ITable             table            = featureWorkspace.OpenTable(tableName);
            ITable             table1           = featureWorkspace1.OpenTable(tableName);
            IDifferenceCursor  differenceCursor = ((IVersionedTable)table).Differences(table1, differenceType, null);
            IFIDSet            fIDSetClass      = new FIDSet();
            IRow row = null;
            int  num = -1;

            differenceCursor.Next(out num, out row);
            while (num != -1)
            {
                fIDSetClass.Add(num);
                differenceCursor.Next(out num, out row);
            }
            fIDSetClass.Reset();
            return(fIDSetClass);
        }
コード例 #2
0
ファイル: VersioningUtil.cs プロジェクト: secondii/Yutai
 private void method_1(IVersionedTable iversionedTable_0, IVersionedTable iversionedTable_1, string string_0,
                       string string_1, esriDifferenceType esriDifferenceType_0, string string_2, bool bool_2, IList ilist_0)
 {
     try
     {
         int          num;
         IRow         row;
         IQueryFilter queryFilter = new QueryFilterClass();
         IObjectClass class2      = iversionedTable_0 as IObjectClass;
         queryFilter.SubFields = class2.OIDFieldName;
         IDifferenceCursor cursor = iversionedTable_0.Differences(iversionedTable_1 as ITable,
                                                                  esriDifferenceType_0, queryFilter);
         cursor.Next(out num, out row);
         while (num != -1)
         {
             if (bool_2)
             {
                 this.method_2(num, esriDifferenceType_0, string_1, string_0, string_2, ilist_0);
             }
             else
             {
                 this.method_2(num, esriDifferenceType_0, string_0, string_1, string_2, ilist_0);
             }
             cursor.Next(out num, out row);
         }
     }
     catch
     {
     }
 }
コード例 #3
0
        private void method_1(IVersionedTable iversionedTable_0, IVersionedTable iversionedTable_1, string string_0,
                              string string_1, esriDifferenceType esriDifferenceType_0, string string_2, bool bool_2, IList ilist_0)
        {
            int  num;
            IRow row;

            try
            {
                IQueryFilter queryFilterClass = new QueryFilter()
                {
                    SubFields = (iversionedTable_0 as IObjectClass).OIDFieldName
                };
                IDifferenceCursor differenceCursor = iversionedTable_0.Differences(iversionedTable_1 as ITable,
                                                                                   esriDifferenceType_0, queryFilterClass);
                differenceCursor.Next(out num, out row);
                while (num != -1)
                {
                    if (!bool_2)
                    {
                        this.method_2(num, esriDifferenceType_0, string_0, string_1, string_2, ilist_0);
                    }
                    else
                    {
                        this.method_2(num, esriDifferenceType_0, string_1, string_0, string_2, ilist_0);
                    }
                    differenceCursor.Next(out num, out row);
                }
            }
            catch
            {
            }
        }
コード例 #4
0
        /// <summary>
        ///     Gets the changes between the <paramref name="source" /> (or child) and <paramref name="table" /> (or parent)
        ///     version of the table.
        /// </summary>
        /// <param name="source">The source (or child) version.</param>
        /// <param name="table">The table (or parent) version.</param>
        /// <param name="filter">The predicate used to filter the differences.</param>
        /// <param name="differenceTypes">The types of differences that are detected.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{DifferenceRow}" /> representing the differences for the table.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     table
        ///     or
        ///     differenceTypes
        /// </exception>
        public static IEnumerable <DifferenceRow> GetDifferences(this IVersionedTable source, ITable table, IQueryFilter filter, params esriDifferenceType[] differenceTypes)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (differenceTypes == null)
            {
                throw new ArgumentNullException("differenceTypes");
            }

            foreach (var differenceType in differenceTypes)
            {
                using (ComReleaser cr = new ComReleaser())
                {
                    IDifferenceCursor differenceCursor = source.Differences(table, differenceType, filter);
                    cr.ManageLifetime(differenceCursor);

                    // 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 table again.
                    List <int> oids = new List <int>();
                    IRow       differenceRow;
                    int        oid;

                    differenceCursor.Next(out oid, out differenceRow);
                    while (oid != -1)
                    {
                        oids.Add(oid);
                        differenceCursor.Next(out oid, out differenceRow);
                    }

                    if (oids.Count > 0)
                    {
                        // When the feature was deleted in the source we need to use the parent version.
                        ITable differenceTable = (differenceType == esriDifferenceType.esriDifferenceTypeDeleteNoChange || differenceType == esriDifferenceType.esriDifferenceTypeDeleteUpdate)
                            ? table
                            : (ITable)source;

                        // Fetch the rows for read-write access.
                        ICursor cursor = differenceTable.GetRows(oids.ToArray(), false);
                        cr.ManageLifetime(cursor);

                        int i = 0;
                        while ((differenceRow = cursor.NextRow()) != null)
                        {
                            yield return(new DifferenceRow(differenceType, oids[i++], differenceRow));
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: perezjust/GPVersionCompare
        public static IFIDSet FindVersionDifferences(IWorkspace workspace, String sourceVersionName, String targetVersionName, String tableName, esriDifferenceType differenceType)
        {
            // Get references to the child and parent versions.
            IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
            IVersion            sourceVersion      = versionedWorkspace.FindVersion(sourceVersionName);
            IVersion            targetVersion      = versionedWorkspace.FindVersion(targetVersionName);

            // Cast to the IVersion2 interface to find the common ancestor.
            IVersion2 sourceVersion2        = (IVersion2)sourceVersion;
            IVersion  commonAncestorVersion = sourceVersion2.GetCommonAncestor(targetVersion);

            // Cast the child version to IFeatureWorkspace and open the table.
            IFeatureWorkspace targetFWS   = (IFeatureWorkspace)sourceVersion;
            ITable            targetTable = targetFWS.OpenTable(tableName);

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

            // Cast to the IVersionedTable interface to create a difference cursor.
            IVersionedTable   versionedTable   = (IVersionedTable)targetTable;
            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;

            // Step through the cursor, showing the ID of each modified row.
            differenceCursor.Next(out objectID, out differenceRow);
            while (objectID != -1)
            {
                fidSet.Add(objectID);
                differenceCursor.Next(out objectID, out differenceRow);
            }

            fidSet.Reset();
            return(fidSet);
        }
コード例 #6
0
ファイル: VersionHelper.cs プロジェクト: secondii/Yutai
        public static IFIDSet FindVersionDifferences(IWorkspace workspace, string childVersionName,
                                                     string parentVersionName, string tableName, esriDifferenceType differenceType)
        {
            IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
            IVersion            version            = versionedWorkspace.FindVersion(childVersionName);
            IVersion            version1           = versionedWorkspace.FindVersion(parentVersionName);
            IVersion            commonAncestor     = ((IVersion2)version).GetCommonAncestor(version1);
            ITable            table            = ((IFeatureWorkspace)version).OpenTable(tableName);
            ITable            table1           = ((IFeatureWorkspace)commonAncestor).OpenTable(tableName);
            IDifferenceCursor differenceCursor = ((IVersionedTable)table).Differences(table1, differenceType, null);
            IFIDSet           fIDSetClass      = new FIDSet();
            IRow row = null;
            int  num = -1;

            differenceCursor.Next(out num, out row);
            while (num != -1)
            {
                fIDSetClass.Add(num);
                differenceCursor.Next(out num, out row);
            }
            fIDSetClass.Reset();
            return(fIDSetClass);
        }
コード例 #7
0
        private byte[] ProcessEditAreas(IServerObject serverObject, string versionName)
        {
            try
            {
                // Open utility network
                IDataset   unDataset = _soiUtil.GetUNDataset(serverObject, versionName);
                IWorkspace workspace = (IWorkspace)unDataset.Workspace;

                // Get all the dirty areas in the given validation area
                IBaseNetwork baseNetwork    = (IBaseNetwork)unDataset;
                ITable       dirtyAreaTable = baseNetwork.DirtyAreaTable;

                string shapeFieldName    = ((IFeatureClass)dirtyAreaTable).ShapeFieldName;
                int    areaFieldIndex    = dirtyAreaTable.FindField(shapeFieldName);
                int    creatorFieldIndex = dirtyAreaTable.FindField("CREATOR");

                // Get UN schema version
                IDatasetComponent dsComponent   = (IDatasetComponent)unDataset;
                IDEBaseNetwork    deBaseNetwork = (IDEBaseNetwork)dsComponent.DataElement;
                int unVersion = deBaseNetwork.SchemaGeneration;

                // Get inserts made to dirty areas table in the current version
                // For UN > V4, Errors are discarded (ERROCODE>0) to only retain true dirty areas
                // Note that changes made in the last edit session must be saved for this to work
                // as it is not possible to get the modifications until they have been saved.

                IVersionedTable versionedTable = (IVersionedTable)dirtyAreaTable;
                QueryFilter     qryFilter      = null;
                if (unVersion >= 4)
                {
                    qryFilter             = new QueryFilter();
                    qryFilter.WhereClause = _errorCodeFName + "=0";
                }

                IDifferenceCursor diffCursor = versionedTable.Differences(dirtyAreaTable, esriDifferenceType.esriDifferenceTypeInsert, qryFilter);

                // Loop through added rows to construct the modified zone extent
                int       editCount = 0;
                int       OID;
                IRow      diffRow;
                IEnvelope editZone = null;
                string    creator  = "";

                diffCursor.Next(out OID, out diffRow);

                // Return an error if no dirty areas found as it may be because the last edits were not saved
                if (diffRow == null)
                {
                    JSONObject responseJSON = new JSONObject();
                    responseJSON.AddBoolean("success", false);
                    JSONObject errorJSON = new JSONObject();
                    errorJSON.AddLong("extendedCode", (int)fdoError.FDO_E_DIRTY_AREA_BUILD_EXTENT_DO_NOT_INTERSECT);
                    errorJSON.AddString("message", "A dirty area is not present within the validate network topology input extent. A validate network topology process did not occur.");
                    JSONArray detailsJSON = new JSONArray();
                    detailsJSON.AddString("Make sure to save edits before validating.");
                    errorJSON.AddJSONArray("details", detailsJSON);
                    responseJSON.AddJSONObject("error", errorJSON);

                    return(Encoding.UTF8.GetBytes(responseJSON.ToJSONString(null)));
                }

                while (diffRow != null)
                {
                    editCount += 1;
                    creator    = diffRow.Value[creatorFieldIndex].ToString();
                    IGeometry rowShape = (IGeometry)diffRow.Value[areaFieldIndex];
                    IEnvelope rowArea  = rowShape.Envelope;
                    if (editZone != null)
                    {
                        editZone.Union(rowArea);
                    }
                    else
                    {
                        editZone = rowArea.Envelope;
                    }

                    diffCursor.Next(out OID, out diffRow);
                }
                diffCursor     = null;
                versionedTable = null;
                workspace      = null;

                // Add new or modify existing edit zone
                if (editZone != null)
                {
                    AddEditArea(serverObject, creator, versionName, editCount, editZone);
                }
            }
            catch (Exception e)
            {
                _serverLog.LogMessage(ServerLogger.msgType.infoStandard, _soiName + ".AddEditArea()",
                                      200, "Error while adding edit are: " + e.ToString());
            }

            return(null);
        }