/* * This method returns the current utility network properties */ private IPropertySet GetUNProperties() { IPropertySet unProps = new PropertySet(); // Get UN IBaseNetwork bn = (IBaseNetwork)unDataset; // Get data element IDatasetComponent dsComponent = (IDatasetComponent)unDataset; IDEDataset deDS = dsComponent.DataElement; IDEBaseNetwork deBN = (IDEBaseNetwork)deDS; unProps.SetProperty("proVersion", deBN.ProVersion); unProps.SetProperty("schemaGeneration", deBN.SchemaGeneration); unProps.SetProperty("userIdentity", deBN.UserIdentity); unProps.SetProperty("creationTime", deBN.CreationTime.ToString()); // Get topology IBaseNetworkTopology bnTopo = (IBaseNetworkTopology)bn; unProps.SetProperty("hasValidNetworkTopology", bnTopo.HasValidNetworkTopology()); return(unProps); }
/* * This method executes a utility network trace to find all the low voltage service points * serviced by the specified transformer and returns the service points global IDs */ private IStringArray FindLVServicePoints(string xfrGlobalID) { //Get required Utility Network interfaces IBaseNetwork unBaseNetwork = (IBaseNetwork)unDataset; IDatasetComponent datasetComponent = (IDatasetComponent)unDataset; IDEDataset deDataset = datasetComponent.DataElement; IDEBaseNetwork deBaseNetwork = (IDEBaseNetwork)deDataset; IDEUtilityNetwork deUtilityNetwork = (IDEUtilityNetwork)deBaseNetwork; IDataElement deElement = (IDataElement)deDataset; //Create and initialize network tracer IUtilityNetworkQuery unQry = unBaseNetwork.CreateQuery(); ITracer unTracer = unBaseNetwork.CreateTracer(); unTracer.Initialize(unQry, (IDataElement)deDataset); // Add transformer as trace starting point IStringArray startGUID = new StrArrayClass(); startGUID.Add(xfrGlobalID); ILongArray startTerm = new LongArrayClass(); startTerm.Add(MV_XFR_TERMINAL_ID); unTracer.AddTraceLocationForJunctionFeatures(esriTraceLocationType.esriTLTStartingPoint, startGUID, startTerm); // Configure trace parameters UNTraceConfiguration traceConfig = new UNTraceConfiguration(); traceConfig.IgnoreBarriersAtStartingPoints = true; traceConfig.IncludeContainers = false; traceConfig.IncludeBarriers = false; traceConfig.IncludeContent = true; traceConfig.IncludeIsolated = false; traceConfig.IncludeStructures = false; traceConfig.IncludeUpToFirstSpatialContainer = false; traceConfig.DomainNetworkName = DOMAIN_NETWORK; traceConfig.TierName = MV_TIER_NAME; traceConfig.TargetTierName = MV_TIER_NAME; traceConfig.TraversabilityScope = esriTraversabilityScope.esriTSJunctionsAndEdges; traceConfig.FilterScope = esriTraversabilityScope.esriTSJunctionsAndEdges; traceConfig.ValidateConsistency = false; // Add output filter to only return service points IArray outFilters = new ArrayClass(); for (int i = 0; i < LV_SERVICE_ASSETTYPES.Length; i++) { UNOutputFilter outFilter = new UNOutputFilter(); outFilter.NetworkSourceID = DEVICE_SOURCE_ID; outFilter.AssetGroupCode = LV_SERVICE_ASSETGROUP; outFilter.AssetTypeCode = LV_SERVICE_ASSETTYPES[i]; outFilters.Add(outFilter); } traceConfig.OutputFilters = outFilters; unTracer.TraceConfiguration = (ITraceConfiguration)traceConfig; // Execute the trace long[] jEid = new long[1]; long[] eEid = new long[1]; unTracer.Trace(esriUtilityNetworkTraceType.esriUNTTDownstream, out jEid, out eEid); // Get features from returned elements IUNTraceResults unTraceResults = (IUNTraceResults)unTracer; ILongArray junctionNetworkSourceIDs = new LongArrayClass(); IStringArray junctionGlobalIDs = new StrArrayClass(); ILongArray junctionObjectIDs = new LongArrayClass(); ILongArray junctionTerminalIDs = new LongArrayClass(); ILongArray junctionAssetGroupCodes = new LongArrayClass(); ILongArray junctionAssetTypeCodes = new LongArrayClass(); ILongArray edgeNetworkSourceIDs = new LongArrayClass(); IStringArray edgeGlobalIDs = new StrArrayClass(); ILongArray edgeObjectIDs = new LongArrayClass(); ILongArray edgeAssetGroupCodes = new LongArrayClass(); ILongArray edgeAssetTypeCodes = new LongArrayClass(); unTraceResults.TraceResultFeatures(out junctionNetworkSourceIDs, out junctionGlobalIDs, out junctionObjectIDs, out junctionTerminalIDs, out junctionAssetGroupCodes, out junctionAssetTypeCodes, out edgeNetworkSourceIDs, out edgeGlobalIDs, out edgeObjectIDs, out edgeAssetGroupCodes, out edgeAssetTypeCodes); return(junctionGlobalIDs); }
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); }