Ejemplo n.º 1
0
        /// <summary>
        /// Method to Export the given plot window to PDF
        /// </summary>
        /// <param name="pw"></param>
        private void ExportToPDF(IGTPlotWindow pw)
        {
            IGTExportService        svcExport  = null;
            IGTPDFPrinterProperties printProps = null;

            try
            {
                // Construct printer properties
                PageOrientationType orientation =
                    (pw.NamedPlot.PaperWidth > pw.NamedPlot.PaperHeight)
                    ? PageOrientationType.Portrait : PageOrientationType.Landscape;

                printProps             = GTClassFactory.Create <IGTPDFPrinterProperties>();
                printProps.PageWidth   = pw.NamedPlot.PaperWidth;
                printProps.PageHeight  = pw.NamedPlot.PaperHeight;
                printProps.Orientation = orientation;
                printProps.PageSize    = PageSizeValue.Auto;
                printProps.Resolution  = ResolutionValue.DPI600;

                // Perform export
                svcExport = GTClassFactory.Create <IGTExportService>();
                svcExport.PDFLayersEnabled = false;
                svcExport.SaveAsPDF(m_strDoumentsPath, printProps, pw, true);

                m_oGTTransactionManager.Begin("Attach Street Light Supplemental Agreement Plot");

                IGTKeyObject gTTempKeyObject = m_gTDataContext.OpenFeature(m_gTDesignAreaKeyObject.FNO, m_gTDesignAreaKeyObject.FID);
                Recordset    rs = gTTempKeyObject.Components.GetComponent(8130).Recordset;

                rs.AddNew("G3E_FID", gTTempKeyObject.FID);
                rs.Fields["HYPERLINK_T"].Value   = m_strDoumentsPath;
                rs.Fields["DESCRIPTION_T"].Value = "Street Supplemental Plot";
                rs.Fields["TYPE_C"].Value        = "SUPPLEPLOT";
                rs.Fields["G3E_FNO"].Value       = 8100;
                rs.Update();
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Commit();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                svcExport  = null;
                printProps = null;
                pw         = null;
            }
        }
