public void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject) { //Reading the arguments IGTPolygonGeometry oCPLGeom = null; double XOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString()); double YOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString()); if (selectedObject.Geometry.Type == "OrientedPointGeometry") { IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry; oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset); RotateGeom(iPointGeom, ref oCPLGeom); } else if (selectedObject.Geometry.Type == "PolygonGeometry") //GTGeometryTypeConstants.gtgtPolygonGeometry { IGTPolygonGeometry iPolygonGeom = (IGTPolygonGeometry)selectedObject.Geometry; // We do not know what is the first placement point. So we will loop through all the points and grab one point from two identical points // because First and Last point would be same // TODO Is there any better way ? To confirm.. var dupPoint = from p in iPolygonGeom.Points group p by p.X into g where g.Count() > 1 select g.ToString(); IGTPoint duplicated = iPolygonGeom.Points.First(p => dupPoint.Contains(p.X.ToString())); oCPLGeom = GetPolyGeom(duplicated, XOffset, YOffset); RotateGeom(iPolygonGeom, ref oCPLGeom); } if (oCPLGeom != null) { m_PTHelper.SetGeometry(oCPLGeom); m_PTHelper.EndPlacement(); this.AssemblyCopyToModel(oCPLGeom); } }
private void ProcessWPSync(IGTDDCKeyObject selectedObject) { try { WorkPointOperations oWorkPointOperations = null; IGTComponents gTComponents = GTClassFactory.Create <IGTComponents>(); IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); Recordset cuComponentRs = feature.Components.GetComponent(21).Recordset; if (cuComponentRs != null && cuComponentRs.RecordCount > 0) { gTComponents.Add(feature.Components.GetComponent(21)); } // Set Activity in Ancillary CU attributes if (feature.Components.GetComponent(22) != null) { Recordset acuComponentRs = feature.Components.GetComponent(22).Recordset; if (acuComponentRs != null && acuComponentRs.RecordCount > 0) { gTComponents.Add(feature.Components.GetComponent(22)); } } // Synchronize the workpoint oWorkPointOperations = new WorkPointOperations(gTComponents, feature, m_DataContext); oWorkPointOperations.DoWorkpointOperations(); } catch (Exception) { throw; } }
/// <summary> /// This method will update the feature state for the selected feature /// </summary> /// <param name="selectedObject"></param> private void SetFeatureState(IGTDDCKeyObject selectedObject) { string featureState = string.Empty; ADODB.Recordset commonComponentRs = null; try { IGTKeyObject feature = m_iGtApp.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); IGTComponent commonComponent = feature.Components.GetComponent(1); if (commonComponent != null) { commonComponentRs = commonComponent.Recordset; if (commonComponentRs != null && commonComponentRs.RecordCount > 0) { commonComponentRs.MoveFirst(); featureState = Convert.ToString(commonComponentRs.Fields["FEATURE_STATE_C"].Value); if (featureState == "PPI" || featureState == "ABI") { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "INI"; } if (featureState == "PPR" || featureState == "ABR") { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "OSR"; } } } } catch (Exception) { throw; } }
/// <summary> /// Validating Custom Command Conditions Selected feature is neither Permit nor Easement /// </summary> private bool Validate() { bool isValidation = false; IGTDDCKeyObject m_DDCSelectedKeyFeat = null; try { m_DDCSelectedKeyFeat = m_igtApplication.SelectedObjects.GetObjects()[0]; if (m_DDCSelectedKeyFeat.FNO == 226 || m_DDCSelectedKeyFeat.FNO == 220) { isValidation = true; m_selectedFID = m_DDCSelectedKeyFeat.FID; m_selectedFNO = m_DDCSelectedKeyFeat.FNO; } return(isValidation); } catch (Exception) { throw; } finally { if (m_DDCSelectedKeyFeat != null) { m_DDCSelectedKeyFeat.Dispose(); } m_DDCSelectedKeyFeat = null; } }
public frmCopyAncillaryCUs(IGTDDCKeyObject initialFeature, DataTable dataTable) { InitializeComponent(); m_iGtApplication = GTClassFactory.Create <IGTApplication>(); m_originalObject = initialFeature; grdACUs.DataSource = dataTable; AdjustGridViewUI(); }
/// <summary> /// Method to set the activity attribute of the CU and ACU components /// </summary> /// <param name="selectedObject">Selected feature on map window</param> private void SetActivity(IGTDDCKeyObject selectedObject) { Recordset cuComponentRs = null; Recordset acuComponentRs = null; WorkPointOperations oWorkPointOperations = null; IGTComponents gTComponents = GTClassFactory.Create <IGTComponents>(); try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); // Set Activity in CU attributes cuComponentRs = feature.Components.GetComponent(21).Recordset; if (cuComponentRs != null && cuComponentRs.RecordCount > 0) { gTComponents.Add(feature.Components.GetComponent(21)); cuComponentRs.MoveFirst(); while (!cuComponentRs.EOF) { cuComponentRs.Fields["ACTIVITY_C"].Value = "A"; cuComponentRs.MoveNext(); } } // Set Activity in Ancillary CU attributes if (feature.Components.GetComponent(22) != null) { acuComponentRs = feature.Components.GetComponent(22).Recordset; if (acuComponentRs != null && acuComponentRs.RecordCount > 0) { gTComponents.Add(feature.Components.GetComponent(22)); acuComponentRs.MoveFirst(); while (!acuComponentRs.EOF) { string retiremenType = Convert.ToString(acuComponentRs.Fields["RETIREMENT_C"].Value); if (retiremenType == "1" || retiremenType == "2") { acuComponentRs.Fields["ACTIVITY_C"].Value = "R"; } acuComponentRs.MoveNext(); } } } //// Synchronize the workpoint //oWorkPointOperations = new WorkPointOperations(gTComponents, feature, m_DataContext); //oWorkPointOperations.DoWorkpointOperations(); } catch (Exception) { throw; } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { #region Perform validations m_oGTCustomCommandHelper = CustomCommandHelper; m_oGTTransactionManager.Begin(" begin Repeat reconductoring..."); if (CheckIfNonWrJob()) { ExitCommand(); MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); m_ooddcKeyObjects = m_iGtApplication.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in m_ooddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } m_originalObject = selectedObjects[0]; if (!CheckIfConductorFeature()) { ExitCommand(); MessageBox.Show("This command only applies to conductors.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!ValidateFeatureState()) { ExitCommand(); MessageBox.Show("Select a PPX conductor span from which to copy reconductoring information.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion SubscribeEvents(); CheckFeatureAndGetCno(); ReadCUsWithActivity(); } catch (Exception ex) { ExitCommand(); MessageBox.Show("Error during execution of Repeat Reconductoring custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Method to check whether the CU attributes component exists for active feature /// </summary> /// <param name="selectedObject">Selected feature on map window</param> /// <returns>true, if CU attributes component exists</returns> private bool CheckIfCuAttributesExists(IGTDDCKeyObject selectedObject) { try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); IGTComponent cuComponent = feature.Components.GetComponent(21); if (cuComponent != null) { return(true); } return(false); } catch (Exception) { throw; } }
/// <summary> /// Method to validate the feature state /// </summary> /// <param name="selectedObject">Selected feature on map window</param> /// <returns>false if feature state is not in one of legel features states</returns> private bool ValidateFeatureState(IGTDDCKeyObject selectedObject) { string featureState = string.Empty; Recordset commonComponentRs = null; try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); IGTComponent commonComponent = feature.Components.GetComponent(1); if (commonComponent != null) { commonComponentRs = commonComponent.Recordset; if (commonComponentRs != null && commonComponentRs.RecordCount > 0) { commonComponentRs.MoveFirst(); featureState = Convert.ToString(commonComponentRs.Fields["FEATURE_STATE_C"].Value); } } if (string.IsNullOrEmpty(featureState) || !m_featureStatesList.Contains(featureState)) { if (featureState == "PPR") { Recordset tempRs = GetRecordSet(string.Format("select G3E_IDENTIFIER from asset_history where g3e_fid = {0} and rownum = 1 order by change_date desc", selectedObject.FID)); if (tempRs != null && tempRs.RecordCount > 0) { tempRs.MoveFirst(); if (Convert.ToString(tempRs.Fields["G3E_IDENTIFIER"].Value) == m_DataContext.ActiveJob) { return(true); } } else { m_AssetHistoryCheckpassed = false; } } return(false); } return(true); } catch (Exception) { throw; } }
public void HighLightOnMapWindow(short p_fno, int p_fid) { try { IGTDDCKeyObject gTDDCKeyObject = m_oGTApplication.DataContext.GetDDCKeyObjects(p_fno, p_fid, GTComponentGeometryConstants.gtddcgAllGeographic)[0]; m_oGTApplication.ActiveMapWindow.HighlightedObjects.Clear(); m_oGTApplication.ActiveMapWindow.HighlightedObjects.AddSingle(gTDDCKeyObject); m_oGTApplication.ActiveMapWindow.SelectBehavior = GTSelectBehaviorConstants.gtmwsbHighlightAndCenter; m_oGTApplication.RefreshWindows(); } catch { throw; } }
/// <summary> /// The entry point for the custom command. /// </summary> /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param> public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { m_CustomCommandHelper = CustomCommandHelper; // Get the job information. Used for validating command enabling. if (!CommonDT.GetJobInformation()) { m_CustomCommandHelper.Complete(); return; } if (m_Application.SelectedObjects.FeatureCount > 1) { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_MULTIPLE_FEATURES_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_CustomCommandHelper.Complete(); return; } else if (m_Application.SelectedObjects.FeatureCount == 1) { // Only one feature in select set. Check if selected feature is a Duct Bank. IGTDDCKeyObjects oGTDCKeys = m_Application.SelectedObjects.GetObjects(); IGTDDCKeyObject objKeyObject = GTClassFactory.Create <IGTDDCKeyObject>(); if (oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_SECCOND && oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_COND) { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_FEATURE_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_CustomCommandHelper.Complete(); return; } } frmCablePullTension.m_CustomCommandHelper = CustomCommandHelper; frmCablePullTension.StartPosition = FormStartPosition.CenterScreen; frmCablePullTension.Show(m_Application.ApplicationWindow); return; } catch (Exception ex) { MessageBox.Show(m_Application.ApplicationWindow, "IGTCustomCommandModeless_Activate:" + Environment.NewLine + "Error (" + ex.Source + ") - " + ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); CustomCommandHelper.Complete(); } }
/// <summary> /// This method will update the feature state for the selected feature as per Job status /// </summary> /// <param name="selectedObject">Selected feature on map window</param> private void SetFeatureStateBasedOnJobStatus(IGTDDCKeyObject selectedObject, string JobStatus) { Recordset commonComponentRs = null; try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); IGTComponent commonComponent = feature.Components.GetComponent(1); if (commonComponent != null) { commonComponentRs = commonComponent.Recordset; if (commonComponentRs != null && commonComponentRs.RecordCount > 0) { commonComponentRs.MoveFirst(); if (!string.IsNullOrEmpty(m_JobType) && (JobStatus.ToUpper() == "WR-MAPCOR")) { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "OSA"; } else if (!string.IsNullOrEmpty(JobStatus) && (JobStatus.ToUpper() == "DESIGN")) { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "PPA"; } else if (!string.IsNullOrEmpty(JobStatus) && JobStatus.ToUpper() == "ASBUILT") { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "ABA"; } else if (!string.IsNullOrEmpty(JobStatus) && JobStatus.ToUpper() == "CONSTRUCTIONCOMPLETE") { commonComponentRs.Fields["FEATURE_STATE_C"].Value = "OSA"; } } } } catch (Exception) { throw; } }
public void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject) { //Reading the arguments IGTPolygonGeometry oCPLGeom = null; double XOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString()); double YOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString()); if (selectedObject.Geometry.Type == "OrientedPointGeometry") { IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry; oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset); RotateGeom(iPointGeom, ref oCPLGeom); } else { // oCPLGeom = GetPolyGeom(selectedObject.Geometry.FirstPoint, Length, Width, XOffset, YOffset); } if (oCPLGeom != null) { m_PTHelper.SetGeometry(oCPLGeom); m_PTHelper.EndPlacement(); this.AssemblyCopyToModel(oCPLGeom); } }
private bool CheckIfInstallAndActiveWrAreDifferent(IGTDDCKeyObject selectedObject) { try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID); IGTComponent cuComponent = feature.Components.GetComponent(21); Recordset cuComponentRs = cuComponent.Recordset; cuComponentRs.MoveFirst(); while (!cuComponentRs.EOF) { string installWr = Convert.ToString(cuComponentRs.Fields["WR_ID"].Value); if (!installWr.Equals(m_DataContext.ActiveJob)) { return(true); } cuComponentRs.MoveNext(); } return(false); } catch (Exception) { throw; } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { #region Perform validations m_oGTCustomCommandHelper = CustomCommandHelper; if (CheckIfNonWrJob()) { MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); m_ooddcKeyObjects = m_iGtApplication.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in m_ooddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } m_originalObject = selectedObjects[0]; if (!CheckIfACUAttributesExists()) { MessageBox.Show("This command applies only to features with Ancillary CUs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); ExitCommand(); return; } #endregion m_oGTTransactionManager.Begin("begin Copy Ancillaries..."); SubscribeEvents(); DataTable acuDataTable = GetData(); if (acuDataTable.Rows.Count != 0) { m_ofrmCopyAncillaryCUs = new frmCopyAncillaryCUs(m_originalObject, acuDataTable); if (m_ofrmCopyAncillaryCUs.ShowDialog(m_iGtApplication.ApplicationWindow) == DialogResult.Cancel) { ExitCommand(); return; } } else { if (MessageBox.Show("Selected feature has no Ancillary CUs. Continue and only delete Ancillary CUs from targeted features?", "G/Technology", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { ExitCommand(); } } } catch (Exception ex) { if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); } ExitCommand(); MessageBox.Show("Error during execution of Copy Ancillaries custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// This method is used to validate the initial conditions of the relocate custom command. /// </summary> /// <param name="relatedFeaturesOWB"></param> /// <returns></returns> private bool ValidateCC(out IGTKeyObjects relatedFeaturesOWB) { bool execute = true; string sql = ""; Recordset rsValidate = null; int reCount = 0; IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>(); relatedFeaturesOWB = GTClassFactory.Create <IGTKeyObjects>(); try { //Validate conditions to run the custom command. // 1. This command applies only to WR jobs. #region First Condition sql = "select G3E_JOBTYPE,G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER=?"; //sql = "select JOB_TYPE,G3E_STATUS from G3E_JOB where G3E_IDENTIFIER=?"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_gtApplication.DataContext.ActiveJob); if (rsValidate.RecordCount > 0) { rsValidate.MoveFirst(); if (!rsValidate.EOF && !rsValidate.BOF) { m_strJobtype = Convert.ToString(rsValidate.Fields[0].Value); m_strStatus = Convert.ToString(rsValidate.Fields[1].Value); } } #endregion if (m_strJobtype == "NON-WR") { MessageBox.Show("This command applies only to WR jobs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { //2. This command applies only to features with CUs. #region Second Condition m_gtDDCKeyObjects = m_gtApplication.Application.SelectedObjects.GetObjects(); m_activeFeatureDDCKey = m_gtDDCKeyObjects[0]; m_selectedFno = m_activeFeatureDDCKey.FNO; m_selectedFid = m_activeFeatureDDCKey.FID; sql = "SELECT count(*) FROM G3E_FEATURECOMPS_OPTABLE WHERE G3E_FNO=? AND G3E_CNO=21"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno); if (rsValidate.RecordCount > 0) { rsValidate.MoveFirst(); if (!rsValidate.EOF && !rsValidate.BOF) { reCount = Convert.ToInt32(rsValidate.Fields[0].Value); } } #endregion if (reCount < 1) { MessageBox.Show("This command applies only to features with CUs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { // 3. Cannot Relocate a feature that is not currently owned. #region Third Condition m_oActiveKeyObject = m_gtApplication.DataContext.OpenFeature(m_selectedFno, m_selectedFid); relationShipService.ActiveFeature = m_oActiveKeyObject; relationShipService.DataContext = m_gtApplication.DataContext; int ownFcount = 0; try { relatedFeaturesOWB = relationShipService.GetRelatedFeatures(3); ownFcount = relatedFeaturesOWB.Count; } catch { } #endregion if (ownFcount <= 0) { MessageBox.Show("Cannot relocate a feature that is not currently owned.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { // 4. This command applies only to point features. #region Fourth Condition sql = "SELECT * FROM G3E_COMPONENTINFO_OPTABLE WHERE G3E_CNO IN(SELECT G3E_PRIMARYGEOGRAPHICCNO FROM G3E_FEATURES_OPTABLE WHERE G3E_FNO=?) AND UPPER(G3E_GEOMETRYTYPE) LIKE '%POINT%'"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno); #endregion if (rsValidate.RecordCount <= 0) { MessageBox.Show("This command applies only to point features.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { //execute = true; if (!CheckIfInstallAndActiveWrAreDifferent()) { MessageBox.Show("The same feature may not be installed and relocated in the same WR.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { execute = true; } } } } } } catch (Exception ex) { throw ex; } finally { if (rsValidate != null) { if (rsValidate.State == 1) { rsValidate.Close(); rsValidate.ActiveConnection = null; } rsValidate = null; } if (relationShipService != null) { relationShipService.Dispose(); relationShipService = null; } } return(execute); }
public void Activate() { string jobStatus = string.Empty; bool dummyCuCodeExists = false; oHelper = new Helper(); oHelper.m_dataContext = m_dataContext; oIsolationScenario = new IsolationScenario(m_dataContext); try { #region Perform validations if (CheckIfNonWrJob()) { MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); IGTDDCKeyObjects ddcKeyObjects = m_iGtApplication.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } m_selectedObject = selectedObjects[0]; oHelper.m_fid = m_selectedObject.FID; oHelper.m_fno = m_selectedObject.FNO; if (!CheckIfFeatureIsReplaceable()) { MessageBox.Show("Replace Feature is not configured to operate on the selected feature class.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!CheckIfValidCuAttributesExists(out dummyCuCodeExists)) { MessageBox.Show("This command applies only to features with CUs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dummyCuCodeExists) { MessageBox.Show("This command cannot operate on dummy CUs (i.e.- CU codes beginning with ZZ).", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!ValidateFeatureState()) { MessageBox.Show("One or more features are in an invalid feature state for this operation.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!GetOffsetValuesFromGeneralParameters()) { MessageBox.Show("General parameters JobMgmt_ReplaceOffsetX or JobMgmt_ReplaceOffsetY is not configured correctly.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!CheckIfPointFeature()) { MessageBox.Show("Command is restricted to only work for point features.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!CheckIfInstallAndActiveWrAreDifferent()) { MessageBox.Show("The same feature may not be installed and replaced in the same WR.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion frmSelectReplacementStatus oReplacementStatusForm = new frmSelectReplacementStatus(); if (oReplacementStatusForm.ShowDialog(m_iGtApplication.ApplicationWindow) == DialogResult.Cancel) { return; } else { this.m_replaceAction = oReplacementStatusForm.ReplacementStatus; m_iGtApplication.BeginWaitCursor(); m_oIsolationScenario = oIsolationScenario.CheckIsoScenarioFeature(m_selectedObject.FNO, m_selectedObject.FID); ProcessReplacement(); m_TransactionManager.RefreshDatabaseChanges(); } } catch (Exception ex) { m_iGtApplication.EndWaitCursor(); m_TransactionManager.Rollback(); MessageBox.Show("Error during execution of Replace Feature custom command." + Environment.NewLine + "Replace failed for selected feature." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_TransactionManager = null; m_iGtApplication.EndWaitCursor(); } }
private void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject) { try { //Reading the arguments IGTPolygonGeometry oCPLGeom = null; double XOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString()); double YOffset = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString()); if (selectedObject.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) { IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry; //oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset); oCPLGeom = GetPolyGeom(iPointGeom.Origin, 0, 0); RotateGeom(iPointGeom, ref oCPLGeom); } else if (selectedObject.Geometry.Type == GTGeometryTypeConstants.gtgtPolygonGeometry) { IGTPolygonGeometry iPolygonGeom = (IGTPolygonGeometry)selectedObject.Geometry; List <Point2D> polygonPoints = new List <Point2D>(); foreach (IGTPoint point in iPolygonGeom.Points) { polygonPoints.Add(new Point2D { x = point.X, y = point.Y }); } //Calulate approx minimum length for sides of polygon double sideLength1 = 0.0; double sideLength2 = 0.0; double sideLength3 = 0.0; double length = 0.0; if (polygonPoints.Count > 3) { sideLength1 = Math.Abs(polygonPoints[0].y - polygonPoints[0].x); sideLength2 = Math.Abs(polygonPoints[1].y - polygonPoints[1].x); sideLength3 = Math.Abs(polygonPoints[2].y - polygonPoints[2].x); length = Math.Min(sideLength1, sideLength2); length = Math.Min(length, sideLength3); } int vertexCount = iPolygonGeom.Points.Count - 1; Point2D centroid = Compute2DPolygonCentroid(polygonPoints, vertexCount); m_CentriodPoint = GTClassFactory.Create <IGTPoint>(); m_CentriodPoint.X = centroid.x; m_CentriodPoint.Y = centroid.y; m_CentriodPoint.Z = 0.0; //oCPLGeom = GetPolyGeom(m_CentriodPoint, XOffset, YOffset); oCPLGeom = GetPolyGeom(m_CentriodPoint, 0, 0, length); RotateGeom(iPolygonGeom, ref oCPLGeom); } if (oCPLGeom != null) { m_PTHelper.SetGeometry(oCPLGeom); m_PTHelper.EndPlacement(); this.AssemblyCopyToModel(oCPLGeom); } } catch (Exception) { throw; } }
public void Activate() { IGTComponent cuComponent = null; short aFno = 0; int aFid = 0; int wpNotAssoFeaturesCount = 0; try { IGTDDCKeyObjects gtDDCKeyObjects = m_ogtApplication.Application.SelectedObjects.GetObjects(); activeFeatureDDCKey = gtDDCKeyObjects[0]; IGTJobHelper gTJobHelper = null; gTJobHelper = GTClassFactory.Create <IGTJobHelper>(); ADODB.Recordset myfeatures = gTJobHelper.FindPendingEdits(); if (myfeatures != null && myfeatures.RecordCount > 0) { myfeatures.MoveFirst(); myfeatures.Find("g3e_fid=" + activeFeatureDDCKey.FID + ""); if (!(myfeatures.BOF || myfeatures.EOF)) { MessageBox.Show("This command cannot be used on unposted features.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } } gTJobHelper = null; myfeatures = null; commonRevertAPI rFeature = new commonRevertAPI(m_ogtApplication); if (ValidateCommand()) { if (!rFeature.ValidateActiveFetature(m_oActiveKeyObject)) { //m_ogtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Feature has been edited by WR " + rFeature.m_WRID + "; cannot revert."); MessageBox.Show("Feature has been edited by WR " + rFeature.m_WRID + "; cannot revert.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } else { if (m_oActiveKeyObject.FNO == 191) { m_oGTTransactionManager.Begin("Revert Feature Fno=" + m_oActiveKeyObject.FNO + " FID=" + m_oActiveKeyObject.FID); cuComponent = m_oActiveKeyObject.Components.GetComponent(19104); if (cuComponent != null && cuComponent.Recordset != null && cuComponent.Recordset.RecordCount > 0) { cuComponent.Recordset.MoveFirst(); while (!cuComponent.Recordset.EOF) { aFno = Convert.ToInt16(cuComponent.Recordset.Fields["ASSOC_FNO"].Value); aFid = Convert.ToInt32(cuComponent.Recordset.Fields["ASSOC_FID"].Value); if (!rFeature.ValidateActiveFetature(m_ogtApplication.DataContext.OpenFeature(aFno, aFid))) { wpNotAssoFeaturesCount = wpNotAssoFeaturesCount + 1; } cuComponent.Recordset.MoveNext(); } } if (wpNotAssoFeaturesCount == 0) { rFeature.RevertWPFeature(m_oActiveKeyObject); if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); } } else if (wpNotAssoFeaturesCount == cuComponent.Recordset.RecordCount) { MessageBox.Show("All features associated with this Work Point have been edited by other WRs and cannot be reverted.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } else if (wpNotAssoFeaturesCount < cuComponent.Recordset.RecordCount) { DialogResult dResult = MessageBox.Show("One or more features associated with this Work Point have been edited by other WRs and cannot be reverted. Continue reverting other associated features?", "G/Technology", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dResult == DialogResult.OK) { rFeature.RevertWPFeature(m_oActiveKeyObject); if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); } } else { m_oGTTransactionManager.Rollback(); } } } else { if (m_oActiveKeyObject.Components["COMMON_N"].Recordset != null && m_oActiveKeyObject.Components["COMMON_N"].Recordset.RecordCount > 0) { m_oGTTransactionManager.Begin("Revert Feature Fno=" + m_oActiveKeyObject.FNO + " FID=" + m_oActiveKeyObject.FID); rFeature.RevertFeture(m_oActiveKeyObject.FNO, m_oActiveKeyObject.FID, m_ostrActFeatureState, 0, 0, 0); if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); } } } if (rFeature.m_uProcessedCUs) { MessageBox.Show("Command was unable to revert all activity.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); m_oGTTransactionManager.Rollback(); } }
void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e) { IGTLocateService selectedFeaturesService; IGTDDCKeyObjects selectedFeatures; try { m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ""); m_iGtApplication.BeginWaitCursor(); m_invalidFeatureMessage = false; if (e.Button == 1) { selectedFeaturesService = m_iGtApplication.ActiveMapWindow.LocateService; selectedFeatures = selectedFeaturesService.Locate(e.WorldPoint, -1, 0, GTSelectionTypeConstants.gtmwstSelectAll); IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); foreach (IGTDDCKeyObject ddcKeyObject in selectedFeatures) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } if (selectedObjects == null || selectedObjects.Count == 0) { return; } m_selectedObject = selectedObjects[0]; if (m_selectedObject.FNO != m_originalObject.FNO || m_selectedObject.FID == m_originalObject.FID) // Restrict selection to features of the same class as the original feature { m_invalidFeatureMessage = true; m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Invalid feature selected.Selected feature(s) are not of same class as source feature or selected feature itself is source feature."); return; } m_iGtApplication.ActiveMapWindow.HighlightedObjects.AddSingle(m_selectedObject); if (m_oGTTransactionManager != null && !m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Begin(" begin Repeat reconductoring..."); } if (ProcessChangeOutsToTargetFeature()) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); // Synchronize Work points - ALM-1838-JIRA-2514 SynchronizeWP(m_dataContext.OpenFeature(m_originalObject.FNO, m_originalObject.FID)); SynchronizeWP(m_dataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID)); m_iGtApplication.EndWaitCursor(); m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Identify next span to changeout wires; double-click to exit."); } } } catch (Exception ex) { if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); } ExitCommand(); MessageBox.Show("Error during execution of Repeat Reconductoring custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_iGtApplication.EndWaitCursor(); } }