/// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes all splices for a cable to any other at any splice closure
        /// </summary>
        /// <param name="cable">Cable</param>
        /// <param name="isExistingOperation">Are we already in an edit operation?</param>
        /// <returns>Success</returns>
        public bool BreakAllSplices(FiberCableWrapper cable, bool isExistingOperation)
        {
            bool success         = false;
            bool isOperationOpen = false;

            #region Validation
            if (null == cable)
            {
                throw new ArgumentNullException("cable");
            }

            if (ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing == _editor.EditState)
            {
                throw new InvalidOperationException("You must be editing to perform this operation");
            }
            #endregion

            if (!isExistingOperation)
            {
                _editor.StartOperation();
                isOperationOpen = true;
            }

            try
            {
                ESRI.ArcGIS.Geodatabase.ITable spliceTable = _wkspHelper.FindTable(ConfigUtil.FiberSpliceTableName);
//                ESRI.ArcGIS.Geodatabase.ITable spliceTable = GdbUtils.GetTable(cable.Feature.Class, ConfigUtil.FiberSpliceTableName);
                ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();

                // A and B is arbitrary, so we check the given combinations going both ways. The structure is:
                // Where either the A or B cableID is our cable ID
                filter.WhereClause = string.Format("{0}='{1}' OR {2}='{1}'",
                                                   ConfigUtil.ACableIdFieldName,
                                                   cable.IPID,
                                                   ConfigUtil.BCableIdFieldName);

                spliceTable.DeleteSearchedRows(filter);
                ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(filter);

                if (isOperationOpen)
                {
                    _editor.StopOperation("Break Splices");
                    isOperationOpen = false;
                }

                success = true;
            }
            catch
            {
                if (isOperationOpen)
                {
                    _editor.AbortOperation();
                }

                success = false;
            }

            return(success);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes given splices from one cable to the other, at a given splice closure
        /// </summary>
        /// <param name="cableA">Cable A</param>
        /// <param name="cableB">Cable B</param>
        /// <param name="splice">Splice Closure</param>
        /// <param name="strands">Strands to remove</param>
        /// <param name="isExistingOperation">Flag to control whether we need to wrap this in an edit operation</param>
        /// <returns>Success</returns>
        public bool BreakSplices(FiberCableWrapper cableA, SpliceableCableWrapper cableB, SpliceClosureWrapper splice, Dictionary <int, FiberSplice> strands, bool isExistingOperation)
        {
            bool success         = false;
            bool isOperationOpen = false;

            #region Validation
            if (null == cableA)
            {
                throw new ArgumentNullException("cableA");
            }

            if (null == cableB)
            {
                throw new ArgumentNullException("cableB");
            }

            if (null == splice)
            {
                throw new ArgumentNullException("splice");
            }

            if (ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing == _editor.EditState)
            {
                throw new InvalidOperationException("You must be editing to perform this operation");
            }
            #endregion

            if (!isExistingOperation)
            {
                _editor.StartOperation();
                isOperationOpen = true;
            }

            try
            {
                ESRI.ArcGIS.Geodatabase.ITable spliceTable = _wkspHelper.FindTable(ConfigUtil.FiberSpliceTableName);
//                ESRI.ArcGIS.Geodatabase.ITable spliceTable = GdbUtils.GetTable(splice.Feature.Class, ConfigUtil.FiberSpliceTableName);

                using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser())
                {
                    ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                    releaser.ManageLifetime(filter);

                    // A and B is arbitrary, so we check the given combinations going both ways. The structure is:
                    // Where the splice closure IPID is ours and
                    // ((the A Cable/Fiber matches our A cable and B Cable/Fiber matches our B)
                    //  OR (the A Cable/Fiber matches our B cable and B Cable/Fiber matches our A))
                    string format = "{0}='{1}' AND (({2}='{3}' AND {4}={5} AND {6}='{7}' AND {8}={9})" +
                                    " OR ({2}='{7}' AND {4}={9} AND {6}='{3}' AND {8}={5}))";

                    foreach (KeyValuePair <int, FiberSplice> pair in strands)
                    {
                        filter.WhereClause = string.Format(format,
                                                           ConfigUtil.SpliceClosureIpidFieldName,
                                                           splice.IPID,
                                                           ConfigUtil.ACableIdFieldName,
                                                           cableA.IPID,
                                                           ConfigUtil.AFiberNumberFieldName,
                                                           pair.Key,
                                                           ConfigUtil.BCableIdFieldName,
                                                           cableB.IPID,
                                                           ConfigUtil.BFiberNumberFieldName,
                                                           pair.Value.BRange.Low);

                        spliceTable.DeleteSearchedRows(filter);
                    }

                    if (isOperationOpen)
                    {
                        _editor.StopOperation("Break Splices");
                        isOperationOpen = false;
                    }

                    success = true;
                }
            }
            catch
            {
                if (isOperationOpen)
                {
                    _editor.AbortOperation();
                }

                success = false;
            }

            return(success);
        }