Ejemplo n.º 2
0
        private string ExportToPDF(string p_destDir, string p_destName, bool p_append, IGTPlotWindow p_outputWindow, out string p_msg)
        {
            string retVal = string.Empty;

            p_msg = "";

            try
            {
                string destPathName = Path.Combine(p_destDir, p_destName);
                IGTPDFPrinterProperties pdfProps = GTClassFactory.Create <IGTPDFPrinterProperties>();
                pdfProps.EmbedFont = true;

                if (p_outputWindow.NamedPlot != null)
                {
                    pdfProps.PageHeight = p_outputWindow.NamedPlot.PaperHeight;
                    pdfProps.PageWidth  = p_outputWindow.NamedPlot.PaperWidth;
                }
                pdfProps.Orientation = PageOrientationType.Portrait;
                pdfProps.PageSize    = PageSizeValue.Auto;
                pdfProps.Resolution  = ResolutionValue.DPI600;

                // Perform export
                IGTExportService svcExport = GTClassFactory.Create <IGTExportService>();
                svcExport.PDFLayersEnabled = false;

                svcExport.SaveAsPDF(destPathName, pdfProps, p_outputWindow, p_append);
                svcExport = null;

                // Close output window
                p_outputWindow.Close();

                retVal = destPathName;
            }
            catch (Exception ex)
            {
                p_msg = ex.Message;
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to Export the given plot window to PDF
        /// </summary>
        /// <param name="p_destDir">Directory path of the target PDF filename.</param>
        /// <param name="p_destName">PDF filename</param>
        /// <param name="p_append">Append the results to destFileName, if destFileName already exists; otherwise create/overwrite FileName</param>
        /// <param name="pw">Plot window which needs to be exported to PDF</param>
        private void ExportToPDF(string p_destDir, string p_destName, bool p_append, IGTPlotWindow pw)
        {
            IGTExportService        svcExport  = null;
            IGTPDFPrinterProperties printProps = null;

            try
            {
                // Construct full path
                string destPathName = Path.Combine(p_destDir, p_destName);

                // Construct printer properties
                PageOrientationType orientation =
                    (pw.NamedPlot.PaperWidth > pw.NamedPlot.PaperHeight)
                    ? PageOrientationType.Portrait : PageOrientationType.Landscape;

                printProps             = GTClassFactory.Create <IGTPDFPrinterProperties>();
                printProps.PageWidth   = pw.NamedPlot.PaperWidth;
                printProps.PageHeight  = pw.NamedPlot.PaperHeight;
                printProps.Orientation = orientation;
                printProps.PageSize    = PageSizeValue.Auto;
                printProps.Resolution  = ResolutionValue.DPI600;

                // Perform export
                svcExport = GTClassFactory.Create <IGTExportService>();
                svcExport.PDFLayersEnabled = false;
                svcExport.SaveAsPDF(destPathName, printProps, pw, p_append);
            }
            catch
            {
                throw;
            }
            finally
            {
                svcExport  = null;
                printProps = null;
                pw         = null;
            }
        }
Ejemplo n.º 4
0
        public void Activate()
        {
            IGTPlotWindow           igtPlotWindow           = null;
            IGTExportService        igtExportService        = null;
            IGTPDFPrinterProperties igtPDFPrinterProperties = null;

            OncDocManage.OncDocManage tmpOncDocMgr = new OncDocManage.OncDocManage();


            try
            {
                m_igtApplication        = GTClassFactory.Create <IGTApplication>();
                igtPlotWindow           = m_igtApplication.ActivePlotWindow;
                igtExportService        = GTClassFactory.Create <IGTExportService>();
                igtPDFPrinterProperties = GTClassFactory.Create <IGTPDFPrinterProperties>();
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing to selected feature started");

                if (Validate())
                {
                    m_plotwindowPdfFilename = m_plotwindowPath + igtPlotWindow.Caption + ".pdf";
                    m_igtApplication.BeginWaitCursor();

                    setPDFPrinterProps(ref igtPDFPrinterProperties);

                    igtExportService.SaveAsPDF(m_plotwindowPdfFilename, igtPDFPrinterProperties, igtPlotWindow, false);
                    igtExportService        = null;
                    igtPDFPrinterProperties = null;
                    igtPlotWindow           = null;
                    //m_igtApplication.EndWaitCursor();
                    if (File.Exists(m_plotwindowPdfFilename))
                    {
                        if (GetGeneralParams(ref tmpOncDocMgr))
                        {
                            m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Adding the Site Drawing PDF file to SharePoint.");
                            tmpOncDocMgr.SrcFilePath = m_plotwindowPdfFilename;
                            tmpOncDocMgr.SPFileName  = m_plotwindowPdfFilename.Substring(m_plotwindowPdfFilename.LastIndexOf("\\") + 1);
                            tmpOncDocMgr.SPFileType  = "Site Drawings";
                            tmpOncDocMgr.WrkOrd_Job  = m_igtApplication.DataContext.ActiveJob;

                            if (tmpOncDocMgr.AddSPFile(true))
                            {
                                //add to hyperlink to selected object
                                //AddHyperLinktoSelectedFeature(m_selectedFNO, m_selectedFID, m_plotwindowPdfFilename, "Plotwindow " + m_igtApplication.ActivePlotWindow.Caption + " pdf", "SITE");
                                AddHyperLinktoSelectedFeature(m_selectedFNO, m_selectedFID,
                                                              tmpOncDocMgr.RetFileURL, tmpOncDocMgr.RetFileName,
                                                              "Plotwindow " + m_igtApplication.ActivePlotWindow.Caption + " pdf", tmpOncDocMgr.SPFileType);
                            }
                            else
                            {
                                MessageBox.Show("Error during while trying to add the file to SharePoint. Error: " + tmpOncDocMgr.RetErrMessage, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_igtApplication.ApplicationWindow, "Ad hoc plots may only be attached to a Permit or Easement feature.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing Command has ended.");
                m_igtApplication.EndWaitCursor();
            }
            catch (Exception ex)
            {
                m_igtApplication.EndWaitCursor();
                MessageBox.Show("Error during execution of Attach Site Drawing custom command" + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing Command has ended with errors.");
            }
        }