public ActionResult DeleteConfirmed(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); if (osmconfig.FeatureService != null) { ServicePublisher.Services service = new ServicePublisher.Services(); try { service.DeleteService(Request.Url.Host, ConfigurationManager.AppSettings["ArcGISInstance"], osmconfig.ID, osmconfig.FeatureDataSet, osmconfig.FeatureService, ConfigurationManager.AppSettings["MxdOutput"], ConfigurationManager.AppSettings["DatabaseConnection"], ConfigurationManager.AppSettings["AgsAdminUser"], ConfigurationManager.AppSettings["AgsAdminPwd"], ConfigurationManager.AppSettings["PythonScriptDir"]); } catch (Exception ex) { throw ex; } } context.OsmConfigs.Remove(osmconfig); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditFeatures(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); ServicePublisher.Services service = new ServicePublisher.Services(); return(RedirectToAction("Index", new RouteValueDictionary( new { controller = "Editor", action = "Index", FeatureService = osmconfig.FeatureService }))); }
// // GET: /OsmConfigs/Delete/5 public ActionResult Delete(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); ServicePublisher.Services service = new ServicePublisher.Services(); try { service.DeleteService(Request.Url.Host, osmconfig.ID, osmconfig.FeatureDataSet, osmconfig.FeatureService, ConfigurationManager.AppSettings["MxdOutput"], ConfigurationManager.AppSettings["DatabaseConnection"]); } catch { } return(View(osmconfig)); }
public ActionResult EditFeatures(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); ServicePublisher.Services service = new ServicePublisher.Services(); return RedirectToAction("Index", new RouteValueDictionary( new { controller = "Editor", action = "Index", FeatureService = osmconfig.FeatureService })); }
public ActionResult DeleteConfirmed(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); if (osmconfig.FeatureService != null) { ServicePublisher.Services service = new ServicePublisher.Services(); try { service.DeleteService(Request.Url.Host, ConfigurationManager.AppSettings["ArcGISInstance"], osmconfig.ID, osmconfig.FeatureDataSet, osmconfig.FeatureService, ConfigurationManager.AppSettings["MxdOutput"], ConfigurationManager.AppSettings["DatabaseConnection"], ConfigurationManager.AppSettings["AgsAdminUser"], ConfigurationManager.AppSettings["AgsAdminPwd"], ConfigurationManager.AppSettings["PythonScriptDir"]); } catch (Exception ex) { throw ex; } } context.OsmConfigs.Remove(osmconfig); context.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Index(string DataBaseObjectID) { // Check if OSM is up //http://www.openstreetmap.org/api/0.6/map?bbox=-117.32410,33.89612,-117.32147,33.89794 WebClient client = new WebClient(); try { client.DownloadString("http://www.openstreetmap.org/api/0.6/map?bbox=-117.32410,33.89612,-117.32147,33.89794"); } catch { ViewBag.Success = "OpenStreetMap is down, please try later"; return View(); } if (DataBaseObjectID != null) { // Get the configuration to download OsmConfig myConfigToDownload = null; foreach (OsmConfig config in context.OsmConfigs.ToList()) { if (config.ID == DataBaseObjectID) { myConfigToDownload = config; break; } } if (myConfigToDownload == null) { ViewBag.Result = "Cannot find the configuration, aborted."; return View(); } // Download the configuration string results = JustDownload(myConfigToDownload); if (!(string.IsNullOrEmpty(results))) { ViewBag.Result = results; return View(); } // publish ServicePublisher.Services publisher = new ServicePublisher.Services(); // Make sure to publish the correct host string sHostRequest = Request.Url.Host; // Publish 10.1 myConfigToDownload.FeatureService = publisher.CreateService10_1(SetTargetDatasetParamGP(myConfigToDownload), sHostRequest, DataBaseObjectID.Replace("-", ""), myConfigToDownload.MxdTemplate, bUseSDE, ConfigurationManager.AppSettings["MxdOutput"], ConfigurationManager.AppSettings["AgsConnectionFile"], ConfigurationManager.AppSettings["PythonScriptDir"]); if (ConfigurationManager.AppSettings["HostAddress"] != null) { if (ConfigurationManager.AppSettings["HostAddress"].ToString().Length > 0) sHostRequest = ConfigurationManager.AppSettings["HostAddress"].ToString(); myConfigToDownload.FeatureService = myConfigToDownload.FeatureService.Replace(Request.Url.Host, sHostRequest); } //Override the instance of the server if needed if (ConfigurationManager.AppSettings["ArcGISServerInstanceName"] != null) { if (ConfigurationManager.AppSettings["ArcGISServerInstanceName"].ToString().Length > 0) { myConfigToDownload.FeatureService = myConfigToDownload.FeatureService.Replace("/arcgis/", "/" + ConfigurationManager.AppSettings["ArcGISServerInstanceName"].ToString() + "/"); } } context.Entry(myConfigToDownload).State = System.Data.EntityState.Modified; context.SaveChanges(); ViewBag.Result = myConfigToDownload.FeatureService; ViewBag.ResultMapServer = myConfigToDownload.FeatureService.Replace("/FeatureServer", "/MapServer"); ViewBag.TitleReturn = "Download Complete"; ViewBag.EditingUrl = Url.Content("~/Editor?FeatureService=" + myConfigToDownload.FeatureService); ViewBag.ArcGIS_Com = "http://arcgis.com/home/webmap/viewer.html?url=" + myConfigToDownload.FeatureService; } ViewBag.Success = "Successfully created the Feature Service by downloading the requested data from OpenStreetMap."; return View(); }
public ActionResult Index(string DataBaseObjectID) { // Check if OSM is up //http://www.openstreetmap.org/api/0.6/map?bbox=-117.32410,33.89612,-117.32147,33.89794 WebClient client = new WebClient(); try { client.DownloadString("http://www.openstreetmap.org/api/0.6/map?bbox=-117.32410,33.89612,-117.32147,33.89794"); } catch { ViewBag.Success = "OpenStreetMap is down, please try later"; return(View()); } if (DataBaseObjectID != null) { // Get the configuration to download OsmConfig myConfigToDownload = null; foreach (OsmConfig config in context.OsmConfigs.ToList()) { if (config.ID == DataBaseObjectID) { myConfigToDownload = config; break; } } if (myConfigToDownload == null) { ViewBag.Result = "Cannot find the configuration, aborted."; return(View()); } // Download the configuration string results = JustDownload(myConfigToDownload); if (!(string.IsNullOrEmpty(results))) { ViewBag.Result = results; return(View()); } // publish ServicePublisher.Services publisher = new ServicePublisher.Services(); // Make sure to publish the correct host string sHostRequest = Request.Url.Host; // Pass the arguments to create a map service. myConfigToDownload.FeatureService = publisher.CreateService(SetTargetDatasetParamGP(myConfigToDownload), sHostRequest, DataBaseObjectID, myConfigToDownload.MxdTemplate, bUseSDE, ConfigurationManager.AppSettings["MxdOutput"]); if (ConfigurationManager.AppSettings["HostAddress"] != null) { if (ConfigurationManager.AppSettings["HostAddress"].ToString().Length > 0) { sHostRequest = ConfigurationManager.AppSettings["HostAddress"].ToString(); } myConfigToDownload.FeatureService = myConfigToDownload.FeatureService.Replace(Request.Url.Host, sHostRequest); } //Override the instance of the server if needed if (ConfigurationManager.AppSettings["ArcGISServerInstanceName"] != null) { if (ConfigurationManager.AppSettings["ArcGISServerInstanceName"].ToString().Length > 0) { myConfigToDownload.FeatureService = myConfigToDownload.FeatureService.Replace("/arcgis/", "/" + ConfigurationManager.AppSettings["ArcGISServerInstanceName"].ToString() + "/"); } } context.Entry(myConfigToDownload).State = System.Data.EntityState.Modified; context.SaveChanges(); ViewBag.Result = myConfigToDownload.FeatureService; ViewBag.ResultMapServer = myConfigToDownload.FeatureService.Replace("/FeatureServer", "/MapServer"); ViewBag.TitleReturn = "Download Complete"; ViewBag.EditingUrl = Url.Content("~/Editor?FeatureService=" + myConfigToDownload.FeatureService); ViewBag.ArcGIS_Com = "http://arcgis.com/home/webmap/viewer.html?url=" + myConfigToDownload.FeatureService; } ViewBag.Success = "Successfully created the Feature Service by downloading the requested data from OpenStreetMap."; return(View()); }
// // GET: /OsmConfigs/Delete/5 public ActionResult Delete(string id) { OsmConfig osmconfig = context.OsmConfigs.Single(x => x.ID == id); ServicePublisher.Services service = new ServicePublisher.Services(); try { service.DeleteService(Request.Url.Host, osmconfig.ID, osmconfig.FeatureDataSet, osmconfig.FeatureService, ConfigurationManager.AppSettings["MxdOutput"], ConfigurationManager.AppSettings["DatabaseConnection"]); } catch { } return View(osmconfig); }