/// <summary> /// Delete the ports for a given device /// </summary> /// <param name="device">The device feature</param> /// <returns>True if completed</returns> private bool DeletePorts(ESRI.ArcGIS.Geodatabase.IFeature device, int highInputPort, int highOutputPort, ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog, ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel) { bool isCancelled = false; ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = (ESRI.ArcGIS.esriSystem.IStepProgressor)progressDialog; ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship((ESRI.ArcGIS.Geodatabase.IFeatureClass)device.Class); if (null != deviceHasPorts) { using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ITable portTable = (ESRI.ArcGIS.Geodatabase.ITable)deviceHasPorts.DestinationClass; releaser.ManageLifetime(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}='{5}'", deviceHasPorts.OriginForeignKey, device.get_Value(device.Fields.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.PortIdFieldName, highInputPort, ConfigUtil.PortTypeFieldName, 1); stepProgressor.Message = "Deleting higher input ports..."; int deletedPorts = portTable.RowCount(filter); portTable.DeleteSearchedRows(filter); for (int i = 0; i < deletedPorts; i++) { stepProgressor.Step(); } filter.WhereClause = string.Format("{0}='{1}' AND {2} > {3} AND {4}='{5}'", deviceHasPorts.OriginForeignKey, device.get_Value(device.Fields.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.PortIdFieldName, highOutputPort, ConfigUtil.PortTypeFieldName, 2); stepProgressor.Message = "Deleting higher output ports..."; deletedPorts = portTable.RowCount(filter); portTable.DeleteSearchedRows(filter); for (int i = 0; i < deletedPorts; i++) { stepProgressor.Step(); } } } return(!isCancelled); }
///// <summary> ///// The active view has refreshed. Redraw our results, if we have any ///// </summary> ///// <param name="Display">Display to draw on</param> ///// <param name="phase"></param> //private void _arcMapWrapper_ActiveViewAfterDraw(ESRI.ArcGIS.Display.IDisplay Display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase) //{ // if (phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection) // { // // Draw after the selection // if (null != _currentResults) // { // ESRI.ArcGIS.Display.ILineSymbol lineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbol(); // ESRI.ArcGIS.Display.IRgbColor color = new ESRI.ArcGIS.Display.RgbColorClass(); // color.Red = 255; // color.Green = 0; // color.Blue = 0; // lineSymbol.Color = color; // lineSymbol.Width = 4; // ESRI.ArcGIS.Display.ISimpleMarkerSymbol markerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass(); // markerSymbol.Color = color; // markerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle; // markerSymbol.Size = 6; // for (int i = 0; i < _currentResults.Count; i++) // { // ESRI.ArcGIS.Geometry.IGeometry geometry = _currentResults[i]; // if (geometry is ESRI.ArcGIS.Geometry.IPolyline) // { // Display.SetSymbol((ESRI.ArcGIS.Display.ISymbol)lineSymbol); // Display.DrawPolyline((ESRI.ArcGIS.Geometry.IPolyline)geometry); // } // else if (geometry is ESRI.ArcGIS.Geometry.IPoint) // { // Display.SetSymbol((ESRI.ArcGIS.Display.ISymbol)markerSymbol); // Display.DrawPoint((ESRI.ArcGIS.Geometry.IPoint)geometry); // } // } // } // } //} private List <ESRI.ArcGIS.Geodatabase.IRow> TracePath(ESRI.ArcGIS.Geodatabase.IFeature cableFeature, int fiberNumber, bool isStartingAtFromEnd) { List <ESRI.ArcGIS.Geodatabase.IRow> result = new List <ESRI.ArcGIS.Geodatabase.IRow>(); string ipid = cableFeature.get_Value(cableFeature.Fields.FindField(ConfigUtil.IpidFieldName)).ToString(); ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = (ESRI.ArcGIS.Geodatabase.IFeatureClass)cableFeature.Class; ESRI.ArcGIS.Geodatabase.IFeatureClass spliceFtClass = _wkspHelper.FindFeatureClass(ConfigUtil.SpliceClosureFtClassName); ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = _wkspHelper.FindTable(ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IFields spliceFields = fiberSpliceTable.Fields; string fiberClassName = ConfigUtil.FiberTableName; ESRI.ArcGIS.Geodatabase.IRelationshipClass fiberRelationship = GdbUtils.GetRelationshipClass(cableFtClass, ConfigUtil.FiberCableToFiberRelClassName); if (null != fiberRelationship && null != fiberRelationship.DestinationClass) { fiberClassName = GdbUtils.ParseTableName(fiberRelationship.DestinationClass as ESRI.ArcGIS.Geodatabase.IDataset); } ESRI.ArcGIS.Geodatabase.ITable fiberTable = _wkspHelper.FindTable(fiberClassName); _aCableIdx = spliceFields.FindField(ConfigUtil.ACableIdFieldName); _bCableIdx = spliceFields.FindField(ConfigUtil.BCableIdFieldName); _aFiberNumIdx = spliceFields.FindField(ConfigUtil.AFiberNumberFieldName); _bFiberNumIdx = spliceFields.FindField(ConfigUtil.BFiberNumberFieldName); _isAFromIdx = spliceFields.FindField(ConfigUtil.IsAFromEndFieldName); _isBFromIdx = spliceFields.FindField(ConfigUtil.IsBFromEndFieldName); _spliceClosureIpidIdx = spliceFields.FindField(ConfigUtil.SpliceClosureIpidFieldName); ESRI.ArcGIS.Geodatabase.IQueryFilter spliceFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); spliceFilter.WhereClause = string.Format("({0}='{1}' AND {2}={3})" + " OR ({4}='{1}' AND {5}={3})", ConfigUtil.ACableIdFieldName, ipid, ConfigUtil.AFiberNumberFieldName, fiberNumber, ConfigUtil.BCableIdFieldName, ConfigUtil.BFiberNumberFieldName); int connections = fiberSpliceTable.RowCount(spliceFilter); if (2 < connections) { // TODO: warning? System.Windows.Forms.MessageBox.Show("Less than 2 connections were detected: " + fiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } string spliceClosureIpid = string.Empty; string nextCableId = string.Empty; int nextFiberNumber = -1; bool isNextFromEnd = false; // {{0}} causes the string.format to string cableWhereFormat = string.Format("{0}='{{0}}'", ConfigUtil.IpidFieldName); string spliceWhereFormat = string.Format("{0}='{{0}}'", ConfigUtil.IpidFieldName); string fiberWhereFormat = string.Format("{0}='{{0}}' AND {1}={{1}}", fiberRelationship.OriginForeignKey, ConfigUtil.Fiber_NumberFieldName); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); // Ripple down the start cable's to end ESRI.ArcGIS.Geodatabase.IRow spliceRow = GetNextSplice(fiberSpliceTable, ipid, fiberNumber, isStartingAtFromEnd, out nextCableId, out nextFiberNumber, out spliceClosureIpid, out isNextFromEnd); while (null != spliceRow) { ESRI.ArcGIS.Geodatabase.IFeature spliceClosure = null; if (spliceClosureIpid.Equals("")) { System.Windows.Forms.MessageBox.Show("Found Splice with no SpliceClosure (ID/#) " + nextCableId + "/" + nextFiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } else { filter.WhereClause = string.Format(spliceWhereFormat, spliceClosureIpid); ESRI.ArcGIS.Geodatabase.IFeatureCursor spliceCursor = spliceFtClass.Search(filter, false); releaser.ManageLifetime(spliceCursor); spliceClosure = spliceCursor.NextFeature(); if (spliceClosure == null) { System.Windows.Forms.MessageBox.Show("Invalid SpliceClosure referenced: (IPID)" + spliceClosureIpid, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } } filter.WhereClause = string.Format(cableWhereFormat, nextCableId); ESRI.ArcGIS.Geodatabase.IFeatureCursor cableCursor = cableFtClass.Search(filter, false); releaser.ManageLifetime(cableCursor); ESRI.ArcGIS.Geodatabase.IFeature cable = cableCursor.NextFeature(); if (cable == null) { System.Windows.Forms.MessageBox.Show("Invalid cable ID referenced: (ID)" + nextCableId, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } filter.WhereClause = string.Format(fiberWhereFormat, nextCableId, nextFiberNumber); ESRI.ArcGIS.Geodatabase.ICursor fiberCursor = fiberTable.Search(filter, false); releaser.ManageLifetime(fiberCursor); ESRI.ArcGIS.Geodatabase.IRow fiber = fiberCursor.NextRow(); if (fiber == null) { System.Windows.Forms.MessageBox.Show("Invalid Fiber Cable or # referenced: (ID/#) " + nextCableId + "/" + nextFiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } if (isStartingAtFromEnd) { if (spliceRow != null) { result.Add(spliceRow); } if (spliceClosure != null) { result.Add(spliceClosure); } if (fiber != null) { result.Add(fiber); } if (cable != null) { result.Add(cable); } } else { if (spliceClosure != null) { result.Add(spliceClosure); } if (spliceRow != null) { result.Add(spliceRow); } if (cable != null) { result.Add(cable); } if (fiber != null) { result.Add(fiber); } } spliceRow = GetNextSplice(fiberSpliceTable, nextCableId, nextFiberNumber, !isNextFromEnd, out nextCableId, out nextFiberNumber, out spliceClosureIpid, out isNextFromEnd); } // See if there is a port for this one ESRI.ArcGIS.Geodatabase.IRow portRow = null; ESRI.ArcGIS.Geodatabase.IFeature deviceFt = null; if (GetConnectedPort(cableFtClass, nextCableId, nextFiberNumber, isNextFromEnd, out portRow, out deviceFt)) { if (isStartingAtFromEnd) { result.Add(portRow); result.Add(deviceFt); } else { result.Add(deviceFt); result.Add(portRow); } } return(result); } }