示例#1
0
        private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            //在地块图层获得关系类
            IFeatureClass          pFeatClass             = pParcelFeatLayer.FeatureClass;
            IObjectClass           pObjectClass           = pFeatClass as IObjectClass;
            IEnumRelationshipClass pEnumRelationshipClass = pObjectClass.get_RelationshipClasses(esriRelRole.esriRelRoleOrigin);

            pEnumRelationshipClass.Reset();
            IRelationshipClass pRelationshipClass = pEnumRelationshipClass.Next();
            IRow         pOwnerRow;
            IFeature     pParcelFeature;
            AxMapControl axMap = pMainFrm.getMapControl();

            for (int i = 0; i <= pFeatArray.Count - 1; i++)
            {
                pParcelFeature = pFeatArray.get_Element(i) as IFeature;
                ISet pRelatedSet = pRelationshipClass.GetObjectsRelatedToObject(pParcelFeature);
                pRelatedSet.Reset();
                pOwnerRow = pRelatedSet.Next() as IRow;

                if (pOwnerRow != null)
                {
                    if (pOwnerRow.get_Value(pOwnerRow.Fields.FindField("TMK")).ToString() == e.Item.Text)
                    {
                        Utility.FlashFeature(pParcelFeature, axMap.ActiveView.FocusMap);
                        break;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 获取与标注对应的关联设备
        /// </summary>
        /// <param name="pAnnoFeature"></param>
        /// <returns></returns>
        public static IFeature GetLinkedFeature(IAnnotationFeature2 pAnnoFeature)
        {
            // 方法一
            IFeature               pFeature      = (IFeature)pAnnoFeature;
            IFeatureClass          pfClass       = (IFeatureClass)pFeature.Class;
            IEnumRelationshipClass pEnumRelation =
                pfClass.get_RelationshipClasses(esriRelRole.esriRelRoleAny);
            IRelationshipClass pRelationship = pEnumRelation.Next();

            if (pRelationship == null)
            {
                return(null);
            }

            ISet pSet = pRelationship.GetObjectsRelatedToObject(pFeature);

            if (pSet == null)
            {
                return(null);
            }

            object o = pSet.Next();

            if (o == null || !(o is IFeature))
            {
                return(null);
            }

            pFeature = (IFeature)o;
            return(pFeature);

            // 方法二

            /*
             * IFeature pFeature = (IFeature)pAnnoFeature;
             * IFeatureClass pfClass = (IFeatureClass)pFeature.Class;
             * IEnumRelationshipClass enumRelCls =
             *          pfClass.get_RelationshipClasses(esriRelRole.esriRelRoleAny);
             * IRelationshipClass pRelationship = enumRelCls.Next();
             * if (pRelationship == null)
             *  return null;
             *
             * // 注记的FeatureClass
             * IFeatureClass pDestionClass = (IFeatureClass)pRelationship.OriginClass;
             * if (pDestionClass == null)
             *  return null;
             *
             * string foreignKey = pRelationship.DestinationPrimaryKey;
             * if (string.IsNullOrEmpty(foreignKey))
             *  return null;
             *
             * pFeature = pDestionClass.GetFeature(pAnnoFeature.LinkedFeatureID);
             * return pFeature;
             */
        }
示例#3
0
 /// <summary>
 /// This function use the "OpenRelationshipClass" function to open a relationship class in the passed in workspace. Then the relationship class uses the
 /// "GetObjectsRelated" to return an ISet of the objects that are related to the specified input object.
 /// </summary>
 /// <param name="relatedTable">the relateionship table</param>
 /// <param name="obj">the object to find relationships for</param>
 /// <param name="fws">the feature workspace to work in</param>
 /// <returns>ISet of all relationships for passed in object</returns>
 public static ISet PerformRelatedObjectQuery(string relatedTable, IObject obj, IFeatureWorkspace fws)
 {
     try
     {
         IRelationshipClass pRelClass = fws.OpenRelationshipClass(relatedTable);
         return(pRelClass.GetObjectsRelatedToObject(obj));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#4
0
        /// <summary>
        /// 获取与要素设置的releationshipclss对应的标注要素

        /// </summary>
        /// <param name="pFeature">地图要素</param>
        /// <returns>标注要素</returns>
        public static IAnnotationFeature2 GetLinkedFeature(IFeature pFeature)
        {
            // 方法一
            IFeatureClass          pfClass       = (IFeatureClass)pFeature.Class;
            IEnumRelationshipClass pEnumRelation =
                pfClass.get_RelationshipClasses(esriRelRole.esriRelRoleAny);
            IRelationshipClass pRelationship = pEnumRelation.Next();

            if (pRelationship == null)
            {
                return(null);
            }

            ISet pSet = pRelationship.GetObjectsRelatedToObject(pFeature);

            if (pSet == null)
            {
                return(null);
            }

            object o = pSet.Next();

            if (o == null || !(o is IAnnotationFeature2))
            {
                return(null);
            }

            IAnnotationFeature2 pAnnoFeature = (IAnnotationFeature2)o;

            return(pAnnoFeature);

            /*
             * 方法二
             *
             * // 注记的FeatureClass
             * IFeatureClass pDestionClass = (IFeatureClass)pRelationship.DestinationClass;
             * if (pDestionClass == null)
             *  return null;
             *
             * string foreignKey = pRelationship.OriginForeignKey;
             * if (string.IsNullOrEmpty(foreignKey))
             *  return null;
             *
             * string where = foreignKey + "='" + pFeature.OID + "'";
             * IAnnotationFeature2 pAnnoFeature =
             *  (IAnnotationFeature2)GeometryHelper.SearchFeature(pDestionClass, where);
             *
             * return pAnnoFeature;
             */
        }
示例#5
0
 private void method_1(IEnumRelationshipClass ienumRelationshipClass_0, IObject iobject_0, TreeNode treeNode_0,
                       bool bool_3)
 {
     ienumRelationshipClass_0.Reset();
     for (IRelationshipClass class2 = ienumRelationshipClass_0.Next();
          class2 != null;
          class2 = ienumRelationshipClass_0.Next())
     {
         try
         {
             IObjectClass destinationClass;
             if (bool_3)
             {
                 destinationClass = class2.DestinationClass;
             }
             else
             {
                 destinationClass = class2.OriginClass;
             }
             TreeNode node = new TreeNode(destinationClass.AliasName)
             {
                 Tag = destinationClass
             };
             ISet objectsRelatedToObject = class2.GetObjectsRelatedToObject(iobject_0);
             objectsRelatedToObject.Reset();
             for (IRowBuffer buffer = objectsRelatedToObject.Next() as IRowBuffer;
                  buffer != null;
                  buffer = objectsRelatedToObject.Next() as IRowBuffer)
             {
                 TreeNode node2 = new TreeNode(buffer.get_Value(0).ToString())
                 {
                     Tag = buffer
                 };
                 node.Nodes.Add(node2);
             }
             if (node.Nodes.Count > 0)
             {
                 treeNode_0.Nodes.Add(node);
             }
         }
         catch (Exception exception)
         {
             exception.ToString();
         }
     }
 }
示例#6
0
        //上朔追踪列出所有地块
        private void UpstreamCreateOwnerList(IFeatureLayer pParcelFeatLayer, IArray pFeatArray)
        {
            listView1.Columns.Clear();
            listView1.Items.Clear();
            listView1.Columns.Add("物主", 50, HorizontalAlignment.Left);
            listView1.Columns.Add("地址", 50, HorizontalAlignment.Center);
            listView1.Columns.Add("街道", 50, HorizontalAlignment.Center);
            listView1.Columns.Add("城市", 50, HorizontalAlignment.Center);
            listView1.Columns.Add("邮编", 50, HorizontalAlignment.Center);

             
            //在地块图层获得关系类
            IFeatureClass          pFeatClass             = pParcelFeatLayer.FeatureClass;
            IObjectClass           pObjectClass           = pFeatClass as IObjectClass;
            IEnumRelationshipClass pEnumRelationshipClass = pObjectClass.get_RelationshipClasses(esriRelRole.esriRelRoleOrigin);

            pEnumRelationshipClass.Reset();
            IRelationshipClass pRelationshipClass = pEnumRelationshipClass.Next();
            IRow pOwnerRow;

            for (int i = 0; i <= pFeatArray.Count - 1; i++)
            {
                IFeature pParcelFeature = pFeatArray.get_Element(i) as IFeature;
                ISet     pRelatedSet    = pRelationshipClass.GetObjectsRelatedToObject(pParcelFeature);
                pRelatedSet.Reset();
                pOwnerRow = pRelatedSet.Next() as IRow;

                if (pOwnerRow != null)
                {
                    ListViewItem item = new ListViewItem();

                    item.SubItems.Clear();
                    item.SubItems[0].Text = pOwnerRow.get_Value(pOwnerRow.Fields.FindField("TMK")).ToString();

                    item.SubItems.Add(pOwnerRow.get_Value(pOwnerRow.Fields.FindField("ADDR")).ToString());

                    item.SubItems.Add(pOwnerRow.get_Value(pOwnerRow.Fields.FindField("STREET")).ToString());

                    item.SubItems.Add(pOwnerRow.get_Value(pOwnerRow.Fields.FindField("CITY")).ToString());

                    item.SubItems.Add(pOwnerRow.get_Value(pOwnerRow.Fields.FindField("ZIP")).ToString());

                    listView1.Items.Add(item);
                }
            }
        }
示例#7
0
        /// <summary>
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="objectClass"></param>
        /// <param name="relClasses"></param>
        /// <param name="parentCursor"></param>
        private void ExportRelatedObjects(XmlWriter writer, ObjectClass objectClass, IEnumRelationshipClass relClasses,
            ICursor parentCursor)
        {
            IRelationshipClass class2 = relClasses.Next();
            IDataset originClass = null;
            while (class2 != null)
            {
                originClass = (IDataset) class2.OriginClass;
                if (originClass.Name == objectClass.name)
                    break;

                originClass = (IDataset) class2.DestinationClass;
                if (originClass.Name == objectClass.name)
                    break;

                class2 = relClasses.Next();
            }

            if (class2 == null)
                return;

            IDisplayTable displayTableFromDatasetName = GetDisplayTableFromDatasetName(originClass.Name);
            StartExportObjectClass(writer, objectClass, displayTableFromDatasetName);
            for (IRow row = parentCursor.NextRow(); row != null; row = parentCursor.NextRow())
            {
                ISet objectsRelatedToObject = class2.GetObjectsRelatedToObject(row as IObject);
                for (var row2 = objectsRelatedToObject.Next() as IRow;
                    row2 != null;
                    row2 = objectsRelatedToObject.Next() as IRow)
                {
                    ExportRow(writer, objectClass, displayTableFromDatasetName, row2);
                }
            }

            EndExportObjectClass(writer);
        }
        void OnChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            // Don't do anything if the extension is disabled
            if (IsExtensionEnabled != true)
            {
                return;
            }

            // Bail if this is not a valid NCGMP workspace
            if (m_DatabaseIsValid == false)
            {
                return;
            }

            #region "Groundwork"
            // Grab the FeatureClass name from the Row's Table (as an IDataset).
            IRow     theRow    = obj;
            ITable   theTable  = theRow.Table;
            IDataset theDS     = (IDataset)theTable;
            string   TableName = theDS.Name;

            // Parse the table name in order to strip out unneccessary bits of SDE tables
            ISQLSyntax nameParser = (ISQLSyntax)theDS.Workspace;
            string     parsedDbName, parsedOwnerName, parsedTableName;
            nameParser.ParseTableName(TableName, out parsedDbName, out parsedOwnerName, out parsedTableName);
            #endregion

            #region "Calculate SymbolRotation"
            if (m_DatabaseUsesRepresentation == true)
            {
                if (parsedTableName == "OrientationPoints")
                {
                    // Get the Azimuth from the feature - this is ugly -- why is this m_identifier a double?
                    int Azimuth = (int)Math.Round((double)theRow.get_Value(theTable.FindField("Azimuth")), 0);
                    // Calculate the stupid form of rotation...
                    int Rotation = CalculateSymbolRotation(Azimuth);
                    // Set the SymbolRotation Field
                    theRow.set_Value(theTable.FindField("SymbolRotation"), double.Parse(Rotation.ToString()));
                }
            }
            #endregion

            // Debugging flag to turn off repositioning of related data when stations are edited:
            bool adjustLocations = false;

            if (adjustLocations == true)
            {
                #region "Adjust Samples/OrientationPoints to Match Stations"
                if (parsedTableName == "Stations")
                {
                    // Cast the obj as a Feature in order to access Geometry information
                    IFeature  theStation  = (IFeature)obj;
                    IGeometry stationGeom = theStation.ShapeCopy;

                    // Find related Samples
                    IRelationshipClass          stationSampleLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationSampleLink");
                    ESRI.ArcGIS.esriSystem.ISet relatedSamples    = stationSampleLink.GetObjectsRelatedToObject(obj);

                    // Loop through the related Samples and set their Geometry to that of the Station
                    relatedSamples.Reset();
                    IFeature aSample = (IFeature)relatedSamples.Next();
                    while (aSample != null)
                    {
                        aSample.Shape = stationGeom;
                        aSample.Store();
                        aSample = (IFeature)relatedSamples.Next();
                    }

                    // Find related OrientationPoints
                    IRelationshipClass          stationStructureLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationOrientationPointsLink");
                    ESRI.ArcGIS.esriSystem.ISet relatedStructures    = stationStructureLink.GetObjectsRelatedToObject(obj);

                    // Loop through the related OrientationPoints and set their Geometry to that of the Station
                    relatedStructures.Reset();
                    IFeature aStructure = (IFeature)relatedStructures.Next();
                    while (aStructure != null)
                    {
                        aStructure.Shape = stationGeom;
                        aStructure.Store();
                        aStructure = (IFeature)relatedStructures.Next();
                    }
                }
                #endregion
            }
        }
示例#9
0
        private bool RemoveFiberCableConfigDomains(IWorkspace wksp)
        {
            bool result = true;

            if (wksp == null || ((wksp as IWorkspaceDomains3) == null))
            {
                return(false);
            }

            try
            {
                // get Handles to everything we need first or bail.
                IFeatureClass cableFc = FindFeatureClass(ConfigUtil.FiberCableFtClassName);
                if (cableFc == null)
                {
                    return(false);
                }
                ISubtypes subs = cableFc as ISubtypes;
                if (subs == null)
                {
                    return(false);
                }
                IClassSchemaEdit4 schEdit = cableFc as IClassSchemaEdit4;
                if (schEdit == null)
                {
                    return(false);
                }

                // ----------------------------------------------------
                // First we have to unassign the domains from the FC fields
                // ----------------------------------------------------
                schEdit.AlterDomain(ConfigUtil.NumberOfFibersFieldName, null);
                schEdit.AlterDomain(ConfigUtil.NumberOfBuffersFieldName, null);
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Unassigned FiberCable domains", "NumberOfFibers + NumberOfBuffers");

                // ----------------------------------------------------
                // Also have to remove domain from the subtypes (arghh)
                // 1 & 2 are overhead and underground.
                // ----------------------------------------------------
                IEnumSubtype types = subs.Subtypes;
                subs.set_Domain(1, ConfigUtil.NumberOfFibersFieldName, null);
                subs.set_Domain(2, ConfigUtil.NumberOfFibersFieldName, null);
                subs.set_Domain(1, ConfigUtil.NumberOfBuffersFieldName, null);
                subs.set_Domain(2, ConfigUtil.NumberOfBuffersFieldName, null);
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Removed FiberCable subtype domains", "NumberOfFibers + NumberOfBuffers");

                // ----------------------------------------------------
                // Now we can remove the domains
                // ----------------------------------------------------
                IWorkspaceDomains3 wkspDomains = wksp as IWorkspaceDomains3;
                if (wkspDomains.get_CanDeleteDomain("NumberOfFibers") &&
                    wkspDomains.get_CanDeleteDomain("NumberOfBuffers"))
                {
                    wkspDomains.DeleteDomain("NumberOfFibers");
                    wkspDomains.DeleteDomain("NumberOfBuffers");
                    MessageBox.Show("Domains successfully deleted");
                    _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Domains successfully deleted", "NumberOfFibers + NumberOfBuffers");
                }
                else
                {
                    MessageBox.Show("Upgrade failed. \nCould not get exclusive access to this database. \nPLEASE RESTORE FROM YOUR BACKUP");
                    _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Cannot delete domains.", "Non-Exclusive access?");
                    return(false);
                }

                // ----------------------------------------------------
                // Recalculate the fields based on the count of actual
                // related objects found. We'll use this code later
                // for integrity checking.
                // ----------------------------------------------------
                IRelationshipClass bufferRelationship = GdbUtils.GetRelationshipClass(cableFc, ConfigUtil.FiberCableToBufferRelClassName);
                IRelationshipClass strandRelationship = GdbUtils.GetRelationshipClass(cableFc, ConfigUtil.FiberCableToFiberRelClassName);
                IFeature           ft;
                int bufferIdx = cableFc.Fields.FindField(ConfigUtil.NumberOfBuffersFieldName);
                int strandIdx = cableFc.Fields.FindField(ConfigUtil.NumberOfFibersFieldName);
                if (bufferIdx == -1 || strandIdx == -1)
                {
                    _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Cannot find buffer or strand fields.",
                                           ConfigUtil.NumberOfBuffersFieldName + " " + ConfigUtil.NumberOfFibersFieldName);
                    MessageBox.Show("Upgrade failed. \nCould not find appropriate fields based on current config settings. \nPLEASE RESTORE FROM YOUR BACKUP.");
                    return(false);
                }
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Recalculating buffer and strand counts...");
                // Start edit session do the updates....
                ArcMap.Editor.StartEditing(wksp);
                IFeatureCursor cables = cableFc.Update(null, false);
                int            count  = cableFc.FeatureCount(null);

                //ProgressBar
                ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();

                ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();

                // Set the properties of the Step Progressor
                ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = progressDialogFactory.Create(trackCancel, ArcMap.Application.hWnd);
                stepProgressor.MinRange  = 1;
                stepProgressor.MaxRange  = count;
                stepProgressor.StepValue = 1;
                stepProgressor.Message   = "Updating cable config for " + count + " cables";

                // Create the ProgressDialog. This automatically displays the dialog
                ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                // Set the properties of the ProgressDialog
                progressDialog.CancelEnabled = false;
                progressDialog.Description   = "";
                progressDialog.Title         = "Workspace Upgrade";
                progressDialog.Animation     = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe;
                progressDialog.ShowDialog();

                int i = 1;
                while ((ft = cables.NextFeature()) != null)
                {
                    progressDialog.Description = string.Format("Updating cable {0} of {1}", i, count);
                    stepProgressor.Step();

                    ISet buffers = bufferRelationship.GetObjectsRelatedToObject(ft);
                    ft.set_Value(bufferIdx, buffers.Count);
                    ISet strands = strandRelationship.GetObjectsRelatedToObject(ft);
                    ft.set_Value(strandIdx, strands.Count);
                    ft.Store();
                    i++;
                }
                progressDialog.HideDialog();
                ArcMap.Editor.StopEditing(true);
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Upgrade Completed Successfully.");
                MessageBox.Show("Upgrade Completed Successfully.");
            }
            catch (Exception e)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "RemoveFiberCableConfigDomains", e.Message);
                result = false;
            }
            return(result);
        }
示例#10
0
        private void populate(IFeature src, IFeature dest, IRelationshipClass rc, string[] fnames)
        {
            // the rc is 1-1
            ISet st = rc.GetObjectsRelatedToObject(src);
            if(st.Count!=1)
            {
                Logger.Write("Join not found for "+((IDataset)rc).Name);
                return;
            }
            IRow row = (IRow)st.Next();

            // extract the fields
            for(int i=0;i<fnames.Length;i++)
            {
                int index = dest.Fields.FindField(fnames[i]);
                int index2 = row.Fields.FindField(fnames[i]);
                if(index > -1 && index2 > -1)
                {
                    dest.set_Value(index,row.get_Value(index2));
                }
            }
        }
        protected override void OnClick()
        {
            try
            {
                if (_wkspHelper.CurrentWorkspace == null)
                {
                    MessageBox.Show("You must select and open a telecom workspace before running this tool");
                    return;
                }

                DialogResult res = MessageBox.Show(null, "This test may run for a considerable time (15+ minutes) and may make modifications to the database to resolve issues. \n\nConsider taking a backup before doing this. \n\nDo you wish to proceed?", "DB Integrity Check", MessageBoxButtons.OKCancel);
                if (res != DialogResult.OK)
                {
                    return;
                }

                IFeatureClass cableFc = _wkspHelper.FindFeatureClass(ConfigUtil.FiberCableFtClassName);
                if (cableFc == null)
                {
                    return;
                }

                IFeatureWorkspace fworkspace = _wkspHelper.CurrentWorkspace;
                if (fworkspace == null)
                {
                    return;
                }

                // --------------------------------------------
                // Check the integrity of the cable feature class
                // --------------------------------------------
                IRelationshipClass fiberCableToFiberRc  = fworkspace.OpenRelationshipClass(ConfigUtil.FiberCableToFiberRelClassName);
                IRelationshipClass fiberCableToBufferRc = fworkspace.OpenRelationshipClass(ConfigUtil.FiberCableToBufferRelClassName);
                IFeature           feature;
                bool            badCable           = false;
                bool            badBuffers         = false;
                bool            badFibers          = false;
                bool            conversionRequired = false;
                IWorkspaceEdit2 edit        = fworkspace as IWorkspaceEdit2;
                ITransactions   transaction = edit as ITransactions;

                edit.StartEditing(true);
                edit.StartEditOperation();

                IQueryFilter qf = new QueryFilter();
                qf.AddField(ConfigUtil.NumberOfBuffersFieldName);
                qf.AddField(ConfigUtil.NumberOfFibersFieldName);
                qf.AddField(ConfigUtil.IpidFieldName);

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    IFeatureCursor fCursor = (IFeatureCursor)cableFc.Update(qf, false);
                    ICursor        pCursor = fCursor as ICursor;
                    comReleaser.ManageLifetime(fCursor);

                    int buffersFieldIdx = cableFc.FindField(ConfigUtil.NumberOfBuffersFieldName);
                    int fibersFieldIdx  = cableFc.FindField(ConfigUtil.NumberOfFibersFieldName);
                    int ipidFieldIdx    = cableFc.FindField(ConfigUtil.IpidFieldName);

                    int count = 0;
                    while ((feature = fCursor.NextFeature()) != null)
                    {
                        // Cables should have non null field values
                        if (feature.get_Value(ipidFieldIdx) == DBNull.Value)
                        {
                            badCable = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with NULL IPID value");
                            continue;
                        }
                        if (feature.get_Value(buffersFieldIdx) == DBNull.Value)
                        {
                            badBuffers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with NULL buffer field value", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }
                        if (feature.get_Value(fibersFieldIdx) == DBNull.Value)
                        {
                            badFibers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with NULL fiber field value", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }

                        int bufferCount = (int)feature.get_Value(buffersFieldIdx);
                        int fiberCount  = (int)feature.get_Value(fibersFieldIdx);

                        // Cables should have non zero values
                        if (bufferCount == 0)
                        {
                            badBuffers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with 0 buffer field value", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }
                        if (fiberCount == 0)
                        {
                            badFibers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with 0 strand field value", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }

                        // Cables should have relationships
                        int rcBufferCount = fiberCableToBufferRc.GetObjectsRelatedToObject(feature).Count;
                        if (rcBufferCount == 0)
                        {
                            badBuffers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with 0 related buffers", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }
                        int rcFiberCount = fiberCableToFiberRc.GetObjectsRelatedToObject(feature).Count;
                        if (rcFiberCount == 0)
                        {
                            badFibers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with 0 related fibers", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }

                        // Buffer field count & relationships to buffers not matching
                        if (bufferCount != rcBufferCount)
                        {
                            badBuffers = true;
                            String output = "Expected: " + bufferCount + " Found: " + rcBufferCount + " Cable ID: " + feature.get_Value(ipidFieldIdx).ToString();
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Found Fiber Cable with buffer count->relationship mismatch", output);
                            continue;
                        }

                        // other checks
                        if (rcFiberCount % rcBufferCount != 0)
                        {
                            badFibers = true;
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Fiber Cable with invalid strand count - (relationships % buffercount) is non zero", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            continue;
                        }

                        // we must be dealing with a total count (convert to per buffer tube value)
                        if (fiberCount == rcFiberCount && bufferCount > 1)
                        {
                            count++;
                            Debug.Write(count + " Strand Total to Strands Per Buffer conversion", " Cable ID: " + feature.get_Value(ipidFieldIdx).ToString() + "\n");
                            conversionRequired = true;
                            //                            _logHelper.addLogEntry(DateTime.Now.ToString(), "INTEGRITY", "Strand Total to Strands Per Buffer conversion", "Cable ID: " + feature.get_Value(ipidFieldIdx).ToString());
                            feature.set_Value(fibersFieldIdx, rcFiberCount / rcBufferCount);
                            feature.Store();
                        }
                    }
                }
                edit.StopEditOperation();
                edit.StopEditing(true);

                if (badCable)
                {
                    MessageBox.Show("Database integrity issues were detected. Found invalid Fiber Cable. Please see the log file for more details");
                }
                if (badBuffers)
                {
                    MessageBox.Show("Database integrity issues were detected. Found Fiber Cable with buffer count issues. Please see the log file for more details");
                }
                if (badFibers)
                {
                    MessageBox.Show("Database integrity issues were detected. Found Fiber Cable with strands count issues. Please see the log file for more details");
                }
                if (conversionRequired)
                {
                    MessageBox.Show("Database integrity issues were detected. Strand Total to Strands Per Buffer conversion was done.");
                }
            }
            catch (Exception e)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Integrity Check Error", e.Message);
            }

            MessageBox.Show("The results of the DB checks are listed in the tools Log window");
        }