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(); } }