/// <summary> /// Calling the rest end points for the GP /// </summary> /// <param name="myConfigToDownload"></param> private void DownloadDataGP(OsmConfig myConfigToDownload) { WebClient client = new WebClient(); // This assumes is port 80 string sGpUrl = "http://" + Request.Url.Host + "/" + System.Configuration.ConfigurationManager.AppSettings["ArcGISInstance"].ToString() + "/rest/services/OSM_on_AGS/GPServer/Download%20OSM%20Data%20Serverside"; ESRI.ArcGIS.Client.Tasks.Geoprocessor geoprocessorTask = new ESRI.ArcGIS.Client.Tasks.Geoprocessor(sGpUrl); List <ESRI.ArcGIS.Client.Tasks.GPParameter> parameters = new List <ESRI.ArcGIS.Client.Tasks.GPParameter>(); string[] myExtent = myConfigToDownload.Extent.Split(','); ESRI.ArcGIS.Client.Geometry.PointCollection pointCollect = new ESRI.ArcGIS.Client.Geometry.PointCollection(); // X1 Y1 pointCollect.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(WebMercator.FromWebMercatorX(Convert.ToDouble(myExtent[0])), WebMercator.FromWebMercatorY(Convert.ToDouble(myExtent[1])))); // X2 Y1 pointCollect.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(WebMercator.FromWebMercatorX(Convert.ToDouble(myExtent[2])), WebMercator.FromWebMercatorY(Convert.ToDouble(myExtent[1])))); // X2 Y2 pointCollect.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(WebMercator.FromWebMercatorX(Convert.ToDouble(myExtent[2])), WebMercator.FromWebMercatorY(Convert.ToDouble(myExtent[3])))); // X1 Y2 pointCollect.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(WebMercator.FromWebMercatorX(Convert.ToDouble(myExtent[0])), WebMercator.FromWebMercatorY(Convert.ToDouble(myExtent[3])))); // X1 Y1 pointCollect.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(WebMercator.FromWebMercatorX(Convert.ToDouble(myExtent[0])), WebMercator.FromWebMercatorY(Convert.ToDouble(myExtent[1])))); ESRI.ArcGIS.Client.Geometry.Polygon polygon = new ESRI.ArcGIS.Client.Geometry.Polygon(); polygon.Rings.Add(pointCollect); polygon.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326); parameters.Add(new ESRI.ArcGIS.Client.Tasks.GPFeatureRecordSetLayer("Feature_Set", polygon)); parameters.Add(new ESRI.ArcGIS.Client.Tasks.GPString("Name_of_OSM_Dataset", myConfigToDownload.FeatureDataSet)); AppLogs logs = new AppLogs(); ESRI.ArcGIS.Client.Tasks.JobInfo info = null; try { info = geoprocessorTask.SubmitJob(parameters); } catch (Exception e) { logs.AddLog("DOWNLOADLOGS", "Exception " + e.Message); if (info != null) { for (int i = 0; i < info.Messages.Count; i++) { logs.AddLog("DOWNLOADLOGS", "Exception: DownloadDataGP messages " + info.Messages[i].Description); } } } while (info.JobStatus != ESRI.ArcGIS.Client.Tasks.esriJobStatus.esriJobSucceeded && info.JobStatus != ESRI.ArcGIS.Client.Tasks.esriJobStatus.esriJobFailed) { Thread.Sleep(2000); info = geoprocessorTask.CheckJobStatus(info.JobId); } if (info.JobStatus == ESRI.ArcGIS.Client.Tasks.esriJobStatus.esriJobFailed) { for (int i = 0; i < info.Messages.Count; i++) { logs.AddLog("DOWNLOADLOGS", "JobFailed: DownloadDataGP messages " + info.Messages[i].Description); } throw new ApplicationException("JobFailed: Please view logs for details"); } }