Beispiel #1
0
        internal List <IGTKeyObject> GetAllRelatedFeatures(NodeType p_NodeType)
        {
            IGTKeyObjects  oRelatedObjects = GTClassFactory.Create <IGTKeyObjects>();
            IGTApplication oApp            = GTClassFactory.Create <IGTApplication>();

            using (IGTRelationshipService oRelationshipObj = GTClassFactory.Create <IGTRelationshipService>())
            {
                oRelationshipObj.DataContext   = oApp.DataContext;
                oRelationshipObj.ActiveFeature = AffectedFeature;

                List <IGTKeyObject> RelatedFeaturesList = new List <IGTKeyObject>();
                switch (p_NodeType)
                {
                case NodeType.Node1:
                    try
                    {
                        oRelatedObjects = oRelationshipObj.GetRelatedFeatures(RNOConnectivity, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                    }
                    catch (System.Exception)
                    {
                    }

                    break;

                case NodeType.Node2:
                    try
                    {
                        oRelatedObjects = oRelationshipObj.GetRelatedFeatures(RNOConnectivity, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                    }
                    catch (System.Exception)
                    {
                    }

                    break;

                case NodeType.Both:
                    oRelatedObjects = oRelationshipObj.GetRelatedFeatures(RNOConnectivity, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinalAll);
                    break;

                default:
                    break;
                }

                foreach (IGTKeyObject item in oRelatedObjects)
                {
                    RelatedFeaturesList.Add(item);
                }

                return(RelatedFeaturesList);
            }
        }
Beispiel #2
0
        private void ProcessActiveStreetLightDDC(IGTDDCKeyObjects ddcStreetLightList)
        {
            try
            {
                foreach (IGTDDCKeyObject ddcobj in ddcStreetLightList)
                {
                    if ((ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) || (ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtPointGeometry))
                    {
                        IGTKeyObject koStreetLight = oDC.OpenFeature(ddcobj.FNO, ddcobj.FID);

                        oRelationService.ActiveFeature = koStreetLight;

                        IGTKeyObjects koOwnedByList = oRelationService.GetRelatedFeatures(3);                         // Owned By

                        if (koOwnedByList == null)
                        {
                            continue;
                        }

                        if (koOwnedByList.Count == 0)
                        {
                            continue;
                        }

                        //Should only be one IGTKeyObject that owns a streetlight
                        //Need Common_N data on both the structure and the streetlight
                        IGTKeyObject koStructure = koOwnedByList[0];

                        GTActiveStreetLight objStreetLight = CommandUtilities.GetCommonNActiveFeature(koStreetLight, koStructure, oDiag);

                        if (objStreetLight == null)
                        {
                            continue;
                        }

                        objStreetLight.G3E_FID       = ddcobj.FID;
                        objStreetLight.G3E_FNO       = ddcobj.FNO;
                        objStreetLight.Structure_FID = koStructure.FID;
                        objStreetLight.StructureFNO  = koStructure.FNO;

                        this.oActiveList.Add(objStreetLight);
                    }
                }
            }
            catch (Exception ex)
            {
                CommandUtilities.LogException(oDiag, "ProcessActiveStreetLightDDC", ex);
                throw ex;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns the related feature for a corresponding relationship number
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <param name="cRNO"></param>
        /// <returns></returns>
        private IGTKeyObjects GetRelatedFeatures(IGTKeyObject activeFeature, short cRNO)
        {
            try
            {
                using (IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>())
                {
                    relService.DataContext   = DataContext;
                    relService.ActiveFeature = activeFeature;

                    IGTKeyObjects relatedFeatures = null;
                    try
                    {
                        relatedFeatures = relService.GetRelatedFeatures(cRNO);
                    }
                    catch
                    {
                    }

                    return(relatedFeatures);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #4
0
        public void DeleteExistingDucts(short p_FNO, int p_FID)
        {
            try
            {
                IGTKeyObject           oKeyObject = m_oDataContext.OpenFeature(p_FNO, p_FID);
                IGTRelationshipService oRelSVC    = GTClassFactory.Create <IGTRelationshipService>();
                oRelSVC.DataContext   = m_oDataContext;
                oRelSVC.ActiveFeature = oKeyObject;
                IGTKeyObjects oDucks = oRelSVC.GetRelatedFeatures(7);

                if (oDucks != null && oDucks.Count > 0)
                {
                    for (int i = 0; i < oDucks.Count; i++)
                    {
                        foreach (IGTComponent item in oDucks[i].Components)
                        {
                            DeleteComponent(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }
        }
Beispiel #5
0
        public void DetermineConnectivityNode(IGTKeyObject activeKO, IGTKeyObject relatedKO, ref GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            IGTKeyObjects m_relatedFeatures = null;
            bool          foundNode         = false;

            try
            {
                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.DataContext   = m_dataContext;
                    oRel.ActiveFeature = relatedKO;

                    m_relatedFeatures = oRel.GetRelatedFeatures(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                }
                foreach (IGTKeyObject feature in m_relatedFeatures)
                {
                    if (feature.FID == activeKO.FID)
                    {
                        relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;
                        foundNode = true;
                        break;
                    }
                }

                if (!foundNode)
                {
                    relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2;
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #6
0
        private void DeleteNodeRelatedfeatures(GTRelationshipOrdinalConstants ordinal, IGTKeyObject m_feature)
        {
            try
            {
                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.DataContext   = m_dataContext;
                    oRel.ActiveFeature = m_feature;

                    IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();
                    try
                    {
                        relatedFeatures = oRel.GetRelatedFeatures(14, ordinal);
                    }
                    catch
                    {
                    }

                    if (relatedFeatures != null)
                    {
                        foreach (IGTKeyObject feature in relatedFeatures)
                        {
                            if (m_IsoScenarioselectedFeatureFNOs.Contains(feature.FNO))
                            {
                                oRel.SilentDelete(14, ordinal);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #7
0
 /// <summary>
 /// GetRelatedFeatures
 /// </summary>
 /// <param name="gtActiveFeature"></param>
 /// <param name="RNO"></param>
 /// <param name="relatedFNO"></param>
 /// <returns></returns>
 protected IGTKeyObjects GetRelatedFeature(IGTKeyObject activeFeature, short RNO, int relatedFNO)
 {
     try
     {
         IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>();
         m_gtRelationshipService.DataContext   = m_gtApplication.DataContext;
         m_gtRelationshipService.ActiveFeature = activeFeature;
         IGTKeyObjects m_gtRelatedFeatures = m_gtRelationshipService.GetRelatedFeatures(RNO);
         if (relatedFNO > 0)
         {
             for (int i = m_gtRelatedFeatures.Count; 0 < i; i--)
             {
                 if ((m_gtRelatedFeatures[i - 1].FNO) != relatedFNO)
                 {
                     m_gtRelatedFeatures.RemoveAt(i - 1);
                 }
             }
         }
         m_gtRelationshipService = null;
         return(m_gtRelatedFeatures);
     }
     catch
     {
         throw;
     }
 }
Beispiel #8
0
        /// <summary>
        /// Method to check if selected feature is a parent feature
        /// </summary>
        /// <returns> true- if feature is an owner</returns>
        private bool CheckIfOwnerFeatureAndGetOwnedFeatures()
        {
            ChildFeatureInfo       oChildFeatureInfo;
            IGTKeyObjects          ownedFeatures = null;
            IGTRelationshipService oService      = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                int          fId            = m_selectedObject.FID;
                short        fNo            = m_selectedObject.FNO;
                IGTKeyObject oActiveFeature = m_dataContext.OpenFeature(fNo, fId);
                oService.DataContext   = m_dataContext;
                oService.ActiveFeature = oActiveFeature;
                try
                {
                    ownedFeatures = oService.GetRelatedFeatures(2);
                }
                catch
                {
                    return(false);
                }
                if (ownedFeatures.Count > 0)
                {
                    m_childFeatureInfoList = new List <ChildFeatureInfo>();
                    foreach (IGTKeyObject child in ownedFeatures)
                    {
                        oChildFeatureInfo             = new ChildFeatureInfo();
                        oChildFeatureInfo.GtKeyObject = child;
                        Recordset childRs = child.Components.GetComponent(1).Recordset;
                        childRs.MoveFirst();
                        Recordset parentRs = oActiveFeature.Components.GetComponent(1).Recordset;
                        parentRs.MoveFirst();
                        if (Convert.ToString(childRs.Fields["OWNER1_ID"].Value) == Convert.ToString(parentRs.Fields["G3E_ID"].Value))
                        {
                            oChildFeatureInfo.Owner1IdExists = true;
                        }
                        else if (Convert.ToString(childRs.Fields["OWNER2_ID"].Value) == Convert.ToString(parentRs.Fields["G3E_ID"].Value))
                        {
                            oChildFeatureInfo.Owner2IdExists = true;
                        }
                        m_childFeatureInfoList.Add(oChildFeatureInfo);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                oService.Dispose();
                oService = null;
            }
        }
Beispiel #9
0
        /// <summary>
        /// override After establish
        /// </summary>
        public override void AfterEstablish()
        {
            IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>() as IGTRelationshipService;

            try
            {
                if ((ActiveFeature.FNO == Capacitor_FNO) || (ActiveFeature.FNO == TransformerOH_FNO) || (ActiveFeature.FNO == PrimaryEnclosure_FNO) || (ActiveFeature.FNO == TransformerUG_FNO) || (ActiveFeature.FNO == TransformerOHN_FNO) || (ActiveFeature.FNO == TransformerUGN_FNO))
                {
                    gtRelationshipService.DataContext   = gtApplication.DataContext;
                    gtRelationshipService.ActiveFeature = this.ActiveFeature;

                    //Get related features
                    IGTKeyObjects relationshipcandidates = gtRelationshipService.GetRelatedFeatures(m_RNO);
                    if (relationshipcandidates != null)
                    {
                        for (int i = 0; i < relationshipcandidates.Count; i++)
                        {
                            // check if opposite nodes are connected otherwise .. change the node of the related feature
                            if ((relationshipcandidates.Count == 2) || (GetComponentType(relationshipcandidates[i].CNO).ToString() == "PolylineGeometry") && (GetComponentType(ActiveFeature.CNO) != GetComponentType(relationshipcandidates[i].CNO)))
                            {
                                if ((Convert.ToString(relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value)) == (Convert.ToString(relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value)))
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    //relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = 0;
                                    //gtRelationshipService.SilentEstablish(m_RNO, relationshipcandidates[i + 1], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                    break;
                                }
                                else
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    // gtRelationshipService.SilentEstablish(m_RNO, relationshipcandidates[i + 1], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (gtRelationshipService != null)
                {
                    gtRelationshipService.Dispose();
                    gtRelationshipService = null;
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Method to return the RelatedFeatures of active feature
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <param name="cRNO"></param>
        /// <returns></returns>
        private IGTKeyObjects GetRelatedFeatures(IGTKeyObject p_activeFeature, short p_cRNO, string nodeOrdinal)
        {
            using (IGTRelationshipService m_relService = GTClassFactory.Create <IGTRelationshipService>())
            {
                IGTKeyObjects m_relatedFeatures = null;

                m_relService.DataContext   = DataContext;
                m_relService.ActiveFeature = p_activeFeature;

                if (nodeOrdinal == "NODE1")
                {
                    m_relatedFeatures = m_relService.GetRelatedFeatures(p_cRNO, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                }
                else if (nodeOrdinal == "NODE2")
                {
                    m_relatedFeatures = m_relService.GetRelatedFeatures(p_cRNO, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                }
                return(m_relatedFeatures);
            }
        }
Beispiel #11
0
        /// <summary>
        /// To find owners of a linear feature.
        /// </summary>
        /// <returns></returns>
        public IGTKeyObjects LocateOwnersOfActiveFeature()
        {
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();
            IGTKeyObjects          gTOwnerKeyObjects   = GTClassFactory.Create <IGTKeyObjects>();

            try
            {
                relationShipService.ActiveFeature = m_ActiveKeyObject;
                relationShipService.DataContext   = m_gTDataContext;
                if (m_ActiveKeyObject.FNO != 2400)
                {
                    gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(3);
                }
                else if (m_ActiveKeyObject.FNO == 2400)
                {
                    IGTKeyObjects gTFormationOwnerKeyObjects = relationShipService.GetRelatedFeatures(6);
                    if (gTFormationOwnerKeyObjects != null && gTFormationOwnerKeyObjects.Count > 0)
                    {
                        foreach (IGTKeyObject gTKeyObject in gTFormationOwnerKeyObjects)
                        {
                            relationShipService.ActiveFeature = gTKeyObject;
                            gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(122);
                            if (gTOwnerKeyObjects != null && gTOwnerKeyObjects.Count > 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            finally
            {
                relationShipService.Dispose();
                relationShipService = null;
            }
            return(gTOwnerKeyObjects);
        }
Beispiel #12
0
 /// <summary>
 /// GetRelatedFeatures
 /// </summary>
 /// <param name="activeFeature"></param>
 /// <param name="cRNO"></param>
 /// <returns></returns>
 public IGTKeyObjects GetRelatedFeatures(IGTKeyObject p_activeFeature, short p_RNO)
 {
     try
     {
         IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>();
         relService.DataContext   = m_oGTDataContext;
         relService.ActiveFeature = p_activeFeature;
         IGTKeyObjects relatedFeatures = relService.GetRelatedFeatures(p_RNO);
         return(relatedFeatures);
     }
     catch
     {
         throw;
     }
 }
Beispiel #13
0
        /// <summary>
        /// Gets the owned feature for the input active feature
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <returns>Collection of owned feature if any or null</returns>
        private List <Tuple <short, int> > GetOwnedFeatures(IGTKeyObject activeFeature)
        {
            IGTRelationshipService     gTRelationshipService = null;
            List <Tuple <short, int> > ownedFeatures         = null;
            IGTKeyObjects gTKeyObjects = null;

            try
            {
                gTRelationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                gTRelationshipService.DataContext   = DataContext;
                gTRelationshipService.ActiveFeature = activeFeature;

                try
                {
                    gTKeyObjects = gTRelationshipService.GetRelatedFeatures(2);
                }
                catch
                {
                    return(null);
                }

                if (gTKeyObjects != null && gTKeyObjects.Count > 0)
                {
                    ownedFeatures = new List <Tuple <short, int> >();

                    foreach (IGTKeyObject feature in gTKeyObjects)
                    {
                        if (!IsActiveFeatureIsLinear(feature.FNO))
                        {
                            ownedFeatures.Add(new Tuple <short, int>(feature.FNO, feature.FID));
                        }
                    }
                }
                return(ownedFeatures);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (gTRelationshipService != null)
                {
                    gTRelationshipService.Dispose();
                    gTRelationshipService = null;
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Returns the related feature for a corresponding relationship number
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <param name="cRNO"></param>
        ///  <param name="dataContext"></param>
        /// <returns></returns>
        private IGTKeyObjects GetRelatedFeatures(IGTKeyObject activeFeature, short cRNO, IGTDataContext dataContext)
        {
            IGTKeyObjects relatedFeatures = null;

            try
            {
                IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>();
                relService.DataContext   = dataContext;
                relService.ActiveFeature = activeFeature;
                relatedFeatures          = relService.GetRelatedFeatures(cRNO);
            }
            catch (Exception)
            {
            }
            return(relatedFeatures);
        }
Beispiel #15
0
        private void GetIsolationPoint(IGTKeyObject feature, ref IGTKeyObject oIsolationPointParent, GTRelationshipOrdinalConstants node)
        {
            try
            {
                IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.ActiveFeature = feature;
                    oRel.DataContext   = m_dataContext;
                    try
                    {
                        relatedFeatures = oRel.GetRelatedFeatures(14, node);
                    }
                    catch
                    {
                    }

                    if (relatedFeatures != null && relatedFeatures.Count > 0)
                    {
                        if (feature != null)
                        {
                            foreach (IGTKeyObject item in relatedFeatures)
                            {
                                if (m_IsoScenarioselectedFeatureFNOs.Contains(item.FNO) && CheckAssociatedVirtualPoint(item.FID, feature.FID))
                                {
                                    if (m_elbowConnected)
                                    {
                                        m_elbowConnected = false;
                                        continue;
                                    }
                                    else
                                    {
                                        oIsolationPointParent = item;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #16
0
 /// <summary>
 /// GetRelatedFeatures:Returns the related feature for a corresponding relationship number
 /// </summary>
 /// <param name="activeFeature"></param>
 /// <param name="cRNO"></param>
 /// <returns></returns>
 private IGTKeyObjects GetRelatedFeatures(IGTKeyObject p_activeFeature, short p_cRNO)
 {
     try
     {
         using (IGTRelationshipService m_relService = GTClassFactory.Create <IGTRelationshipService>())
         {
             m_relService.DataContext   = DataContext;
             m_relService.ActiveFeature = p_activeFeature;
             IGTKeyObjects m_relatedFeatures = m_relService.GetRelatedFeatures(p_cRNO);
             return(m_relatedFeatures);
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #17
0
        /// <summary>
        /// Determines which node of the related feature is connected to the active feature.
        /// </summary>
        /// <param name="activeKO">Active feature to connect.</param>
        /// <param name="relatedKO">Related feature to connect.</param>
        /// <param name="relatedRelationshipOrdinal">Node on the related feature to connect.</param>
        /// <returns>Boolean indicating status</returns>
        public bool DetermineConnectivityNode(IGTKeyObject activeKO, IGTKeyObject relatedKO, ref GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            IGTKeyObjects          m_relatedFeatures   = null;
            bool foundNode = false;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = relatedKO;

                m_relatedFeatures = relationshipService.GetRelatedFeatures(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);

                foreach (IGTKeyObject feature in m_relatedFeatures)
                {
                    if (feature.FID == activeKO.FID)
                    {
                        relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;
                        foundNode = true;
                        break;
                    }
                }

                if (!foundNode)
                {
                    relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2;
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                returnValue = false;
                if (InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:DetermineConnectivityNode - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            relationshipService.Dispose();

            return(returnValue);
        }
Beispiel #18
0
        private IGTKeyObjects GetRelatedFeaturesAtStructure(IGTKeyObject p_Structure)
        {
            IGTKeyObjects oKeyObjectsCollection = null;

            using (IGTRelationshipService oRelSvc = GTClassFactory.Create <IGTRelationshipService>())
            {
                oRelSvc.DataContext   = m_oApp.DataContext;
                oRelSvc.ActiveFeature = p_Structure;

                try
                {
                    oKeyObjectsCollection = oRelSvc.GetRelatedFeatures(2);
                }
                catch (Exception)
                {
                }
            }
            return(oKeyObjectsCollection);
        }
Beispiel #19
0
        /// <summary>
        /// To find owners of a linear feature.
        /// </summary>
        /// <returns></returns>
        private IGTKeyObjects LocateOwnersOfActiveFeature(short rno, IGTKeyObject gTKeyObject)
        {
            IGTKeyObjects gTOwnerKeyObjects = GTClassFactory.Create <IGTKeyObjects>();

            try
            {
                using (IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>())
                {
                    relationShipService.ActiveFeature = gTKeyObject;
                    relationShipService.DataContext   = m_dataContext;
                    gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(rno);
                }
            }
            catch
            {
            }

            return(gTOwnerKeyObjects);
        }
        /// <summary>
        /// GetRelatedFeatures
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <param name="cRNO"></param>
        /// <returns></returns>
        private IGTKeyObjects GetRelatedFeatures(IGTKeyObject activeFeature)
        {
            using (IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>())
            {
                relService.DataContext   = DataContext;
                relService.ActiveFeature = activeFeature;
                IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();

                try
                {
                    relatedFeatures = relService.GetRelatedFeatures(m_cRNO);
                }
                catch (Exception)
                {
                }

                return(relatedFeatures);
            }
        }
        private string GetQuantityLength(IGTKeyObject p_keyObj)
        {
            IGTKeyObjects DuctsBankObjects = null;
            string        length           = null;

            try
            {
                if (p_keyObj.FNO == 2400)
                {
                    using (IGTRelationshipService o_RelSVC = GTClassFactory.Create <IGTRelationshipService>())
                    {
                        o_RelSVC.DataContext   = m_oDataContext;
                        o_RelSVC.ActiveFeature = p_keyObj;
                        DuctsBankObjects       = o_RelSVC.GetRelatedFeatures(6);
                    }

                    for (int i = 0; i <= DuctsBankObjects.Count - 1; i++)
                    {
                        if (DuctsBankObjects[i].FNO == 2200)
                        {
                            p_keyObj = DuctsBankObjects[i];
                            break;
                        }
                    }
                }

                if (p_keyObj.Components["COMMON_N"] != null && p_keyObj.Components["COMMON_N"].Recordset.RecordCount > 0)
                {
                    p_keyObj.Components["COMMON_N"].Recordset.MoveFirst();

                    if (!IsDBNull(p_keyObj.Components["COMMON_N"].Recordset.Fields["LENGTH_ACTUAL_Q"].Value))
                    {
                        length = Convert.ToString(p_keyObj.Components["COMMON_N"].Recordset.Fields["LENGTH_ACTUAL_Q"].Value);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(length);
        }
Beispiel #22
0
        private void EstablishIsolationPointConnectivity(IGTKeyObject oIsolationPointParent, IGTKeyObject oIsolationPointNew, GTRelationshipOrdinalConstants node)
        {
            try
            {
                IGTKeyObjects oldIsoRelatedFeatures = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.ActiveFeature = oIsolationPointParent;
                    oRel.DataContext   = m_dataContext;
                    try
                    {
                        oldIsoRelatedFeatures = oRel.GetRelatedFeatures(14, node);
                    }
                    catch
                    {
                    }

                    oRel.ActiveFeature = oIsolationPointNew;

                    oRel.SilentDelete(14, node);
                    GTRelationshipOrdinalConstants relatedNode = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;

                    foreach (IGTKeyObject feature in oldIsoRelatedFeatures)
                    {
                        if (m_isolationScenarioType == IsolationScenarios.BYPASS && feature.FNO == 40)
                        {
                            continue;
                        }
                        else
                        {
                            DetermineConnectivityNode(oIsolationPointParent, feature, ref relatedNode);
                            EstablishConnectivity(oIsolationPointNew, feature, node, relatedNode);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Returns the related feature for a corresponding relationship number
        /// <returns></returns>
        /// <summary>
        private IGTKeyObjects GetRelatedFeatures()
        {
            try
            {
                IGTKeyObjects configuredKeyObjects = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>())
                {
                    relService.DataContext   = DataContext;
                    relService.ActiveFeature = ActiveFeature;
                    IGTKeyObjects relatedFeatures = relService.GetRelatedFeatures(RNO);

                    if (ProcessingMode.Equals(GTRelationshipGeometryProcessingModeConstants.gtrgiValidation))
                    {
                        foreach (IGTKeyObject item in relatedFeatures)
                        {
                            if (IsFeatureConfiguredInRelationshipGeomtery(item.FNO))
                            {
                                if ((ActiveFeature.FNO == 16 && (item.FNO == 17 || item.FNO == 18)) || ((ActiveFeature.FNO == 17 || ActiveFeature.FNO == 18) && item.FNO == 16))
                                {
                                    continue;
                                }
                                else
                                {
                                    configuredKeyObjects.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        configuredKeyObjects = relatedFeatures;
                    }
                    return(configuredKeyObjects);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #24
0
        /// <summary>
        /// Method to get related features
        /// <summary>
        public IGTKeyObjects GetRelatedFeatures()
        {
            try
            {
                IGTKeyObjects configuredKeyObjects = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService relService = GTClassFactory.Create <IGTRelationshipService>())
                {
                    relService.DataContext   = m_rgiBase.DataContext;
                    relService.ActiveFeature = m_rgiBase.ActiveFeature;
                    IGTKeyObjects relatedFeatures = relService.GetRelatedFeatures(m_rgiBase.RNO);

                    if (Validation)
                    {
                        foreach (IGTKeyObject item in relatedFeatures)
                        {
                            if (((ActiveFNO == 16 || ActiveFNO == 91) && (item.FNO == 16 || item.FNO == 17 || item.FNO == 18 || item.FNO == 91)) ||
                                ((ActiveFNO == 17 || ActiveFNO == 18) && (item.FNO == 16 || item.FNO == 91)))
                            {
                                continue;
                            }
                            else
                            {
                                configuredKeyObjects.Add(item);
                            }
                        }
                    }
                    else
                    {
                        configuredKeyObjects = relatedFeatures;
                    }
                    return(configuredKeyObjects);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #25
0
        public void EstablishOwnerShip(IGTKeyObject activeKO, IGTKeyObject isolationPoint)
        {
            IGTRelationshipService relationshipService = null;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = activeKO;
                IGTKeyObjects m_relatedFeatures = relationshipService.GetRelatedFeatures(3);

                foreach (IGTKeyObject ownerFeature in m_relatedFeatures)
                {
                    relationshipService.ActiveFeature = isolationPoint;

                    if (relationshipService.AllowSilentEstablish(ownerFeature))
                    {
                        try
                        {
                            relationshipService.SilentEstablish(3, ownerFeature);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                relationshipService.Dispose();
                relationshipService = null;
            }
        }
Beispiel #26
0
        /// <summary>
        /// This method is used to validate the initial conditions of the relocate custom command.
        /// </summary>
        /// <param name="relatedFeaturesOWB"></param>
        /// <returns></returns>
        private bool ValidateCC(out IGTKeyObjects relatedFeaturesOWB)
        {
            bool      execute    = true;
            string    sql        = "";
            Recordset rsValidate = null;
            int       reCount    = 0;
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            relatedFeaturesOWB = GTClassFactory.Create <IGTKeyObjects>();
            try
            {
                //Validate conditions to run the custom command.

                // 1.  This command applies only to WR jobs.

                #region First Condition
                sql = "select G3E_JOBTYPE,G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER=?";
                //sql = "select JOB_TYPE,G3E_STATUS from G3E_JOB where G3E_IDENTIFIER=?";
                rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                       (int)ADODB.CommandTypeEnum.adCmdText, m_gtApplication.DataContext.ActiveJob);

                if (rsValidate.RecordCount > 0)
                {
                    rsValidate.MoveFirst();
                    if (!rsValidate.EOF && !rsValidate.BOF)
                    {
                        m_strJobtype = Convert.ToString(rsValidate.Fields[0].Value);
                        m_strStatus  = Convert.ToString(rsValidate.Fields[1].Value);
                    }
                }
                #endregion

                if (m_strJobtype == "NON-WR")
                {
                    MessageBox.Show("This command applies only to WR jobs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button1);
                    execute = false;
                }
                else
                {
                    //2. This command applies only to features with CUs.

                    #region Second Condition

                    m_gtDDCKeyObjects     = m_gtApplication.Application.SelectedObjects.GetObjects();
                    m_activeFeatureDDCKey = m_gtDDCKeyObjects[0];
                    m_selectedFno         = m_activeFeatureDDCKey.FNO;
                    m_selectedFid         = m_activeFeatureDDCKey.FID;

                    sql        = "SELECT count(*) FROM G3E_FEATURECOMPS_OPTABLE WHERE G3E_FNO=? AND G3E_CNO=21";
                    rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                           (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno);

                    if (rsValidate.RecordCount > 0)
                    {
                        rsValidate.MoveFirst();
                        if (!rsValidate.EOF && !rsValidate.BOF)
                        {
                            reCount = Convert.ToInt32(rsValidate.Fields[0].Value);
                        }
                    }

                    #endregion

                    if (reCount < 1)
                    {
                        MessageBox.Show("This command applies only to features with CUs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);

                        execute = false;
                    }
                    else
                    {
                        // 3. Cannot Relocate a feature that is not currently owned.
                        #region Third Condition
                        m_oActiveKeyObject = m_gtApplication.DataContext.OpenFeature(m_selectedFno, m_selectedFid);
                        relationShipService.ActiveFeature = m_oActiveKeyObject;
                        relationShipService.DataContext   = m_gtApplication.DataContext;
                        int ownFcount = 0;
                        try
                        {
                            relatedFeaturesOWB = relationShipService.GetRelatedFeatures(3);
                            ownFcount          = relatedFeaturesOWB.Count;
                        }
                        catch
                        {
                        }

                        #endregion
                        if (ownFcount <= 0)
                        {
                            MessageBox.Show("Cannot relocate a feature that is not currently owned.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                            MessageBoxDefaultButton.Button1);

                            execute = false;
                        }
                        else
                        {
                            // 4. This command applies only to point features.
                            #region Fourth Condition
                            sql        = "SELECT * FROM G3E_COMPONENTINFO_OPTABLE WHERE G3E_CNO IN(SELECT G3E_PRIMARYGEOGRAPHICCNO FROM G3E_FEATURES_OPTABLE WHERE G3E_FNO=?) AND UPPER(G3E_GEOMETRYTYPE) LIKE '%POINT%'";
                            rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                                   (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno);

                            #endregion
                            if (rsValidate.RecordCount <= 0)
                            {
                                MessageBox.Show("This command applies only to point features.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                MessageBoxDefaultButton.Button1);

                                execute = false;
                            }
                            else
                            {
                                //execute = true;
                                if (!CheckIfInstallAndActiveWrAreDifferent())
                                {
                                    MessageBox.Show("The same feature may not be installed and relocated in the same WR.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                    MessageBoxDefaultButton.Button1);
                                    execute = false;
                                }
                                else
                                {
                                    execute = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (rsValidate != null)
                {
                    if (rsValidate.State == 1)
                    {
                        rsValidate.Close();
                        rsValidate.ActiveConnection = null;
                    }
                    rsValidate = null;
                }

                if (relationShipService != null)
                {
                    relationShipService.Dispose();
                    relationShipService = null;
                }
            }

            return(execute);
        }
Beispiel #27
0
        public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray)
        {
            ErrorPriorityArray = new string[1];
            ErrorMessageArray  = new string[1];

            short iFNOActive = 0;
            int   iFIDActive = 0;

            short iFNORelated = 0;
            int   iFIDRelated;

            string sActivePhase = string.Empty;
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            IGTKeyObject  oRelatedFeature        = null;
            IGTKeyObjects oRelatedFeatureOwnedBy = null;
            string        sPriCondNodeType       = string.Empty;

            IGTKeyObject  oActiveFeature        = null;
            IGTKeyObjects oActiveFeatureOwnedBy = null;
            int           activePhaseCount      = 0;

            GTValidationLogger gTValidationLogger = null;
            IGTComponent       activeComponent    = ActiveComponents[ActiveComponentName];
            int activeFID = 0;

            if (activeComponent != null)
            {
                activeComponent.Recordset.MoveFirst();
                activeFID = int.Parse(activeComponent.Recordset.Fields["G3E_FID"].Value.ToString());
            }

            IGTComponent relatedComponent = RelatedComponents[RelatedComponentName];
            int          relatedFID       = 0;

            if (relatedComponent != null)
            {
                relatedComponent.Recordset.MoveFirst();
                relatedFID = int.Parse(relatedComponent.Recordset.Fields["G3E_FID"].Value.ToString());
            }

            if (new gtLogHelper().CheckIfLoggingIsEnabled())
            {
                LogEntries logEntries = new LogEntries
                {
                    ActiveComponentName = ActiveComponentName,
                    ActiveFID           = activeFID,
                    ActiveFieldName     = ActiveFieldName,
                    ActiveFieldValue    = Convert.ToString(activeComponent.Recordset.Fields[ActiveFieldName].Value),
                    JobID = DataContext.ActiveJob,
                    RelatedComponentName    = RelatedComponentName,
                    RelatedFID              = relatedFID,
                    RelatedFieldName        = RelatedFieldName,
                    RelatedFieldValue       = Convert.ToString(relatedComponent.Recordset.Fields[RelatedFieldName].Value),
                    ValidationInterfaceName = "Conductor Validation",
                    ValidationInterfaceType = "RAI",
                };
                gTValidationLogger = new GTValidationLogger(logEntries);

                gTValidationLogger.LogEntry("TIMING", "START", "Conductor Validation Entry", "N/A", "");
            }



            try
            {
                if (m_oActiveComponents[m_sActiveComponentName].Recordset != null)
                {
                    if (!(m_oActiveComponents[m_sActiveComponentName].Recordset.EOF && m_oActiveComponents[m_sActiveComponentName].Recordset.BOF))
                    {
                        iFNOActive = Convert.ToInt16(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["g3e_fno"].Value);
                        iFIDActive = Convert.ToInt32(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["g3e_fid"].Value);

                        sActivePhase     = Convert.ToString(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["PHASE_ALPHA"].Value);
                        activePhaseCount = sActivePhase.Length;
                        oActiveFeature   = m_oDataContext.OpenFeature(iFNOActive, iFIDActive);
                    }
                }

                if (m_oRelatedComponents[m_sRelatedComponentName].Recordset != null)
                {
                    if (!(m_oRelatedComponents[m_sRelatedComponentName].Recordset.EOF && m_oRelatedComponents[m_sRelatedComponentName].Recordset.BOF))
                    {
                        iFNORelated = Convert.ToInt16(m_oRelatedComponents[m_sRelatedComponentName].Recordset.Fields["g3e_fno"].Value);
                        iFIDRelated = Convert.ToInt32(m_oRelatedComponents[m_sRelatedComponentName].Recordset.Fields["g3e_fid"].Value);

                        oRelatedFeature = m_oDataContext.OpenFeature(iFNORelated, iFIDRelated);

                        if (iFNORelated == 10) //Primary Conductor Node - Store the Type as well
                        {
                            oRelatedFeature.Components["PRI_COND_NODE_N"].Recordset.MoveFirst();
                            sPriCondNodeType = Convert.ToString(oRelatedFeature.Components["PRI_COND_NODE_N"].Recordset.Fields["TYPE_C"].Value);
                        }
                    }
                }

                if ((iFNOActive == 8 || iFNOActive == 9) && (iFNORelated == 13 || iFNORelated == 39) && activePhaseCount == 1)
                {
                    if (sActivePhase != "*")
                    {
                        relationShipService.DataContext   = m_oDataContext;
                        relationShipService.ActiveFeature = oRelatedFeature;
                        oRelatedFeatureOwnedBy            = relationShipService.GetRelatedFeatures(3);

                        if (oRelatedFeatureOwnedBy != null && oRelatedFeatureOwnedBy.Count > 0)
                        {
                            for (int i = 0; i < oRelatedFeatureOwnedBy.Count; i++)
                            {
                                if (oRelatedFeatureOwnedBy[i].FNO == 19)
                                {
                                    ErrorPriorityArray[0] = m_sPriority;
                                    ErrorMessageArray[0]  = "Single-phase conductor should not be connected to a switch gear";
                                }
                            }
                        }
                    }
                }

                if ((iFNOActive == 8 || iFNOActive == 9) && iFNORelated == 10 && sPriCondNodeType.Equals("DEADEND"))
                {
                    relationShipService.DataContext   = m_oDataContext;
                    relationShipService.ActiveFeature = oActiveFeature;
                    oActiveFeatureOwnedBy             = relationShipService.GetRelatedFeatures(3);

                    if (oActiveFeatureOwnedBy != null && oActiveFeatureOwnedBy.Count > 0)
                    {
                        for (int i = 0; i < oActiveFeatureOwnedBy.Count; i++)
                        {
                            if (oActiveFeatureOwnedBy[i].FNO == 110)
                            {
                                IGTKeyObject  oPoleOwner          = null;
                                bool          bGuyFound           = false;
                                IGTKeyObjects oFeatureOwnedByPole = null;

                                oPoleOwner = m_oDataContext.OpenFeature(oActiveFeatureOwnedBy[i].FNO, oActiveFeatureOwnedBy[i].FID);

                                relationShipService.DataContext   = m_oDataContext;
                                relationShipService.ActiveFeature = oPoleOwner;
                                oFeatureOwnedByPole = relationShipService.GetRelatedFeatures(2);

                                if (oFeatureOwnedByPole != null && oFeatureOwnedByPole.Count > 0)
                                {
                                    for (int j = 0; j < oFeatureOwnedByPole.Count; j++)
                                    {
                                        if (oFeatureOwnedByPole[j].FNO == 105)
                                        {
                                            bGuyFound = true;
                                            break;
                                        }
                                    }
                                }
                                if (!bGuyFound)
                                {
                                    ErrorPriorityArray[0] = m_sPriority;
                                    ErrorMessageArray[0]  = "Primary Conductor with a dead end should have a guy present";
                                }
                            }
                        }
                    }
                }

                if (gTValidationLogger != null)
                {
                    gTValidationLogger.LogEntry("TIMING", "END", "Conductor Validation Exit", "N/A", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Conductor Validation Relationship Attribute Interface \n" + ex.Message, "G/Technology");
            }
            finally
            {
                if (relationShipService != null)
                {
                    relationShipService.Dispose();
                    relationShipService = null;
                }
            }
        }
Beispiel #28
0
        //public string node1Structure

        public bool ProcessSelectSet()
        {
            bool bReturnValue = false;

            try
            {
                m_aSortedPoints = new CablePullPoint[1];
                m_aSegments     = new CablePullSegment[1];

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                relationshipService.DataContext = m_Application.DataContext;
                int index = 0;
                m_SelectedFID = oGTDCKeys[index].FID;
                m_SelectedFNO = oGTDCKeys[index].FNO;
                relationshipService.ActiveFeature = m_Application.DataContext.OpenFeature(m_SelectedFNO, m_SelectedFID);

                if (relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value != null)
                {
                    m_featureState = relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value.ToString();
                }

                if (relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.RecordCount > 0)
                {
                    relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.MoveFirst();
                    m_CU = relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.Fields["CU_C"].Value.ToString();
                }

                if (CommonDT.AllowCUEdit(relationshipService.ActiveFeature))
                {
                    m_AllowCUEdit = true;
                }
                else
                {
                    m_AllowCUEdit = false;
                }

                int ductBankFID = 0;

                try
                {
                    IGTKeyObjects relatedDuctKOs = relationshipService.GetRelatedFeatures(6);

                    if (relatedDuctKOs.Count > 0)
                    {
                        relationshipService.ActiveFeature = relatedDuctKOs[0];
                        IGTKeyObjects relatedFormationKOs = relationshipService.GetRelatedFeatures(6);
                        if (relatedFormationKOs.Count > 0)
                        {
                            relationshipService.ActiveFeature = relatedFormationKOs[0];
                            IGTKeyObjects relatedDuctBankKOs = relationshipService.GetRelatedFeatures(3);
                            if (relatedDuctBankKOs.Count > 0)
                            {
                                ductBankFID = relatedDuctBankKOs[0].FID;
                                relationshipService.ActiveFeature = relatedDuctBankKOs[0];
                                IGTKeyObjects structure1 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                IGTKeyObjects structure2 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                                if (structure1.Count > 0)
                                {
                                    IGTKeyObject thing = structure1[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node1Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                                if (structure2.Count > 0)
                                {
                                    IGTKeyObject thing = structure2[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node2Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_NO_RELATED_DUCTBANK, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                catch
                {
                }


                // Get the primary geographic and primary detail componentviews from metadata
                // Get the selected object matching the primary geographic or primary detail componentviews in that order
                Recordset metadataRS           = m_Application.DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + ConstantsDT.FNO_DUCTBANK);
                short     primaryGeographicCNO = 0;
                short     primaryDetailCNO     = 0;
                if (metadataRS.RecordCount > 0)
                {
                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value))
                    {
                        primaryGeographicCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value);
                    }

                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value))
                    {
                        primaryDetailCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value);
                    }
                }

                IGTDDCKeyObjects oDuctBankGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oDuctBankGTDCKeys = m_Application.DataContext.GetDDCKeyObjects(ConstantsDT.FNO_DUCTBANK, ductBankFID, GTComponentGeometryConstants.gtddcgAllPrimary);

                metadataRS = m_Application.DataContext.MetadataRecordset("G3E_COMPONENTVIEWS_OPTABLE");
                string filter = "(g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryGeographicCNO + ") or (g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryDetailCNO + ")";
                metadataRS.Filter = filter;
                if (metadataRS.RecordCount > 0)
                {
                    metadataRS.Sort = "g3e_detail";

                    while (!metadataRS.EOF)
                    {
                        if (metadataRS.Fields["G3E_VIEW"].Value.ToString() == oDuctBankGTDCKeys[index].ComponentViewName)
                        {
                            //m_SelectedFID = oGTDCKeys[index].FID;
                            //m_SelectedFNO = oGTDCKeys[index].FNO;
                            break;
                        }
                        metadataRS.MoveNext();
                        index++;
                    }


                    IGTGeometry         oGeometry     = oDuctBankGTDCKeys[index].Geometry;
                    IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();

                    if (oGeometry.Type == GTGeometryTypeConstants.gtgtPolylineGeometry || oGeometry.Type == GTGeometryTypeConstants.gtgtLineGeometry)
                    {
                        // Geometry is okay to use as it is.
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry;
                        bReturnValue  = true;
                    }
                    else if (oGeometry.Type == GTGeometryTypeConstants.gtgtCompositePolylineGeometry)
                    {
                        // Any arcs must be stroked to line segments
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry.Stroke();
                        bReturnValue  = true;
                    }
                    else
                    {
                        // Invalid geometry type.
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_GEOMETRY, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        bReturnValue = false;
                    }

                    if (bReturnValue)
                    {
                        // Store each point of the line in the feature's geometry
                        StoreLinePoints(oPolyLineGeom, m_SelectedFNO, m_SelectedFID);

                        //Compute the included angles for each set of three points in the sorted array
                        ComputeIncludedAngles();

                        //Build the arrays for the segments and bends that will comprise the pull
                        if (!BuildSegmentsAndBends())
                        {
                            bReturnValue = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_COMPONENT_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    bReturnValue = false;
                }
            }
            catch (Exception e)
            {
                m_aSegments     = new CablePullSegment[1];
                m_aBends        = new double[1];
                m_aSortedPoints = new CablePullPoint[1];
            }

            return(bReturnValue);
        }
Beispiel #29
0
        /// <summary>
        /// Data Source of the datagridview.
        /// </summary>
        /// <returns></returns>
        public DataTable GetData()
        {
            DataTable gridDataTable = GridStructure();
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                int    count              = 0;
                string strAction          = "";
                string strEnergize        = "";
                int    Quantity           = 1;
                string strWattage         = "";
                string strLampType        = "";
                string strRateSchedule    = "";
                string strLuminaireStyle  = "";
                string strIdentifyingType = "";
                string strAddress         = "";
                string strESILocation     = "";
                string strOwnerType       = "";
                string strOwnerCU         = "";
                string strLocation        = "";

                int Latitude  = 0;
                int Longitude = 0;


                IGTComponent gTComponent;

                foreach (IGTKeyObject keyObject in m_SelectedKeyObjects)
                {
                    strESILocation = m_SelectedEsiLocations[count];

                    gTComponent = keyObject.Components["COMMON_N"];

                    GetCommonAttributes(ref strAction, ref strOwnerType, ref strLocation, ref Latitude, ref Longitude, gTComponent);

                    if (strAction == "PPI" || strAction == "ABI" || strAction == "INI")
                    {
                        strAction = "A";
                    }
                    else if (strAction == "PPR" || strAction == "ABO" || strAction == "OSR")
                    {
                        strAction = "R";
                    }
                    else
                    {
                        strAction = "";
                    }

                    if (strAction == "A")
                    {
                        Additions = Additions + 1;
                    }
                    else if (strAction == "R")
                    {
                        Removal = Removal + 1;
                    }

                    strEnergize = "Y";

                    gTComponent = keyObject.Components["STREETLIGHT_N"];

                    GetStreetLightAttributes(ref strWattage, ref strLampType, ref strLuminaireStyle, gTComponent);

                    strRateSchedule = GetRateSchedule(strRateSchedule, strESILocation);

                    gTComponent = keyObject.Components["COMP_UNIT_N"];

                    if (gTComponent != null && gTComponent.Recordset != null && gTComponent.Recordset.RecordCount > 0)
                    {
                        gTComponent.Recordset.MoveFirst();
                        if (!string.IsNullOrEmpty(Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value)))
                        {
                            strIdentifyingType = Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value);
                        }
                    }

                    relationShipService.ActiveFeature = keyObject;
                    relationShipService.DataContext   = m_gTDataContext;
                    IGTKeyObjects gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(3);

                    if (gTOwnerKeyObjects.Count > 0)
                    {
                        foreach (IGTKeyObject keyOwner in gTOwnerKeyObjects)
                        {
                            gTComponent = keyOwner.Components["COMP_UNIT_N"];
                            if (gTComponent != null && gTComponent.Recordset != null && gTComponent.Recordset.RecordCount > 0)
                            {
                                gTComponent.Recordset.MoveFirst();
                                if (!string.IsNullOrEmpty(Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value)))
                                {
                                    strOwnerCU = Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value);
                                }
                            }
                        }
                    }


                    strIdentifyingType = strIdentifyingType + "\n" + strOwnerCU + "\n" + strOwnerType;

                    if (count <= 9)
                    {
                        strAddress = "0" + (count + 1);
                    }
                    else
                    {
                        strAddress = Convert.ToString(count);
                    }

                    strAddress = strAddress + "-" + Latitude + "/" + Longitude + "\n";
                    strAddress = strAddress + strLocation;


                    gridDataTable.Rows.Add(strESILocation, strAction, strEnergize, Quantity, strWattage, strLampType, strRateSchedule, strLuminaireStyle, strIdentifyingType, strAddress);

                    count++;
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                relationShipService.Dispose();
                relationShipService = null;
            }

            return(gridDataTable);
        }