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 { } }
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 { } }
/// <summary> /// Gets the name of the delta (either the A or D) table for the versioned <paramref name="source" />. /// </summary> /// <param name="source">The versioned table or feature class.</param> /// <param name="delta">The delta (indicate the A or D) table.</param> /// <returns> /// Returns a <see cref="string" /> representing the name of the delta table. /// </returns> /// <exception cref="System.ArgumentNullException">delta</exception> /// <exception cref="System.ArgumentException"> /// The delta string must be 1 char long. /// or /// The delta string must contain only 'A' or 'D' chars. /// or /// The table must be versioned for it have a delta table. /// </exception> /// <exception cref="ArgumentException"> /// The delta string must be 1 char long. /// or /// The delta string must contain only 'A' or 'D' chars. /// </exception> public static string GetDeltaTableName(this ITable source, string delta) { if (source == null) { return(null); } if (delta == null) { throw new ArgumentNullException("delta"); } if (delta.Length != 1) { throw new ArgumentException("The delta string must be 1 char long."); } if (delta.Any(@char => @char != 'A' && @char != 'D' && @char != 'a' && @char != 'd')) { throw new ArgumentException("The delta string must contain only 'A' or 'D' chars."); } IVersionedTable versionedTable = source as IVersionedTable; if (versionedTable == null) { throw new ArgumentException("The table must be versioned for it have a delta table."); } string className = ((IDataset)source).Name; int index = className.IndexOf('.'); if (index > 0) { string ownerName = source.GetSchemaName(); string tableName = source.GetTableName(); using (var cr = new ComReleaser()) { IWorkspace workspace = ((IDataset)source).Workspace; var fws = (IFeatureWorkspace)workspace; var syntax = (ISQLSyntax)workspace; string functionName = syntax.GetFunctionName(esriSQLFunctionName.esriSQL_UPPER); IQueryDef queryDef = fws.CreateQueryDef(); queryDef.Tables = "sde.table_registry"; queryDef.SubFields = "registration_id"; queryDef.WhereClause = string.Format("{2}(table_name) = {2}('{0}') AND {2}(owner) = {2}('{1}')", tableName, ownerName, functionName); ICursor cursor = queryDef.Evaluate(); cr.ManageLifetime(cursor); IRow row = cursor.NextRow(); return((row != null) ? string.Format("{0}.{1}{2}", ownerName, delta, row.Value[0]) : null); } } return(null); }
/// <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)); } } } } }
/// <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); }
private async Task <CacheUser> CreateExpectedDocumentAsync(IVersionedTable <CacheUser> userTable, string id = null, DateTime?createdAt = null) { // Create the document. var expectedDocument = new CacheUser { Id = id ?? this.global.RandomId(), VersionId = this.global.RandomId(), Handle = "testhandle", Email = "*****@*****.**", Entity = "https://entity.quentez.com", CreatedAt = createdAt.GetValueOrDefault(DateTime.UtcNow) }; // Add it to the collection. await userTable.InsertAsync(expectedDocument); return(expectedDocument); }
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); }
private void method_5(IVersionedTable iversionedTable_0, IVersionedTable iversionedTable_1, string string_0, string string_1, string string_2, IList ilist_0) { this.bool_1 = false; this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeDeleteNoChange, string_2, true, ilist_0); this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeDeleteUpdate, string_2, true, ilist_0); this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeInsert, string_2, true, ilist_0); this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeUpdateDelete, string_2, true, ilist_0); this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeUpdateNoChange, string_2, true, ilist_0); this.method_1(iversionedTable_1, iversionedTable_0, string_0, string_1, esriDifferenceType.esriDifferenceTypeUpdateUpdate, string_2, true, ilist_0); this.method_1(iversionedTable_0, iversionedTable_1, string_0, string_1, esriDifferenceType.esriDifferenceTypeDeleteNoChange, string_2, false, ilist_0); this.method_1(iversionedTable_0, iversionedTable_1, string_0, string_1, esriDifferenceType.esriDifferenceTypeInsert, string_2, false, ilist_0); this.method_1(iversionedTable_0, iversionedTable_1, string_0, string_1, esriDifferenceType.esriDifferenceTypeUpdateNoChange, string_2, false, ilist_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); }
private IServiceProvider CreateServiceProvider(ICacheStore <CacheUser> userCache, IVersionedTable <CacheUser> userTable) { // Create the services collection. var services = new ServiceCollection(); ServerLibInitializer.RegisterTypes(services, this.global.MakeTestConfiguration()); // Mock the caches. var cachesMock = new Mock <ICaches>(); cachesMock.SetupGet(c => c.Users).Returns(userCache); cachesMock.Setup(c => c.StoreForType <CacheUser>()).Returns(userCache); services.AddSingleton(cachesMock.Object); // Mock the database. var tablesMock = new Mock <ITables>(); tablesMock.Setup(t => t.TableForType <CacheUser>()).Returns(userTable); tablesMock.Setup(t => t.TableForVersionedType <CacheUser>()).Returns(userTable); services.AddSingleton(tablesMock.Object); // Create the service provider and return. return(services.BuildServiceProvider()); }
private IInternalUserLoader CreateInternalUserLoader(ICacheStore <CacheUser> userCache, IVersionedTable <CacheUser> userTable) { var serviceProvider = this.CreateServiceProvider(userCache, userTable); return(serviceProvider.GetService <IInternalUserLoader>()); }