Select to view content in your preferred language

PrintTask with a proxy

847
3
10-01-2012 02:27 PM
DorothyMortenson
Deactivated User
Hello,
I have a web application that has one dataset that is secured through a proxy service. It is only available inhouse.

<esri:ArcGISDynamicMapServiceLayer ID="Tax Lots"  
                         Url="http://someurl/ArcGIS/rest/services/Secure/taxlots/MapServer" 
                         ProxyURL="../../../SilverlightProxy/proxy.ashx" VisibleLayers="0"                               
                         Opacity="1.0" />


I am using the new printtask to allow for printing.  It does not work tho because of this dynamicmapservicelayer.

Do I need to add some kind of proxy for the printtask?
Suggestions on how to do this?

Dorothy
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
ProxyURL="../../../SilverlightProxy/proxy.ashx"


Your issue might be with the proxy relative path.
From the print server, this relative path is likely wrong.
Try by setting an absolute path (by code if needed)
0 Kudos
DorothyMortenson
Deactivated User
I tried the URL to the proxy and it still does not print.
0 Kudos
DorothyMortenson
Deactivated User
I solved it, almost...

In the ExportMap_Click, I turn off the secured layer before I print. This does not help, tho, should we want to actually print the features on the secured layer.

if (myLayer.ID == "Tax Lots" )
   {
        myLayer.Visible = false;
   }


But your suggestion of using the full url for the proxy helped with another issue I had - I wasn't able to test the application right from Visual Studio with the relative pathname.  With the full pathname, I can. Yeah! 😄




For the full code of the ExportMap_Click...
private void ExportMap_Click(object sender, RoutedEventArgs e)
        {
            if (printTask == null || printTask.IsBusy) return;
            busyIndicator.Visibility = Visibility.Visible;

            // Define the LegendOptions. This will show specified Layers in the printed map's legend area.
            LegendOptions myLegendOptions = new LegendOptions();

            // Define a List<LegendLayer> objects to put in the LegendOptions.
            List<LegendLayer> myLegendLayers = new List<LegendLayer>();

            // Loop through all of the Layers in the Map Control.
            foreach (var myLayer in MyMap.Layers)
            {
                // Create a new LegendLayer object to put in the List<LegendLayer> collection.
                LegendLayer myLegendLayer = new LegendLayer();

                // Set the LegendLayer.LayerId to the Layer.ID to add it to the printed map's legend area.
                myLegendLayer.LayerId = myLayer.ID;

                if (myLayer.ID == "Water Rights" || myLayer.ID == "OWRD Layers")
                {
                    // Add a single LegendLayer into the List<LegendLayer> collection.
                    myLegendLayers.Add(myLegendLayer);
                }
                if (myLayer.ID == "Tax Lots" )
                {
                    myLayer.Visible = false;
                }
            }
            // Set the LegendOptions.LegendLayer to the new constructed List<LegendLayer> objects.
            myLegendOptions.LegendLayers = myLegendLayers;
            

            PrintParameters printParameters = new PrintParameters(MyMap)
            {
                LayoutOptions = new LayoutOptions() { Title=MapTitle.Text, 
                    LegendOptions = myLegendOptions},
                ExportOptions = new ExportOptions() { Dpi = 96, OutputSize = new Size(MyMap.ActualWidth, MyMap.ActualHeight) },
                LayoutTemplate = (string)LayoutTemplates.SelectedItem ?? string.Empty,
                Format = (string)Formats.SelectedItem,
            };

            printTask.ExecuteAsync(printParameters);
        }
0 Kudos