ArcIMS BlueViewer
ArcIMS_BlueViewer_VBNet\print.aspx.vb
' Copyright 2011 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 

 

Namespace BlueViewer

    Partial Class print
        Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
        End Sub

        Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender

            Dim imageURL As String = ""
            Dim legendURL As String = ""

            If Session("VALID_USER") = True Then

                Dim sServer As String = ConfigurationManager.AppSettings("DEFAULT_MAPSERVER")
                Dim iPort As Integer = CInt(ConfigurationManager.AppSettings("DEFAULT_MAPPORT"))
                Dim sService As String = ConfigurationManager.AppSettings("DEFAULT_MAPSERVICE")
                Dim iWidth As Integer = CInt(Request.QueryString("WIDTH"))
                Dim iHeight As Integer = CInt(Request.QueryString("HEIGHT"))

                Dim conArcIMS As New ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection(sServer, iPort)
                Dim axlRequest As New ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests
                Dim axlResponse As New System.Xml.XmlDocument
                conArcIMS.ServiceName = sService

                Dim sAXLText As String
                sAXLText = "<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1"">"
                sAXLText = sAXLText & "<REQUEST><GET_IMAGE><PROPERTIES>"
                sAXLText = sAXLText & "<IMAGESIZE width=""" & iWidth & """ height=""" & iHeight & """/>"
                sAXLText = sAXLText & "<ENVELOPE minx=""" & Request.QueryString("XMIN") & """ miny=""" & Request.QueryString("YMIN") & """ maxx=""" & Request.QueryString("XMAX") & """ maxy=""" & Request.QueryString("YMAX") & """ />"
                sAXLText = sAXLText & "<LEGEND display=""true"" autoextend=""true"" title=""Map Legend"" font=""Verdana"" titlefontsize=""14"" />"
                sAXLText = sAXLText & "</PROPERTIES></GET_IMAGE></REQUEST></ARCXML>"

                axlResponse.LoadXml(conArcIMS.Send(sAXLText))

                If axlResponse.GetElementsByTagName("OUTPUT").Count = 1 Then
                    Dim nodeOutput As System.Xml.XmlNodeList = axlResponse.GetElementsByTagName("OUTPUT")
                    imageURL = nodeOutput(0).Attributes("url").Value
                End If

                If axlResponse.GetElementsByTagName("LEGEND").Count = 1 Then
                    Dim nodeOutput As System.Xml.XmlNodeList = axlResponse.GetElementsByTagName("LEGEND")
                    legendURL = nodeOutput(0).Attributes("url").Value
                End If

                imgMap.Src = imageURL
                imgLegend.Src = legendURL
                txtTitle.Value = ConfigurationManager.AppSettings("DEFAULT_PRINT_TITLE")
            Else
                Response.Write("Error: Page Inaccessible.")
            End If
        End Sub
    End Class

End Namespace