/// <summary> /// 删除记录 /// </summary> /// <param name="PFeatureclass"></param> /// <param name="whereClause"></param> public static void DeleteAeFeature(ESRI.ArcGIS.Geodatabase.ITable pTable, string whereClause) { ESRI.ArcGIS.Geodatabase.IQueryFilter pQueryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); pQueryFilter.WhereClause = whereClause; pTable.DeleteSearchedRows(pQueryFilter); System.Runtime.InteropServices.Marshal.ReleaseComObject(pQueryFilter); }
//The SelectReduction procedure works with the input node schematic node candidate to the //reduction and with the input linkElements list of schematic link elements incident to //this schematic node. It must return True for the output reduce boolean parameter if //the node is reduced, false if the node is kept. When the output ppLink schematic link //is not nothing, it determines the target node that will be used to reconnect the links //incidents to the reduced node. In this sample procedure, the node candidate to the //reduction is analyzed. If records related to this node exist in the plants_equipments table, //the node is kept (output reduce parameter is False); else, it is reduced (output reduce //parameter is True). public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link) { // if associated feature doesn't exist do nothing ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedNode; schemAssociatedNode = node as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature; if (schemAssociatedNode == null) { return(false); } // if dataset is not plants do nothing ESRI.ArcGIS.Geodatabase.IDataset schemElementClass; schemElementClass = (ESRI.ArcGIS.Geodatabase.IDataset)schemAssociatedNode.SchematicElementClass; if (schemElementClass == null) { return(false); } if (schemElementClass.Name.IndexOf("plants") < 0) { return(false); } // get workspace ESRI.ArcGIS.Geodatabase.IFeatureWorkspace plantsWorkspace; plantsWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)schemElementClass.Workspace; // open table plants_equipments ESRI.ArcGIS.Geodatabase.ITable plantsEquipment; plantsEquipment = plantsWorkspace.OpenTable("plants_equipments"); if (plantsEquipment == null) { return(false); } // filter for the selected feature ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation schemAssociation; schemAssociation = schemAssociatedNode as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation; if (schemAssociation == null) { return(false); } ESRI.ArcGIS.Geodatabase.IQueryFilter plantsFilter; plantsFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); plantsFilter.WhereClause = ("PlantID = " + schemAssociation.ObjectID); ESRI.ArcGIS.Geodatabase.ICursor plantsCursor; plantsCursor = plantsEquipment.Search(plantsFilter, true); // if found equipment return false if (plantsCursor != null && plantsCursor.NextRow() != null) { return(false); } return(true); // if this far }
/// <summary> /// Gets a list of all strand numbers from a cable that are spliced on the given end /// </summary> /// <param name="cable">Cable to check</param> /// <param name="isFromEnd">True to check from end, False to check to end</param> /// <returns>List of int</returns> private static List <int> GetSplicedStrands(FiberCableWrapper cable, bool isFromEnd) { if (null == cable) { throw new ArgumentNullException("cable"); } List <int> result = new List <int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = TelecomWorkspaceHelper.Instance().FindTable(ConfigUtil.FiberSpliceTableName); // ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = GdbUtils.GetTable(cable.Feature.Class, ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}'", ConfigUtil.ACableIdFieldName, cable.IPID, ConfigUtil.IsAFromEndFieldName, (isFromEnd ? "T" : "F")); ESRI.ArcGIS.Geodatabase.ICursor spliceCursor = fiberSpliceTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow spliceRow = spliceCursor.NextRow(); int fiberIdIdx = fiberSpliceTable.FindField(ConfigUtil.AFiberNumberFieldName); while (null != spliceRow) { result.Add((int)spliceRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = spliceCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceCursor); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}'", ConfigUtil.BCableIdFieldName, cable.IPID, ConfigUtil.IsBFromEndFieldName, (isFromEnd ? "T" : "F")); spliceCursor = fiberSpliceTable.Search(filter, true); spliceRow = spliceCursor.NextRow(); fiberIdIdx = fiberSpliceTable.FindField(ConfigUtil.BFiberNumberFieldName); while (null != spliceRow) { result.Add((int)spliceRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = spliceCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceCursor); } return(result); }
public static ESRI.ArcGIS.Geodatabase.ICursor obterCursor(ESRI.ArcGIS.Geodatabase.ITable table, string subFields, string whereClause, string order) { ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); queryFilter.SubFields = subFields; queryFilter.WhereClause = whereClause; ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition queryFilterDef = (ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)queryFilter; queryFilterDef.PostfixClause = order; return(table.Search(queryFilter, true)); }
/// <summary> /// Gets a list of all port numbers from a device that are not connected on the given end /// </summary> /// <param name="device">Device to check</param> /// <param name="portType">Check input or output ports</param> /// <returns>List of int</returns> private static List <int> GetOpenPorts(DeviceWrapper device, PortType portType) { #region Validation if (null == device) { throw new ArgumentNullException("device"); } if (null == device.Feature) { throw new ArgumentException("device.Class cannot be null"); } #endregion List <int> result = new List <int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; if (null != portTable) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2} IS NULL AND {3}='{4}'", deviceHasPorts.OriginForeignKey, device.Feature.get_Value(deviceFtClass.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.ConnectedCableFieldName, ConfigUtil.PortTypeFieldName, (PortType.Input == portType ? "1" : "2")); ESRI.ArcGIS.Geodatabase.ICursor portCursor = portTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow portRow = portCursor.NextRow(); int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName); while (null != portRow) { result.Add((int)portRow.get_Value(portIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portRow); portRow = portCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portCursor); } } } return(result); }
public bool ExportFeatureClass(ESRI.ArcGIS.Geodatabase.IFeatureClass InputFeatureClass, string OutputFeatureClassName, ESRI.ArcGIS.Geodatabase.IWorkspace OutputWorkspace, string WhereClause) { ESRI.ArcGIS.Geodatabase.IDataset inputDataset = null; ESRI.ArcGIS.Geodatabase.IFeatureClassName inputFeatureClassName = null; ESRI.ArcGIS.Geodatabase.IDatasetName inputDatasetName = null; ESRI.ArcGIS.Geodatabase.IQueryFilter inputQueryFilter = null; ESRI.ArcGIS.Geodatabase.IFeatureClassName outputFeatureClassNameObject = null; ESRI.ArcGIS.Geodatabase.IDataset outputDataset = null; ESRI.ArcGIS.Geodatabase.IWorkspaceName outputWorkspaceName = null; ESRI.ArcGIS.Geodatabase.IDatasetName outputDatasetName = null; ESRI.ArcGIS.GeoDatabaseUI.ExportOperation exportOperation = null; try { // QI to the Input Dataset Name. inputDataset = (ESRI.ArcGIS.Geodatabase.IDataset)InputFeatureClass; inputFeatureClassName = (ESRI.ArcGIS.Geodatabase.IFeatureClassName)inputDataset.FullName; inputDatasetName = (ESRI.ArcGIS.Geodatabase.IDatasetName)inputFeatureClassName; // If a Where Clause was passed to this method, build a Query Filter to be passed to the Export Operation. if (!System.String.IsNullOrEmpty(WhereClause)) { inputQueryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); inputQueryFilter.WhereClause = WhereClause; } // Define the Output Feature Class. outputFeatureClassNameObject = new ESRI.ArcGIS.Geodatabase.FeatureClassNameClass(); outputDatasetName = (ESRI.ArcGIS.Geodatabase.IDatasetName)outputFeatureClassNameObject; outputDatasetName.Name = OutputFeatureClassName; outputFeatureClassNameObject.FeatureType = InputFeatureClass.FeatureType; outputFeatureClassNameObject.ShapeType = InputFeatureClass.ShapeType; outputFeatureClassNameObject.ShapeFieldName = InputFeatureClass.ShapeFieldName; // Define the Ouput Workspace Name Object. outputDataset = (ESRI.ArcGIS.Geodatabase.IDataset)OutputWorkspace; outputWorkspaceName = (ESRI.ArcGIS.Geodatabase.IWorkspaceName)outputDataset.FullName; // Associate the Workspace with the output Feature class. outputDatasetName.WorkspaceName = outputWorkspaceName; // Export the Feature Class to the output File GeoDatabase. exportOperation = new ESRI.ArcGIS.GeoDatabaseUI.ExportOperationClass(); exportOperation.ExportFeatureClass(inputDatasetName, inputQueryFilter, null, null, outputFeatureClassNameObject, 0); } catch (System.Exception caught) { // Determine the Line Number from which the exception was thrown. System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(caught, true); System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1); int lineNumber = stackFrame.GetFileLineNumber(); // Let the User know that this process failed. if (ErrorMessage != null) { ErrorMessage("The MaintTools.FeatureClassUtilities.ExportFeatureClass() Method failed with error message: " + caught.Message + " (Line: " + lineNumber.ToString() + ")!"); } // Return FALSE to the calling routine to indicate that this process failed. return false; } finally { // If the Input Dataset name Object was instantiated, close it. if (inputDataset != null) { inputDataset = null; } // If the Input Feature Class Name Object was instantiated, close it. if (inputFeatureClassName != null) { inputFeatureClassName = null; } // If the Input Dataset Name Object was instantiated, close it. if (inputDatasetName != null) { inputDatasetName = null; } // If the Input Query Filter Object was instantiated, close it. if (inputQueryFilter != null) { inputQueryFilter = null; } // If the Output Feature Class Name Object was instantiated, close it. if (outputFeatureClassNameObject != null) { outputFeatureClassNameObject = null; } // If the Output Dataset Object was instantiated, close it. if (outputDataset != null) { outputDataset = null; } // If the Output Workspace Name Object was instantiated, close it. if (outputWorkspaceName != null) { outputWorkspaceName = null; } // If the Output Dataset Name Object was instantiated, close it. if (outputDatasetName != null) { outputDatasetName = null; } // If the Export Operation Object was instantiated, close it. if (exportOperation != null) { exportOperation = null; } } // If the process made it to here it was successful so return TRUE to the calling method. return true; }
/// <summary> /// Gets a list of all strand numbers from a cable that are spliced on the given end /// </summary> /// <param name="cable">Cable to check</param> /// <param name="isFromEnd">True to check from end, False to check to end</param> /// <returns>List of int</returns> private static List<int> GetSplicedStrands(FiberCableWrapper cable, bool isFromEnd) { if (null == cable) { throw new ArgumentNullException("cable"); } List<int> result = new List<int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = TelecomWorkspaceHelper.Instance().FindTable(ConfigUtil.FiberSpliceTableName); // ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = GdbUtils.GetTable(cable.Feature.Class, ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}'", ConfigUtil.ACableIdFieldName, cable.IPID, ConfigUtil.IsAFromEndFieldName, (isFromEnd ? "T" : "F")); ESRI.ArcGIS.Geodatabase.ICursor spliceCursor = fiberSpliceTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow spliceRow = spliceCursor.NextRow(); int fiberIdIdx = fiberSpliceTable.FindField(ConfigUtil.AFiberNumberFieldName); while (null != spliceRow) { result.Add((int)spliceRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = spliceCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceCursor); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}'", ConfigUtil.BCableIdFieldName, cable.IPID, ConfigUtil.IsBFromEndFieldName, (isFromEnd ? "T" : "F")); spliceCursor = fiberSpliceTable.Search(filter, true); spliceRow = spliceCursor.NextRow(); fiberIdIdx = fiberSpliceTable.FindField(ConfigUtil.BFiberNumberFieldName); while (null != spliceRow) { result.Add((int)spliceRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = spliceCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceCursor); } return result; }
/// <summary> /// Gets a list of all port numbers from a device that are not connected on the given end /// </summary> /// <param name="device">Device to check</param> /// <param name="portType">Check input or output ports</param> /// <returns>List of int</returns> private static List<int> GetOpenPorts(DeviceWrapper device, PortType portType) { #region Validation if (null == device) { throw new ArgumentNullException("device"); } if (null == device.Feature) { throw new ArgumentException("device.Class cannot be null"); } #endregion List<int> result = new List<int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; if (null != portTable) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2} IS NULL AND {3}='{4}'", deviceHasPorts.OriginForeignKey, device.Feature.get_Value(deviceFtClass.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.ConnectedCableFieldName, ConfigUtil.PortTypeFieldName, (PortType.Input == portType ? "1" : "2")); ESRI.ArcGIS.Geodatabase.ICursor portCursor = portTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow portRow = portCursor.NextRow(); int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName); while (null != portRow) { result.Add((int)portRow.get_Value(portIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portRow); portRow = portCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portCursor); } } } return result; }
/// <summary> /// Gets a list of all strand numbers from a cable that are connected on the given end /// </summary> /// <param name="cable">Cable to check</param> /// <param name="isFromEnd">True to check from end, False to check to end</param> /// <returns>List of int</returns> private static List<int> GetConnectedStrands(FiberCableWrapper cable, bool isFromEnd) { #region Validation if (null == cable) { throw new ArgumentNullException("cable"); } #endregion List<int> result = new List<int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = cable.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; string[] deviceClassNames = ConfigUtil.DeviceFeatureClassNames; for (int i = 0; i < deviceClassNames.Length; i++) { string deviceClassName = deviceClassNames[i]; ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = TelecomWorkspaceHelper.Instance().FindFeatureClass(deviceClassName); // ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = GdbUtils.GetFeatureClass(cableFtClass, deviceClassName); if (null != deviceFtClass) { ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; if (null != portTable) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}' AND {4} IS NOT NULL", ConfigUtil.ConnectedCableFieldName, cable.IPID, ConfigUtil.ConnectedEndFieldName, (isFromEnd ? "T" : "F"), ConfigUtil.ConnectedFiberFieldName); ESRI.ArcGIS.Geodatabase.ICursor portCursor = portTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow portRow = portCursor.NextRow(); int fiberIdIdx = portTable.FindField(ConfigUtil.ConnectedFiberFieldName); while (null != portRow) { result.Add((int)portRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portRow); portRow = portCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portCursor); } } } } } return result; }
/// <summary> /// Get the existing splice ranges between two cables at an existing closure /// </summary> /// <param name="cableA">One cable</param> /// <param name="cableB">Other cable</param> /// <param name="splice">Splice Closure</param> /// <returns>List of FiberSplice</returns> /// <remarks>Currently only checks A/B as passed, does not check the reverse B/A combination</remarks> public static List<FiberSplice> GetSplicedRanges(FiberCableWrapper cableA, FiberCableWrapper cableB, SpliceClosureWrapper splice) { List<FiberSplice> result = new List<FiberSplice>(); string spliceWhere = string.Format("{0}='{1}' AND {2}='{3}' AND {4}='{5}'", ConfigUtil.ACableIdFieldName, cableA.IPID, ConfigUtil.BCableIdFieldName, cableB.IPID, ConfigUtil.SpliceClosureIpidFieldName, splice.IPID); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = TelecomWorkspaceHelper.Instance().FindTable(ConfigUtil.FiberSpliceTableName); // ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = GdbUtils.GetTable(cableA.Feature.Class, ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = spliceWhere; ((ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)filter).PostfixClause = string.Format("ORDER BY {0}",ConfigUtil.AFiberNumberFieldName); int aUnitIdx = fiberSpliceTable.FindField(ConfigUtil.AFiberNumberFieldName); int bUnitIdx = fiberSpliceTable.FindField(ConfigUtil.BFiberNumberFieldName); int lossIdx = fiberSpliceTable.FindField(ConfigUtil.LossFieldName); int typeIdx = fiberSpliceTable.FindField(ConfigUtil.TypeFieldName); ESRI.ArcGIS.Geodatabase.IField typeField = fiberSpliceTable.Fields.get_Field(typeIdx); ESRI.ArcGIS.Geodatabase.ICodedValueDomain typeDomain = typeField.Domain as ESRI.ArcGIS.Geodatabase.ICodedValueDomain; ESRI.ArcGIS.Geodatabase.ICursor splices = fiberSpliceTable.Search(filter, true); releaser.ManageLifetime(splices); ESRI.ArcGIS.Geodatabase.IRow spliceRow = splices.NextRow(); int lastAUnit = -1; int lastBUnit = -1; double? lastLoss = null; object lastType = Type.Missing; int aLow = -1; int bLow = -1; while (null != spliceRow) { // These are not-null columns int aUnit = (int)spliceRow.get_Value(aUnitIdx); int bUnit = (int)spliceRow.get_Value(bUnitIdx); object lossObj = spliceRow.get_Value(lossIdx); double? loss = null; if (DBNull.Value != lossObj) { loss = (double)lossObj; } object type = spliceRow.get_Value(typeIdx); if (aUnit != (lastAUnit + 1) || bUnit != (lastBUnit + 1) || loss != lastLoss || !type.Equals(lastType)) { if (-1 != lastAUnit) { string typeString = string.Empty; if (null != typeString) { if (null != typeDomain) { typeString = GdbUtils.GetDomainNameForValue(typeDomain, lastType); } else { typeString = lastType.ToString(); // DBNull.Value will return string.Empty } } result.Add(new FiberSplice(new Range(aLow, lastAUnit), new Range(bLow, lastBUnit), lastLoss, typeString)); } aLow = aUnit; bLow = bUnit; } lastAUnit = aUnit; lastBUnit = bUnit; lastLoss = loss; lastType = type; ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = splices.NextRow(); } if (-1 < aLow) { string typeString = string.Empty; if (null != typeString) { if (null != typeDomain) { typeString = GdbUtils.GetDomainNameForValue(typeDomain, lastType); } else { typeString = lastType.ToString(); // DBNull.Value will return string.Empty } } result.Add(new FiberSplice(new Range(aLow, lastAUnit), new Range(bLow, lastBUnit), lastLoss, typeString)); } } return result; }
/// <summary> /// Determines if all the ranges fall between 1 to port count /// </summary> /// <param name="ranges">Ranges to check</param> /// <param name="device">Device to check on</param> /// <param name="portType">Port type</param> /// <returns>True if valid ranges</returns> public static bool AreRangesWithinPortCount(List<Range> ranges, DeviceWrapper device, PortType portType) { bool result = false; // Default to false in case we can't even find the port relationship class #region Validation if (null == ranges) { throw new ArgumentNullException("ranges"); } if (null == device) { throw new ArgumentNullException("device"); } #endregion ESRI.ArcGIS.Geodatabase.IFeatureClass ftClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; if (null != ftClass) { using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(ftClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName); if (-1 < portIdIdx) { result = true; // Now that we have the ports, assume we're ok until we find a problem ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.SubFields = ConfigUtil.PortIdFieldName; filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}' AND {4} IS NOT NULL", deviceHasPorts.OriginForeignKey, device.Feature.get_Value(ftClass.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.PortTypeFieldName, PortType.Input == portType ? 1 : 2, ConfigUtil.PortIdFieldName); ((ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)filter).PostfixClause = string.Format("ORDER BY {0}", ConfigUtil.PortIdFieldName); ESRI.ArcGIS.Geodatabase.ICursor cursor = portTable.Search(filter, true); releaser.ManageLifetime(cursor); int minPort = int.MinValue; int maxPort = int.MaxValue; ESRI.ArcGIS.Geodatabase.IRow row = cursor.NextRow(); if (null != row) { minPort = (int)row.get_Value(portIdIdx); while (null != row) { maxPort = (int)row.get_Value(portIdIdx); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(row); row = cursor.NextRow(); } } foreach (Range r in ranges) { if (r.High > maxPort || minPort > r.Low) { result = false; break; } } } } } } return result; }
private void createDataFrame(string sMapName) { try { IMxDocument pMxDoc = (IMxDocument)ArcMap.Document; IMap pMap = new MapClass(); pMap.Name = sMapName; //Dictionary<string, string> dctMapLayers = Dictionary <string, string> dctMapLayers = new Dictionary <string, string>(); switch (sMapName.ToUpper()) { case "ECONOMIC DEVELOPMENT": dctMapLayers = SConst.EconDevLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_EconOnLayers); break; case "FIRE": dctMapLayers = SConst.FireLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_FireOnLayers); break; case "PLANNING": dctMapLayers = SConst.PlanningLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PlanOnLayers); break; case "POLICE": dctMapLayers = SConst.PoliceLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PoliceOnLayers); break; case "PUBLIC WORKS": dctMapLayers = SConst.PublicWorksLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PWOnLayers); break; default: return; } //addMapLayers(ref pMap, sMapName); IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(1, 1, 5, 4); // page units pMxDoc.Maps.Add(pMap); IMapFrame pMapFrame = this.MakeMapFrame(pEnv, pMap); pMapFrame.Map.MapUnits = esriUnits.esriFeet; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; pGC.AddElement((IElement)pMapFrame, 0); pMxDoc.CurrentContentsView.Refresh(null); pMxDoc.UpdateContents(); Application.DoEvents(); // activate the frame and zoom to the extent of the UGB for (int i = 0; i < pMxDoc.Maps.Count; i++) { IMap map = pMxDoc.Maps.get_Item(i); if (map.Name == sMapName) { pMxDoc.ActiveView = (IActiveView)map; //Set the query filter. use the arguements passed into the function ESRI.ArcGIS.Geodatabase.IQueryFilter pQueryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); pQueryFilter.WhereClause = "CITY = 'Medford'"; using (CSpatialSubs oSpatialSubs = new CSpatialSubs()) { oSpatialSubs.selectFeatures(pQueryFilter, this.App, (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, "MEDSDE.DBO.Urban_Growth_Boundary"), true); } pMxDoc.FocusMap.ClearSelection(); } } pMxDoc.UpdateContents(); Application.DoEvents(); } catch (Exception ex) { string s = ex.Message; s += ex.InnerException.Message; s += " "; } }
/// <summary> /// Gets a list of all strand numbers from a cable that are connected on the given end /// </summary> /// <param name="cable">Cable to check</param> /// <param name="isFromEnd">True to check from end, False to check to end</param> /// <returns>List of int</returns> private static List <int> GetConnectedStrands(FiberCableWrapper cable, bool isFromEnd) { #region Validation if (null == cable) { throw new ArgumentNullException("cable"); } #endregion List <int> result = new List <int>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = cable.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; string[] deviceClassNames = ConfigUtil.DeviceFeatureClassNames; for (int i = 0; i < deviceClassNames.Length; i++) { string deviceClassName = deviceClassNames[i]; ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = TelecomWorkspaceHelper.Instance().FindFeatureClass(deviceClassName); // ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = GdbUtils.GetFeatureClass(cableFtClass, deviceClassName); if (null != deviceFtClass) { ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; if (null != portTable) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}' AND {4} IS NOT NULL", ConfigUtil.ConnectedCableFieldName, cable.IPID, ConfigUtil.ConnectedEndFieldName, (isFromEnd ? "T" : "F"), ConfigUtil.ConnectedFiberFieldName); ESRI.ArcGIS.Geodatabase.ICursor portCursor = portTable.Search(filter, true); ESRI.ArcGIS.Geodatabase.IRow portRow = portCursor.NextRow(); int fiberIdIdx = portTable.FindField(ConfigUtil.ConnectedFiberFieldName); while (null != portRow) { result.Add((int)portRow.get_Value(fiberIdIdx)); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portRow); portRow = portCursor.NextRow(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portCursor); } } } } } return(result); }
/// <summary> /// Get the existing splice ranges between two cables at an existing closure /// </summary> /// <param name="cableA">One cable</param> /// <param name="cableB">Other cable</param> /// <param name="splice">Splice Closure</param> /// <returns>List of FiberSplice</returns> /// <remarks>Currently only checks A/B as passed, does not check the reverse B/A combination</remarks> public static List <FiberSplice> GetSplicedRanges(FiberCableWrapper cableA, FiberCableWrapper cableB, SpliceClosureWrapper splice) { List <FiberSplice> result = new List <FiberSplice>(); string spliceWhere = string.Format("{0}='{1}' AND {2}='{3}' AND {4}='{5}'", ConfigUtil.ACableIdFieldName, cableA.IPID, ConfigUtil.BCableIdFieldName, cableB.IPID, ConfigUtil.SpliceClosureIpidFieldName, splice.IPID); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = TelecomWorkspaceHelper.Instance().FindTable(ConfigUtil.FiberSpliceTableName); // ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = GdbUtils.GetTable(cableA.Feature.Class, ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = spliceWhere; ((ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)filter).PostfixClause = string.Format("ORDER BY {0}", ConfigUtil.AFiberNumberFieldName); int aUnitIdx = fiberSpliceTable.FindField(ConfigUtil.AFiberNumberFieldName); int bUnitIdx = fiberSpliceTable.FindField(ConfigUtil.BFiberNumberFieldName); int lossIdx = fiberSpliceTable.FindField(ConfigUtil.LossFieldName); int typeIdx = fiberSpliceTable.FindField(ConfigUtil.TypeFieldName); ESRI.ArcGIS.Geodatabase.IField typeField = fiberSpliceTable.Fields.get_Field(typeIdx); ESRI.ArcGIS.Geodatabase.ICodedValueDomain typeDomain = typeField.Domain as ESRI.ArcGIS.Geodatabase.ICodedValueDomain; ESRI.ArcGIS.Geodatabase.ICursor splices = fiberSpliceTable.Search(filter, true); releaser.ManageLifetime(splices); ESRI.ArcGIS.Geodatabase.IRow spliceRow = splices.NextRow(); int lastAUnit = -1; int lastBUnit = -1; double?lastLoss = null; object lastType = Type.Missing; int aLow = -1; int bLow = -1; while (null != spliceRow) { // These are not-null columns int aUnit = (int)spliceRow.get_Value(aUnitIdx); int bUnit = (int)spliceRow.get_Value(bUnitIdx); object lossObj = spliceRow.get_Value(lossIdx); double?loss = null; if (DBNull.Value != lossObj) { loss = (double)lossObj; } object type = spliceRow.get_Value(typeIdx); if (aUnit != (lastAUnit + 1) || bUnit != (lastBUnit + 1) || loss != lastLoss || !type.Equals(lastType)) { if (-1 != lastAUnit) { string typeString = string.Empty; if (null != typeString) { if (null != typeDomain) { typeString = GdbUtils.GetDomainNameForValue(typeDomain, lastType); } else { typeString = lastType.ToString(); // DBNull.Value will return string.Empty } } result.Add(new FiberSplice(new Range(aLow, lastAUnit), new Range(bLow, lastBUnit), lastLoss, typeString)); } aLow = aUnit; bLow = bUnit; } lastAUnit = aUnit; lastBUnit = bUnit; lastLoss = loss; lastType = type; ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(spliceRow); spliceRow = splices.NextRow(); } if (-1 < aLow) { string typeString = string.Empty; if (null != typeString) { if (null != typeDomain) { typeString = GdbUtils.GetDomainNameForValue(typeDomain, lastType); } else { typeString = lastType.ToString(); // DBNull.Value will return string.Empty } } result.Add(new FiberSplice(new Range(aLow, lastAUnit), new Range(bLow, lastBUnit), lastLoss, typeString)); } } return(result); }
/// <summary> /// Determines if all the ranges fall between 1 to port count /// </summary> /// <param name="ranges">Ranges to check</param> /// <param name="device">Device to check on</param> /// <param name="portType">Port type</param> /// <returns>True if valid ranges</returns> public static bool AreRangesWithinPortCount(List <Range> ranges, DeviceWrapper device, PortType portType) { bool result = false; // Default to false in case we can't even find the port relationship class #region Validation if (null == ranges) { throw new ArgumentNullException("ranges"); } if (null == device) { throw new ArgumentNullException("device"); } #endregion ESRI.ArcGIS.Geodatabase.IFeatureClass ftClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass; if (null != ftClass) { using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(ftClass); if (null != deviceHasPorts) { ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName); if (-1 < portIdIdx) { result = true; // Now that we have the ports, assume we're ok until we find a problem ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.SubFields = ConfigUtil.PortIdFieldName; filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}' AND {4} IS NOT NULL", deviceHasPorts.OriginForeignKey, device.Feature.get_Value(ftClass.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.PortTypeFieldName, PortType.Input == portType ? 1 : 2, ConfigUtil.PortIdFieldName); ((ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)filter).PostfixClause = string.Format("ORDER BY {0}", ConfigUtil.PortIdFieldName); ESRI.ArcGIS.Geodatabase.ICursor cursor = portTable.Search(filter, true); releaser.ManageLifetime(cursor); int minPort = int.MinValue; int maxPort = int.MaxValue; ESRI.ArcGIS.Geodatabase.IRow row = cursor.NextRow(); if (null != row) { minPort = (int)row.get_Value(portIdIdx); while (null != row) { maxPort = (int)row.get_Value(portIdIdx); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(row); row = cursor.NextRow(); } } foreach (Range r in ranges) { if (r.High > maxPort || minPort > r.Low) { result = false; break; } } } } } } return(result); }
//The SelectReduction procedure works with the input node schematic node candidate to the //reduction and with the input linkElements list of schematic link elements incident to //this schematic node. It must return True for the output reduce boolean parameter if //the node is reduced, false if the node is kept. When the output ppLink schematic link //is not nothing, it determines the target node that will be used to reconnect the links //incidents to the reduced node. In this sample procedure, the node candidate to the //reduction is analyzed. If records related to this node exist in the plants_equipments table, //the node is kept (output reduce parameter is False); else, it is reduced (output reduce //parameter is True). public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link) { // if associated feature doesn't exist do nothing ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedNode; schemAssociatedNode = node as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature; if (schemAssociatedNode == null) return false; // if dataset is not plants do nothing ESRI.ArcGIS.Geodatabase.IDataset schemElementClass; schemElementClass = (ESRI.ArcGIS.Geodatabase.IDataset)schemAssociatedNode.SchematicElementClass; if (schemElementClass == null) return false; if (schemElementClass.Name.IndexOf("plants") < 0) return false; // get workspace ESRI.ArcGIS.Geodatabase.IFeatureWorkspace plantsWorkspace; plantsWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)schemElementClass.Workspace; // open table plants_equipments ESRI.ArcGIS.Geodatabase.ITable plantsEquipment; plantsEquipment = plantsWorkspace.OpenTable("plants_equipments"); if (plantsEquipment == null) return false; // filter for the selected feature ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation schemAssociation; schemAssociation = schemAssociatedNode as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation; if (schemAssociation == null) return false; ESRI.ArcGIS.Geodatabase.IQueryFilter plantsFilter; plantsFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); plantsFilter.WhereClause = ("PlantID = " + schemAssociation.ObjectID); ESRI.ArcGIS.Geodatabase.ICursor plantsCursor; plantsCursor = plantsEquipment.Search(plantsFilter, true); // if found equipment return false if (plantsCursor != null && plantsCursor.NextRow() != null) return false; return true; // if this far }