/// <summary> /// Method to clear out the leftover data in the form closing event. Putting it in the global object should allow it to clear out any data that we may not want. /// </summary> internal static void dispose() { try { if (fieldActivityErrorRecords != null && fieldActivityErrorRecords.State != (int)ADODB.ObjectStateEnum.adStateClosed) { fieldActivityErrorRecords.Close(); } if (gtGeoEditService != null && gtGeoEditService.GeometryCount > 0) { gtGeoEditService.RemoveAllGeometries(); gtGeoEditService = null; } if (metaDataRecords != null) { metaDataRecords.Close(); } if (ColumnRules != null) { ColumnRules.Clear(); } ErrorMessage = null; } catch (Exception e) { MessageBox.Show("Error in Dispose (" + e.Message + ")", "G/Technology"); } }
public void Terminate() { try { UnsubscribeEvents(); if (m_oEditService != null) { if (m_oEditService.GeometryCount > 0) { m_oEditService.RemoveAllGeometries(); } } m_oGTApplication.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ""); if (m_oGTTransactionManager != null && m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); m_oGTTransactionManager.RefreshDatabaseChanges(); } m_oGTApplication.EndWaitCursor(); m_oGTApplication.SelectedObjects.Clear(); m_oGTApplication.RefreshWindows(); } catch (Exception ex) { MessageBox.Show("Error " + ex.Message, m_sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_oGTApplication = null; m_oGTCustomCommandHelper = null; m_osrcGeometry = null; m_otrgFeature = null; m_trgComponent = null; m_oEditService = null; m_oGTTransactionManager = null; m_EditObjects = null; m_locatedObjects = null; m_snapPoint = null; } }
/// <summary> /// Command Click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e) { try { m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow; if (m_blPointSelected) { //Snap to the Selected Geomentry m_firstPoint = GetSnapPoint(m_gSrcGeometry, e.WorldPoint); m_blFirstPointSelected = true; m_blSecondPointSelected = false; m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg1); } if ((m_blFirstPointSelected) && (m_blSecondPointSelected)) { try { m_oEditService.EndMove(e.WorldPoint); m_blFirstPointSelected = false; m_oGTTransactionManager.Begin("Divide Landbase Boundries"); // Get the Located object and snap the destination to nearest vertex. IGTDDCKeyObjects m_oLocatedObjects = m_oGTApplication.ActiveMapWindow.LocateService.Locate(e.WorldPoint, 3, 1, GTSelectionTypeConstants.gtmwstSelectSingle); m_secondtPoint = GetSnapPoint(m_oLocatedObjects[0].Geometry, e.WorldPoint); //Perform the break Polygon IGTGeometry[] m_gTargetPolygons = m_gSrcGeometry.BreakPolygon(m_gLineGeom); //Intialise two polygons IGTKeyObject m_oFirstPolygon = m_oGTApplication.DataContext.OpenFeature(m_sourceFNO, m_sourceFID); IGTKeyObject m_oSecondPolygon = m_oGTApplication.DataContext.NewFeature(m_sourceFNO); //Set the geometry with the newly created ones. m_oFirstPolygon.Components.GetComponent(m_primaryGeoCNO).Geometry = CreatePolygon(m_gTargetPolygons[0]); m_oSecondPolygon.Components.GetComponent(m_primaryGeoCNO).Geometry = CreatePolygon(m_gTargetPolygons[1]); //Fetch the required components Recordset rsFirstFeature = m_oFirstPolygon.Components.GetComponent(m_landbaseCNO).Recordset; Recordset rsSecondFeature = m_oSecondPolygon.Components.GetComponent(m_landbaseCNO).Recordset; //Assign required field values rsSecondFeature.Fields["SOURCE"].Value = rsFirstFeature.Fields["SOURCE"].Value; rsSecondFeature.Fields["CREATED_BY"].Value = m_oGTApplication.DataContext.DatabaseUserName; rsSecondFeature.Fields["CREATED_DATE"].Value = System.DateTime.Today; rsSecondFeature.Fields["STAGE"].Value = "Accepted"; m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); m_oGTApplication.RefreshWindows(); m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Commit complete"); m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow; m_oGTCustomCommandHelper.Complete(); } catch (Exception ex) { MessageBox.Show(sStatusBarMsg3, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, sStatusBarMsg3); } } } catch (Exception ex) { MessageBox.Show("Error " + ex.Message, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); ExitCommand(); } finally { if (m_blSecondPointSelected) { m_gLineGeom = null; m_gSrcGeometry = null; m_oEditService.RemoveAllGeometries(); m_oEditService = null; ExitCommand(); } } }