/// <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> /// Verify Selected objects are streetlights or not. /// </summary> /// <returns></returns> public bool IsSelectSetStreetLight() { IList <int> SelectedFeatureIDList = new List <int>(); bool returnValue = true; try { if (m_gTDDCKeyObjects.Count > 0) { foreach (IGTDDCKeyObject ddcKey in m_gTDDCKeyObjects) { if (!SelectedFeatureIDList.Contains(ddcKey.FID)) { SelectedFeatureIDList.Add(ddcKey.FID); if (ddcKey.FNO != 56) { returnValue = false; } m_SelectedKeyObjects.Add(m_gTDataContext.OpenFeature(56, ddcKey.FID)); } } } } catch { throw; } dataLayer.m_SelectedKeyObjects = m_SelectedKeyObjects; return(returnValue); }
//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> /// Locate the associated Work Point feature (if it exists) for the active WR job. /// </summary> /// <param name="gTCommonComponent">Common component</param> /// <returns></returns> public IGTKeyObjects FindWorkpointsOfFeature(IGTComponent gTCommonComponent) { IGTKeyObjects workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); try { if (gTCommonComponent != null && gTCommonComponent.Recordset.RecordCount > 0) { gTCommonComponent.Recordset.MoveFirst(); if (DBNull.Value != gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value) { string strStructureId = Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value); if (!string.IsNullOrEmpty(strStructureId)) { string sql = "select g3e_fid,g3e_fno from workpoint_n where STRUCTURE_ID=? and wr_nbr=?"; Recordset rs = m_gTDataContext.OpenRecordset(sql, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText, strStructureId, m_gTDataContext.ActiveJob); if (rs != null && 0 < rs.RecordCount) { if (1 < rs.RecordCount) { // If we get multiple workpoints for the same structure that below to the same WR, // then that's an error and validation should stop. throw new Exception("Multiple Workpoints found having the same Structure ID and WR values.", new Exception("MULTIPLE WORKPOINTS")); } rs.MoveFirst(); do { workPointKeyObjects.Add(m_gTDataContext.OpenFeature(Convert.ToInt16(rs.Fields["g3e_fno"].Value), Convert.ToInt32(rs.Fields["g3e_fid"].Value))); rs.MoveNext(); } while (!rs.EOF); } } } } } catch { throw; } return(workPointKeyObjects); }
/// <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> /// 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; } }
/// <summary> /// Locate the associated Work Point feature (if it exists) for the active WR job. /// </summary> /// <param name="gTCommonComponent">Common component</param> /// <returns></returns> private IGTKeyObjects FindWorkpointsOfFeature(IGTComponent gTCommonComponent) { string strStructureId = null; string sql = ""; Recordset rsWorkpoints = null; int count = 0; IGTKeyObjects workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); try { if (gTCommonComponent != null && gTCommonComponent.Recordset.RecordCount > 0) { gTCommonComponent.Recordset.MoveFirst(); strStructureId = Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value); } if (!string.IsNullOrEmpty(strStructureId)) { sql = string.Format("select G3E_FID,G3E_FNO from WORKPOINT_N where STRUCTURE_ID = '{0}' and WR_NBR = '{1}'", strStructureId, m_dataContext.ActiveJob); rsWorkpoints = m_dataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, null); if (rsWorkpoints != null && rsWorkpoints.RecordCount > 0) { workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); rsWorkpoints.MoveFirst(); while (!rsWorkpoints.EOF) { IGTKeyObject workPoint = m_dataContext.OpenFeature(Convert.ToInt16(rsWorkpoints.Fields["G3E_FNO"].Value), Convert.ToInt32(rsWorkpoints.Fields["G3E_FID"].Value)); workPointKeyObjects.Add(workPoint); rsWorkpoints.MoveNext(); } } else if (m_NewWorkpointFidList.Count > 0) { foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList) { if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value)) { IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value); workPointKeyObjects.Add(workPoint); } } } } else if (m_NewWorkpointFidList.Count > 0) { foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList) { if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value)) { IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value); workPointKeyObjects.Add(workPoint); } } } } catch { throw; } return(workPointKeyObjects); }