private ADODB.Recordset CreateInMemoryADORS(IGTKeyObjects DDCKeyObjects) { ADODB.Recordset shapeADORecordset = new ADODB.Recordset(); try { shapeADORecordset.Fields.Append("G3E_FNO", ADODB.DataTypeEnum.adInteger, 0, ADODB.FieldAttributeEnum.adFldFixed, null); shapeADORecordset.Fields.Append("G3E_FID", ADODB.DataTypeEnum.adInteger, 0, ADODB.FieldAttributeEnum.adFldFixed, null); shapeADORecordset.Open(System.Type.Missing, System.Type.Missing, ADODB.CursorTypeEnum.adOpenUnspecified, ADODB.LockTypeEnum.adLockUnspecified, 0); foreach (IGTKeyObject keyObject in DDCKeyObjects) { shapeADORecordset.AddNew(System.Type.Missing, System.Type.Missing); shapeADORecordset.Fields["G3E_FNO"].Value = keyObject.FNO; shapeADORecordset.Fields["G3E_FID"].Value = keyObject.FID; shapeADORecordset.Update(System.Type.Missing, System.Type.Missing); } } 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); } return(shapeADORecordset); }
/// <summary> /// Gives the list of all directly connected point features to active feature which have different owner other than active feature owner /// </summary> /// <param name="activeFeature"></param> /// <param name="relatedFeatures"></param> /// <param name="noMatchingOwnerCnt"></param> private void GetActiveAndRelatedFeaturesOwners(IGTKeyObject activeFeature, IGTKeyObjects relatedFeatures, ref int noMatchingOwnerCnt) { int aOwnerID = 0; int rOwnerID = 0; IGTGeometry relatedPrimaryGeom = null; try { GetOwnerID(activeFeature.Components.GetComponent(oCNO).Recordset, ref aOwnerID); foreach (IGTKeyObject relatedFeature in relatedFeatures) { GetPrimaryGeometry(relatedFeature, ref relatedPrimaryGeom); if (relatedPrimaryGeom != null && relatedPrimaryGeom.Type == "OrientedPointGeometry") { GetOwnerID(relatedFeature.Components.GetComponent(oCNO).Recordset, ref rOwnerID); if (aOwnerID != 0 && (rOwnerID != aOwnerID) && CheckValidOwner(relatedFeature.FNO, aOwnerID)) { noMatchingOwnerCnt++; } } } } catch { throw; } }
private bool CheckNotOwnedByPrimarySwitchGear(IGTKeyObject activeFeature) { bool notOwned = true; try { IGTKeyObjects ownerFeatures = GetRelatedFeatures(activeFeature, 3); if (ownerFeatures != null) { foreach (IGTKeyObject owner in ownerFeatures) { if (owner.FNO == 19) { notOwned = false; break; } } } } catch { throw; } return(notOwned); }
public virtual void StartPlacement(Intergraph.GTechnology.API.IGTPlacementTechniqueHelper PTHelper, Intergraph.GTechnology.API.IGTKeyObject KeyObject, Intergraph.GTechnology.API.IGTKeyObjects KeyObjectCollection) { try { m_PTHelper = PTHelper; IGTKeyObject m_KeyObject = KeyObject; IGTKeyObjects m_KeyObjectCollection = KeyObjectCollection; if (bSilent) { m_PTHelper.StatusBarPromptsEnabled = false; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); // End Placement m_PTHelper.EndPlacement(); } else { m_PTHelper.StatusBarPromptsEnabled = true; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); } } catch (Exception ex) { MessageBox.Show("Error in Isolation Scenario PlacementTechnic Interface \n" + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <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 is called when pad/vault mounted switch gear placement is started /// </summary> /// <param name="PTHelper"></param> /// <param name="KeyObject"></param> /// <param name="KeyObjectCollection"></param> public void StartPlacement(IGTPlacementTechniqueHelper PTHelper, IGTKeyObject KeyObject, IGTKeyObjects KeyObjectCollection) { try { m_PTHelper = PTHelper; m_KeyObject = KeyObject; m_KeyObjectCollection = KeyObjectCollection; m_PTHelper.ConstructionAidsEnabled = Intergraph.GTechnology.API.GTConstructionAidsEnabledConstants.gtptConstructionAidsNone; m_PTHelper.ConstructionAidDynamicsEnabled = false; m_PTHelper.StatusBarPromptsEnabled = false; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); m_GTApplication = GTClassFactory.Create <IGTApplication>().Application; m_Arguments = m_ActiveGraphicComponent.Arguments; m_ActiveMapWindow = m_GTApplication.ActiveMapWindow; string ownerFeatureName = m_ActiveMapWindow.DetailID == 0 ? "Pad" : "Vault"; m_GTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Click to select an existing " + ownerFeatureName + " feature to Own the Primary switch gear which is to be placed adjacent to it."); } catch (Exception ex) { MessageBox.Show(ex.Message, Caption); } }
/// <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> /// Get Node Values /// </summary> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtRelativeLines"></param> /// <returns></returns> public void GetNodeValues(IGTKeyObjects m_gtRelativeLines) { try { Recordset m_rsRelativeFirstLine = m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset; if (m_rsRelativeFirstLine != null) { if (!(m_rsRelativeFirstLine.EOF && m_rsRelativeFirstLine.BOF) && !(m_rsRelativeFirstLine.EOF && m_rsRelativeFirstLine.BOF)) { m_rsRelativeFirstLine.MoveFirst(); //Get the related line node value if (!Convert.IsDBNull(m_rsRelativeFirstLine.Fields["NODE_1_ID"].Value)) { m_rlnode1 = Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_1_ID"].Value); } if (!Convert.IsDBNull(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value)) { m_rlnode2 = Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value); } } } } catch { throw; } }
public Dictionary <IGTKeyObject, IGTComponents> GetOwnedFeatureCollection() { Dictionary <IGTKeyObject, IGTComponents> oReturnCollection = new Dictionary <IGTKeyObject, IGTComponents>(); IGTJobManagementService oJobManagement = GTClassFactory.Create <IGTJobManagementService>(); try { oJobManagement.DataContext = m_oApp.DataContext; IGTKeyObjects oRelatedFeatures = GetRelatedFeaturesAtStructure(m_StructureKeyObject); ADODB.Recordset rs = oJobManagement.FindPendingEdits(); if (rs != null && rs.RecordCount > 0) { Features oFeatureCollection = new Features(oRelatedFeatures); oReturnCollection = oFeatureCollection.GetFeatureComponentCollection(); } } 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); } return(oReturnCollection); }
/// <summary> /// Delete Street light and Miscellaneous Structure Features /// </summary> /// <param name="p_delFeatures">Collection of delete objects</param> /// <returns></returns> public void DeleteFeatures(IGTKeyObjects p_delFeatures) { Recordset compRS = null; try { if (p_delFeatures != null && p_delFeatures.Count > 0) { for (int i = 0; i < p_delFeatures.Count; i++) { foreach (IGTComponent component in p_delFeatures[i].Components) { compRS = component.Recordset; if (compRS != null && compRS.RecordCount > 0) { compRS.MoveFirst(); while (!compRS.EOF) { compRS.Delete(); compRS.Update(); compRS.MoveNext(); } } } } } } catch { throw; } }
public override void StartPlacement(IGTPlacementTechniqueHelper PTHelper, Intergraph.GTechnology.API.IGTKeyObject KeyObject, Intergraph.GTechnology.API.IGTKeyObjects KeyObjectCollection) { try { m_PTHelper = PTHelper; IGTKeyObject m_KeyObject = KeyObject; IGTKeyObjects m_KeyObjectCollection = KeyObjectCollection; if (bSilent) { m_PTHelper.StatusBarPromptsEnabled = false; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); } else { //Get the Argument value linearFNOs = new List <int>(Array.ConvertAll(m_GComp.Arguments.GetArgument(0).ToString().Split(','), int.Parse)); m_PTHelper.StatusBarPromptsEnabled = true; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); } } catch (Exception ex) { MessageBox.Show("Error in Isolation Scenario PlacementTechnic Interface - StartPlacement \n" + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } }
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; } }
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; } }
/// <summary> /// Method to return Miscellaneous Structure of type Street Light Point which is owner of Located Street Light which is getting removed. /// </summary> /// <param name="relatedFeatures">RelatedFeatures list of Located StreetLight</param> /// <param name="streetLightFID">Located Street Light FID</param> /// <returns></returns> private IGTKeyObject CheckForMiscellaneousStructure(IGTKeyObjects relatedFeatures, int streetLightFID) { IGTKeyObject structureFeature = null; try { foreach (IGTKeyObject relatedFeature in relatedFeatures) { if (relatedFeature.FNO == 107) { relatedFeature.Components.GetComponent(10701).Recordset.MoveFirst(); if (Convert.ToString(relatedFeature.Components.GetComponent(10701).Recordset.Fields["TYPE_C"].Value) == "SP") { StreetLightImportUtility importUtility = new StreetLightImportUtility(m_oGTDataContext); relatedFeatures = importUtility.GetRelatedFeatures(relatedFeature, 2); if (relatedFeatures.Count == 1 && relatedFeatures[0].FID == streetLightFID) { structureFeature = relatedFeatures[0]; } } } } } catch { throw; } return(structureFeature); }
public virtual void StartPlacement(IGTPlacementTechniqueHelper PTHelper, IGTKeyObject KeyObject, IGTKeyObjects KeyObjectCollection) { try { m_PTHelper = PTHelper; IGTKeyObject m_KeyObject = KeyObject; IGTKeyObjects m_KeyObjectCollection = KeyObjectCollection; if (bSilent) { // Disable construction aids and status bar prompts for silent placement techinque. m_PTHelper.ConstructionAidsEnabled = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone; m_PTHelper.ConstructionAidDynamicsEnabled = false; m_PTHelper.StatusBarPromptsEnabled = false; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); // End Placement m_PTHelper.EndPlacement(); } else { m_PTHelper.StatusBarPromptsEnabled = true; m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection); } } catch (Exception ex) { MessageBox.Show("Error in Isolation Scenario PlacementTechnic Interface \n" + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Finds and Validates the workpoints associated to the input component parameter. /// </summary> /// <param name="gTCommonComponent">Common component</param> private void CreateOrUpdateWorkpoint(IGTComponent gTCommonComponent, bool isLinear, int ownerCount) { try { IGTKeyObjects gTKeyObjects = FindWorkpointsOfFeature(gTCommonComponent); if (gTKeyObjects != null) { if (gTKeyObjects.Count <= 0) { CreateNewWorkpointFeature(Convert.ToInt16(gTCommonComponent.Recordset.Fields["G3E_FNO"].Value), Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value), isLinear, Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value), ownerCount); } else { UpdateWorkpointComponents(Convert.ToInt16(gTCommonComponent.Recordset.Fields["G3E_FNO"].Value), Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value), gTKeyObjects[0], false, Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value), ownerCount, isLinear); } } } catch { throw; } }
//public void SynchronizeWorkPointForObsoleteCUs() //{ // IGTKeyObject oKeyObject = GTClassFactory.Create<IGTKeyObject>(); // try // { // foreach (KeyValuePair<int, Int16> item in m_WorkPointsKeyObjects) // { // oKeyObject = m_oApp.DataContext.OpenFeature(item.Value, item.Key); // DeleteObsoleteCURecords(oKeyObject); // } // } // 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); // } //} public void SynchronizeWorkPointsForDiscardedFeatures() { IGTKeyObjects oKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); IGTKeyObject oKeyObject = GTClassFactory.Create <IGTKeyObject>(); try { foreach (KeyValuePair <int, Int16> item in m_WorkPointsKeyObjects) { oKeyObject = m_oApp.DataContext.OpenFeature(item.Value, item.Key); if (DiscardWorkPoint(oKeyObject)) { oKeyObjects.Add(oKeyObject); } // DeleteObsoleteCURecords(oKeyObject); } if (oKeyObjects.Count > 0) { ADODB.Recordset rsDiscardRecordSet = CreateInMemoryADORS(oKeyObjects); m_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Synchronizing Workpoints..."); m_jobManagement.DiscardFeatureEdits(rsDiscardRecordSet); } } 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> /// Establish Relationship /// </summary> /// <param name="m_gtRelativePoint"></param> /// <param name="m_gtRelativeLines"></param> /// <returns></returns> public void EstablishRelationship(IGTKeyObject m_gtRelativePoint, IGTKeyObjects m_gtRelativeLines) { try { //Fetch the required components Recordset m_rsRelativeFirstLine = m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset; if (m_rsRelativeFirstLine != null) { if (!(m_rsRelativeFirstLine.EOF && m_rsRelativeFirstLine.BOF) && !(m_rsRelativeFirstLine.EOF && m_rsRelativeFirstLine.BOF)) { m_rsRelativeFirstLine.MoveFirst(); // check if opposite nodes are connected otherwise .. change the node of the related feature if (m_gtRelativeLines.Count == 2) { Recordset m_rsRelativeSecondLine = m_gtRelativeLines[1].Components.GetComponent(ConnectivityCNO).Recordset; if (m_rsRelativeSecondLine != null) { if (!(m_rsRelativeSecondLine.EOF && m_rsRelativeSecondLine.BOF) && !(m_rsRelativeSecondLine.EOF && m_rsRelativeSecondLine.BOF)) { m_rsRelativeSecondLine.MoveFirst(); if ((Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value)) != (Convert.ToInt64(m_rsRelativeSecondLine.Fields["NODE_1_ID"].Value))) { m_rpnode1 = Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value); m_rpnode2 = Convert.ToInt64(m_rsRelativeSecondLine.Fields["NODE_1_ID"].Value); } else { m_rpnode1 = Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value); //Get the node value from node edge connectivity sequence Int64 iNodeID = GetNextNodeID(); m_rpnode2 = iNodeID; m_rsRelativeSecondLine.Fields["NODE_1_ID"].Value = iNodeID; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = iNodeID; m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update(); m_rsRelativeSecondLine.Update(); } } } } //check if active feature is connected at end if (m_gtRelativeLines.Count == 1) { if ((Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_2_ID"].Value) != Convert.ToInt64(m_rsRelativeFirstLine.Fields["NODE_1_ID"].Value)) && (Convert.ToInt64(m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value) != 0)) { m_rpnode1 = Convert.ToInt64(m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value); m_rpnode2 = 0; } } } } } catch { throw; } }
private void ProcessActiveStructureDDC(IGTDDCKeyObjects ddcStructureList) { try { foreach (IGTDDCKeyObject ddcobj in ddcStructureList) { if ((ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) || (ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtPointGeometry)) { IGTKeyObject koStructure = oDC.OpenFeature(ddcobj.FNO, ddcobj.FID); oRelationService.ActiveFeature = koStructure; IGTKeyObjects koOwnsList = oRelationService.GetRelatedFeatures(2); if (koOwnsList == null) { continue; } if (koOwnsList.Count == 0) { continue; } GTActiveStructure oStructure = new GTActiveStructure(); oStructure.G3E_FID = ddcobj.FID; oStructure.G3E_FNO = ddcobj.FNO; IGTOrientedPointGeometry ogeom = ddcobj.Geometry as IGTOrientedPointGeometry; oStructure.OGG_X1 = ogeom.Origin.X; oStructure.OGG_Y1 = ogeom.Origin.Y; oStructure.OGG_Z1 = ogeom.Origin.Z; string sid = CommandUtilities.GetCommonNStructureID(koStructure, oDiag); if (koOwnsList != null) { if (koOwnsList.Count > 0) { foreach (IGTKeyObject koObj in koOwnsList) { if (koObj.FNO == 56) { oStructure.StreetlightKOList.Add(koObj); } } } } this.oActiveStructureList.Add(oStructure); } } } catch (Exception ex) { CommandUtilities.LogException(oDiag, "ProcessActiveStreetLightDDC", ex); throw ex; } }
/// <summary> /// Method to delete StreetLight. /// </summary> /// <param name="streetLightAttributeRS">Recordset of StreetLight Attribute</param> /// <param name="locatable">Bool value whether StreetLight is Located to delete</param> /// <returns></returns> private void DeleteStreetLight(Recordset streetLightAttributeRS, bool locatable) { IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>(); IGTKeyObjects deleteFeatures = GTClassFactory.Create <IGTKeyObjects>(); IGTKeyObject feature = GTClassFactory.Create <IGTKeyObject>(); try { StreetLightImportUtility importUtility = new StreetLightImportUtility(m_oGTDataContext); if (!m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Begin("Importing Street Light(s) using Import Tool"); } if (locatable) { streetLightAttributeRS.MoveFirst(); feature = m_oGTDataContext.OpenFeature(Convert.ToInt16(streetLightAttributeRS.Fields["G3E_FNO"].Value), Convert.ToInt32(streetLightAttributeRS.Fields["G3E_FID"].Value)); deleteFeatures.Add(feature); relatedFeatures = importUtility.GetRelatedFeatures(feature, 3); if (relatedFeatures.Count > 0) { feature = CheckForMiscellaneousStructure(relatedFeatures, feature.FID); if (feature != null) { deleteFeatures.Add(feature); } } } else { streetLightAttributeRS.MoveFirst(); while (!streetLightAttributeRS.EOF) { feature = m_oGTDataContext.OpenFeature(Convert.ToInt16(streetLightAttributeRS.Fields["G3E_FNO"].Value), Convert.ToInt32(streetLightAttributeRS.Fields["G3E_FID"].Value)); deleteFeatures.Add(feature); streetLightAttributeRS.MoveNext(); } } importUtility.DeleteFeatures(deleteFeatures); if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(true); m_oGTTransactionManager.RefreshDatabaseChanges(); } } 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> /// Checks whether active feature Owner2 feature has Work point or not and if present WP number is equal to Related WP. /// </summary> /// <param name="ownerKeyObject"></param> /// <param name="relatedWP"></param> /// <param name="noWorkPoint"></param> /// <param name="noMatchingWorkPoint"></param> /// <param name="strArgument1"></param> /// <param name="strArgument2"></param> private void CheckValidationForOwner2Feature(IGTKeyObject ownerKeyObject, int relatedWP, ref bool noWorkPoint, ref bool noMatchingWorkPoint, ref string strArgument1, ref string strArgument2) { IGTKeyObjects gTKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); try { ownerKeyObject.Components.GetComponent(1).Recordset.MoveFirst(); strArgument1 = Convert.ToString(ownerKeyObject.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value); gTKeyObjects = FindWorkpointsOfFeature(ownerKeyObject.Components.GetComponent(1)); if (gTKeyObjects.Count <= 0) { noWorkPoint = true; noMatchingWorkPoint = true; } else { if (relatedWP != 0) { foreach (IGTKeyObject gtwpKey in gTKeyObjects) { if (gtwpKey.Components["WORKPOINT_N"] != null && gtwpKey.Components["WORKPOINT_N"].Recordset != null && gtwpKey.Components["WORKPOINT_N"].Recordset.RecordCount > 0) { gtwpKey.Components["WORKPOINT_N"].Recordset.MoveFirst(); if (!string.IsNullOrEmpty( Convert.ToString(gtwpKey.Components["WORKPOINT_N"].Recordset.Fields["WP_NBR"].Value))) { strArgument2 = Convert.ToString(gtwpKey.Components["WORKPOINT_N"].Recordset.Fields["WP_NBR"].Value); if (relatedWP != Convert.ToUInt32(gtwpKey.Components["WORKPOINT_N"].Recordset.Fields["WP_NBR"].Value)) { noMatchingWorkPoint = false; } } else { noMatchingWorkPoint = false; } } } } } } 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); } }
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; } }
/// <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> /// Custom Command activate method: This mwthos checks all validation and once it is passed RelocateFeature class will be called to relocate the feature. /// </summary> /// <param name="CustomCommandHelper"></param> public void Activate(IGTCustomCommandHelper CustomCommandHelper) { bool ccValidation = false; IGTKeyObjects relatedFeaturesOWB = GTClassFactory.Create <IGTKeyObjects>(); try { m_GTCustomCommandHelper = CustomCommandHelper; // check if the command is called multiple times for (int i = 0; i < m_gtApplication.Application.Properties.Keys.Count; i++) { if (string.Equals("RelocateFeatureCC", Convert.ToString(m_gtApplication.Application.Properties.Keys.Get(i)))) { return; } } m_gtApplication.Application.Properties.Add("RelocateFeatureCC", "RelocateFeature"); GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Relocate Feature custom command...."); ccValidation = ValidateCC(out relatedFeaturesOWB); if (ccValidation) { RelocateFeature feature_T = new RelocateFeature(m_GTCustomCommandHelper, m_gtApplication, m_oActiveKeyObject, relatedFeaturesOWB, TransactionManager, m_strStatus, m_strJobtype); GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Relocate Feature Custom Command: Please select new owner feature or press Esc key to exit the command."); } else { ExitCmd(); } } catch (Exception ex) { if (m_gtApplication.Application.Properties.Count > 0) { m_gtApplication.Application.Properties.Remove("RelocateFeatureCC"); } MessageBox.Show(ex.Message, "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } finally { } }
/// <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); }