/// <summary> /// Get boundaries touching Street Light /// </summary> /// <param name="fnoArray"></param> /// <returns></returns> private IDictionary <int, short> GetBoundaryTouchStreetLight(short[] fnoArray) { IDictionary <int, short> boundaryFids = new Dictionary <int, short>(); IGTSpatialService gtspatialService = GTClassFactory.Create <IGTSpatialService>(); gtspatialService.DataContext = _gtDataContext; //gtspatialService.FilterGeometry = _gtDataContext.GetDDCKeyObjects(_gtFeature.FNO, _gtFeature.FID, GTComponentGeometryConstants.gtddcgPrimaryGeographic)[0].Geometry; if (null != Feature.Components["STREETLIGHT_S"].Geometry) { gtspatialService.FilterGeometry = Feature.Components["STREETLIGHT_S"].Geometry; } else { throw new Exception("A Street Light's symbol geometry must exist before an ESI Location can be assigned to it."); } gtspatialService.Operator = GTSpatialOperatorConstants.gtsoTouches; Recordset rs = gtspatialService.GetResultsByFNO(fnoArray); if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); while (!rs.EOF) { boundaryFids.Add(Convert.ToInt32(rs.Fields["G3E_FID"].Value), Convert.ToInt16(rs.Fields["G3E_FNO"].Value)); rs.MoveNext(); } } return(boundaryFids); }
/// <summary> /// Performs buffer query with a given reference point, distance and FNO. /// FNO is the target feature FNO for which feature class instances are to be searched inside the buffer zone. /// </summary> /// <returns>Key Value pair of feature class instance and distance from reference point</returns> public Dictionary <int, double> PerformBufferQuery() { Recordset resultRecordSet = null; IGTGeometry gTGeometry = null; try { IGTOrientedPointGeometry gTOrientedPointGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); gTOrientedPointGeometry.Origin = m_referencePoint; IGTZoneService gTZoneService = GTClassFactory.Create <IGTZoneService>(); gTZoneService.ZoneWidth = m_distance; gTZoneService.InputGeometries = gTOrientedPointGeometry; IGTGeometry outPutGeometry = gTZoneService.OutputGeometries; IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_iGtDataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContains; spatialService.FilterGeometry = outPutGeometry; resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_targetFno }); if (resultRecordSet != null && resultRecordSet.RecordCount > 0) { resultRecordSet.MoveFirst(); m_fidDistancePair = new Dictionary <int, double>(); short primaryGraphicCno = GetPrimaryGraphicCno(m_targetFno); while (!resultRecordSet.EOF) { int fid = Convert.ToInt32(resultRecordSet.Fields["G3E_FID"].Value); gTGeometry = m_iGtDataContext.OpenFeature(m_targetFno, fid).Components.GetComponent(primaryGraphicCno).Geometry; if (gTGeometry != null) { m_fidDistancePair.Add(fid, CalculateDistanceFromReferencePoint(gTGeometry.FirstPoint)); } resultRecordSet.MoveNext(); } } return(m_fidDistancePair); } catch (Exception) { throw; } finally { if (resultRecordSet != null) { resultRecordSet.Close(); resultRecordSet = null; } } }
public void Execute() { int fId = 0; short fNo = 0; short treeTrimmingGraphicCno = 19002; short workPointFno = 191; short treeTrimmingFno = 190; short workPointGcNo = 19102; IGTOrientedPointGeometry workPointGeometry = null;; IGTKeyObject treeTrimmingFeature = null; IGTKeyObject workPointFeature = null; IGTComponent mainComponent = null; short cid = 0; try { IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_DataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContains; spatialService.FilterGeometry = Components.GetComponent(treeTrimmingGraphicCno).Geometry; Recordset rs = spatialService.GetResultsByFNO(new short[] { workPointFno }); if (rs != null) { IGTComponent tTVGraphic = Components.GetComponent(treeTrimmingGraphicCno); int tTVFid = Convert.ToInt32(tTVGraphic.Recordset.Fields["G3E_FID"].Value); treeTrimmingFeature = DataContext.OpenFeature(treeTrimmingFno, tTVFid); DeleteWorkLabelGeometry(treeTrimmingFeature); if (rs.RecordCount > 0) { rs.MoveFirst(); while (!rs.EOF) { fId = Convert.ToInt32(rs.Fields["G3E_FID"].Value.ToString()); workPointFeature = DataContext.OpenFeature(workPointFno, fId); mainComponent = workPointFeature.Components.GetComponent(workPointGcNo); mainComponent.Recordset.MoveFirst(); workPointGeometry = (IGTOrientedPointGeometry)mainComponent.Geometry; cid = (short)(cid + 1); CreateWorkLabelGeometry(workPointGeometry, treeTrimmingFeature, cid); rs.MoveNext(); } } } } catch (Exception ex) { MessageBox.Show("Error during Tree Trimming Labels execution." + ex.Message, "G/Technology"); } }
/// <summary> /// Method to Get Workpoint Recordset Contained by placed TreeTrimming feature. /// </summary> /// <param name="p_oTreeTrimmingfeature">Current placed feature</param> /// <returns></returns> public Recordset GetWorkpointRsContainedByTreeTrimming(IGTKeyObject p_oTreeTrimmingfeature) { Recordset wpRs = null; try { IGTSpatialService spatialService = GTClassFactory.Create<IGTSpatialService>(); spatialService.DataContext = m_oGTApp.DataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContains; spatialService.FilterGeometry = p_oTreeTrimmingfeature.Components.GetComponent(19002).Geometry; wpRs = spatialService.GetResultsByFNO(new short[] { 191 }); } catch (Exception) { throw; } return wpRs; }
/// <summary> /// This method performs point in polygon query and if the point exists inside polygon, then it returns the boundary feature recordset /// </summary> /// <returns></returns> public Recordset PerformPointInPolygon() { Recordset resultRecordSet = null; try { IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_iGtDataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContainedBy; IGTOrientedPointGeometry pointGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); IGTPoint gtPoint = GTClassFactory.Create <IGTPoint>(); gtPoint.X = m_iGtpoint.X; gtPoint.Y = m_iGtpoint.Y; gtPoint.Z = 0; pointGeometry.Origin = gtPoint; spatialService.FilterGeometry = pointGeometry; if (this.m_boundaryFid == 0) { resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_boundaryFno }); return(resultRecordSet); } // FID is provided. Retrieve the geometry of the boundary feature and check whether the boundary contains the point resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_boundaryFno }); if (resultRecordSet != null && resultRecordSet.RecordCount > 0) { resultRecordSet.MoveFirst(); while (!resultRecordSet.EOF) { if (Convert.ToString(resultRecordSet.Fields["G3E_FID"].Value) == this.m_boundaryFid.ToString()) { return(resultRecordSet); } resultRecordSet.MoveNext(); } } return(resultRecordSet); } catch (Exception) { throw; } }
/// <summary> /// This method performs point in polygon query and if the point exists inside polygon, then it returns the boundary feature recordset /// </summary> /// <returns></returns> public Recordset PerformPointInPolygon() { Recordset resultRecordSet = null; try { IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_iGtDataContext; if (this.m_boundaryFid == 0) { spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContainedBy; IGTOrientedPointGeometry pointGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); IGTPoint gtPoint = GTClassFactory.Create <IGTPoint>(); gtPoint.X = m_iGtpoint.X; gtPoint.Y = m_iGtpoint.Y; gtPoint.Z = 0; pointGeometry.Origin = gtPoint; spatialService.FilterGeometry = pointGeometry; resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_boundaryFno }); return(resultRecordSet); } // FID is provided. Retrieve the geometry of the boundary feature and check whether the boundary contains the point IGTKeyObject boundaryFeature = m_iGtDataContext.OpenFeature(this.m_boundaryFno, this.m_boundaryFid); IGTGeometry boundaryGeometry = (IGTGeometry)boundaryFeature.Components.GetComponent(FnoGraphicCnoPair[this.m_boundaryFno]).Geometry; spatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContains; spatialService.FilterGeometry = boundaryGeometry; resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_pointFno }); if (resultRecordSet != null && resultRecordSet.RecordCount > 0) { resultRecordSet = boundaryFeature.Components.GetComponent(FnoGraphicCnoPair[this.m_boundaryFno]).Recordset; } return(resultRecordSet); } catch (Exception) { throw; } }
public string CheckForBoundaryErrorValidate() { try { //get the esilocation for the street light if (m_Components["STREETLIGHT_N"].Recordset.EOF) { m_Components["STREETLIGHT_N"].Recordset.MoveFirst(); } var lightAccountID = m_Components["STREETLIGHT_N"].Recordset.Fields["ACCOUNT_ID"].Value; string SQL = "select ESI_LOCATION from STLT_ACCOUNT where ESI_LOCATION = ?"; Recordset RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, lightAccountID); string esiLocation; if (null != RS && RS.RecordCount > 0) { esiLocation = Convert.ToString(RS.Fields["ESI_LOCATION"].Value); } else { return(string.Empty); //do not go any further if an ESI_LOCATION cannot be found. This means the user has not entered one yet, so the symbol was likely just placed. } //query 1 SQL = "select a.boundary_id,bnd.bnd_fno,ai.g3e_field,ai.g3e_cno,ai.g3e_componenttable from stlt_account a join stlt_boundary bnd on a.boundary_class = bnd.bnd_class join g3e_attributeinfo_optable ai on bnd.bnd_id_ano = ai.g3e_ano where a.esi_location = ?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, esiLocation); if (null != RS && RS.RecordCount > 0) { string boundaryID = Convert.ToString(RS.Fields["BOUNDARY_ID"].Value); string g3eField1 = Convert.ToString(RS.Fields["G3E_FIELD"].Value); string componentTable1 = Convert.ToString(RS.Fields["G3E_COMPONENTTABLE"].Value); string g3eCno1 = Convert.ToString(RS.Fields["G3E_CNO"].Value); //decimal bndFNOdecimal = RS.Fields["BND_FNO"].Value; //short bndFNOshort = (short)bndFNOdecimal; //short[] bndFNOarray = new short[] { bndFNOshort }; Int16[] bndFNOarray = new Int16[] { Convert.ToInt16(RS.Fields["BND_FNO"].Value) }; IGTOrientedPointGeometry lightGeometry = (IGTOrientedPointGeometry)m_Components[m_ComponentName].Geometry; IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_DataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoTouches; spatialService.FilterGeometry = lightGeometry; Recordset features = spatialService.GetResultsByFNO(bndFNOarray); if (null != features && features.RecordCount > 0) { //query 2 SQL = "select bnd.bnd_type,ai.g3e_field,ai.g3e_cno,ai.g3e_componenttable from stlt_account a join stlt_boundary bnd on a.boundary_class = bnd.bnd_class join g3e_attributeinfo_optable ai on bnd.bnd_type_ano = ai.g3e_ano where a.esi_location = ?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, esiLocation); string bndType = null; string g3eField2 = null; string componentTable2 = null; string g3eCno2 = null; if (RS.RecordCount > 0) { bndType = Convert.ToString(RS.Fields["BND_TYPE"].Value); g3eField2 = Convert.ToString(RS.Fields["G3E_FIELD"].Value); componentTable2 = Convert.ToString(RS.Fields["G3E_COMPONENTTABLE"].Value); g3eCno2 = Convert.ToString(RS.Fields["G3E_CNO"].Value); } do { string fid = Convert.ToString(features.Fields["G3E_FID"].Value); //get the fid value for the current feature in feature list being iterated through. if (RS.RecordCount > 0) //if "type" attribute is found in query 2 { if (componentTable2.Equals(componentTable1)) //if component tables match { SQL = "select g3e_id from " + componentTable1 + " where g3e_cno = ? and g3e_fid = ? and " + g3eField1 + " =? and " + g3eField2 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, g3eCno2, fid, boundaryID, bndType); if (!(RS.RecordCount > 0) && jobManager.JobStatus.ToUpper() == "NON-WR") { return("GRAPHIC EDIT REJECTED: Street Light is located outside the associated Street Light Account boundary."); } else if (!(RS.RecordCount > 0)) { return("ACCOUNT # CONFLICT: Street Light is located outside the associated Street Light Account boundary."); } else { return(string.Empty); } } else //if component tables do not match { SQL = "select g3e_id from " + componentTable1 + " p join " + componentTable2 + " la on p.g3e_fid=la.g3e_fid where g3e_cno = ? and g3e_fid = ? and p." + g3eField1 + " =? and la." + g3eField2 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, g3eCno2, fid, boundaryID, bndType); if (!(RS.RecordCount > 0) && jobManager.JobStatus.ToUpper() == "NON-WR") { return("GRAPHIC EDIT REJECTED: Street Light is located outside the associated Street Light Account boundary."); } else if (!(RS.RecordCount > 0)) { return("ACCOUNT # CONFLICT: Street Light is located outside the associated Street Light Account boundary."); } else { return(string.Empty); } } } else //if no "type" attribute is found, determination is done by comparing the value of boundary_id to g3e_field value from g3e_attributeinfo_optable in first query 1 { SQL = "select g3e_id from " + componentTable1 + " where g3e_fid = ? and g3e_cno = ? and " + g3eField1 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, fid, g3eCno1, boundaryID); if (!(RS.RecordCount > 0) && jobManager.JobStatus.ToUpper() == "NON-WR") { return("GRAPHIC EDIT REJECTED: Street Light is located outside the associated Street Light Account boundary."); } else if (!(RS.RecordCount > 0)) { return("ACCOUNT # CONFLICT: Street Light is located outside the associated Street Light Account boundary."); } else { return(string.Empty); } } } while(!features.EOF); } else { return(string.Empty); //nothing to validate in this case, since spatial query did not return any features } } else { return(string.Empty); //nothing to validate in this case, since the street light account does not have a boundary. } } 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 bool CheckForBoundaryErrorExecute() { if (m_Components["STREETLIGHT_N"].Recordset.EOF) { m_Components["STREETLIGHT_N"].Recordset.MoveFirst(); } //get the esi_location for the street light var lightAccountID = m_Components["STREETLIGHT_N"].Recordset.Fields["ACCOUNT_ID"].Value; string SQL = "select ESI_LOCATION from STLT_ACCOUNT where ESI_LOCATION = ?"; Recordset RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, lightAccountID); string esiLocation; if (RS.RecordCount > 0) { esiLocation = Convert.ToString(RS.Fields["ESI_LOCATION"].Value); } else { return(false); //do not go any further if an ESI_LOCATION cannot be found. This means the user has not entered one yet, so the symbol was likely just placed. } //query 1 SQL = "select a.boundary_id,bnd.bnd_fno,ai.g3e_field,ai.g3e_cno,ai.g3e_componenttable from stlt_account a join stlt_boundary bnd on a.boundary_class = bnd.bnd_class join g3e_attributeinfo_optable ai on bnd.bnd_id_ano = ai.g3e_ano where a.esi_location = ?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, esiLocation); if (RS.RecordCount > 0) { string boundaryID = Convert.ToString(RS.Fields["BOUNDARY_ID"].Value); string g3eField1 = Convert.ToString(RS.Fields["G3E_FIELD"].Value); string componentTable1 = Convert.ToString(RS.Fields["G3E_COMPONENTTABLE"].Value); string g3eCno1 = Convert.ToString(RS.Fields["G3E_CNO"].Value); //object bndFnoObject = RS.Fields["BND_FNO"].Value; //cast from object to uint to short //decimal bndFNOdecimal = RS.Fields["BND_FNO"].Value; //short bndFNOshort = (short)bndFNOdecimal; //short[] bndFNOarray = new short[] { bndFNOshort }; Int16[] bndFNOarray = new Int16[] { Convert.ToInt16(RS.Fields["BND_FNO"].Value) }; IGTOrientedPointGeometry lightGeometry = (IGTOrientedPointGeometry)m_Components[m_ComponentName].Geometry; IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_DataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoTouches; spatialService.FilterGeometry = lightGeometry; Recordset features = spatialService.GetResultsByFNO(bndFNOarray); if (features.RecordCount > 0) { //query 2 SQL = "select bnd.bnd_type,ai.g3e_field,ai.g3e_cno,ai.g3e_componenttable from stlt_account a join stlt_boundary bnd on a.boundary_class = bnd.bnd_class join g3e_attributeinfo_optable ai on bnd.bnd_type_ano = ai.g3e_ano where a.esi_location = ?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, esiLocation); string bndType = null; string g3eField2 = null; string componentTable2 = null; string g3eCno2 = null; if (RS.RecordCount > 0) { bndType = Convert.ToString(RS.Fields["BND_TYPE"].Value); g3eField2 = Convert.ToString(RS.Fields["G3E_FIELD"].Value); componentTable2 = Convert.ToString(RS.Fields["G3E_COMPONENTTABLE"].Value); g3eCno2 = Convert.ToString(RS.Fields["G3E_CNO"].Value); } bool errorDisplayed; do { string fid = Convert.ToString(features.Fields["G3E_FID"].Value); //get the fid value for the current feature in feature list being iterated through. if (RS.RecordCount > 0) //if "type" attribute is found { if (componentTable2.Equals(componentTable1)) //if component tables match { SQL = "select 1 from " + componentTable1 + " where g3e_cno = ? and g3e_fid = ? and " + g3eField1 + " =? and " + g3eField2 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, g3eCno2, fid, boundaryID, bndType); errorDisplayed = DisplayBoundaryErrorExecute(RS); if (errorDisplayed) { return(true); } } else //if component tables do not match { SQL = "select 1 from " + componentTable1 + " p join " + componentTable2 + " la on p.g3e_fid=la.g3e_fid where g3e_cno = ? and g3e_fid = ? and p." + g3eField1 + " =? and la." + g3eField2 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, g3eCno2, fid, boundaryID, bndType); errorDisplayed = DisplayBoundaryErrorExecute(RS); if (errorDisplayed) { return(true); } } } else //if no "type" attribute is found, determination is done by comparing the value of boundary_id to g3e_field value from g3e_attributeinfo_optable in first query 1 { SQL = "select 1 from " + componentTable1 + " where g3e_fid = ? and g3e_cno = ? and " + g3eField1 + " =?"; RS = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, fid, g3eCno1, boundaryID); errorDisplayed = DisplayBoundaryErrorExecute(RS); if (errorDisplayed) { return(true); } } } while(!features.EOF); } } return(false); //nothing to validate in this case, since the street light account does not have a boundary. }
//public RestrictedArea(short Fno, int Fid) //{ // m_fno = Fno; // m_fid = Fid; // m_iGtApplication = GTClassFactory.Create<IGTApplication>(); // m_iGtDataContext = m_iGtApplication.DataContext; //} /// <summary> /// Process Restricted Area validation /// </summary> /// <returns>true if the process is complete without errors, else returns false</returns> public bool Process() { IGTGeometry featureGeometry = null; IGTSpatialService gTSpatialService = null; IGTComponent restrictedAreaAttributes = null; try { foreach (IGTKeyObject feature in m_features) { m_fno = feature.FNO; m_fid = feature.FID; IGTComponents selectedfeatureComponents = m_iGtDataContext.OpenFeature(m_fno, m_fid).Components; CommonFunctions commonFunctions = new CommonFunctions(); short primaryCno = commonFunctions.GetPrimaryGraphicCno(m_fno, true); // If the CNO is zero (not defined), then try the detail CNO if (0 == primaryCno) { primaryCno = commonFunctions.GetPrimaryGraphicCno(m_fno, false); } IGTComponent primaryGraphicComponent = selectedfeatureComponents.GetComponent(primaryCno); if (primaryGraphicComponent != null) { Recordset graphicCompRs = primaryGraphicComponent.Recordset; if (graphicCompRs != null && graphicCompRs.RecordCount > 0) { graphicCompRs.MoveFirst(); // Retrieve the geometry of the primary graphic component featureGeometry = primaryGraphicComponent.Geometry; // Find any Restricted Area features whose area component overlaps the retrieved geometry; if none are found, return with a successful status. gTSpatialService = GTClassFactory.Create <IGTSpatialService>(); gTSpatialService.DataContext = m_iGtDataContext; gTSpatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContainedBy; gTSpatialService.FilterGeometry = featureGeometry; Recordset restrictedAreaFeaturesRs = gTSpatialService.GetResultsByFNO(new short[] { RestrictedAreaFno }); if (restrictedAreaFeaturesRs != null && restrictedAreaFeaturesRs.RecordCount > 0) { //Prathyusha //if (restrictedAreaFeaturesRs.RecordCount == 0) //{ // return false; //} restrictedAreaFeaturesRs.MoveFirst(); while (!restrictedAreaFeaturesRs.EOF) { int fid = Convert.ToInt32(restrictedAreaFeaturesRs.Fields["G3E_FID"].Value); restrictedAreaAttributes = m_iGtDataContext.OpenFeature(RestrictedAreaFno, fid).Components.GetComponent(RestrictedAreaAttributesCno); if (!ValidateRestrictedAreaFeature(restrictedAreaAttributes)) { return(false); } restrictedAreaFeaturesRs.MoveNext(); } return(true); } } } } return(true);// Prathyusha: return false; } catch (Exception) { throw; } }
public void GetRecorsetOfAssociateFeaturesForVP(IGTGeometry p_tempGeometry, short[] lstFNO, ref DataTable p_associatedRs, short p_AactiveFno, Dictionary <short, string> p_relatedFeatures) { DataAccess dataAccess = null; Recordset rsTemp = null; IGTKeyObject gTKeyObject = null; List <string> IsolationFs = new List <string> { "PPI", "ABI" }; List <string> byPassFs = new List <string> { "PPR", "ABR", "PPI", "ABI" }; bool emptyRecord = true; p_associatedRs = new DataTable("Results"); p_associatedRs.Columns.Add("Feature"); p_associatedRs.Columns.Add("Feature Instance"); p_associatedRs.Columns.Add("G3E_FNO"); string value = null; try { IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>(); spatialService.DataContext = m_oGTApplication.DataContext; spatialService.Operator = GTSpatialOperatorConstants.gtsoIndexIntersect; spatialService.FilterGeometry = p_tempGeometry; Recordset rsCommon = null; rsTemp = spatialService.GetResultsByFNO(lstFNO); if (rsTemp != null && rsTemp.RecordCount > 0) { rsTemp.MoveFirst(); while (!rsTemp.EOF) { gTKeyObject = m_oGTApplication.DataContext.OpenFeature(Convert.ToInt16(rsTemp.Fields["g3e_fno"].Value), Convert.ToInt32(rsTemp.Fields["G3E_FID"].Value)); rsCommon = gTKeyObject.Components["COMMON_N"].Recordset; if (rsCommon != null && rsCommon.RecordCount > 0) { rsCommon.MoveFirst(); if (p_AactiveFno == 40 || p_AactiveFno == 80) { if (byPassFs.Contains(Convert.ToString(rsCommon.Fields["FEATURE_STATE_C"].Value))) { DataRow row = p_associatedRs.NewRow(); value = ""; p_relatedFeatures.TryGetValue(Convert.ToInt16(rsTemp.Fields["g3e_fno"].Value), out value); row["Feature"] = value; row["Feature Instance"] = Convert.ToInt32(rsTemp.Fields["G3E_FID"].Value); row["G3E_FNO"] = Convert.ToInt16(rsTemp.Fields["g3e_fno"].Value); p_associatedRs.Rows.Add(row); emptyRecord = false; } } else if (p_AactiveFno == 6 || p_AactiveFno == 82) { if (IsolationFs.Contains(Convert.ToString(rsCommon.Fields["FEATURE_STATE_C"].Value))) { DataRow row = p_associatedRs.NewRow(); value = ""; p_relatedFeatures.TryGetValue(Convert.ToInt16(rsTemp.Fields["g3e_fno"].Value), out value); row["Feature"] = value; row["Feature Instance"] = Convert.ToInt32(rsTemp.Fields["G3E_FID"].Value); row["G3E_FNO"] = Convert.ToInt16(rsTemp.Fields["g3e_fno"].Value); p_associatedRs.Rows.Add(row); emptyRecord = false; } } } rsTemp.MoveNext(); } } if (emptyRecord) { p_associatedRs = null; } } catch { throw; } finally { if (dataAccess != null) { dataAccess = null; } } }
/// <summary> /// Method to set the Normal and As-Operated status for features in INI and CLS states /// </summary> /// <param name="activeFeature"></param> /// <param name="relatedFeatures"></param> private void SetNormalAndAsOperatedAttributes(IGTKeyObject activeFeature, IGTKeyObjects relatedFeatures) { Dictionary <int, short> relatedIsolationPoints = new Dictionary <int, short>(); string normalStatus = string.Empty; string asOperatedStatus = string.Empty; try { // Set status attributes for active feature irrespective of feature class // ALM-2356-JIRA-2798 // ALM-2356 change complete IGTComponent connectivityComponent = activeFeature.Components.GetComponent(11); if (connectivityComponent == null) { return; } Recordset connectivityRs = connectivityComponent.Recordset; normalStatus = Convert.ToString(connectivityRs.Fields["STATUS_NORMAL_C"].Value); asOperatedStatus = Convert.ToString(connectivityRs.Fields["STATUS_OPERATED_C"].Value); // If feature state is changed from INI to CLS, do nothing if (m_featureStateBeforeChange == "INI" && m_featureState == "CLS") { } else { if (asOperatedStatus != normalStatus) { connectivityRs.Fields["STATUS_OPERATED_C"].Value = normalStatus; } } // ALM-2360-JIRA-2799 - when feature state transitions to INI or CLS, // copy the affected proposed voltages to the actual voltage attributes (Voltage 2 for Transformers, and both Voltage 1 & 2 for Autotransformers). // ALM affects Auto Transformer, Transformer OH and OH Network, Transformer UG and UG Network features if (m_transformerFNOs.Contains(activeFeature.FNO)) { if (activeFeature.FNO == 34) // Autotransformer { connectivityRs.Fields["VOLT_1_Q"].Value = connectivityRs.Fields["PP_VOLT_1_Q"].Value; connectivityRs.Fields["VOLT_2_Q"].Value = connectivityRs.Fields["PP_VOLT_2_Q"].Value; } else // Other transformers { connectivityRs.Fields["VOLT_2_Q"].Value = connectivityRs.Fields["PP_VOLT_2_Q"].Value; } } // Set status attributes for associated isolation points incase of Isolation scenario features if (m_IsoScenarioFNOs.Contains(activeFeature.FNO)) { // update statuses for inline isolation points. Inlines isolation points are related/connected to active feature. foreach (IGTKeyObject relatedFeature in relatedFeatures) { if (m_virtualPointFNOs.Contains(relatedFeature.FNO)) { relatedIsolationPoints.Add(relatedFeature.FID, relatedFeature.FNO); Recordset relatedFeatureRs = relatedFeature.Components.GetComponent(11).Recordset; if (relatedFeatureRs.RecordCount > 0) { relatedFeatureRs.MoveFirst(); normalStatus = Convert.ToString(relatedFeatureRs.Fields["STATUS_NORMAL_C"].Value); asOperatedStatus = Convert.ToString(relatedFeatureRs.Fields["STATUS_OPERATED_C"].Value); if (!asOperatedStatus.Equals(normalStatus)) { relatedFeatureRs.Fields["STATUS_OPERATED_C"].Value = normalStatus; } } } } // Find out whether there is any third isolation point. The Recloser would have a third isolation point (true Bypass point) that is not connected to the Recloser. // We will find out the true Bypass point using Zone and Spatial service and if it exists we will update the statuses. // For some active features ,say Transformer UG, there are NO isolation points but they do have other connected features which are not isolated points. // We want to consider only related isolation points leaving out the rest of the connected features if (relatedIsolationPoints.Count != 0) { foreach (KeyValuePair <int, short> feature in relatedIsolationPoints) { IGTOrientedPointGeometry gTOrientedPointGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); gTOrientedPointGeometry.Origin = ((IGTOrientedPointGeometry)activeFeature.Components.GetComponent(GetPrimaryGraphicCno(activeFeature.FNO)).Geometry).Origin; IGTZoneService gTZoneService = GTClassFactory.Create <IGTZoneService>(); gTZoneService.ZoneWidth = 4; gTZoneService.InputGeometries = gTOrientedPointGeometry; IGTGeometry outPutGeometry = gTZoneService.OutputGeometries; IGTSpatialService gTSpatialService = GTClassFactory.Create <IGTSpatialService>(); gTSpatialService.DataContext = m_GTDataContext; gTSpatialService.Operator = GTSpatialOperatorConstants.gtsoEntirelyContains; gTSpatialService.FilterGeometry = outPutGeometry; Recordset resultRecordSet = gTSpatialService.GetResultsByFNO(new short[] { feature.Value }); if (resultRecordSet != null && resultRecordSet.RecordCount > 0) { // the recordset contains the isolated points that are within the zone and hence contains already connected isolation points resultRecordSet.MoveFirst(); while (!resultRecordSet.EOF) { int fid = Convert.ToInt32(resultRecordSet.Fields["G3E_FID"].Value); short fno = Convert.ToInt16(resultRecordSet.Fields["G3E_FNO"].Value); // we would like to consider the isolation point that is not connected to the active feature, but it is part of the active feature. if (!relatedIsolationPoints.ContainsKey(fid)) { Recordset thirdIsolationPoint = m_GTDataContext.OpenFeature(fno, fid).Components.GetComponent(11).Recordset; if (thirdIsolationPoint != null && thirdIsolationPoint.RecordCount > 0) { thirdIsolationPoint.MoveFirst(); normalStatus = Convert.ToString(thirdIsolationPoint.Fields["STATUS_NORMAL_C"].Value); asOperatedStatus = Convert.ToString(thirdIsolationPoint.Fields["STATUS_OPERATED_C"].Value); if (!asOperatedStatus.Equals(normalStatus)) { thirdIsolationPoint.Fields["STATUS_OPERATED_C"].Value = normalStatus; } } } resultRecordSet.MoveNext(); } } } } } } catch (Exception) { throw; } }