/// <summary> /// Get Left Origin Point /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetLeftOriginPoint(IGTKeyObject m_KeyObject, IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry, IGTKeyObjects m_gtRelativeLines) { try { //Get Left Origin Point IGTPoint m_gtLeftOriginPoint = null; IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); m_gtRelationshipService.DataContext = m_gtApplication.DataContext; if (m_rlnode2 != 0) { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, xOffset, 0); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); //establish the relationship m_gtRelationshipService.ActiveFeature = m_KeyObject; m_gtRelationshipService.SilentEstablish(iRNO, m_gtRelativeLines[0], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, -xOffset, 0); m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0; m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); } m_gtRelationshipService = null; return(m_gtLeftOriginPoint); } catch { throw; } }
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; } }
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; } }
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); } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } } }
/// <summary> /// Get Left Origin Point /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetLeftOriginPoint(IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry, IGTKeyObjects m_gtRelativeLines) { try { //Get Left Origin Point IGTPoint m_gtLeftOriginPoint = null; IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); if ((m_gtRelativePoint.FNO == transformerUGFNO) || (m_gtRelativePoint.FNO == AutotransfomerFNO)) { //establish the connectivity for Relative point with Linear feature EstablishRelationship(m_gtRelativePoint, m_gtRelativeLines); } else { //set the node value for Bypass point placed at top if (m_KeyObjectCollection[1] != null) { m_gtRelationshipService.DataContext = m_gtApplication.DataContext; m_gtRelationshipService.ActiveFeature = m_KeyObjectCollection[1]; m_gtRelationshipService.SilentDelete(iRNO); IGTComponent m_gtBypassComp = m_KeyObjectCollection[1].Components.GetComponent(ConnectivityCNO); m_gtBypassComp.Recordset.Fields["NODE_1_ID"].Value = 0; m_gtBypassComp.Recordset.Fields["NODE_2_ID"].Value = 0; m_gtBypassComp.Recordset.Update(); } } //set the node value for Bypass point placed at Left if ((m_rlnode2 != 0) && (m_rlnode2 == m_rpnode1)) { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode2; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, -xOffset, 0); m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = m_rlnode1; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } m_gtRelationshipService = null; return(m_gtLeftOriginPoint); } catch { throw; } }
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); } }
public bool EstablishConnectivity(IGTKeyObject activeKO, IGTKeyObject relatedKO, GTRelationshipOrdinalConstants activeRelationshipOrdinal, GTRelationshipOrdinalConstants relatedRelationshipOrdinal) { bool returnValue = false; IGTRelationshipService relationshipService = null; Int32 node1 = 0; Int32 node2 = 0; Recordset connRS = null; try { connRS = relatedKO.Components.GetComponent(11).Recordset; if (connRS.RecordCount > 0) { connRS.MoveFirst(); node1 = Convert.ToInt32(connRS.Fields["NODE_1_ID"].Value); node2 = Convert.ToInt32(connRS.Fields["NODE_2_ID"].Value); } relationshipService = GTClassFactory.Create <IGTRelationshipService>(); relationshipService.DataContext = m_dataContext; relationshipService.ActiveFeature = activeKO; if (relationshipService.AllowSilentEstablish(relatedKO)) { relationshipService.SilentEstablish(14, relatedKO, activeRelationshipOrdinal, relatedRelationshipOrdinal); } returnValue = true; } catch { //returnValue = false; returnValue = true; // Reset connectivity if (connRS != null) { if (connRS.RecordCount > 0) { connRS.MoveFirst(); connRS.Fields["NODE_1_ID"].Value = node1; connRS.Fields["NODE_2_ID"].Value = node2; } } } relationshipService.Dispose(); return(returnValue); }
/// <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; } }
/// <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; } } }
/// <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); }
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; } }
/// <summary> /// Set Right Node Values /// </summary> /// <param name="m_gtComponents"></param> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtLineGeometry"></param> /// <returns></returns> private IGTPoint GetRightOriginPoint(IGTKeyObject m_KeyObject, IGTKeyObject m_gtRelativeLine, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry) { try { IGTPoint m_gtRightOriginPoint = null; IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); m_gtRelationshipService.DataContext = m_gtApplication.DataContext; //get the related feature IGTKeyObjects m_gtElbow = GetRelatedFeature(m_gtRelativePoint, iRNO, m_KeyObject.FNO); //delete the relationship to remove primary conductor m_gtRelationshipService.ActiveFeature = m_gtRelativePoint; m_gtRelationshipService.SilentDelete(iRNO, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtElbow[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update(); //establish the relationhip m_gtRelationshipService.SilentEstablish(iRNO, m_gtElbow[0], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2); m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtElbow[0].Components.GetComponent(ConnectivityCNO).Recordset.Update(); if (m_rlnode1 != 0) { m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, xOffset, 0); m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update(); //establish the relationhip m_gtRelationshipService.ActiveFeature = m_KeyObject; m_gtRelationshipService.SilentEstablish(iRNO, m_gtRelativeLine, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1); m_KeyObject.Components.GetComponent(ConnectivityCNO).Recordset.Update(); } else { m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, -xOffset, 0); m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0; } m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_gtRelationshipService = null; return(m_gtRightOriginPoint); } catch { throw; } }
/// <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; } }
/// <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); }
/// <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 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); }
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); }
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; } }
/// <summary> /// Establish ownership between street light and Miscellaneous Structure. /// </summary> /// <param name="gtStreetLightKObject"></param> private void EstablishOwnership(IGTKeyObject gtStreetLightKObject) { IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>(); try { Recordset ownerRNORecords = m_oGTDataContext.MetadataRecordset("G3E_RELATIONSHIPS_OPTABLE", "G3E_TYPE = 3 AND G3E_TABLE = 'G3E_OWNERSHIP_ELEC' AND G3E_USERNAME = '******'"); ownerRNORecords.MoveFirst(); gtRelationshipService.DataContext = m_oGTDataContext; gtRelationshipService.ActiveFeature = gtStreetLightKObject; if (gtRelationshipService.AllowSilentEstablish(gTOwnerKeyObject)) { gtRelationshipService.SilentEstablish(Convert.ToInt16(ownerRNORecords.Fields["G3E_RNO"].Value), gTOwnerKeyObject); } } catch { throw; } }
/// <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); } }
/// <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; } }
/// <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); }
/// <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; } }
public void CreateDuct(string sASSIGNMENT, int iPOS_HORZ_FROM, int iPOS_VERT_FROM, int iPOS_HORZ_TO, int iPOS_VERT_TO, int iSTALE_FLAG_FROM, int iSTALE_FLAG_TO) { IGTKeyObject tmpFeatureDuct = null; try { object oMissing = System.Reflection.Missing.Value; //Create fORMATION tmpFeatureDuct = m_oDataContext.NewFeature(csConstant.SHORT_DUCT); //NETELEM tmpFeatureDuct.Components["COMMON_N"].Recordset.MoveFirst(); //csGlobals.tmpFeatureFormation.Components["GC_NETELEM"].Recordset.Fields["FEATURE_STATE"].Value = dataGridViewExpansion.Rows[i].Cells["STATE"].Value.ToString(); //MAIN COMPONENT tmpFeatureDuct.Components["DUCT_N"].Recordset.MoveFirst(); //ASSIGNMENT,POS_HORZ_FROM,POS_HORZ_TO,POS_VERT_FROM,POS_VERT_TO,STALE_FLAG_FROM,STALE_FLAG_TO tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["ASSIGNMENT_ID"].Value = sASSIGNMENT; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_HORZ"].Value = iPOS_HORZ_FROM; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_HORZ"].Value = iPOS_HORZ_TO; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_VERT"].Value = iPOS_VERT_FROM; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_VERT"].Value = iPOS_VERT_TO; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_STALE_FLAG"].Value = iSTALE_FLAG_FROM; tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_STALE_FLAG"].Value = iSTALE_FLAG_TO; IGTRelationshipService gServices = GTClassFactory.Create <IGTRelationshipService>(); gServices.DataContext = m_oDataContext; gServices.ActiveFeature = m_FormationFeature; gServices.SilentEstablish(csConstant.iContains, tmpFeatureDuct); gServices.Dispose(); gServices = null; } catch (Exception ex) { MessageBox.Show(ex.Message, "Create Duct", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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; } }