private bool MapFrameExists(IGTNamedPlot p_NamedPlot) { bool bReturn = true; int iCount = 0; try { for (int i = 0; i < p_NamedPlot.Frames.Count; i++) { if (p_NamedPlot.Frames[i].Type == GTPlotFrameTypeConstants.gtpftMap) { iCount = iCount + 1; } } if (iCount == 0 || iCount > 1) { bReturn = false; } } catch (Exception) { throw; } return(bReturn); }
private void SetAutomaticFields(IGTNamedPlot p_NamedPlot, int p_TotalCount, int p_current_count, IGTApplication p_oApp) { foreach (IGTPlotRedline item in p_NamedPlot.GetRedlines(GTPlotRedlineCollectionConstants.gtprcTextOnly)) { if ((item.AutomaticTextField == "SHEET m OF n")) { ((IGTTextPointGeometry)(item.Geometry)).Text = "SHEET " + p_current_count + " OF " + p_TotalCount; } else if ((item.AutomaticTextField == "SCALE")) { foreach (IGTPlotFrame tmpFrame in p_NamedPlot.Frames) { if (tmpFrame.Type == GTPlotFrameTypeConstants.gtpftMap) { // ((IGTTextPointGeometry)(item.Geometry)).Text = p_NamedPlot.Frames[0].PlotMap.DisplayScale.ToString(); ((IGTTextPointGeometry)(item.Geometry)).Text = tmpFrame.PlotMap.DisplayScale.ToString(); break; } } } } p_NamedPlot.FieldsQuery = @"select G3E_JOB.WR_NBR ""WR NO"",G3E_JOB.SERVICE_CENTER_C ""SERVICE CENTER"", G3E_JOB.OFFICE_C ""OFFICE"", G3E_JOB.DESIGNER_NM || '[' || G3E_JOB.DESIGNER_UID || ']' || ' ' || '(' || SUBSTR(G3E_JOB.DESIGNER_PHONE, 1, 3) || ')' || SUBSTR(G3E_JOB.DESIGNER_PHONE, 4, 3) || '-' || SUBSTR(G3E_JOB.DESIGNER_PHONE, 7, 4) ""DESIGNER"",G3E_JOB.PROJMGR_NM || '[' || G3E_JOB.PROJMGR_RACFID || ']' || ' ' || '(' || SUBSTR(G3E_JOB.PROJMGR_PHONE, 1, 3) || ')' || SUBSTR(G3E_JOB.PROJMGR_PHONE, 4, 3) || '-' || SUBSTR(G3E_JOB.PROJMGR_PHONE, 7, 4) ""PROJECT MANAGER"",G3E_JOB.G3E_DESCRIPTION ""WR NAME"", G3E_JOB.CUSTOMER_NM ""CUSTOMER"", G3E_JOB.WR_HOUSE_NBR || ' ' || G3E_JOB.WR_HOUSE_NBR_FRACTION || ' ' || G3E_JOB.WR_STREET_LEADING_DIR || ' ' || G3E_JOB.WR_STREET_NM || ' ' || G3E_JOB.WR_STREET_TYPE || ' ' || G3E_JOB.WR_STREET_TRAILING_DIR || ',' || G3E_JOB.WR_TOWN_C ""ADDRESS"", G3E_JOB.LOCATION ""LOCATION"" from g3e_job where g3e_IDENTIFIER = '" + p_oApp.DataContext.ActiveJob + "'"; }
private bool IsTemplateExist() { Recordset rs = null; string strPlotTemplateName = ""; IGTNamedPlots gTNamedPlots = null; try { rs = m_gTDataContext.OpenRecordset("select PARAM_VALUE from SYS_GENERALPARAMETER where PARAM_NAME=:1", CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText, strParamName); if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); strPlotTemplateName = Convert.ToString(rs.Fields[0].Value); if (!string.IsNullOrEmpty(strPlotTemplateName)) { gTNamedPlots = gTApplication.NamedPlots; if (gTNamedPlots != null && gTNamedPlots.Count > 0) { foreach (IGTNamedPlot npt in gTNamedPlots) { if (npt.Name == strPlotTemplateName) { gTNamedPlot = npt; return(true); } } } } } } catch { throw; } finally { rs.Close(); rs = null; } return(false); }
public bool IsValid() { bool validate = true; try { CheckValidation checkValidation = new CheckValidation(gTDataContext, gTDDCKeyObjects, gTApplication, gTCustomCommandHelper); checkValidation.strParamName = strParamName; validate = checkValidation.IsValid(); strErrorMessage = checkValidation.strErrorMessage; ActiveWorkRequest = checkValidation.ActiveWorkRequest; m_SelectedEsiLocations = checkValidation.m_SelectedEsiLocations; m_descriptionId = checkValidation.m_descriptionId; gTKeyObjects = checkValidation.gTKeyObjects; gTNamedPlot = checkValidation.gTNamedPlot; processPlot = new ProcessPlot(gTApplication, gTNamedPlot, m_SelectedEsiLocations); } catch { throw; } return(validate); }
private void setPDFPrinterProps(ref IGTPDFPrinterProperties tmpPrintProps) { IGTNamedPlot tmpNamedPlt = null; try { tmpNamedPlt = m_igtApplication.ActivePlotWindow.NamedPlot; tmpPrintProps.PageHeight = tmpNamedPlt.PaperHeight; tmpPrintProps.PageWidth = tmpNamedPlt.PaperWidth; if (tmpNamedPlt.PaperHeight > tmpNamedPlt.PaperWidth) { tmpPrintProps.Orientation = PageOrientationType.Portrait; } else { tmpPrintProps.Orientation = PageOrientationType.Landscape; } } catch (Exception ex) { MessageBox.Show("Error in ccAttachSiteDrawing.setPDFPrinterProps. Error: " + ex.Message, "setPDFPrinterProps Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Generates the construction prints (plots) for the active job. Generates a new string List for the prints parameter. /// </summary> /// <param name="prints">string that will contain the path/file name of the generated plots.</param> /// <returns>true if successful; else, false</returns> private bool GenerateConstructionPrints(out string prints) { bool retVal = false; prints = string.Empty; try { IGTApplication app = GTClassFactory.Create <IGTApplication>(); CommonMapPrintingHelper mpHelper = new CommonMapPrintingHelper(app); string tmpFileName = string.Format("{0}-Close-WorkPrint", app.DataContext.ActiveJob); string tmpFilePath = System.IO.Path.GetTempPath(); #region Code in this region to be removed entirely once Plotting Template(s) are available. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Until we get plot templates, then check whether the "Construction Print" named plot exists. // If it doesn't, then create one to serve as a temporary solution for a missing plot sheet. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool needNamedPlot = true; foreach (IGTNamedPlot namedPlot in app.NamedPlots) { if (namedPlot.Name == "Construction Print") { needNamedPlot = false; } } // If the Construction Print named plot doesn't exist, then create one. if (needNamedPlot) { IGTNamedPlot np = app.NewNamedPlot("Construction Print"); IGTPlotWindow pw = app.NewPlotWindow(np); IGTPoint frameTopLeft = GTClassFactory.Create <IGTPoint>(); frameTopLeft.X = 0.0; frameTopLeft.Y = 0.0; IGTPoint frameBottomRight = GTClassFactory.Create <IGTPoint>(); frameBottomRight.X = 20000.0; frameBottomRight.Y = 30000.0; IGTPaperRange paperRange = GTClassFactory.Create <IGTPaperRange>(); paperRange.TopLeft = frameTopLeft; paperRange.BottomRight = frameBottomRight; IGTPlotMap map = pw.InsertMap(paperRange); } #endregion ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // For now, defaulting the legend name to Distribution Design Legend for these prints; however, // this may be enhanced to determine which legend to use based on the WR type. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (mpHelper.GenerateConstructionPlots("Distribution Design Legend", tmpFileName, tmpFilePath)) { prints = string.Format("{0}\\{1}", tmpFilePath, tmpFileName); retVal = true; } } catch (Exception ex) { string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); MessageBox.Show(exMsg, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return(retVal); }
public bool GeneratePlot(string strPlot, string strCity, string strDivision) { IGTNamedPlot gTNewNamedPlot = GTClassFactory.Create <IGTNamedPlot>(); IGTPlotFrame gTNewPlotFrame = GTClassFactory.Create <IGTPlotFrame>(); IGTPlotWindow gTPlotWindow = GTClassFactory.Create <IGTPlotWindow>(); IGTPlotMap gtNewPlotMap = GTClassFactory.Create <IGTPlotMap>(); IGTPlotRedlines gTPlotRedlines = null; //Recordset rs = null; object objectValue = null; string strNewPlotName = ""; try { if (!IsPlotNameExist(strPlot)) { strNewPlotName = strPlot; if (m_gTNamedPlot != null && !string.IsNullOrEmpty(strNewPlotName)) { gTNewNamedPlot = m_gTNamedPlot.CopyPlot(strNewPlotName); gTPlotWindow = m_gTApplication.NewPlotWindow(gTNewNamedPlot); gTPlotWindow.BackColor = System.Drawing.Color.White; gTPlotWindow.Caption = gTPlotWindow.NamedPlot.Name; if (!String.IsNullOrEmpty(m_gTNamedPlot.FieldsQuery)) { gTPlotWindow.NamedPlot.FieldsQuery = m_gTNamedPlot.FieldsQuery; } //rs = gTDataContext.OpenRecordset(gTPlotWindow.NamedPlot.FieldsQuery, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, // (int)ADODB.CommandTypeEnum.adCmdText, gTDataContext.ActiveJob); gTPlotRedlines = gTPlotWindow.NamedPlot.GetRedlines(GTPlotRedlineCollectionConstants.gtprcTextOnly); foreach (IGTPlotRedline prl in gTPlotRedlines) { IGTTextPointGeometry gTTextPointGeometry = (IGTTextPointGeometry)prl.Geometry.Copy(); if (prl.AutomaticTextSource == GTPlotAutomaticTextSourceConstants.gtpatPlotByQuery) { string currentVal = String.IsNullOrEmpty(gTTextPointGeometry.Text) ? " " : gTTextPointGeometry.Text; if (prl.AutomaticTextField.ToString() == "WR") { objectValue = m_gTApplication.DataContext.ActiveJob; } else if (prl.AutomaticTextField.ToString() == "StreetLightESILocation") { string esiLocations = ""; foreach (string esiL in m_SelectedEsiLocations) { if (!string.IsNullOrEmpty(esiLocations)) { esiLocations = esiLocations + ",'" + esiL + "'"; } else { esiLocations = "'" + esiL + "'"; } } objectValue = esiLocations; } else if (prl.AutomaticTextField.ToString() == "CountofStreetLightsinselectset") { objectValue = m_SelectedEsiLocations.Length + " Street Lights"; } else if (prl.AutomaticTextField.ToString() == "Subdivision") { objectValue = strDivision; } else if (prl.AutomaticTextField.ToString() == "City") { objectValue = strCity; } gTTextPointGeometry.Text = (objectValue == null) ? " " : objectValue.ToString(); prl.Geometry = gTTextPointGeometry; } } foreach (IGTPlotFrame plf in gTNewNamedPlot.Frames) { if (plf.Type == GTPlotFrameTypeConstants.gtpftMap) { gTNewPlotFrame = plf; } } if (gTNewPlotFrame != null) { gtNewPlotMap = gTNewPlotFrame.PlotMap; gTNewPlotFrame.Activate(); gTNewPlotFrame.PlotMap.FitSelectedObjects(1.2); gTNewPlotFrame.Deactivate(); m_gTApplication.RefreshWindows(); return(true); } } } else { MessageBox.Show("Plot name already exists in workspace. Please enter a different plot name", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } } catch { throw; } return(false); }
public ProcessPlot(IGTApplication gTApplication, IGTNamedPlot gTNamedPlot, string[] SelectedEsiLocations) { m_gTApplication = gTApplication; m_gTNamedPlot = gTNamedPlot; m_SelectedEsiLocations = SelectedEsiLocations; }
/// <summary> /// Method to check of the Vegetation management PlotTemplate in Workspace. /// </summary> /// <param name="p_vegMngSheetTemp">Name of the copy of the Vegetation management HTML sheet template</param> /// <param name="p_newTreeTrimmingfeature">Current placed feature</param> public void CreateVegetationManagementPlotTemplateCopy(string p_vegMngSheetTemp, IGTKeyObject p_newTreeTrimmingfeature) { string plotTemplateName = null; Recordset rs = null; bool found = false; IGTNamedPlot template = null; try { rs = m_oGTApplication.DataContext.OpenRecordset("select PARAM_VALUE from sys_generalparameter where PARAM_NAME='VegMgmtEstimate_Plot'", CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText); if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); plotTemplateName = Convert.ToString(rs.Fields["PARAM_VALUE"].Value); IGTNamedPlots npcollection = m_oGTApplication.NamedPlots; if (npcollection != null) { if (npcollection.Count > 0) { foreach (IGTNamedPlot np in npcollection) { if (np.Name == plotTemplateName) { template = np; found = true; break; } } } } if (!found) { DialogResult result = MessageBox.Show(m_oGTApplication.ApplicationWindow, "Unable to generate plot; missing template " + plotTemplateName + ". Send anyway? ", "G /Technology", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.OK: { break; } case DialogResult.Cancel: { m_oUserCancelRequest = true; if (!String.IsNullOrEmpty(p_vegMngSheetTemp)) { File.Delete(p_vegMngSheetTemp); } break; } } } else { CreatePlotWindowAndPlotPDF(template, p_newTreeTrimmingfeature); } } } catch (Exception) { m_oUserCancelRequest = true; throw; } }
/// <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; } }
internal void BuildWorkPrint(List <PlotBoundaryAttributes> p_PlotBoundaryCollection, IGTApplication p_oApp, string p_destDir, string p_outputFileName, string p_legendName) { try { List <string> PDFNames = new List <string>(); for (int i = 0; i < p_PlotBoundaryCollection.Count; i++) { string sErrMsg = string.Empty; IGTNamedPlot oNamedPlot = null; IGTKeyObject oClipGeom = p_oApp.DataContext.OpenFeature(p_PlotBoundaryCollection[i].FNO, p_PlotBoundaryCollection[i].FID); IGTComponent oComp = oClipGeom.Components.GetComponent(18802); oComp.Recordset.MoveFirst(); IGTPolygonGeometry oGeom = (IGTPolygonGeometry)oComp.Geometry; foreach (IGTNamedPlot item in p_oApp.NamedPlots) { if (item.Name.Equals(p_PlotBoundaryCollection[i].PlotTemplateName)) { oNamedPlot = item; break; } } DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i, p_oApp); IGTNamedPlot oCopiedPlot = oNamedPlot.CopyPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i); IGTPlotWindow oPlotWindow = p_oApp.NewPlotWindow(oCopiedPlot); IGTPlotFrame oFrame = null; foreach (IGTPlotFrame tmpFrame in oPlotWindow.NamedPlot.Frames) { // IGTPlotFrame oFrame = oPlotWindow.NamedPlot.Frames[0]; if (tmpFrame.Type == GTPlotFrameTypeConstants.gtpftMap) { oFrame = tmpFrame; break; } } oFrame.Activate(); oFrame.PlotMap.DisplayService.ReplaceLegend(p_legendName); AssignClipGeometryToFrame(p_oApp, oFrame, oGeom); oPlotWindow.Activate(); SetAutomaticFields(oPlotWindow.NamedPlot, p_PlotBoundaryCollection.Count, i + 1, p_oApp); p_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, string.Format("Generating Construction Print {0} of {1}", i + 1, p_PlotBoundaryCollection)); ExportToPDF(p_destDir, p_outputFileName + "-" + i + ".pdf", false, oPlotWindow, out sErrMsg); PDFNames.Add(p_outputFileName + "-" + i + ".pdf"); oPlotWindow.Close(); DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i + 1, p_oApp); } if (PDFNames.Count > 0) { MergePDFs(p_destDir, PDFNames, p_outputFileName); } } catch (Exception) { throw; } }