本文整理汇总了C#中Geoprocessor.CheckJobStatusAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.CheckJobStatusAsync方法的具体用法?C# Geoprocessor.CheckJobStatusAsync怎么用?C# Geoprocessor.CheckJobStatusAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geoprocessor
的用法示例。
在下文中一共展示了Geoprocessor.CheckJobStatusAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartGP_Click
private async void StartGP_Click(object sender, RoutedEventArgs e)
{
StartGP.IsEnabled = false;
ClearGraphics();
ClearButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
ProcessingTextBlock.Visibility = Visibility.Collapsed;
var inputPolyline = await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline);
var inputGraphic = new Graphic { Geometry = inputPolyline };
GraphicsLayer inputLayer = mapView1.Map.Layers["InputLayer"] as GraphicsLayer;
inputLayer.Graphics.Add(inputGraphic);
MyProgressRing.Visibility = Visibility.Visible;
MyProgressRing.IsActive = true;
string message = null;
Geoprocessor task = new Geoprocessor(new Uri(ServiceUri));
var inputParameter = new GPInputParameter();
inputParameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPolyline));
inputParameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, Int32.Parse(DistanceTextBox.Text)));
try
{
//Submit the job and await the results
var gpJobInfo = await task.SubmitJobAsync(inputParameter);
//Poll the server every 5 seconds for the status of the job.
//Cancelled, Cancelling, Deleted, Deleting, Executing, Failed, New, Submitted, Succeeded, TimedOut, Waiting
while (gpJobInfo.JobStatus != GPJobStatus.Cancelled &&
gpJobInfo.JobStatus != GPJobStatus.Deleted &&
gpJobInfo.JobStatus != GPJobStatus.Failed &&
gpJobInfo.JobStatus != GPJobStatus.Succeeded &&
gpJobInfo.JobStatus != GPJobStatus.TimedOut)
{
gpJobInfo = await task.CheckJobStatusAsync(gpJobInfo.JobID);
await Task.Delay(5000);
}
//Now that the job is completed, check whether the service returned the results as Features or as a GPResultImageLayer.
//This can happen if the number of features to return exceeds the limit set on the service
if (gpJobInfo.JobStatus == GPJobStatus.Succeeded)
{
var resultData = await task.GetResultDataAsync(gpJobInfo.JobID, "Clipped_Counties");
if (resultData is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer gpLayer = resultData as GPFeatureRecordSetLayer;
if (gpLayer.FeatureSet.Features.Count == 0)
{
var resultImageLayer = await task.GetResultImageLayerAsync(gpJobInfo.JobID, "Clipped_Counties");
GPResultImageLayer gpImageLayer = resultImageLayer;
gpImageLayer.Opacity = 0.5;
mapView1.Map.Layers.Add(gpImageLayer);
ProcessingTextBlock.Visibility = Visibility.Visible;
ProcessingTextBlock.Text = "Greater than 500 features returned. Results drawn using map service.";
return;
}
GraphicsLayer resultLayer = mapView1.Map.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
foreach (Graphic g in gpLayer.FeatureSet.Features)
{
resultLayer.Graphics.Add(g);
}
}
}
MyProgressRing.Visibility = Visibility.Collapsed;
MyProgressRing.IsActive = false;
ClearButton.Visibility = Visibility.Visible;
StartGP.IsEnabled = true;
}
catch (Exception ex)
{
message = ex.Message;
}
if (message != null)
await new MessageDialog(message, "GP Failed").ShowAsync();
}
示例2: StartButton_Click
private async void StartButton_Click(object sender, RoutedEventArgs e)
{
StartButton.IsEnabled = false;
ClearResultsButton.Visibility = Visibility.Collapsed;
//get the user's input point
var inputPoint = await MyMapView.Editor.RequestPointAsync();
//update UI elements
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
MyProgressRing.IsActive = true;
viewshedLayer.Graphics.Clear();
inputLayer.Graphics.Clear();
inputLayer.Graphics.Add(new Graphic() { Geometry = inputPoint });
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));
var parameter = new GPInputParameter()
{
OutSpatialReference = new SpatialReference(102100)
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPoint));
parameter.GPParameters.Add(new GPString("Height", HeightTextBox.Text));
parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, Convert.ToDouble(MilesTextBox.Text)));
var result = await task.SubmitJobAsync(parameter);
//Poll the server for results every 2 seconds.
while (result.JobStatus != GPJobStatus.Cancelled && result.JobStatus != GPJobStatus.Deleted &&
result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
//show the status
StatusTextBlock.Text = string.Join(Environment.NewLine, result.Messages.Select(x => x.Description));
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
//get the results as a ArcGISDynamicMapServiceLayer
StatusTextBlock.Text = "Finished processing. Retrieving results...";
var viewshedResult = await task.GetResultDataAsync(result.JobID, "View") as GPFeatureRecordSetLayer;
var rangeResult = await task.GetResultDataAsync(result.JobID, "Range") as GPFeatureRecordSetLayer;
if (viewshedResult != null && viewshedResult.FeatureSet != null && viewshedResult.FeatureSet.Features != null)
{
foreach (var feature in viewshedResult.FeatureSet.Features)
{
viewshedLayer.Graphics.Add((Graphic)feature);
}
}
//Reset the UI
StatusTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
StartButton.IsEnabled = true;
ClearResultsButton.Visibility = Visibility.Visible;
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
MyProgressRing.IsActive = false;
}
}
示例3: getInputLineAndClip
// Waits for the user to draw a line, then performs the buffer and clip operation
private async void getInputLineAndClip()
{
if (m_firstPointAdded)
return;
// Get line from user
var clipLine = await Editor.RequestShapeAsync(DrawShape.Polyline,
new SimpleLineSymbol() { Color = Colors.Red, Width = 2, Style = SimpleLineStyle.Dash });
ClipLines.Add(new Graphic() { Geometry = clipLine });
// Show busy UI
BusyVisibility = Visibility.Visible;
StatusText = "Executing...";
string error = null;
// Initialize the Geoprocessing task with the buffer and clip service endpoint
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps10.esri.com/ArcGIS/rest/services/SamplesNET/" +
"USA_Data_ClipTools/GPServer/ClipCounties"));
// Initialize input parameters
var parameter = new GPInputParameter()
{
OutSpatialReference = SpatialReferences.WebMercator
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", clipLine)); // input geometry
parameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, BufferDistance)); // buffer distance
try
{
// Submit the job and await the results
var result = await task.SubmitJobAsync(parameter);
// Poll the server every two seconds for the status of the job.
while (result.JobStatus != GPJobStatus.Cancelled
&& result.JobStatus != GPJobStatus.Deleted
&& result.JobStatus != GPJobStatus.Failed
&& result.JobStatus != GPJobStatus.Succeeded
&& result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
// show the status
var descriptions = result.Messages.Select(msg => msg.Description);
var status = string.Join(Environment.NewLine, descriptions);
if (!string.IsNullOrEmpty(status))
StatusText = status;
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
// Get the results
var resultData = await task.GetResultDataAsync(result.JobID, "Clipped_Counties");
if (resultData is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer resultsLayer = resultData as GPFeatureRecordSetLayer;
if (resultsLayer.FeatureSet != null
&& resultsLayer.FeatureSet.Features != null
&& resultsLayer.FeatureSet.Features.Count != 0)
{
// Results were returned as graphics. Add them to the ClippedCounties collection
ClippedCounties = new ObservableCollection<Graphic>(resultsLayer.FeatureSet.Features);
}
else // Try to get results as a GPResultImageLayer
{
StatusText = "Clip operation complete. Retrieving results...";
m_clippedCountiesLayer = await task.GetResultImageLayerAsync(result.JobID, "Clipped_Counties");
// If successful, add the layer to the layers collection
if (m_clippedCountiesLayer != null)
{
m_clippedCountiesLayer.Opacity = 0.5;
// Insert the layer below the input layer
Layers.Insert(Layers.IndexOf(m_clipLinesLayer), m_clippedCountiesLayer);
// Wait until the result layer is initialized
await m_clippedCountiesLayer.InitializeAsync();
}
else
{
error = "No results found";
}
}
}
else
{
error = "Clip operation failed";
}
}
else
{
error = "Clip operation failed";
}
}
catch (Exception ex)
{
//.........这里部分代码省略.........
示例4: StartButton_Click
private async void StartButton_Click(object sender, RoutedEventArgs e)
{
StartButton.IsEnabled = false;
ClearResultsButton.Visibility = Visibility.Collapsed;
//get the user's input point
var inputPoint = await mapView1.Editor.RequestPointAsync();
//update UI elements
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
MyProgressRing.IsActive = true;
inputLayer.Graphics.Clear();
inputLayer.Graphics.Add(new Graphic() { Geometry = inputPoint });
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));
var parameter = new GPInputParameter()
{
OutSpatialReference = new SpatialReference(102100)
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPoint));
parameter.GPParameters.Add(new GPString("Height", HeightTextBox.Text));
parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, Convert.ToDouble(MilesTextBox.Text)));
var result = await task.SubmitJobAsync(parameter);
//Poll the server for results every 2 seconds.
while (result.JobStatus != GPJobStatus.Cancelled && result.JobStatus != GPJobStatus.Deleted &&
result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
//show the status
StatusTextBlock.Text = string.Join(Environment.NewLine, result.Messages.Select(x => x.Description));
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
//get the results as a ArcGISDynamicMapServiceLayer
StatusTextBlock.Text = "Finished processing. Retrieving results...";
var resultLayer = task.GetResultMapServiceLayer(result.JobID);
if (resultLayer != null)
{
//Add an ID so that we can reference this layer (to remove it)
resultLayer.ID = "MyResultsLayer";
//Insert the results layer just beneath the input graphics layer.
//This allows us to see the input point at all times.
mapView1.Map.Layers.Insert(mapView1.Map.Layers.IndexOf(inputLayer), resultLayer);
}
//Reset the UI
StatusTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
StartButton.IsEnabled = true;
ClearResultsButton.Visibility = Visibility.Visible;
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
MyProgressRing.IsActive = false;
}
}
示例5: CheckJobStatus
private void CheckJobStatus(JobResult jobResult, string taskUrl, string outputName, object userToken = null)
{
var d = new DispatcherTimer();
d.Interval = TimeSpan.FromMilliseconds(UpdateDelay);
var gp = new Geoprocessor(taskUrl) { Token = Token, DisableClientCaching = true };
gp.StatusUpdated += (s, e) =>
{
if (e.JobInfo.JobStatus == esriJobStatus.esriJobCancelled ||
e.JobInfo.JobStatus == esriJobStatus.esriJobDeleted ||
e.JobInfo.JobStatus == esriJobStatus.esriJobFailed ||
e.JobInfo.JobStatus == esriJobStatus.esriJobSucceeded ||
e.JobInfo.JobStatus == esriJobStatus.esriJobTimedOut)
{
d.Stop();
if (e.JobInfo.JobStatus == esriJobStatus.esriJobSucceeded)
GetResultLayer(jobResult, taskUrl, outputName, userToken);
else
OnAnalysisCompleted(new AnalysisEventArgs(new Exception(string.Format("Job has been {0}", e.JobInfo.JobStatus.ToString().ToLower().Replace("esrijob", string.Empty))), userToken));
}
};
d.Tick += (s, e) =>
{
gp.CheckJobStatusAsync(jobResult.ID);
};
d.Start();
}
示例6: mapView1_Tap
private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
{
if (BusyVisibility == Visibility.Visible)
{
MessageBox.Show("Please wait until the current operation is complete.");
return;
}
// Show busy UI
BusyVisibility = Visibility.Visible;
StatusText = "Executing...";
// Clear previous results
TapPoints.Clear();
if (m_viewshedLayer != null)
Layers.Remove(m_viewshedLayer);
// Create graphic and add to tap points
var g = new Graphic() { Geometry = e.Location };
TapPoints.Add(g);
string error = null;
// Initialize the Geoprocessing task with the viewshed calculation service endpoint
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/ArcGIS/rest/services/" +
"ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));
// Initialize input parameters
var parameter = new GPInputParameter()
{
OutSpatialReference = SpatialReferences.WebMercator
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", e.Location));
parameter.GPParameters.Add(new GPString("Height", "50"));
parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, 10));
try
{
var result = await task.SubmitJobAsync(parameter);
// Poll the server for results every two seconds.
while (result.JobStatus != GPJobStatus.Cancelled
&& result.JobStatus != GPJobStatus.Deleted
&& result.JobStatus != GPJobStatus.Failed
&& result.JobStatus != GPJobStatus.Succeeded
&& result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
// show the status
var descriptions = result.Messages.Select(msg => msg.Description);
var status = string.Join(Environment.NewLine, descriptions);
if (!string.IsNullOrEmpty(status))
StatusText = status;
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
// get the results as a ArcGISDynamicMapServiceLayer
StatusText = "Calculation complete. Retrieving results...";
m_viewshedLayer = task.GetResultMapServiceLayer(result.JobID);
if (m_viewshedLayer != null)
{
// Insert the results layer beneath the tap points layer.
// This allows the input point to be visible at all times.
Layers.Insert(Layers.IndexOf(m_tapPointsLayer), m_viewshedLayer);
// Wait until the viewshed layer is initialized
await m_viewshedLayer.InitializeAsync();
}
else
{
error = "No results returned";
}
}
else
{
error = "Viewshed calculation failed";
}
}
catch (Exception ex)
{
error = "Viewshed calculation failed: " + ex.Message;
}
// If operation did not succeed, notify user
if (error != null)
MessageBox.Show(error);
// Hide busy UI
BusyVisibility = Visibility.Collapsed;
StatusText = "";
}