private void GeoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e) { if (e.JobInfo.JobStatus != esriJobStatus.esriJobSucceeded) { MessageBox.Show("Geoprocessor service failed" ); ProcessingTextBlock.Text = ""; ProcessingTextBlock.Visibility = Visibility.Collapsed; GraphicsLayer graphicsLayer = Map.Layers["Results"] as GraphicsLayer; GraphicsLayer startLayer = Map.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); startLayer.ClearGraphics(); this.SpreadModel.IsOpen = !this.SpreadModel.IsOpen; } else { Geoprocessor geoprocessorTask = sender as Geoprocessor; geoprocessorTask.GetResultDataCompleted += (s1, ev1) => { if (ev1.Parameter is GPFeatureRecordSetLayer) { GraphicsLayer graphicsLayer = Map.Layers["Results"] as GraphicsLayer; GPFeatureRecordSetLayer gpLayer = ev1.Parameter as GPFeatureRecordSetLayer; foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphic.Symbol = LayoutRoot.Resources["MyGreenFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphic); } } if (ev1.Parameter is GPDataFile) { GPDataFile gpdata = ev1.Parameter as GPDataFile; Uri uri = new Uri(gpdata.Url); btndownload.NavigateUri = uri; urltodownload = uri; geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "RelativeSpread"); } }; geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "Outfile"); } }
Solved! Go to Solution.
I don't think I understand. I only have one task giving me two results. How do I access the results without firing the getResultData twice, once for each result?
Thanks for your help I really do appreciate it.
Ah, that might be me - only skim-reading the code, let me check again. (not doing too well with this stuff today!)
function SpreadModel1(){ if (map.graphics.graphics.length === 0) { alert('Please place your starting point'); return; } //get starting point var features = []; features.push(map.graphics.graphics[0]); var featureSet = new esri.tasks.FeatureSet(); featureSet.features = features; //get Break Values var box0 = dijit.byId("dbv1"); gp = new esri.tasks.Geoprocessor("http://blah/ArcGIS/rest/services/APHIS/SpreadModel1/GPServer/APHIS%20Group1"); var params = { "Input_Layer": dijit.byId('spreadmodel1layers').value, "Start_locations": featureSet, "Default_break_values": box0.attr("value") } esri.show(loading); gp.submitJob(params, completeCallback, statusCallback, function(error){ alert(error); esri.hide(loading); }); }
gp.getResultData(jobInfo.jobId,"Outfile",downloadFile)
Nothing obvious leaps out, the only thing I've spotted so far is a missing semi colon!gp.getResultData(jobInfo.jobId,"Outfile",downloadFile)
Perhaps someone with sharper eyes can spot an issue, I've tried re-jigging the sample to run multiple concurrent getDataResult() requests and can't recreate an issue so far.
Do both callbacks actually get invoked?