public void SelectTracedDevices() { // ----------------------------------------------- // Following section of code causes cable, splice // and device features to be selected on the map // using the IFeatureSelection & ISelectionSet // interfaces // ----------------------------------------------- // Remove any previous trace results. _hookHelper.FocusMap.ClearSelection(); Dictionary <string, List <int> > deviceOidLists = new Dictionary <string, List <int> >(); // First get set of OIDs that were traced. foreach (IRow traceItem in this._traceResults) { ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset; string className = GdbUtils.ParseTableName(dataset); if (ConfigUtil.IsDeviceClassName(className)) { List <int> deviceOids = null; if (deviceOidLists.ContainsKey(className)) { deviceOids = deviceOidLists[className]; } else { deviceOids = new List <int>(); deviceOidLists[className] = deviceOids; } deviceOids.Add(traceItem.OID); } } // Do the actual selections foreach (KeyValuePair <string, List <int> > deviceOidPair in deviceOidLists) { ESRI.ArcGIS.Carto.IFeatureSelection deviceFtSelection = _hookHelper.FindFeatureLayer(deviceOidPair.Key) as ESRI.ArcGIS.Carto.IFeatureSelection; if (null != deviceFtSelection) { ESRI.ArcGIS.Geodatabase.ISelectionSet deviceSelectionSet = deviceFtSelection.SelectionSet; List <int> deviceOidList = deviceOidPair.Value; if (null != deviceSelectionSet && 0 < deviceOidList.Count) { int[] oidList = deviceOidList.ToArray(); deviceSelectionSet.AddList(deviceOidList.Count, ref oidList[0]); } } else { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", deviceOidPair.Key + " not found.", "Layer removed from TOC?"); } } }
public void SelectTracedSpliceClosures() { // ----------------------------------------------- // Following section of code causes cable, splice // and device features to be selected on the map // using the IFeatureSelection & ISelectionSet // interfaces // ----------------------------------------------- List <int> spliceOidList = new List <int>(); // First get set of OIDs that were traced. foreach (IRow traceItem in this._traceResults) { ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset; string className = GdbUtils.ParseTableName(dataset); if (0 == string.Compare(className, ConfigUtil.SpliceClosureFtClassName, true)) { if (traceItem.HasOID) { spliceOidList.Add(traceItem.OID); } } } // Do the actual selection ESRI.ArcGIS.Carto.IFeatureSelection scFtSelection = _hookHelper.FindFeatureLayer(ConfigUtil.SpliceClosureFtClassName) as ESRI.ArcGIS.Carto.IFeatureSelection; if (scFtSelection == null) { // No selection to be made as layer not in TOC _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", ConfigUtil.SpliceClosureFtClassName + " not found.", "Layer removed from TOC?"); } else { ESRI.ArcGIS.Geodatabase.ISelectionSet scSelectionSet = scFtSelection.SelectionSet; if (null != scSelectionSet && 0 < spliceOidList.Count) { int[] oidList = spliceOidList.ToArray(); scSelectionSet.AddList(spliceOidList.Count, ref oidList[0]); } } }