/// <summary> /// This function gathers all premises that should be displayed. Any premise w/out a number that /// is attached to a selected service point or, if no service points are found, all premises without /// numbers. This should get data in a format that cn be used in a data grid. /// </summary> public static void LoadData() { try { IGTKeyObjects servicePoints = GTClassFactory.Create <IGTKeyObjects>(); IGTJobHelper jobHelper = GTClassFactory.Create <IGTJobHelper>(); selectedObjects = gtApp.SelectedObjects.GetObjects(); string PremiseMetaDataQuery = "SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'PREMISE_N'"; PremiseMetaRecords = gtDataContext.OpenRecordset(PremiseMetaDataQuery, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, -1); PremiseMetaRecords.MoveFirst(); while (!PremiseMetaRecords.EOF && PremiseMetaRecords.RecordCount > 0) { string[] values = { PremiseMetaRecords.Fields["DATA_TYPE"].Value.ToString(), PremiseMetaRecords.Fields["DATA_LENGTH"].Value.ToString(), PremiseMetaRecords.Fields["DATA_PRECISION"].Value.ToString(), PremiseMetaRecords.Fields["DATA_SCALE"].Value.ToString() }; ColumnRules.Add(PremiseMetaRecords.Fields["COLUMN_NAME"].Value.ToString(), new List <string>(values)); PremiseMetaRecords.MoveNext(); } //If we have objects selected if (selectedObjects.Count > 0) {//this code is a bit broken, instead of doing 1 call it calls multiple times. List <int> FIDs = new List <int>(); int badObject = 0; foreach (IGTDDCKeyObject x in selectedObjects) { if (x.FNO == FNO) { if (!FIDs.Contains(x.FID))//don't want this to trigger the else statement { FIDs.Add(x.FID); } } else { badObject++; } } //If we have Service Points selected if (FIDs.Count > 0 && badObject == 0) { //LOGIC to detect service points and if they have premise records w/out ESI Locations string FIDsString = string.Join(", ", FIDs); //if we have service points if (FIDs.Count > 0) { //LOGIC to detect service points and if they have premise records w/out ESI Locations string PremiseQuery = "SELECT * FROM PREMISE_N WHERE G3E_FID IN (" + FIDsString + " ) AND PREMISE_NBR IS null"; PremiseRecords = gtDataContext.OpenRecordset(PremiseQuery, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, -1); if (PremiseRecords.EOF && PremiseRecords.BOF) { ErrorMessage = "All selected Service Points have ESI Locations."; } } } //Anything other than Service Points selected else { ErrorMessage = "The select set contains features other than Service Points." + Environment.NewLine + Environment.NewLine + "Before running the command select a Service Point or unselect all features to process all Service Points in the active Job."; } } // If no objects are selected else { Recordset edits; edits = jobHelper.FindPendingEdits(); List <int> FIDs = new List <int>(); //if we have edits in the current job if (edits != null && !edits.EOF) { edits.MoveFirst(); if (edits.Fields["G3E_FNO"].Value == FNO) {//hard coding in column index FIDs.Add(Convert.ToInt32(edits.Fields["G3E_FID"].Value.ToString())); edits.MoveNext(); } while (!edits.EOF) { if (edits.Fields["G3E_FNO"].Value == FNO) { FIDs.Add(Convert.ToInt32(edits.Fields["G3E_FID"].Value.ToString())); } edits.MoveNext(); } //We need to make a string from our list of FIDS string FIDsString = string.Join(", ", FIDs); //if we have service points if (FIDs.Count > 0) { //LOGIC to detect service points and if they have premise records w/out ESI Locations string PremiseQuery = "SELECT * FROM PREMISE_N WHERE G3E_FID IN (" + FIDsString + " ) AND PREMISE_NBR IS null"; PremiseRecords = gtDataContext.OpenRecordset(PremiseQuery, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, -1); if (PremiseRecords.EOF && PremiseRecords.BOF) { ErrorMessage = "All Service Points have ESI Locations."; } } //no service points edited in job else { ErrorMessage = "No Service Points in active job."; } } else { ErrorMessage = "No Service Points in active job."; } } } catch (Exception error) { MessageBox.Show("Error in LoadData (" + error.Message + ")", "G/Technology"); } }
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(); } }