private async Task CreateServices() { try { // Arrange the data before starting the services string mapServicePath = await GetMpkPath(); string featureServicePath = await GetFeatureLayerPath(); string geoprocessingPath = await GetGpPath(); // Create each service but don't start any _localMapService = new LocalMapService(mapServicePath); _localFeatureService = new LocalFeatureService(featureServicePath); _localGeoprocessingService = new LocalGeoprocessingService(geoprocessingPath); // Subscribe to status updates for each service _localMapService.StatusChanged += (o, e) => { UpdateUiWithServiceUpdate("Map Service", e.Status); }; _localFeatureService.StatusChanged += (o, e) => { UpdateUiWithServiceUpdate("Feature Service", e.Status); }; _localGeoprocessingService.StatusChanged += (o, e) => { UpdateUiWithServiceUpdate("Geoprocessing Service", e.Status); }; // Enable the UI to select services comboServiceSelect.IsEnabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed to create services"); } }
private async void btnGeoProcess_Click(object sender, RoutedEventArgs e) { //Get the local proprocessing package _gpService = new LocalGeoprocessingService(@"C:\Temp\tile_package_service.gpkx", GeoprocessingServiceType.AsynchronousSubmit); // Start the local service. try { await _gpService.StartAsync(); } catch (Exception exe) { MessageBox.Show(exe.Message); } // If the service is started, get the URL for the specific geoprocessing tool. string gpSvcUrl = _gpService.Url.AbsoluteUri + "/TP_Model"; // Create the geoprocessing task with the URL. _gpTask = await GeoprocessingTask.CreateAsync(new Uri(gpSvcUrl)); GeoprocessingParameters gpParams = new GeoprocessingParameters(GeoprocessingExecutionType.AsynchronousSubmit); //****************************************** //***This is the bit I think is wrong how do I pass a map obkect as a gpstring parameter?**** //********************************************* gpParams.Inputs["Input_Map"] = new GeoprocessingString(MyMapView.Name); _gpJob = _gpTask.CreateJob(gpParams); _gpJob.JobChanged += GeoprocessingJob_JobChanged; _gpJob.Start(); }
/// <summary> /// Initializes a new instance of the ViewshedViewModel class. /// </summary> public ClipViewModel() { this.ClipRelayCommand = new RelayCommand(Clip); Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) => { this.mapView = mapView; this.simpleInputLineSymbol = new SimpleLineSymbol(); this.simpleInputLineSymbol.Color = System.Windows.Media.Colors.Red; this.simpleInputLineSymbol.Width = 2; this.simpleInputLineSymbol.Style = SimpleLineStyle.Solid; this.simpleResultLineSymbol = new SimpleLineSymbol(); this.simpleResultLineSymbol.Color = (Color)ColorConverter.ConvertFromString("#FF0000FF"); this.simpleResultFillSymbol = new SimpleFillSymbol(); this.simpleResultFillSymbol.Color = (Color)ColorConverter.ConvertFromString("#770000FF"); this.simpleResultFillSymbol.Outline = this.simpleResultLineSymbol; this.simpleResultRenderer = new SimpleRenderer(); this.simpleResultRenderer.Symbol = this.simpleResultFillSymbol; this.inputLineRenderer = new SimpleRenderer(); this.inputLineRenderer.Symbol = this.simpleInputLineSymbol; this.localGPService = new LocalGeoprocessingService(this.clipGPKPath, GeoprocessingServiceType.SubmitJob); this.localGPService.StartAsync(); this.resultGraphicsLayer = new GraphicsLayer(); this.resultGraphicsLayer.ID = "Clip Result"; this.resultGraphicsLayer.DisplayName = "Viewshed"; this.resultGraphicsLayer.Renderer = this.simpleResultRenderer; this.resultGraphicsLayer.InitializeAsync(); this.inputGraphicsLayer = new GraphicsLayer(); this.inputGraphicsLayer.ID = "Input Line"; this.inputGraphicsLayer.DisplayName = "Input Line"; this.inputGraphicsLayer.Renderer = this.inputLineRenderer; this.inputGraphicsLayer.InitializeAsync(); this.mapView.Map.Layers.Add(this.inputGraphicsLayer); this.mapView.Map.Layers.Add(this.resultGraphicsLayer); }); }
private async void something() { localServiceGP = new LocalGeoprocessingService(gpServiceUrl); localServiceGP.ServiceType = GeoprocessingServiceType.SynchronousExecute; localServiceGP.StatusChanged += async(svc, args) => { if (args.Status == LocalServerStatus.Started) { // 获取工具的本地地址 var gpSvcUrl = (svc as LocalGeoprocessingService).Url.AbsoluteUri + "/flowCount1"; // 在浏览器打开 toolUrl = gpSvcUrl; GeoprocessingTask gpRouteTask = new GeoprocessingTask(new Uri(gpSvcUrl)); GeoprocessingParameters para = new GeoprocessingParameters(GeoprocessingExecutionType.SynchronousExecute); para.Inputs.Add("i", new GeoprocessingRaster(new Uri(rasterPath), "GPRasterDataLayer")); if (rasterWeightPath != "") { para.Inputs.Add("w", new GeoprocessingRaster(new Uri(rasterWeightPath), "GPRasterDataLayer")); } para.Inputs.Add("dataType", new GeoprocessingString(dataType)); para.Inputs.Add("o", new GeoprocessingString(rasterResultPath)); GeoprocessingJob routeJob = gpRouteTask.CreateJob(para); try { t1.Text = "处理中..."; GeoprocessingResult geoprocessingResult = await routeJob.GetResultAsync(); t1.Text = "流量处理完成."; myUserControl.IsEnabled = true; } catch (Exception ex) { if (routeJob.Status == JobStatus.Failed && routeJob.Error != null) { MessageBox.Show("GP流处理错误:\n" + routeJob.Error.Message, "Geoprocessing error"); } else { MessageBox.Show("非GP流错误:\n" + ex.ToString() + "/**/", "Sample error"); } } } }; await localServiceGP.StartAsync(); }
/// <summary> /// Initializes a new instance of the ViewshedViewModel class. /// </summary> public ClipViewModel() { this.ClipRelayCommand = new RelayCommand(Clip); Messenger.Default.Register <Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) => { this.mapView = mapView; this.simpleInputLineSymbol = new SimpleLineSymbol(); this.simpleInputLineSymbol.Color = System.Windows.Media.Colors.Red; this.simpleInputLineSymbol.Width = 2; this.simpleInputLineSymbol.Style = SimpleLineStyle.Solid; this.simpleResultLineSymbol = new SimpleLineSymbol(); this.simpleResultLineSymbol.Color = (Color)ColorConverter.ConvertFromString("#FF0000FF"); this.simpleResultFillSymbol = new SimpleFillSymbol(); this.simpleResultFillSymbol.Color = (Color)ColorConverter.ConvertFromString("#770000FF"); this.simpleResultFillSymbol.Outline = this.simpleResultLineSymbol; this.simpleResultRenderer = new SimpleRenderer(); this.simpleResultRenderer.Symbol = this.simpleResultFillSymbol; this.inputLineRenderer = new SimpleRenderer(); this.inputLineRenderer.Symbol = this.simpleInputLineSymbol; this.localGPService = new LocalGeoprocessingService(this.clipGPKPath, GeoprocessingServiceType.SubmitJob); this.localGPService.StartAsync(); this.resultGraphicsLayer = new GraphicsLayer(); this.resultGraphicsLayer.ID = "Clip Result"; this.resultGraphicsLayer.DisplayName = "Viewshed"; this.resultGraphicsLayer.Renderer = this.simpleResultRenderer; this.resultGraphicsLayer.InitializeAsync(); this.inputGraphicsLayer = new GraphicsLayer(); this.inputGraphicsLayer.ID = "Input Line"; this.inputGraphicsLayer.DisplayName = "Input Line"; this.inputGraphicsLayer.Renderer = this.inputLineRenderer; this.inputGraphicsLayer.InitializeAsync(); this.mapView.Map.Layers.Add(this.inputGraphicsLayer); this.mapView.Map.Layers.Add(this.resultGraphicsLayer); }); }
private async void StopServerButtonClicked(object sender, RoutedEventArgs e) { // Update the UI btnServiceStart.IsEnabled = false; btnServiceStop.IsEnabled = false; LocalServerStartButton.IsEnabled = true; LocalServerStopButton.IsEnabled = false; // Stop the server await LocalServer.Instance.StopAsync(); // Clear references to the services _localFeatureService = null; _localMapService = null; _localGeoprocessingService = null; }
public MainWindow() { InitializeComponent(); // Start the LocalGeoprocessing Service LocalGeoprocessingService.GetServiceAsync(@"..\Maps-and-Data\SimpleBuffer.gpk", GPServiceType.Execute, (gpService) => { // Check the error... if (gpService.Error != null) { MessageBox.Show(gpService.Error.Message); return; } _gpTask = new Geoprocessor(gpService.Tasks[0].Url); MyMap.MouseClick += MyMap_MouseClick; DataContext = this; IsBusy = false; }); }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Load the tiled layer and get the path string rasterPath = GetRasterPath(); // Create a tile cache using the path to the raster TileCache myTileCache = new TileCache(rasterPath); // Create the tiled layer from the tile cache ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(myTileCache); // Try to load the tiled layer try { // Wait for the layer to load await tiledLayer.LoadAsync(); // Zoom to extent of the tiled layer await MyMapView.SetViewpointGeometryAsync(tiledLayer.FullExtent); } catch (Exception) { MessageBox.Show("Couldn't load the tile package, ending sample load."); return; } // Add the layer to the map MyMapView.Map.OperationalLayers.Add(tiledLayer); // Try to start Local Server try { // LocalServer must not be running when setting the data path. if (LocalServer.Instance.Status == LocalServerStatus.Started) { await LocalServer.Instance.StopAsync(); } // Set the local data path - must be done before starting. On most systems, this will be C:\EsriSamples\AppData. // This path should be kept short to avoid Windows path length limitations. string tempDataPathRoot = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.Windows)).FullName; string tempDataPath = Path.Combine(tempDataPathRoot, "EsriSamples", "AppData"); Directory.CreateDirectory(tempDataPath); // CreateDirectory won't overwrite if it already exists. LocalServer.Instance.AppDataPath = tempDataPath; // Start the local server instance await LocalServer.Instance.StartAsync(); } catch (Exception ex) { var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); return; } // Get the path to the geoprocessing task string gpServiceUrl = GetGpPath(); // Create the geoprocessing service _gpService = new LocalGeoprocessingService(gpServiceUrl, GeoprocessingServiceType.AsynchronousSubmitWithMapServiceResult); // Take action once the service loads _gpService.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _gpService.StartAsync(); } catch (Exception) { MessageBox.Show("geoprocessing service failed to start."); } }
public MainWindow() { // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs. InitializeComponent(); /* * Asynchronously start all the services... */ LocalGeoprocessingService.GetServiceAsync(@"..\Maps-and-Data\TraceGeometricNetwork.gpk", GPServiceType.SubmitJob, localServiceCallback => { if (localServiceCallback.Error != null) { MessageBox.Show(localServiceCallback.Error.Message); return; } traceNetworkLocalGpService = localServiceCallback; geoprocessorTask = new Geoprocessor(traceNetworkLocalGpService.Tasks[0].Url); // Enable the UI when the Trace Geometric Network service is available TraceUpstreamButton.IsEnabled = true; }); LocalGeometryService.GetServiceAsync(callback => { localGeometryService = callback; geometryTask = new GeometryService(); geometryTask.Url = localGeometryService.UrlGeometryService; }); LocalMapService.GetServiceAsync(@"..\Maps-and-Data\WaterDistributionNetwork.mpk", callback => { if (callback.Error != null) { MessageBox.Show("WaterDistributionNetwork map failed to load"); return; } waterNetworkLocalMapService = callback; ArcGISLocalDynamicMapServiceLayer WaterDistributionNetworkLayer = new ArcGISLocalDynamicMapServiceLayer(waterNetworkLocalMapService); MyMap.Layers.Insert(1, WaterDistributionNetworkLayer); }); /* * Create the Results GraphicsLayers and associated Renderers */ valvesGraphicsLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = MainGrid.Resources["ValveMarkerSymbol"] as Symbol } }; mainsGraphicsLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = new SimpleLineSymbol() { Color = new SolidColorBrush(Colors.Red), Width = 8, Style = SimpleLineSymbol.LineStyle.Dash } } }; // Add the GraphicsLayers to the Map MyMap.Layers.Add(mainsGraphicsLayer); MyMap.Layers.Add(valvesGraphicsLayer); }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Load the tiled layer and get the path string rasterPath = await GetRasterPath(); // Create a tile cache using the path to the raster TileCache myTileCache = new TileCache(rasterPath); // Create the tiled layer from the tile cache ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(myTileCache); // Try to load the tiled layer try { // Wait for the layer to load await tiledLayer.LoadAsync(); // Zoom to extent of the tiled layer await MyMapView.SetViewpointGeometryAsync(tiledLayer.FullExtent); } catch (Exception) { MessageBox.Show("Couldn't load the tile package, ending sample load."); return; } // Add the layer to the map MyMapView.Map.OperationalLayers.Add(tiledLayer); // Try to start Local Server try { // Start the local server instance await LocalServer.Instance.StartAsync(); } catch (Exception ex) { MessageBox.Show(String.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md or metadata.json. Message: {0}", ex.Message), "Local Server failed to start"); return; } // Get the path to the geoprocessing task string gpServiceUrl = await GetGpPath(); // Create the geoprocessing service _gpService = new LocalGeoprocessingService(gpServiceUrl, GeoprocessingServiceType.AsynchronousSubmitWithMapServiceResult); // Take action once the service loads _gpService.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _gpService.StartAsync(); } catch (Exception) { MessageBox.Show("geoprocessing service failed to start."); } }
private async void ExecuteGPService() { //加载DEM并且缩放到该区域 Map map = new Map(Basemap.CreateTopographic()); string pathToRaster = @"D:\work\github\ExecuteGPK\LasVegasNED13_geoid1.tif"; var myRaster = new Raster(pathToRaster); // create a RasterLayer using the Raster var newRasterLayer = new RasterLayer(myRaster); map.OperationalLayers.Add(newRasterLayer); Viewpoint viewPoint = new Viewpoint(36.131, -115.144, 800000); myMapView.Map = map; await myMapView.SetViewpointAsync(viewPoint, TimeSpan.FromSeconds(2)); StartLocalServer(); LocalGeoprocessingService localServiceGP = new LocalGeoprocessingService(@"D:\work\github\ExecuteGPK\InterpolateShape.gpk"); localServiceGP.ServiceType = GeoprocessingServiceType.SynchronousExecute; // Handle the status changed event to check when it's loaded localServiceGP.StatusChanged += async(svc, args) => { // If service started successfully, create a gp task if (args.Status == LocalServerStatus.Started) { // Get the URL for the specific geoprocessing tool var gpSvcUrl = (svc as LocalGeoprocessingService).Url.AbsoluteUri + "/InterpolateShape"; // Create the geoprocessing task GeoprocessingTask gpRouteTask = new GeoprocessingTask(new Uri(gpSvcUrl)); GeoprocessingParameters para = new GeoprocessingParameters(GeoprocessingExecutionType.SynchronousExecute); // Create the schema for a lines table (one text field to contain a name attribute) var inputFeatures = new FeatureCollectionTable(new List <Field>(), GeometryType.Polyline, myMapView.SpatialReference); Feature inputFeature = inputFeatures.CreateFeature(); var geometry = await myMapView.SketchEditor.StartAsync(SketchCreationMode.Polyline, false); inputFeature.Geometry = geometry; await inputFeatures.AddFeatureAsync(inputFeature); para.Inputs.Add("inputLine", new GeoprocessingFeatures(inputFeatures)); para.ReturnZ = true; para.OutputSpatialReference = myMapView.SpatialReference; GeoprocessingJob routeJob = gpRouteTask.CreateJob(para); try { // Execute analysis and wait for the results GeoprocessingResult geoprocessingResult = await routeJob.GetResultAsync(); GeoprocessingFeatures resultFeatures = geoprocessingResult.Outputs["outputLine"] as GeoprocessingFeatures; IFeatureSet interpolateShapeResult = resultFeatures.Features; Esri.ArcGISRuntime.Geometry.Polyline elevationLine = interpolateShapeResult.First().Geometry as Esri.ArcGISRuntime.Geometry.Polyline; MapPoint startPoint = elevationLine.Parts[0].Points[0]; int count = elevationLine.Parts[0].PointCount; MapPoint stopPoint = elevationLine.Parts[0].Points[count - 1]; double chazhi = stopPoint.Z - startPoint.Z; MessageBox.Show("终点的Z值为: " + stopPoint.Z.ToString() + ",起点的Z值为: " + startPoint.Z.ToString()); } catch (Exception ex) { if (routeJob.Status == JobStatus.Failed && routeJob.Error != null) { MessageBox.Show("Executing geoprocessing failed. " + routeJob.Error.Message, "Geoprocessing error"); } else { MessageBox.Show("An error occurred. " + ex.ToString(), "Sample error"); } } // Create parameters, run the task, process results, etc. // ... } }; // Start the local geoprocessing service await localServiceGP.StartAsync(); }
private async void Initialize() { // Set paths that are relative to execution path string currentDir = Directory.GetCurrentDirectory(); int idx = currentDir.IndexOf("bin") - 1; appRootDir = currentDir.Substring(0, idx); appDataDir = appRootDir + @"\Data"; appTempDir = appRootDir + @"\temp"; // Set up files testImage = appDataDir + @"\sampleFile.tiff"; gpPackage = appDataDir + @"\CreateMapTilePackage.gpkx"; mapPackage = appDataDir + @"\emptyMapPackage.mpkx"; Debug.WriteLine(">> App Root Directory = " + appRootDir); Debug.WriteLine(">> App Data Directory = " + appDataDir); Debug.WriteLine(">> App Temp Directory = " + appTempDir); ////////////// start Q Basket set up ////////////////// // Create raster layer from a raster file (Geotiff) Debug.WriteLine("Loading raster layer from " + testImage); RasterLayer inRasterLayer = new RasterLayer(testImage); // Load Raster into Raster Layer try { await inRasterLayer.LoadAsync(); if (inRasterLayer.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded) { Debug.WriteLine("Error - Input Raster Layer not loaded "); } } catch (Exception ex) { string msg = "Unable to load the raster\n"; msg += "Raster file = " + testImage; msg += "Load status = " + inRasterLayer.LoadStatus.ToString(); msg += "\n\nMessage: " + ex.Message; MessageBox.Show(msg, "inRasterLayer.LoadAsync failed"); } // Create a new EnvelopeBuilder from the full extent of the raster layer. // Add a small zoom to make sure entire map is viewable EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(inRasterLayer.FullExtent); envelopeBuilder.Expand(0.75); // Create a basemap from the raster layer Basemap baseMap = new Basemap(inRasterLayer); // Create a new map using the new basemap Map newMap = new Map(baseMap); // Set the viewpoint of the map to the proper extent. newMap.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent); // Create a map and add it to the view MyMapView.Map = newMap; // Load new map to display basemap try { // Add map to the map view. MyMapView.Map = newMap; // Wait for the map to load. await newMap.LoadAsync(); } catch (Exception ex) { string msg = "Unable to load the Map\n"; msg += "\n\nMessage: " + ex.Message; MessageBox.Show(msg, "newMap.LoadAsync failed"); } // Wait for rendering to finish before taking the screenshot for the thumbnail await WaitForRenderCompleteAsync(MyMapView); ////////////// end Q Basket set up ////////////////// // Start the Local Server try { // LocalServer must not be running when setting the data path. if (LocalServer.Instance.Status == LocalServerStatus.Started) { await LocalServer.Instance.StopAsync(); } // Set the local data path - must be done before starting. // Avoid Windows path length limitations (260). // CreateDirectory won't overwrite if it already exists. Directory.CreateDirectory(appTempDir); LocalServer.Instance.AppDataPath = appTempDir; // Start the local server instance await LocalServer.Instance.StartAsync(); MessageBox.Show("Local Server started"); Debug.WriteLine(">> Local Server started"); // Get the URL for the localServer // localhost port is variable localServerURL = LocalServer.Instance.Url.AbsoluteUri; Debug.WriteLine("\n>> Local server url - " + localServerURL); Debug.WriteLine(">> Local server App Data Path - " + LocalServer.Instance.AppDataPath); } catch (Exception ex) { string msg = "Please ensure the local server is installed \nand configured correctly"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // LOCAL MAP SERVICE INIT // Create and start the local map service try { _localMapService = new LocalMapService(mapPackage); } catch (Exception ex) { string msg = "Cannot create the local map service"; msg += "Map Package = " + mapPackage; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Map Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // RASTER WORKSPACE CREATION // Create the Raster workspace; this workspace name was chosen arbitrarily // Does workspace need to be the same directory as rasters? // setting to temp directory rasterWorkspace = new RasterWorkspace("raster_wkspc", appTempDir); Debug.WriteLine(">> raster workspace folder = " + rasterWorkspace.FolderPath); Debug.WriteLine(">> raster workspace id = " + rasterWorkspace.Id); // Create the layer source that represents the Raster on disk RasterSublayerSource source = new RasterSublayerSource(rasterWorkspace.Id, testImage); // Create a sublayer instance from the table source _rasterSublayer = new ArcGISMapImageSublayer(0, source); // Add the dynamic workspace to the map service _localMapService.SetDynamicWorkspaces(new List <DynamicWorkspace>() { rasterWorkspace }); // Register map service status chagne event handle _localMapService.StatusChanged += _localMapService_StatusChanged; // Start the map service try { await _localMapService.StartAsync(); } catch (Exception ex) { string msg = "Cannot start the local map service"; msg += "Map Package = " + mapPackage; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Map Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // Get the url to the local map service localMapServiceURL = _localMapService.Url.AbsoluteUri; MessageBox.Show("Local Map Service URL = " + localMapServiceURL); Debug.WriteLine("Local Map Service URL = " + localMapServiceURL); // LOCAL GEOPROCESSING SERVICE INIT // Create the geoprocessing service _localGPservice = new LocalGeoprocessingService(gpPackage, gpServiceType); // Ass GP service status chagned event handler _localGPservice.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _localGPservice.StartAsync(); if (_localGPservice.Status == LocalServerStatus.Failed) { string msg = ("Geoprocessing service failed to start.\n"); MessageBox.Show(msg, "gpService.StartAsync failed"); App.Current.Shutdown(); } else if (_localGPservice.Status == LocalServerStatus.Started) { localGPserviceUrl = _localGPservice.Url.AbsoluteUri + "/CreateMapTilePackage"; string msg = ("Geoprocessing service started.\n"); msg += "\n>> GP Service URL: " + localGPserviceUrl; msg += ">> GP Service Max Records: " + _localGPservice.MaxRecords; msg += ">> GP Service Package Path: " + _localGPservice.PackagePath; msg += ">> GP Service Type: " + _localGPservice.ServiceType; MessageBox.Show(msg, "gpService.StartAsync started"); Debug.WriteLine("\n>> GP Service URL: " + localGPserviceUrl); Debug.WriteLine(">> GP Service Max Records: " + _localGPservice.MaxRecords); Debug.WriteLine(">> GP Service Package Path: " + _localGPservice.PackagePath); Debug.WriteLine(">> GP Service Type: " + _localGPservice.ServiceType); } } catch (Exception ex) { string msg = ("Geoprocessing service failed to start.\n"); msg += "\nGeoprocessing package - " + gpPackage + "\n"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "gpService.StartAsync failed"); return; } // GEOPROCESSING TASK INIT // Create the geoprocessing task from the service try { string url = _localGPservice.Url + "/CreateMapTilePackage"; _gpTask = await GeoprocessingTask.CreateAsync(new Uri(url)); } catch (Exception ex) { string msg = ("Geoprocessing task failed to start.\n"); msg += "\nlocalGPserviceUrl- " + localGPserviceUrl + "\n"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "GeoprocessingTask.CreateAsync failed"); return; } MessageBox.Show("GeoprocessingTask.CreateAsync created"); // GEOPROCESSING JOB // Create the geoprocessing parameters GeoprocessingParameters gpParams = new GeoprocessingParameters(gpExecutionType); // Add the interval parameter to the geoprocessing parameters //GeoprocessingString Input_Map = new GeoprocessingString("MyMapView.Map"); GeoprocessingString Input_Map = new GeoprocessingString("localMapServiceURL"); GeoprocessingDouble Max_LOD = new GeoprocessingDouble(10); GeoprocessingString Output_Package = new GeoprocessingString("C://Karen/Data/TilePackages/test.tpkx"); gpParams.Inputs.Add("Input_Map", Input_Map); gpParams.Inputs.Add("Max_LOD", Max_LOD); gpParams.Inputs.Add("Output_Package", Output_Package); // Create the job try { _gpJob = _gpTask.CreateJob(gpParams); } catch (Exception ex) { string msg = ("Geoprocessing job cannot be created.\n"); msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "_gpTask.CreateJob failed"); return; } MessageBox.Show("GeoprocessingTask.CreateJob created"); MyLoadingIndicator.Visibility = Visibility.Visible; // Update the UI when job progress changes _gpJob.ProgressChanged += (sender, args) => { Dispatcher.Invoke(() => { MyLoadingIndicator.Value = _gpJob.Progress; }); }; // Be notified when the task completes (or other change happens) _gpJob.JobChanged += GpJobOnJobChanged; // Start the job try { _gpJob.Start(); } catch (Exception ex) { string msg = ("Geoprocessing start job failed to start.\n"); msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "_gpjob.Start failed"); return; } MessageBox.Show("GeoprocessingTask job started"); }