ArcIMS_BlueViewer_CSharp\print.aspx.cs
// 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. // using System.Configuration; namespace BlueViewer { public partial class print : System.Web.UI.Page { [System.Diagnostics.DebuggerStepThrough()] private void InitializeComponent() { } override protected void OnInit(System.EventArgs e) { base.OnInit(e); InitializeComponent(); } override protected void OnLoad(System.EventArgs e) { base.OnLoad(e); } override protected void OnPreRender(System.EventArgs e) { base.OnPreRender(e); string imageURL = ""; string legendURL = ""; if ((bool)Session["VALID_USER"]) { string sServer = ConfigurationManager.AppSettings["DEFAULT_MAPSERVER"]; int iPort = System.Convert.ToInt32(ConfigurationManager.AppSettings["DEFAULT_MAPPORT"]); string sService = ConfigurationManager.AppSettings["DEFAULT_MAPSERVICE"]; int iWidth = System.Convert.ToInt32(Request.QueryString["WIDTH"]); int iHeight = System.Convert.ToInt32(Request.QueryString["HEIGHT"]); ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection conArcIMS = new ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection(sServer, iPort); ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests axlRequest = new ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests(); System.Xml.XmlDocument axlResponse = new System.Xml.XmlDocument(); conArcIMS.ServiceName = sService; string sAXLText = null; 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) { System.Xml.XmlNodeList nodeOutput = axlResponse.GetElementsByTagName("OUTPUT"); imageURL = nodeOutput[0].Attributes["url"].Value; } if (axlResponse.GetElementsByTagName("LEGEND").Count == 1) { System.Xml.XmlNodeList nodeOutput = axlResponse.GetElementsByTagName("LEGEND"); legendURL = nodeOutput[0].Attributes["url"].Value; } imgMap.Src = imageURL; imgLegend.Src = legendURL; txtTitle.Value = ConfigurationManager.AppSettings["DEFAULT_PRINT_TITLE"]; } else { Response.Write("Error: Page Inaccessible."); } } } }