Nakul, John, and JayI'm so sorry to post again and ask another question. I thought I had this figured out:(I have everything going and I'm trying to add my 3rd output parameter (the zip file).My first two are returning fine (Clipped Buffered Parcels graphic and an HTML file) and I'm able to get the hyperlink button to appear for the zip file but it is linking to the HTML page so both the html button and the zip button are bring up the htlm output. Would you mind looking at my code and letting me know what I'm doing wrong.Thanks again for all the help!Christine
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Tasks;
namespace GeoProcessTest
{
public partial class MainPage : UserControl
{
private DispatcherTimer _processingTimer;
private Draw MyDrawObject;
public MainPage()
{
InitializeComponent();
_processingTimer = new System.Windows.Threading.DispatcherTimer();
_processingTimer.Interval = new TimeSpan(0, 0, 0, 0, 800);
_processingTimer.Tick += ProcessingTimer_Tick;
MyDrawObject = new Draw(MyMap)
{
DrawMode = DrawMode.Polyline,
IsEnabled = true,
LineSymbol = LayoutRoot.Resources["ClipLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol
};
MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
}
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
{
MyDrawObject.IsEnabled = false;
ProcessingTextBlock.Visibility = Visibility.Visible;
_processingTimer.Start();
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
Graphic graphic = new Graphic()
{
Symbol = LayoutRoot.Resources["ClipLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol,
Geometry = args.Geometry
};
graphicsLayer.Graphics.Add(graphic);
Geoprocessor geoprocessorTask = new Geoprocessor("http://GisServer/ArcGIS/rest/services/GeoProcessTest/GPServer/Model");
geoprocessorTask.UpdateDelay = 5000;
geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPLinearUnit("Enter_Buffer_Distance", esriUnits.esriFeet, Int32.Parse(DistanceTextBox.Text)));
parameters.Add(new GPFeatureRecordSetLayer("Draw_a_line_or_multiple_lines_to_select_parcels_", args.Geometry));
parameters.Add(new GPString("HTML_TITLE", (TitleTextBox.Text)));
geoprocessorTask.SubmitJobAsync(parameters);
}
private void GeoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
{
Geoprocessor geoprocessorTask = sender as Geoprocessor;
geoprocessorTask.GetResultDataCompleted += (s1, ev1) =>
{
GraphicsLayer graphicsLayer = MyMap.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
if (ev1.Parameter is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer gpLayer = ev1.Parameter as GPFeatureRecordSetLayer;
if (gpLayer.FeatureSet.Features.Count == 0)
{
geoprocessorTask.GetResultImageLayerCompleted += (s2, ev2) =>
{
GPResultImageLayer gpImageLayer = ev2.GPResultImageLayer;
gpImageLayer.Opacity = 0.5;
MyMap.Layers.Add(gpImageLayer);
ProcessingTextBlock.Text = "Greater than 500 features returned. Results drawn using map service.";
_processingTimer.Stop();
};
geoprocessorTask.GetResultImageLayerAsync(e.JobInfo.JobId, "BufferedParcels");
return;
}
foreach (Graphic graphic in gpLayer.FeatureSet.Features)
{
graphic.Symbol = LayoutRoot.Resources["ClipFeaturesFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
graphicsLayer.Graphics.Add(graphic);
}
}
//add code to add zip file
if (ev1.Parameter is GPDataFile)
{
GPDataFile gpdata = ev1.Parameter as GPDataFile;
Uri uri = new Uri(gpdata.Url);
button1.TargetName = "_blank";
button1.NavigateUri = uri;
button1.Content = "HTML FILE";
button1.Visibility = System.Windows.Visibility.Visible;
//System.Windows.Browser.HtmlPage.Window.Navigate(uri);
//Uri uri2 = new Uri(gpdata.Url);
//button2.NavigateUri = uri2;
//button2.Content = "ZIP FILE";
//button2.Visibility = System.Windows.Visibility.Visible;
geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "BufferedParcels");
}
//if (ev1.Parameter is GPDataFile)
//{
// GPDataFile gpdata2 = ev1.Parameter as GPDataFile;
// Uri uri2 = new Uri(gpdata2.Url);
// button2.NavigateUri = uri2;
// button2.Content = "ZIP FILE";
// button2.Visibility = System.Windows.Visibility.Visible;
//}
ProcessingTextBlock.Visibility = Visibility.Collapsed;
_processingTimer.Stop();
};
geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "Output_htm__2_");
geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "output_zip");
// geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "BufferedParcels");
}
private void GeoprocessorTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Geoprocessor service failed: " + e.Error);
}
private void ClearButton_Click(object sender, RoutedEventArgs e)
{
List<Layer> gpResultImageLayers = new List<Layer>();
foreach (Layer layer in MyMap.Layers)
if (layer is GraphicsLayer)
(layer as GraphicsLayer).ClearGraphics();
else if (layer is GPResultImageLayer)
gpResultImageLayers.Add(layer);
for (int i = 0; i < gpResultImageLayers.Count; i++)
MyMap.Layers.Remove(gpResultImageLayers);
MyDrawObject.IsEnabled = true;
ProcessingTextBlock.Text = "";
ProcessingTextBlock.Visibility = Visibility.Collapsed;
}
void ProcessingTimer_Tick(object sender, EventArgs e)
{
if (ProcessingTextBlock.Text.Length > 20 || !ProcessingTextBlock.Text.StartsWith("Processing"))
ProcessingTextBlock.Text = "Processing.";
else
ProcessingTextBlock.Text = ProcessingTextBlock.Text + ".";
}
}
}