/// <summary> /// Support method for Geocode locate. May be removed at a later date. /// </summary> /// <param name="x"></param> /// <param name="y"></param> internal static void geoLocate(double x, double y) { gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; gtGeoEditService.RemoveAllGeometries(); gtApp.ActiveMapWindow.DisplayScale = 250; IGTPoint locationPoint = gCoordinateConvert(x, y, 0); IGTWorldRange gtWorldRange = gtApp.ActiveMapWindow.GetRange(); double xOffset = (gtWorldRange.TopRight.X - gtWorldRange.BottomLeft.X) / 2; double yOffset = (gtWorldRange.TopRight.Y - gtWorldRange.BottomLeft.Y) / 2; IGTPoint tempPt = GTClassFactory.Create <IGTPoint>(); tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X + xOffset; tempPt.Y = locationPoint.Y + yOffset; gtWorldRange.TopRight = tempPt; tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X - xOffset; tempPt.Y = locationPoint.Y - yOffset; gtWorldRange.BottomLeft = tempPt; gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; IGTPointGeometry newSymbol = GTClassFactory.Create <IGTPointGeometry>(); newSymbol.Origin = locationPoint; gtGeoEditService.AddGeometry(newSymbol, Convert.ToInt16(GTStyleIDConstants.gtstyleHandleSquareX)); gtApp.ActiveMapWindow.DisplayScale = 250; gtApp.ActiveMapWindow.ZoomArea(gtWorldRange); gtApp.RefreshWindows(); }
/// <summary> /// Execute Procudure to Detect Polygon Edge Mismatch /// </summary> private void DetectPolygonEdgeMismatch() { Recordset rs = null; string sqlStmt = "Begin LBM_UTL.DetectPolygonEdgeMismatch; end;"; string mergeStatus = string.Empty; try { gtApp.BeginWaitCursor(); gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Polygon Edge Mismatch...."); gtTransactionManager.Begin("Detect Polygon Edge Mismatch"); rs = Execute(sqlStmt); gtTransactionManager.Commit(); } catch (Exception ex) { gtTransactionManager.Rollback(); throw ex; } finally { rs = null; gtTransactionManager.RefreshDatabaseChanges(); gtApp.RefreshWindows(); gtApp.EndWaitCursor(); } }
/// <summary> /// Execute Procudure to Purge Expired Archived Landbase /// </summary> private void PurgeLandbase() { ADODB.Recordset rs = null; string sqlStmt = "Begin LBM_UTL.PurgeExpiredArchivedLandbase; end;"; string mergeStatus = string.Empty; try { gtTransactionManager.Begin("Purge Expired Landbase"); gtApp.BeginWaitCursor(); rs = Execute(sqlStmt); gtTransactionManager.Commit(); } catch (Exception ex) { gtTransactionManager.Rollback(); throw ex; } finally { rs = null; gtTransactionManager.RefreshDatabaseChanges(); gtApp.RefreshWindows(); gtApp.EndWaitCursor(); } }
/// <summary> /// Execute Procudure to Purge Expired Archived Landbase /// </summary> private void DetectOverlapping(int g3eFno, bool selfOverlap) { ADODB.Recordset rs = null; string sqlStmt = "Begin LBM_UTL.DetectOverlappingPolygons({0},{1}); end;"; try { gtApp.BeginWaitCursor(); sqlStmt = string.Format(sqlStmt, g3eFno, selfOverlap); gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Overlapping Boundarys...."); gtTransactionManager.Begin("Detect Overlapping Boundarys"); rs = Execute(sqlStmt); gtTransactionManager.Commit(); MessageBox.Show("Detecting Overlapping Boundarys Analysis is Completed", msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { gtTransactionManager.Rollback(); throw ex; } finally { rs = null; gtTransactionManager.RefreshDatabaseChanges(); gtApp.RefreshWindows(); gtApp.EndWaitCursor(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { stltNonLocatedCtx.MiscStructG3eFid = streetLightAcct.MiscStructFid; if (this.streetLights.Where <StreetLightNonLocated>(s => s.EntityState != EntityMode.Review).Count() > 0) { _gtTransactionManager.Begin("Saving Street Light(s)"); try { // ALM 2044 - Set the CU for the current street light. // The same customer-owned CU will apply to all non-located lights for the active account. // If there's not a customer-owned CU for this account, then allow the user to exit the save operation. string CU = CommonUtil.CustomerOwnedSteetLightCU(this.streetLightAcct.LAMP_TYPE, this.streetLightAcct.Wattage, this.streetLightAcct.LUMINARE_STYLE); if (string.IsNullOrEmpty(CU)) { string msg = string.Format("A unique customer-owned CU was not found where Lamp Type = {0} and Wattage = {1} and Luminaire Style = {2}.{3}{3}Continue?", this.streetLightAcct.LAMP_TYPE, this.streetLightAcct.Wattage, this.streetLightAcct.LUMINARE_STYLE, Environment.NewLine); if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { return; } } //Save the Street Light Boundary _gtApp.BeginWaitCursor(); foreach (StreetLightNonLocated streetLight in this.streetLights.Where <StreetLightNonLocated>(s => s.EntityState != EntityMode.Review)) { if (streetLight.EntityState == EntityMode.Add) { streetLight.LAMP_TYPE = this.streetLightAcct.LAMP_TYPE; streetLight.LUMINARE_STYLE = this.streetLightAcct.LUMINARE_STYLE; streetLight.Wattage = this.streetLightAcct.Wattage; streetLight.ESI_LOCATION = this.streetLightAcct.ESI_LOCATION; streetLight.RATE_CODE = this.streetLightAcct.RATE_CODE; streetLight.RATE_SCHEDULE = this.streetLightAcct.RATE_SCHEDULE; streetLight.CU = this.CU; } stltNonLocatedCtx.SaveStreetLight(streetLight); } _gtTransactionManager.Commit(true); this.streetLights = stltNonLocatedCtx.GetStreetLightByAccountID(this.streetLightAcct.ESI_LOCATION); dtGridViewNonLocated.DataSource = this.streetLights; _gtApp.RefreshWindows(); _gtApp.EndWaitCursor(); MessageBox.Show("Pending changes committed successfully.", ManageNonLocatedTxt, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (_gtTransactionManager.TransactionInProgress) { _gtTransactionManager.Rollback(); } _gtApp.EndWaitCursor(); MessageBox.Show("Error while Saving Street Light(s): " + ex.Message, ManageNonLocatedTxt, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Delete the trace from the legend. /// </summary> /// <param name="displayPathName">Node on the legend that contains the trace entry</param> /// <param name="displayName">Name of the trace entry on the legend</param> /// <returns>Boolean indicating status</returns> public bool RemoveTraceLegendItem(string displayPathName, string displayName) { bool returnValue = false; try { // --- Remove from display control IGTMapWindows gtMapWindows = m_Application.GetMapWindows(GTMapWindowTypeConstants.gtapmtGeographic); foreach (IGTMapWindow gtMapWindow in gtMapWindows) { try { gtMapWindow.DisplayService.Remove(displayPathName, displayName); } catch { // Ignore error if node is not on display control } } gtMapWindows = null; m_Application.RefreshWindows(); returnValue = true; } catch (Exception ex) { if (m_InteractiveMode) { MessageBox.Show(m_Application.ApplicationWindow, TRACE_DELETE_LEGEND_ERROR + ": " + ex.Message, ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } WriteToCommandLog("ERROR", TRACE_DELETE_LEGEND_ERROR + ": " + ex.Message, "commonTraceHelper.RemoveTraceLegendItem"); returnValue = false; } return(returnValue); }
public void Terminate() { try { UnsubscribeEvents(); if (m_oEditService != null) { 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, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_oGTApplication = null; m_oGTCustomCommandHelper = null; m_oGTTransactionManager = null; } }
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; } }
private bool AssignClipGeometryToFrame(IGTApplication oApp, IGTPlotFrame apf, IGTPolygonGeometry clipPG) { bool bReturn = false; apf.Activate(); // Need to Zoom out a little more as the WorldToPaper seems to fail on pts that are on the edge. IGTPoint originPt = GTClassFactory.Create <IGTPoint>(0, 0, 0); IGTGeometry prClipBufferPG = ((IGTGeometry)clipPG).CopyGeometryParallel(originPt, 2); apf.PlotMap.ZoomArea(prClipBufferPG.Range); apf.ClipGeometry = GetClipBoundary(oApp, clipPG); apf.IsClipped = true; apf.Deactivate(); oApp.RefreshWindows(); bReturn = true; return(bReturn); }
private void ExitCommand() { try { m_ooddcKeyObjects.Clear(); m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ""); UnsubscribeEvents(); if (m_oGTCustomCommandHelper != null) { m_oGTCustomCommandHelper.Complete(); m_oGTCustomCommandHelper = null; } m_iGtApplication.EndWaitCursor(); m_iGtApplication.RefreshWindows(); } catch (Exception) { throw; } }
private static Boolean bDisplayConstRedLineFile(string pPathAndFile) { Boolean tmpRetVal = false; IGTDisplayService tmpDispSvr = null; try { tmpDispSvr = gCurrActMapWind.DisplayService; tmpDispSvr.AppendRedlines("Constructions Redlines", pPathAndFile); gApp.RefreshWindows(); tmpRetVal = true; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error: gGetRedLineFilesfromSp", MessageBoxButtons.OK, MessageBoxIcon.Error); tmpRetVal = false; } return(tmpRetVal); }
public void Execute() { if (Convert.ToInt32(_components[_componentName].Recordset.Fields["g3E_fno"].Value) != 106) { return; } ADODB.Recordset rs = null; IGTComponent gtComponent = _components["MANHOLE_DP"]; double xCoord = 0; double yCoord = 0; IGTMapWindow mapWindow = null; try { if (gtComponent.Recordset.RecordCount == 0) { if (_components["MANHOLE_N"].Recordset != null) { if (_components["MANHOLE_N"].Recordset.RecordCount > 0) { _components["MANHOLE_N"].Recordset.MoveFirst(); } } // Check Mamhole Detail Footprint component count if count==0 then call procedure to generate Footprint Detial components instance otherwise skip _gtApp = GTClassFactory.Create <IGTApplication>(); gtComponent = _components["DETAILIND_T"]; //Check Manhole Map window exists otherwise throw message to create Detial Map winod if (gtComponent.Recordset.RecordCount > 0 && _components["MANHOLE_N"].Recordset.Fields["TYPE_C"].Value.GetType() != typeof(DBNull)) { rs = gtComponent.Recordset; rs.MoveFirst(); //Get MBR X and Y . Calculate midpoint xCoord = (Convert.ToDouble(rs.Fields["MBR_X_HIGH"].Value) + Convert.ToDouble(rs.Fields["MBR_X_LOW"].Value)) / 2; yCoord = (Convert.ToDouble(rs.Fields["MBR_Y_HIGH"].Value) + Convert.ToDouble(rs.Fields["MBR_Y_LOW"].Value)) / 2; //Pass ,fid,Detialid,X and Y,Manhole Type to place Detail Footprint in Detail window PlaceManholeFootprint(Convert.ToInt32(rs.Fields["G3e_FID"].Value), Convert.ToInt32(rs.Fields["G3E_DETAILID"].Value), xCoord, yCoord, _components["MANHOLE_N"].Recordset.Fields["TYPE_C"].Value.ToString()); if (_components["MANHOLE_DP"].Recordset.RecordCount > 0) { _components["MANHOLE_DP"].Recordset.Update(); } IGTMapWindows maps = _gtApp.GetMapWindows(GTMapWindowTypeConstants.gtapmtDetail); foreach (IGTMapWindow detWindow in _gtApp.GetMapWindows(GTMapWindowTypeConstants.gtapmtAll)) { if (detWindow.DetailID == Convert.ToInt32(rs.Fields["G3E_DETAILID"].Value)) { mapWindow = detWindow; break; } } if (mapWindow != null) { mapWindow.CenterSelectedObjects(); } _gtApp.RefreshWindows(); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error in fiManholeFootPrintPlacement " + ex.StackTrace, "G/Technology"); throw ex; } }
/// <summary> /// Method to create a Plot window with given template and exports the plot window to create a PDF. /// </summary> /// <param name="p_template">Specified plot template using which need to create a new named plot </param> /// <param name="p_newTreeTrimmingfeature">Current placed feature</param> private void CreatePlotWindowAndPlotPDF(IGTNamedPlot p_template, IGTKeyObject p_newTreeTrimmingfeature) { Recordset oPlotRS = null; IGTPlotRedlines oRLs = null; IGTPlotFrame gTPlotFrame = GTClassFactory.Create <IGTPlotFrame>(); IGTPlotMap gtPlotMap = GTClassFactory.Create <IGTPlotMap>(); IGTNamedPlot namedPlot = GTClassFactory.Create <IGTNamedPlot>(); IGTPlotWindow gTPlotWindow = GTClassFactory.Create <IGTPlotWindow>(); string plotName = null; object autoVal = null; try { plotName = GetPlotName(); namedPlot = p_template.CopyPlot(plotName); gTPlotWindow = m_oGTApplication.NewPlotWindow(namedPlot); gTPlotWindow.BackColor = System.Drawing.Color.White; gTPlotWindow.Caption = gTPlotWindow.NamedPlot.Name; foreach (IGTPlotFrame apf in namedPlot.Frames) { if (apf.Type == GTPlotFrameTypeConstants.gtpftMap) { gTPlotFrame = apf; } } if (gTPlotFrame != null) { gtPlotMap = gTPlotFrame.PlotMap; if (!String.IsNullOrEmpty(p_template.FieldsQuery)) { gTPlotWindow.NamedPlot.FieldsQuery = p_template.FieldsQuery; } else { gTPlotWindow.NamedPlot.FieldsQuery = "Select WR_NBR,G3E_IDENTIFIER,DESIGNER_UID,G3E_DATECREATED,WR_CREW_HQ_C from g3e_job where g3e_identifier='" + m_oGTApplication.DataContext.ActiveJob + "'"; } oPlotRS = m_oGTApplication.DataContext.OpenRecordset(gTPlotWindow.NamedPlot.FieldsQuery, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); oRLs = gTPlotWindow.NamedPlot.GetRedlines(GTPlotRedlineCollectionConstants.gtprcTextOnly); foreach (IGTPlotRedline oRL in oRLs) { IGTTextPointGeometry oTPG = (IGTTextPointGeometry)oRL.Geometry.Copy(); if (oRL.AutomaticTextSource == GTPlotAutomaticTextSourceConstants.gtpatPlotByQuery) { if (oRL.AutomaticTextField.ToString() == "WR Number") { autoVal = oPlotRS.Fields["WR_NBR"].Value; } else if (oRL.AutomaticTextField.ToString() == "WR Name") { autoVal = oPlotRS.Fields["G3E_IDENTIFIER"].Value; } else if (oRL.AutomaticTextField.ToString() == "Designer Name") { autoVal = oPlotRS.Fields["DESIGNER_UID"].Value; } else if (oRL.AutomaticTextField.ToString() == "Date") { autoVal = oPlotRS.Fields["G3E_DATECREATED"].Value; } else if (oRL.AutomaticTextField.ToString() == "Crew HQ") { autoVal = oPlotRS.Fields["WR_CREW_HQ_C"].Value; } oTPG.Text = (autoVal == null) ? " " : autoVal.ToString(); oRL.Geometry = oTPG; } } gTPlotFrame.Activate(); gTPlotFrame.PlotMap.ZoomArea(p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry.Range); ZoomToExtents(gTPlotFrame, p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry.Range, 1.2); gTPlotFrame.ClipGeometry = WorldToPaper(gtPlotMap, (IGTPolygonGeometry)p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry); gTPlotFrame.IsClipped = true; gTPlotFrame.Deactivate(); m_oGTApplication.RefreshWindows(); m_oPlotPDFName = plotName.Replace('/', '_').Replace('\\', '_').Replace(' ', '_'); ExportToPDF(Path.GetTempPath(), m_oPlotPDFName, false, gTPlotWindow); } } catch { throw; } finally { oPlotRS = null; } }
public void Activate() { string sql = "SELECT G3E_FID FROM WORKPOINT_N WHERE WR_NBR=:1 AND G3E_FNO=191"; Recordset rsValidate = null; int jFid = 0; short jFno = 0; IGTKeyObject jKeyObject = null; IGTJobManagementService oJobManagement = GTClassFactory.Create <IGTJobManagementService>(); oJobManagement.DataContext = m_ogtApplication.DataContext; try { if (ValidateCommand()) { ADODB.Recordset rsPendingEdits = oJobManagement.FindPendingEdits(); if (rsPendingEdits != null && rsPendingEdits.RecordCount > 0) { oJobManagement.DiscardJob(); //ALM 1321 - Automatically discard job at the start and assume that there are no unposted data m_oGTTransactionManager.RefreshDatabaseChanges(); m_ogtApplication.RefreshWindows(); } rsValidate = m_ogtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, new object[] { m_ogtApplication.DataContext.ActiveJob }); if (rsValidate == null || rsValidate.RecordCount == 0) { return; } m_oGTTransactionManager.Begin("Revert Job"); commonRevertAPI rFeature = new commonRevertAPI(m_ogtApplication); rsValidate.MoveFirst(); while (!rsValidate.EOF) { jFno = 191; jFid = Convert.ToInt32(rsValidate.Fields["G3E_FID"].Value); jKeyObject = m_ogtApplication.DataContext.OpenFeature(jFno, jFid); rFeature.m_FromJob = "JOB"; rFeature.RevertWPFeature(jKeyObject); rsValidate.MoveNext(); } if (rFeature.m_uProcessedCUs) { MessageBox.Show("Check remaining Work Points to make manual corrections.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); m_oGTTransactionManager.Rollback(); } finally { if (rsValidate != null) { if (rsValidate.State == 1) { rsValidate.Close(); rsValidate.ActiveConnection = null; } rsValidate = null; } } }